# NMinimize in one-dimensional Interval

An Interval should be a one-dimensional region, so a region. I tried to minimize a function over an interval, e.g.:

f[x_] := x^5 + 3 x^4 - 2 x^3 + x - 1;
ymin = NMinimize[f[x], x ∈ Interval[{0, π}]]


I get an error message. I do not see why. The variable x is not declared to be numeric (see NIntegrate and Interval regions)

• I don't see why, either. It looks like a bug in NMinimize to me. Commented Feb 7, 2015 at 14:07

This is a syntax issue. Use

ymin = NMinimize[f[x], {x} ∈ Interval[{0, π}]]


(* {-1., {x -> 0.}} *)


Update

Using ImplicitRegion has the same issue. {x} must be used instead of x

ymin = NMinimize[f[x], {x} ∈ ImplicitRegion[0 <= x <= π, {x}]]

• What MathematicaVersion do you use (I have 10.0.2.0) I get the error even when I copy and paste your answer.... Commented Feb 7, 2015 at 14:20
• I copied the wrong line from my notebook. The correct expression appears now. Thanks for identifying my mistake. For completeness, I too have V10.0.2.0. Commented Feb 7, 2015 at 14:28
• I think this is a very interesting finding on your part, but I still think the OP's version ought to work. I have submitted a problem report to WRI tech support arguing the issue. Commented Feb 7, 2015 at 14:35
• @m_goldberg At a minimum, documentation is ambiguous. For single variables, it shows x\[Element]reg, but for multiple variables {x, y} \[Element] reg. It was this disparity that caused me to try {x}. I think you should report the issue. Thanks. Commented Feb 7, 2015 at 14:40
• @m_goldberg Thank you for editing my answer (and the question by @mgamer) to replace \[Pi] by π, etc. Where can we find Greek and special characters to paste into questions, answers, and comments? I searched "Help" without success. Thanks. Commented Feb 7, 2015 at 16:43

Today I got a couple of emails from WRI tech support. The first indicated that they had accepted this issue as a bug.

I have filed a bug report with the development team. Thank you very much for giving us feedback and hopefully this issue would be improved in future release.

The second email retracted the first and reclassified the problem as a documentation issue.

It looks like that this issue is more like a documentation issue. You may use

NMinimize[x, {x} ∈ Interval[{0, 1}]]


or

NMinimize[Indexed[x, 1], x ∈ Interval[{0, 1}]]


to restrain the variable x to be in the interval from 0 to 1.

I will file a separate suggestion for the documentation issue if I get confirmation from the developers.

The second form, which in the context of the question being considered here, becomes

f[x_] := x^5 + 3 x^4 - 2 x^3 + x - 1
NMinimize[f[Indexed[x, 1]], x ∈ Interval[{0, π}]]

{-1., {x -> {0.}}}


may be taken as second answer. See Examples under Indexed for more information of this usage.