Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

simplifying powers in sympy

I am endeavoring to streamline the following mathematical expression:

expr = 200 * x**5 * y**6    
sym.simplify(sym.sqrt(200 * x**5 * y**6))

However, the simplification process has not yielded the anticipated outcome. In pursuit of a resolution, I extended my investigations to encompass the simplification of sqrt(y**6) utilizing both the simplify and powsimp functions. Regrettably, neither of these approaches yielded the desired results.

Upon reflection, it has become apparent that the reluctance of SymPy to simplify sqrt(y**6) may stem from the divergence in outcomes when substituting negative values. I also undertook assessments involving sqrt(y**8) using both the simplify and powsimp functions, which, once again, proved ineffective.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Could you kindly elucidate the methodology to effectively simplify this expression? Additionally, I am intrigued by the factors contributing to SymPy’s reluctance to apply simplification. Should you possess any recommendations for supplementary resources to facilitate further exploration, I would be immensely appreciative.

>Solution :

sympy will make a sqrt divide the power by 2 if you tell it to assume the variables are positive, which is the only case where sqrt(x**6) = x**3, it is only true when x is positive.

import sympy as sym
x, y = sym.symbols('x y', positive = True)
expr = 200 * x**5 * y**6  
sym.simplify(sym.sqrt(200 * x**5 * y**6))
10*sqrt(2)*x**(5/2)*y**3
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading