I've encountered a very strange problem. I'm trying to find a minimum of a real part (or absolute value, or really any possible real-valued expression) of some complex function, which was previously interpolated from numerical data. Let's see here for the minimal "working" example:
func = Interpolation[Table[{x, Exp[I x]}, {x, -5, 5, 0.01}]];
NMaxValue[Re[func[x]], x]
The "result" of this is:
NMaxValue::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations.
-Experimental`NumericalFunction[{x}, -Re[
InterpolatingFunction[{{-5., 5.}}, <>][x]],
"-NumericalFunctionData-"][{-6.42031}]
Can someone point me in the right direction and hint on what the problem might be? It works when I do
func = Interpolation[Table[{x, Cos[x]}, {x, -5, 5, 0.01}]];
NMaxValue[func[x], x]
but my functions are usually complex.
Behavior is the same with NMaximize
. What am i missing here? What is wrong with Re
? What exactly is Experimental``NumericalFunction
? Thanks.