Skip to content

NMaximize ​

A numeric global maximum of f over a BOUNDED interval, as {value, {x -> point}} -- dense sampling plus a golden-section refinement, not an exact answer.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageNMaximize!
NMaximize({f, cons}, x)the numeric global maximum of f over the bounded interval cons implies, for any real-valued f (not just the exact core Maximize covers).
Typed signatures
TypePackageApplies
(tuple<expression, expression>, list<symbol> | symbol) -> expressionanalyticalways

Domain: Calculus

Details
  • NMinimize's exact mirror image -- same method (201-point sampling plus a golden-section refinement, converged to a bracket width under 1e-11 relative to the interval), same requirement for an explicit bounded constraint, same declines. See its details for the full account.
  • When f has more than one point attaining the same global maximum, this reports whichever the sampling grid's basin of attraction happens to land on first -- a different, equally valid witness than another correct implementation (or Wolfram's own NMaximize) might report for the same value.

Examples

Basic #

Sin(x) + Cos(2x) reaches its maximum, 9/8, at more than one point on [0, 6]

live ↗
InNMaximize([sin⁡(x)+cos⁡(2x),x≥0∧x≤6],x)\mathrm{NMaximize}(\bigl\lbrack\sin(x)+\cos(2x), x≥0∧x≤6\bigr\rbrack, x)Out[1.125,[Rule(x,2.888 912 406 121 017 6)]]\bigl\lbrack1.125, \bigl\lbrack\mathrm{Rule}(x, 2.888\,912\,406\,121\,017\,6)\bigr\rbrack\bigr\rbrack
Possible issues #

Declines -- no bounded interval to search

live ↗
InNMaximize(−x2,x)\mathrm{NMaximize}(-x^2, x)OutNMaximize(−x2,x)\mathrm{NMaximize}(-x^2, x)
About
Examples2
Checked againstWolfram Language 2 differ
CrosswalkWolfram Language

See also: NMinimize, Maximize, MaxValue