I'm experiencing a problem using FindMaximum that I don't understand (due to my newbie knowledge of Mathematica's syntax). That is, FindMaximum sometimes returns a (correct) answer, but sometimes returns
The function value some number i is not a real number at {t} = {some number}.
I have two defined functions:
Envelope[t_, A_] := Norm[MatrixExp[(A) t]];
MaxEnvelope[A_, tmax_] := FindMaximum[{First@Envelope[t, A], 0 <= t <= tmax}, t];
Working
For an example matrix that "works":
A1={{-1, 15}, {0, -10}}
MaxEnvelope[A1, 5]
returns
{1.40801, {t -> 0.212153}}
which makes sense given the plot
Plot[Envelope[t, A1], {t, 0, 5}]
Problem
For an example matrix that throws the error:
A2={{-0.293578, -0.880734}, {0.0103211, -0.344037}}
MaxEnvelope[A2,5]
returns
FindMaximum::nrnum: "The function value -1.+4.54871*10^-9\ I is not a real number at {t} = {6.06351*10^-9}. "
There is clearly a maximum here though:
Plot[Envelope[t, A2], {t, 0, 5}]
The problem appears to be the { } that wrap t and what is clearly a real number. But why does the first matrix work and the second one not?
{}
. It's the non-zero imaginary part of the function value (hence it is not real). $\endgroup$Clear[Envelope]; Envelope[t_?NumericQ, A_] := Norm[MatrixExp[(A) t]];
$\endgroup$