Mathematica calls NMinimize with symbols rather than numbers?

孤者浪人 提交于 2019-12-05 05:33:42

Have you tried defining your function to only evaluate for numeric input?

dummy[x_?NumericQ] := ...

For some dummy functions an "exact numeric" call can also be very slow. Example finding the FixedPoint[Sqrt,2.] is fast, but FixedPoint[Sqrt,2] will go until something breaks!

By "exact numeric" I mean things like Integers, Rationals, and numeric symbolics like Sqrt[2], Cos[5], Pi, EulerGamma, etc...
that is, things that will return a numerical value when acted upon by N[].

In this case it is probably better to use

dummy[_?InexactNumberQ] := ....

or even

dummy[_?MachineNumberQ] := ....
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!