软件编程版 #30741 层

关于Mathematica中的“FindMaximum”的使用

楼主 · 1 楼
想使用Mathematica中的最优化函数FindMaximum求解一个两步优化问题:

f[x_] := FindMaximum[-x^2 - y^2, {y, 1}][[1]]
FindMaximum[f[x], {x, 1}]

但不能运行,错误代码为:

FindMaximum::nlnum: The function value {1.\x, 1.} is not a list of numbers \
with dimensions {2} at {y} = {1.`}...


请教高手该怎样修改自定义函数f[x]? 谢谢!

急盼!