We tend to prefer non-expanded to expanded by default, because when a function expands by default, it is impossible to represent it in an unexpanded form. On the other hand, if it doesn't expand, all you have to do is call expand_func() on it.
I wrote up something on the wiki about this: https://github.com/sympy/sympy/wiki/Automatic-Simplification. It's actually debatable if gegenbaur, laguerre, and other functions should expand automatically. In this case, I think that the expanded result is not simpler, and in fact, if n is quite large, then just constructing the function will eat up all your memory, even if otherwise it would be able to manipulate it quite fine. Aaron Meurer On Sun, Sep 15, 2013 at 8:41 PM, Angus Griffith <[email protected]> wrote: > In sympy 0.7.2 the spherical harmonic function Ylm gave 'expanded' results: > > In [3]: sympy.Ylm(sympy.S(3), sympy.S(1), sympy.Symbol('x'), > sympy.Symbol('y')) > Out[3]: -sqrt(21)*(15*cos(x)**2/2 - 3/2)*exp(I*y)*sin(x)/(12*sqrt(pi)) > > > but in sympy it was renamed to Ynm and no longer expands automatically: > > In [3]: sympy.Ynm(sympy.S(3), sympy.S(1), sympy.Symbol('x'), > sympy.Symbol('y')) > Out[3]: Ynm(3, 1, x, y) > > In [4]: _.expand(func=True) > Out[4]: -5*sqrt(21)*sqrt(-cos(x)**2 + 1)*exp(I*y)*cos(x)**2/(8*sqrt(pi)) + > sqrt(21)*sqrt(-cos(x)**2 + 1)*exp(I*y)/(8*sqrt(pi)) > > > Many similar functions do however expand upon being called: > > In [5]: sympy.gegenbauer(sympy.S(6), sympy.S(1), sympy.Symbol('x')) > Out[5]: 64*x**6 - 80*x**4 + 24*x**2 - 1 > > In [6]: sympy.laguerre(5, sympy.Symbol('x')) > Out[6]: -x**5/120 + 5*x**4/24 - 5*x**3/3 + 5*x**2 - 5*x + 1 > > etc > > > The spherical harmonics are the only class of functions I've come across > which behave in this way. > > Is there a criteria for deciding when these types of functions should > expand? > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
