Clever expression manipulation for numerical effiency when evaluating lambda functions / ufuncify

31 views
Skip to first unread message

wo...@gmx.de

unread,
Feb 2, 2016, 11:43:09 AM2/2/16
to sympy
Hi!

I calculated a Taylor Series expansion using SymPy. I want to evaluate this expansion at a lot of points. Now, the expansion (specifcally the derivatives at the development point) contain sin(x),cos(x) x and powers thereof. Hence, I made a substitution subs(sin(x),a) and subs(cos(x),b), where a and b are just real symbols. Then I call T*(x,sin(x),cos(x)) instead of T(x), where T is the Taylor expansion, which gives a huge boost and speed, because the sin and cos terms are not always re-evaluated.
Do you know other such hacks? For example, clever use of collect() should be pretty helpful in many cases.

Cheers,
Wolfgang

Aaron Meurer

unread,
Feb 2, 2016, 11:57:13 AM2/2/16
to sy...@googlegroups.com
One of the goals of the project I am working on is to make it easy to apply these kinds of manipulations automatically. The translation you did can be automated using the cse() function. collect() is also useful. Another good one for polynomial evaluation is horner(), which rewrites polynomial expressions into their most numerically efficient to evaluate form.

Aaron Meurer

--
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+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/2a8340fc-66ff-43e4-a87f-91381aa976b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages