2

I have a function with two global minima, I would like mathmatica to find both of them. for example I have the function:

enter image description here

and I'm trying to find both global minima using:

FindMinimum[{-5 x^4 + 5 x^6 + x^2}, {x}]

this only find one minimum:

{-0.130734, {x -> 0.737666}}

how do I find both?

I don't care if you use Nminimize, FindMinimum, or any other function as long as you find both minima

Adi Ro
  • 121
  • 1
  • 5

2 Answers2

6
findGlobalMin[func_, x_Symbol] := Module[
  {min = MinValue[func, x] // Simplify},
  {min, Select[
    Solve[{
       D[func, x] == 0,
       D[func, {x, 2}] > 0},
      x] // Simplify,
    (func /. #) == min &]}]

f[x_] = -5 x^4 + 5 x^6 + x^2;

findGlobalMin[f[x], x]

enter image description here

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
5

You can do the example emulating pen/pencil and paper,e.g.:

y[x_] := x^4 - x^2
c = x /. Solve[D[y[x], x] == 0, x]
r = D[y[x], {x, 2}];
ans = Pick[c, (r > 0 /. x -> #) & /@ c]
Plot[y[x], {x, -1.5, 1.5}, 
 Epilog -> {Red, PointSize[0.02], Point[{#, y@#} & /@ ans]}]

enter image description here

ubpdqn
  • 60,617
  • 3
  • 59
  • 148
  • I'm looking for the global minima. not all minima. – Adi Ro Apr 18 '16 at 10:35
  • @AdiRo in this (special case and without a domain specified:assumed $-\infty$ to$\infty$) these are global minima. But I take your point that this may have been a MWE and not your desired response. I may leave the answer as, perhaps, others might find useful. – ubpdqn Apr 18 '16 at 10:39
  • @ubpdqn I edited the question to make It clear – Adi Ro Apr 18 '16 at 10:50