6

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...

Igor Rivin
  • 5,094
  • 20
  • 19

1 Answers1

7

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}}}  *)
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198