Hi, I would like to write a function that rewrites an expression to eliminate square root signs. I have read through the simplify module, but I don't quite see how to do this. Is there something in the new polys module that would help me?
Here is an example. I can assume that everything is real if that helps somehow. Sigma_12 = Symbol("Sigma_12") Sigma_13 = Symbol("Sigma_13") Sigma_14 = Symbol("Sigma_14") Sigma_23 = Symbol("Sigma_23") Sigma_24 = Symbol("Sigma_24") Sigma_34 = Symbol("Sigma_34") tau_11 = Symbol("tau_11") tau_22 = Symbol("tau_22") tau_33 = Symbol("tau_33") tau_44 = Symbol("tau_44") expr = ((Sigma_34/(tau_33*tau_44) - Sigma_13*Sigma_14/ (tau_11**2*tau_33*tau_44))/((1 - Sigma_13**2/(tau_11**2*tau_33**2))*(1 - Sigma_14**2/(tau_11**2*tau_44**2)))**(S(1)/2) - (Sigma_24/ (tau_22*tau_44) - Sigma_12*Sigma_14/ (tau_11**2*tau_22*tau_44))*(Sigma_23/(tau_22*tau_33) - Sigma_12*Sigma_13/(tau_11**2*tau_22*tau_33))/(((1 - Sigma_12**2/ (tau_11**2*tau_22**2))*(1 - Sigma_13**2/(tau_11**2*tau_33**2)))**(S(1)/ 2)*((1 - Sigma_12**2/(tau_11**2*tau_22**2))*(1 - Sigma_14**2/ (tau_11**2*tau_44**2)))**(S(1)/2)))**2 expr So if I wanted to simplify expr to eliminate the radicals, I would need to 0) Combine these last two two square roots together ((1 - Sigma_12**2/(tau_11**2*tau_22**2))*(1 - Sigma_13**2/ (tau_11**2*tau_33**2)))**(S(1)/2)*((1 - Sigma_12**2/ (tau_11**2*tau_22**2))*(1 - Sigma_14**2/(tau_11**2*tau_44**2)))**(S(1)/ 2) to get ((1 - Sigma_12**2/(tau_11**2*tau_22**2))*(1 - Sigma_13**2/ (tau_11**2*tau_33**2))*(1 - Sigma_12**2/(tau_11**2*tau_22**2))*(1 - Sigma_14**2/(tau_11**2*tau_44**2)))**(S(1)/2) 1) Recognize that there is now a squared term under the radical and pull that out to get (1 - Sigma_12**2/(tau_11**2*tau_22**2)) * ((1 - Sigma_13**2/ (tau_11**2*tau_33**2))*(1 - Sigma_14**2/(tau_11**2*tau_44**2)))**(S(1)/ 2) 2) Make a common denominator with the first term in expr to get this within the outermost parentheses ((1 - Sigma_12**2/(tau_11**2*tau_22**2)) * (Sigma_34/(tau_33*tau_44) - Sigma_13*Sigma_14/(tau_11**2*tau_33*tau_44)) - (Sigma_23/ (tau_22*tau_33) - Sigma_12*Sigma_13/(tau_11**2*tau_22*tau_33))) / (((1 - Sigma_13**2/(tau_11**2*tau_33**2))*(1 - Sigma_14**2/ (tau_11**2*tau_44**2)))**(S(1)/2) * (1 - Sigma_12**2/ (tau_11**2*tau_22**2))) 3) Square both the numerator and denominator to finally get (((1 - Sigma_12**2/(tau_11**2*tau_22**2)) * (Sigma_34/(tau_33*tau_44) - Sigma_13*Sigma_14/(tau_11**2*tau_33*tau_44)) - (Sigma_23/ (tau_22*tau_33) - Sigma_12*Sigma_13/(tau_11**2*tau_22*tau_33))) / (((1 - Sigma_13**2/(tau_11**2*tau_33**2))*(1 - Sigma_14**2/ (tau_11**2*tau_44**2)))**(S(1)/2) * (1 - Sigma_12**2/ (tau_11**2*tau_22**2))))**2 That would be perfect if I could automate these steps, or it would also be okay if it wanted to expand or simplify the numerator further. But I haven't been able to figure out how to do that without manual intervention. Everything I have tried takes a long time to yield a giant expression that still has square root signs. Can anyone get me started? Thanks, Ben -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sy...@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.