| 1 | initial version |
Hi,
The problem seems to be that sage's minimize_contrained function will call the function f with c being a 1-dimensional array and the diff function expects a variable name.
A workaround to this would be to give a different name to the parameter of f, say x. Then we could differentiate y and substitute c=x[0], as shown below
def f(x):
dy=y.diff(c)
w=5*(c-10)^3
z=dy+w
return z.subs(c=x[0])
It might be the case that sage is differentiating y each time f is called, which might end up consuming some time. To avoid this maybe just defining z=dy+w and calling minimize_constrained(z,[(-10,10)],[9]) would do the job.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.