# Can Minimize get multiple minima producing the same objective value?

Minimize[(x-1)^2(x-2)^2,x]


gives only the solution 1, and not 2 (the help does not seem to mention this issue)

In general, if I do not know how many minimizers I have, I guess I could use smthng like

FindInstance[(x - 1)^2 (x - 2)^2 < 10^(-10), x, 2]


but is there a way to force NMinimize to attempt to find two, three, or more solutions?

• sol = Minimize[(x - 1)^2 (x - 2)^2, x]; Solve[(x - 1)^2 (x - 2)^2 == sol[[1]], x] Commented Nov 4, 2022 at 12:49
• @cvgmt: Unfortunately, that fails on f = Piecewise[{{Exp[-1/(x - 1)^2], x != 1}, {0, x == 1}}] + Piecewise[{{Exp[-1/(x + 1)^2], x != -1}, {0, x == -1}}] , whereas mine works. Commented Nov 4, 2022 at 17:34

h = 1;n=5; Table[Minimize[{(x - 1)^2 (x - 2)^2, x >= h*j && x <= h*(j + 1)},   x], {j, -n, n}]


{{900, {x -> -4}}, {400, {x -> -3}}, {144, {x -> -2}}, {36, {x -> \ -1}}, {4, {x -> 0}}, {0, {x -> 1}}, {0, {x -> 1}}, {0, {x -> 2}}, {4, {x -> 3}}, {36, {x -> 4}}, {144, {x -> 5}}}

?

Play with h and n in need.

• @cvgmt, user64494, Thanks. I'm only interested in x=1 and x=2, which of course may be easily extracted from user64494's "search for the lions in Sahara". I still find it hard to believe that Mathematica does not provide a command for "searching the lions in Sahara" but maybe the solution of cvgmt is so natural (once you learn it :), that Mathematica did not deem necessary to provide it. Commented Nov 4, 2022 at 18:05
• If we choose to solve global optimization by "searching for all the lions in Sahara", maybe it's more efficient to look for all local optima, or rather Karush-Kuhn-Tucker points, since my original problem is multidimensional and has also constraints. My question seems to reduce to finding all KKT points and then comparing them. Commented Nov 4, 2022 at 18:14
• @florin: The DirectSearch package of Maple may be of interest to you. Commented Nov 4, 2022 at 18:15
• @florin: Also pay your attention to dropbox.com/s/jvbs34ndpi1sqjq/CDOS%20method.pdf?dl=0 Commented Nov 4, 2022 at 18:28