python - Simplification of square root of sum -


using sympy, can automatically simplify this:

sqrt(a**2 + 2ab + b**2) 

to:

[(a+b), -(a+b)]? 

perhaps like:

>>> var('a b',positive=true) (a, b) >>> solve(x**2-(a**2 + 2*a*b + b**2), x) [-a - b, + b] 

Comments