5
$\begingroup$

This can be thought of as follow-up to this question. The question is, simply, can anyone explain why both Maximize[] and FindMaximum[] (and their minimalist counterparts) exist. The documentation seems to draw no meaningful distinction between the two...

$\endgroup$
6
$\begingroup$

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

max1 = FindMaximum[x Cos[x], x]

(*  {0.561096, {x -> 0.860334}}  *)

Specifying different starting values gives different results

max2 = FindMaximum[x Cos[x], {x, #}] & /@ {1, 6, 10}

(*  {{0.561096, {x -> 0.860334}}, {6.361, {x -> 6.4373}}, {12.6059, {x -> 
    12.6453}}}  *)

Maximize searches for a global maximum. If f and constraints are linear or polynomial, Maximize will always find a global maximum.

Maximize[{x Cos[x], 0 < x < 15}, x] // N

(*  {12.6059, {x -> 12.6453}}  *)

To find all peaks in the interval

sol3 = ({x Cos[x], {"x" -> x}} /.
    NSolve[{
      D[x Cos[x], x] == 0,
      D[x Cos[x], {x, 2}] < 0,
      0 < x < 15}, x]) /. "x" :> x

(*  {{0.561096, {x -> 0.860334}}, {6.361, {x -> 6.4373}}, {12.6059, {x -> 
    12.6453}}}  *)
$\endgroup$
  • $\begingroup$ Thanks! I did not realize that FindMaximum[] did not even try to look for a global maximum... $\endgroup$ – Igor Rivin Apr 2 '17 at 23:34
  • 2
    $\begingroup$ To add, NMaximize[] tries to find a global maximum. $\endgroup$ – J. M. will be back soon Apr 3 '17 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.