2
$\begingroup$

I defined a function f[x,y] and wanted to study its minimum over x when viewing y as a parameter. So I did the minimization for a list of values of y

yList = Table[i/100.0, {i, 1, 99}];
res = FindMinimum[f[x, #], x] & /@ yList;

The problem is that the minimization does not converge for some values of y. I hope to remove the non-convergent results from res (or replacing them by non-numerical values) so that these ill-behaving data points do not appear on the plot I generate using res. How can I do that?

$\endgroup$
  • 4
    $\begingroup$ Good question! You can wrap each FindMinimum with Check in order to handle error messages (see the documentation for details.). E.g., Check[FindMinimum[f[x, #], x], $Failed] & /@ yList should do what you want. $\endgroup$ – Henrik Schumacher Jul 31 '19 at 19:55
  • $\begingroup$ @HenrikSchumacher It works! Thanks for your answer. $\endgroup$ – Epsilon_F Jul 31 '19 at 20:35
  • $\begingroup$ You're welcome! $\endgroup$ – Henrik Schumacher Jul 31 '19 at 20:40

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.