I have a function that is defined using a variety of things, some matrix algebra, some mathlink functions, etc. But they are all defined to evaluate when called with the parameters :(adsbygoogle = window.adsbygoogle || []).push({});

chi2[mb, vmc, v1, v2, v3, v4, 0.1066, 0.219]

gives me a number back. I can even do a table over some range of parameters and it always returns a value, no matter how fine my grid becomes.

But when I run something like :

Mathematica gives me :Code (Text):NMinValue[chi2[mb, 0.9882, 0.4536, 0.1485, 0.2981, -0.142279, 0.1066, 0.219], {mb, 4.6 - 0.2, 4.6 + 0.2}, AccuracyGoal -> 5]

thoughCode (Text):NMinValue::nnum: The function value 0.584316+<<49>>+<<1>> is not a number at {mb} = {4.66099}. >>

gives me a value, 120.067.Code (Text):chi2[4.660987123189611`, 0.9882000000000001`, 0.4536`, \

0.14850000000000002`, 0.29810000000000003`, -0.14227941068376537`, \

0.1066`, 0.219`]

So I don't know why it is complaining about that point.

I believe it has to do with NMinValue trying to evaluate the expression before it runs its minimization, and due to Mathlink it cant return a value or functional form unless its passed the parameters first. Like how you can specifiy SymbolicPreprocessing in NIntegrate.

I tried Evaluate[] over the chi2, but that doesn't work.

I can't really give a sample code, its much too difficult. But does anyone know if you can force a function to be evaluated at each given point?

I can also plot the function over the range of mb, it is just a simple parabola with a minimum right where I expected it. Plot has no trouble evaluating it.

Does NMinimize use algebraic derivatives? Does it try to preprocess functions before passing it a test argument?

This is all in Mathematica 7 for the moment. I can try 8 and 9 later, but not for a bit.

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# [Mathematica] : Mathlink/Evaluation of a function using NMinValue/NMin

Tags:

Loading...

Similar Threads for Mathematica Mathlink Evaluation |
---|

Mathematica Storing Mathematica output |

Mathematica Mathematica to MATLAB |

Mathematica Cannot do the integral of the Hyper-geometric function? |

Mathematica Cannot Plot This Function in Mathematica |

Mathematica While Loop in Mathematica |

**Physics Forums | Science Articles, Homework Help, Discussion**