Mathematica Asked on July 25, 2021
Bug introduced in 12.2, Fixed in 12.3
Something changed in NMaximze
in v12.2:
NMaximize[E^(-x^2) - 1, x]
(* {(-1 + E^#1)[0.], {x -> 0.}} *)
v12.1 works as expected:
NMaximize[E^(-x^2) - 1, x]
(* {0., {x -> 0.}} *)
as does Maximize
in v12.2:
Maximize[E^(-x^2) - 1, x]
(* {0, {x -> 0}} *)
Do you all agree this is a bug? Any ideas on a workaround?
$Version
(* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *)
It seems (clearly!) to be a bug in the preprocessing for the new convex optimizer. Use one of the other methods (e.g. "DifferentialEvolution"
):
Trace[
NMaximize[E^(-x^2) - 1, x],
_Optimization`MinimizationProblem,
TraceForward -> True,
TraceInternal -> True
]
Workaround:
NMaximize[E^(-x^2) - 1, x, Method -> "DifferentialEvolution"]
(* {0., {x -> -5.45643*10^-9}} *)
Alternatively, you can turn off the convex minimizer:
Block[{Optimization`UseConvexMinimize = False},
NMinimize[-(E^(-x^2) - 1), x]
]
(* {0., {x -> -5.45643*10^-9}} *)
Correct answer by Michael E2 on July 25, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP