0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ FindMinimum finds only one minimum. $\endgroup$ – Adi Ro Apr 18 '16 at 9:53
  • $\begingroup$ Related: mathematica.stackexchange.com/q/5575/131 $\endgroup$ – Yves Klett Apr 18 '16 at 9:55
  • $\begingroup$ and Nminimize does find the global minimum, It says so in the function details: "NMinimize always attempts to find a global minimum of f subject to the constraints given." $\endgroup$ – Adi Ro Apr 18 '16 at 9:56
  • 2
    $\begingroup$ ... it always attempts, but not necessarily manages. Do you only have polynomial functions? $\endgroup$ – Yves Klett Apr 18 '16 at 9:57
  • $\begingroup$ @YvesKlett It's actually trigonometric functions, but I tried to simplify my question... $\endgroup$ – Adi Ro Apr 18 '16 at 10:05
6
$\begingroup$
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

|improve this answer|||||
$\endgroup$
5
$\begingroup$

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

|improve this answer|||||
$\endgroup$
  • $\begingroup$ I'm looking for the global minima. not all minima. $\endgroup$ – Adi Ro Apr 18 '16 at 10:35
  • $\begingroup$ @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. $\endgroup$ – ubpdqn Apr 18 '16 at 10:39
  • $\begingroup$ @ubpdqn I edited the question to make It clear $\endgroup$ – Adi Ro Apr 18 '16 at 10:50

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.