Hello, I am new to both Python and Sympy. I've been going through the documentation with some test problems and have questions regarding how much expansion/simplification/factoring etc. is possible within Sympy compared with CAS products like Mathematica. I have occasional access to Mathematica but would prefer the open source approach. I use the anaconda distribution and ipythoin on a Mac
Here is a toy problem involving some quotients of complex numbers that come up in optics. from sympy import * var('A,B,C,D,u,v,qi,qf') qi = 1/(u-I*v) qf = (A+B/qi)/(C+D/qi) I'd like to get an expansion of 1/qf. My hand calculation and Mathematica both give: (A C)/((A+B u)^2+B^2 v^2)+(B C u)/((A+B u)^2+B^2 v^2)+(A D u)/((A+B u)^2+B^2 v^2)+(B D u^2)/((A+B u)^2+B^2 v^2)+(B D v^2)/((A+B u)^2+B^2 v^2)+I ((B C v)/((A+B u)^2+B^2 v^2)-(A D v)/((A+B u)^2+B^2 v^2)) It is simply taking 1/qf, multiplying top and bottom by the complex conjugate of the denominator, and collecting terms. The real and imaginary parts each relate to a physical parameter of a Gaussian laser beam. I've tried this in iPython/Sympy a few different ways. Definitions as above: In [4]: 1/qf Out[4]: (C + D*(u - I*v))/(A + B*(u - I*v)) In [5]: expand(1/qf) Out[5]: C/(A + B*u - I*B*v) + D*u/(A + B*u - I*B*v) - I*D*v/(A + B*u - I*B*v) In [10]: (expand(1/qf, complex=True)) Out[10]: A massive expression. I can provide it if there's interest but there are hundreds of terms. I've also tried simplify, expand, factor, etc. in various combinations. Nothing quite as simple as what the hand calculation/Mathematica provide. I'd appreciate suggestions including opinions on whether or not sympy is an appropriate choice for what I have in mind. Thanks, JBB -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/0b5e40bc-dc3c-487f-89af-a3d7be8600a1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.