0

im building a program for algebra stuff, right now im trying to get the step by step solution hence it is required for the process im trying to achieve.

i am able to get the final result but i was unable to find something about this in the documentation for sympy

from sympy import *


x = "3"
y = "-1"
z = "-4"

print(latex(sympify('(%s**%s)**%s' %(x,y,z))))

is there anyone that can point me in the right direction? or maybe offer an alternative path

  • It's not clear to me what your question is – Oscar Benjamin Jul 22 '20 at 10:38
  • so to clarifiy, im trying to get the step by step: (3**-1)**-4 the result is 81, but i also need the additional steps (3**-1)**-4 3**-1*-4 3**4 3*3*3*3 81 – Josh Rodriguez Jul 22 '20 at 16:08
  • You can use sympify with evaluate=False to get an unevaluated expression but then you'll need to work through each part manipulating the expression tree yourself to evaluate it step-by-step: https://docs.sympy.org/latest/tutorial/manipulation.html – Oscar Benjamin Jul 22 '20 at 21:31
  • There’s this post here https://stackoverflow.com/questions/39359220/is-there-any-way-to-get-the-step-by-step-solution-in-sympy that proposes the use of binary trees with evaluation turned off. – Sigex Jan 04 '23 at 09:10

0 Answers0