[sage-support] Evaluating a symbolic expression
Hi all, I want to find the max/min of a function f =f(x,y,z) of three variables under two constraints g_1 = 0, g_2=0 using Lagrange multipliers. I am able to build and solve the system, even to form the list of values fox the critical points, say P1=[1,2,3], but then I am not able to cmpute f(P1) in a clean manner... I mean, I can of course do f(P1[0],P1[1],P1[2]), but this is highly non-elegant. What if I had functions of 25 variables? Some ideas? thanks! JC -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] Evaluating a symbolic expression
I mean, I can of course do f(P1[0],P1[1],P1[2]), but this is highly non-elegant. You can use an asterisk: sage: f(x,y,z) = x+10*y+100*z sage: P1 = [2,3,4] sage: f(*P1) 432 Here, * behaves kind of like a dereferencing operator: f(*(x,y,z)) == f(x,y,z). See this StackOverflow question for a longer explanation: http://stackoverflow.com/questions/2921847/python-once-and-for-all-what-does-the-star-operator-mean-in-python Doug -- You received this message because you are subscribed to the Google Groups sage-support group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.