The issue is that sqrt(x)*sqrt(y) does not equal sqrt(x*y), unless x and y are positive (see http://docs.sympy.org/tutorial/tutorial/simplification.html#powers). Unfortunately, your assumptions that A1 and A2 are real is not enough for SymPy to deduce that the things under the square root are positive.
One way to force it to happen is to use powsimp(force=True), like powsimp(coef1*coef2, force=True). You can then expand that to get the simplification you want. Aaron Meurer On Fri, Jun 21, 2013 at 1:29 PM, Anton Loukianov <anton.loukia...@gmail.com> wrote: > Hello, > > How do I expand products of square roots like this? > > import sympy as sp > A1,A1 = sp.symbols('A1,A2', real=True, constant=True) > coef1 = sp.sqrt(1/(A1**2 + A2**2 + sp.sqrt(A1**4 - A1**2*A2**2 + A2**4))) > coef2 = sp.sqrt(1/(A1**2 + A2**2 - sp.sqrt(A1**4 - A1**2*A2**2 + A2**4))) > sp.expand(coef1*coef2) > > I expected to get rid of the inner square root this way, but it doesn't seem > to work. > > - Anton > > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sympy+unsubscr...@googlegroups.com. > To post to this group, send email to sympy@googlegroups.com. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.