You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
Hi,
I would like to evaluate certain functions created with lambdify. Those functions would come from rotations and would have a lot of trigonometric function invocations in them with the same parameters. For example, lets suppose that it would contain cos(a) many times. I plan to heavily use those generated functions, but I am concerned about the performance loss of evaluating cos(a) multiple times in one function invocation, when it would suffice to evaluate it only once.
I am not sure how lambdify treats these cases, i.e. if it would call cos(a) multiple times or not, or if I have to specify it explicitly. Can somebody tell me how it works?
Thanks for your help! :)
Albert Pető
unread,
Oct 14, 2016, 9:09:46 AM10/14/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
Hi, I plan to heavily use a function generated with lambdify from a sympy expression which has repeated occurences of some subexpressions. Specifically it will have a lot of cosine and sine expressions with the same arguments. I don't know if lambdify can notice this pattern and evaluate that subexpression only once, or if it will call it (the numeric sine and cosine functions) as many times as it appears, or if I have to specify it somehow. I am afraid that it would mean a considerable performance loss if, for example, it will have to call 2-3 times as many trigonometric functions as a hand-written code, since I plan to use it a lot. Can somebody provide me some information?
Thanks in advance :)
Björn Dahlgren
unread,
Oct 14, 2016, 11:06:17 AM10/14/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
On Friday, 14 October 2016 15:09:46 UTC+2, Albert Pető wrote:
Hi, I plan to heavily use a function generated with lambdify from a sympy expression which has repeated occurences of some subexpressions.
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sy...@googlegroups.com
To achieve this with lambdify you should call cse() first, then
lambdify each expression separately. We ought to build a wrapper to
make this easier (or a cse=True flag to lambdify).