Reputation: 23
I am new to using Sympy and I want to simplify an expression using symbols. So far here is my code.
a,b,x,y,z = symbols('a b x y z')
d = ((a**3 * b)**2 * b ** 4)**(1/3)
print(simplify(d))
Which returns
(a**6*b**6)**0.333333333333333
I would like it to return a^2 b^2 as in the following image
It would also be nice for sympy to return the steps it used, but this seems to be exceedingly difficult to figure out so this is not required but would definitely be helpful.
Upvotes: 2
Views: 64
Reputation: 18979
If you declare the symbols to be nonnegative, the simplification will happen automatically:
>>> a, b = symbols('a b', nonnegative=True)
>>> ((a**3 * b)**2 * b ** 4)**(S(1)/3)
a**2*b**2
Sometimes powsimp
or expand
with the force=True
option will work for expressions involving powers. But in this case, the assumptions need to be made.
Upvotes: 2