I have a complicated function $f_{a,b}(t)$ of one argument ($t$) whose definition depends on two parameters $a,b$.

For every point in the plane $a-b$ (with $a\in[a_{min}, a_{max}]$ and $b\in[b_{min}, b_{max}]$) I need to find $\min\limits_{t\in\mathbb{R}}{f_{a,b}(t)}$ and verify whether it's positive; all the points $(a,b)$ that satisfy this condition are part of the region that I want to plot.

What's the easiest way to do this?

For example, taking $f_{a,b}(t)=1+at+bt^2$, we can use Minimize[1+at+bt^2, t] and find that the minimum value is (for $b>0$) equal to $\frac{-a^2+4b}{4b}$. Then the plot is given by RegionPlot[(-a^2+4b)/(4b)>0, {a, amin, amax}, {b, bmin, bmax}] for the given values of amin etc.

The issue is that in my case $f_{a,b}(t)$ is more complicated and the minimum must be found numerically (in general).

I have tried with RegionPlot[Minimize[f, x][[1]]> 0, {a, amin, amax}, {b, bmin, bmax}] but the evaluation never completes; replacing Minimize with FindMinimum only gives me a long list of error messages.

Any help is appreciated!


1 Answer 1


If your function is to complicated to do it analytically, use NMinimize.

RegionPlot[First@NMinimize[f[a, b, t], t] > 0, {a, 0, 3}, {b, 0, 4}]

enter image description here

  • $\begingroup$ This does not work actually, as (for the simple function in my example) I get a long list of error messages such as NMinimize::nnum: The function value 1-0.829053 a+0.687328 b is not a number at {t} = {-0.829053}. Can you provide a minimal working example of the code you used to produce your image? $\endgroup$
    – GioMott
    Nov 27, 2017 at 20:32
  • $\begingroup$ First I defined your simple example function f[a_, b_, t_] = 1 + a t + b t^2, Then the command you see above RegionPlot[First@NMinimize[f[a, b, t], t] > 0, {a, 0, 3}, {b, 0, 4}]. This works fine. $\endgroup$
    – Akku14
    Nov 28, 2017 at 20:48
  • $\begingroup$ Maybe we are using two different versions of Mathematica then, as this still only produces error messages of the form above. I am currently using 11.1 $\endgroup$
    – GioMott
    Nov 29, 2017 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.