1

I am trying to simplify expressions containing exponents on SymPy. However, the desired results are not returned.

This is what I have tried thus far:

import sympy as sp

a, b, c, d = sp.symbols("a b c d", real = True, positive = True)


exp1 = (a - b + c)**3
exp2 = (a - b + c)**3 - ((a - b + c)**2 - d)**sp.Rational(3, 2)

Exp1 = exp1**sp.Rational(1, 3)
print(Exp1)
Output[1]: ((a - b + c)**3)**(1/3)

The expected result for Exp1 was a - b + c since I assumsed all the variales are positive.

Exp2 = exp2.subs(d, 0)
print(Exp2)
Output[2]: (a - b + c)**3 - (a - b + c)**2*Abs(a - b + c)

The expected result for Exp2 was 0.

Is there a way of forcing Sympy to return the fully simplified expressions or results when the base of the exponent has more than one variable.

The following answers did not help solve my problem:

Answer 1

Answer 2

Answer 3

smichr
  • 16,948
  • 2
  • 27
  • 34

1 Answers1

1

Use the force option:

>>> powdenest(Exp1, force=True)
a - b + c

You can read the docstring for cbrt to get an explanation of how the principle root concept keeps cbrt(x**3) from being returned as x.

smichr
  • 16,948
  • 2
  • 27
  • 34