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...
Asked
Active
Viewed 943 times
6
Igor Rivin
- 5,094
- 20
- 19
-
Some useful information can be found in Ruskeepää's Mathematica Navigator (3rd ed), pp. 741 ff.. – gwr Apr 11 '17 at 12:21
1 Answers
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
-
Thanks! I did not realize that
FindMaximum[]did not even try to look for a global maximum... – Igor Rivin Apr 02 '17 at 23:34 -
2To add,
NMaximize[]tries to find a global maximum. – J. M.'s missing motivation Apr 03 '17 at 00:38