Stef1611
Stef1611

Reputation: 2387

Sympy : How is it possible to simplify power of sum?

Considering an expression of this form:

x,y,n=sp.symbols("x y n",positive=True,real=True)
sp.Pow(x+y+x**2,n+1)*sp.Pow(x+2*y+4*y**3,-n-1)

how is it possible to simplify it to have a common power ? (i.e. sp.Pow((x+y+x**2)/(x+2*y+y**3),n+1) )

Upvotes: 1

Views: 151

Answers (1)

smichr
smichr

Reputation: 19057

This is the same general problem as here

>>> var('z', positiv=True)
z
>>> expr = sp.Pow(x+y+x**2,n+1)*sp.Pow(x+2*y+4*y**3,-n-1)
>>> powsimp(expr.subs(n + 1, var('z',positive=1))).subs(z, n + 1)
((x**2 + x + y)/(x + 4*y**3 + 2*y))**(n + 1)

Upvotes: 1

Related Questions