Is it possible to find all (or as many as possible) minimizers of a given function? For example, minimizing the function $\cos(\pi(p-q))+\cos(\pi(q+p))$ for $-3\leq p,q\leq 3 $ can be done using NMinimize as follows

min = NMinimize[{Cos[Pi (p - q)] + Cos[Pi (q + p)], -3 <= q <= 3 && -3 <= p <= 3}, {q, p}]

This yields the answer

{-2., {q -> 2., p -> 3.}}

Naturally there are more minimizer pairs, for example $p=-2,q=-3$. Is it possible to get all minimizers?

My attempt: Once I have the minimum value, min[[1]], I know FindInstance takes an argument n which allows to find n instances, so I guess I could try working with this, and setting, for a large enough n,

n = 100;
FindInstance[{Cos[Pi (p - q)] + Cos[Pi (q + p)] == min[[1]], -3 <= q <= 3 && -3 <= p <= 3}, {q, p}, n]

This finds 24 possible minimizer pairs. For more complex functions, however, this does not work (using N[Rationalize[min[[1]]]] instead of min[[1]] may help). Numerically minimizing will have an associated precision error which depends on the way NMinimize internally works, so any help is appreciated. I wonder if there's already an inbuilt or better/fast way of doing it in Mathematica.

Edit: I decided to share my main function in this follow-up question, because it seems that its complexity might suggest different approaches. Please take a look.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.