ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 21 Aug 2012 14:49:37 +0200How do I exec a function of N variables.https://ask.sagemath.org/question/9260/how-do-i-exec-a-function-of-n-variables/The python code:
f(x,y)=sin(x) + cos(y) Can be both differentiated and evaluated.
like this:
dfx=diff(f,x);
dfy=diff(f,y)
then evaluated like this:
f(pi/6,pi/9) -> cos(1/9*pi) + 1/2
dfx(pi/6,pi/9) -> 1/2*sqrt(3)
I'm wanting to do something like:
exec("f(t1,t2)=cos(t1)+sin(t2)")
so that I can write an @interact function to define the equations of N variables interactively. When I try the above exec I receive the error: "SyntaxError: can't assign to function call"
I can almost do it, but I'm getting into a horrible inelegant tangle of of eval statements in the process!
Is there a clean way to do it with sage?oldbradTue, 21 Aug 2012 14:49:37 +0200https://ask.sagemath.org/question/9260/