# NMinimize extremely slow for simple, non-oscillatory function on an interval

The minimum of $$f(x) = -(x+1/2 \sqrt{1-x})$$ for $$x$$ between $$0$$ and $$1$$ occurs at $$x=15/16$$ with $$f(15/16)=-17/16$$. This is a function that Mathematica evaluates quickly, and I have plotted the function and its minimum values below:

Mathematica quickly evaluates

Minimize[{-x - 1/2 Sqrt[1 - x] , x > 0, x < 1}, x]


but is extremely slow in evaluating

NMinimize[{-x - 1/2 Sqrt[1 - x] , x > 0, x < 1}, x]


(In fact, Mathematica appears to hang when I try to evaluate the above.)

Why is this and how can I speed up the evaluation? Is it the way I specified the bounds? I have in mind somewhat more complicated examples but I'm hoping to understand this simple example first. I'm running 12.0 Student Edition on Windows 10.

• On my installation (MM 12.1 on MacOS), both commands run effectively instantaneously, with the latter returning {-1.0625, {x -> 0.9375}} as expected. So this may be a version-dependent bug. Sep 16, 2021 at 20:27
• Try this comparison on a fresh kernel. Sep 17, 2021 at 18:43

The Method->"DifferentialEvolution" option helps: compare

Minimize[{-x - 1/2 Sqrt[1 - x], x > 0, x < 1}, x] // AbsoluteTiming


{0.287915, {-(17/16), {x -> 15/16}}}

with

NMinimize[{-x - 1/2 Sqrt[1 - x], x > 0, x < 1}, x,
Method -> "DifferentialEvolution"] // AbsoluteTiming


{0.116188, {-1.0625, {x -> 0.9375}}}

and with

NMinimize[{-x - 1/2 Sqrt[1 - x], x > 0, x < 1}, x] // AbsoluteTiming


0.298761, {-1.0625, {x -> 0.9375}}}

• The above is done in 12.3.1 on Windows 10. Though the NMinimize command was updated in 12.3, but its parts related to Methods weren't up to the documentation. Sep 17, 2021 at 18:58
• The difference is night and day on my installation - it finishes running when implementing the method you recommended, so this solves my problem. Sep 17, 2021 at 20:23