Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

NMaximize[f,x] maximizes f numerically with respect to x.

FindMaximum[f,x] searches for a local maximum in f, starting from an automatically selected point.

FindMaximum is in my experience about an order of magnitude faster than NMaximize. Reading the description, I think the difference is that NMaximize checks a smaller range of values for the maximum (presumably until the nearest point where f' == 0 on either size of the starting point), while FindMaximum checks a wider range, in case a higher value can be found somewhere past the f' == 0 turning point. I'm not sure how NMaximize bounds the input values it checks, if no explicit bounds are provided by the user.

Can anybody confirm or deny -- is my understanding above correct, and is there any other difference between these functions?

Thank you.

share|improve this question
1  
FM searches for a local maximum whereas NM attempts to search for a global maximum (which is a pretty big difference), which is why it's slower (there might be other implementation details that I'm not aware of). – rm -rf Jan 9 at 4:45
5  
I think the best thing to do here is really to point to the well-written tutorial Numerical Nonlinear Global Optimization – Jens Jan 9 at 5:39
1  
They use completely different algorithms. Read their documentation, specifically regarding the Method option, to understand what each one does. Another difference, not discussed in the documentation, is that NMinimize is implemented in top-level Mathematica code, whereas FindMinimum is considerably lower-level (at least partly C/Fortran-based). This might also account for some of the speed discrepancy, albeit obviously only as a constant factor with all other things being equal. – Oleksandr R. Jan 9 at 13:30
@Jens thank you, that page indeed answered all of my questions. Oleksandr R's comment was also interesting. – Michael Stern Jan 9 at 17:23
Voting to close as TL since the answer turned out to exist already as part of the documentation. – Oleksandr R. Jan 11 at 11:22

closed as too localized by Oleksandr R., whuber, rcollyer, rm -rf Jan 13 at 15:50

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.