3
$\begingroup$
g = 0.9;
H = {{g, I}, {I, -g}};
G = MatrixExp[t*H];
Plot[Norm[G], {t, 0, 20}, AspectRatio -> 1]

FindMaxValue[Norm[G], {t, 1}]

enter image description here

The matrix has a parameter t. Then the norm of G is a function of t, and the Norm[G]-t is plotted above. Then I want to find the maximum of Norm[G] by

FindMaxValue[Norm[G], {t, 1}]

However, there are errors:

Max::nord: Invalid comparison with 0.454874 +2.44073*10^-16 I attempted. >>

Max::nord: Invalid comparison with 2.19841 +2.52506*10^-16 I attempted. >>

FindMaxValue::nrnum: The function value -1. Max[0.454874 +2.44073*10^-16I,2.19841 +2.52506*10^-16 I] is not a real number at {t} = {1.}. >>

It seems that the reason is when t=1, the Norm[G] is calculated based on the maximum of singular values of G. And the two singular values are 0.454874 +2.44073*10^-16I and 2.19841 +2.52506*10^-16 I, which can not be compared. In fact, these two singular values should be real numbers(as shwon have tiny imaginary part).

And why there is no this error in Plot function?

My question is how to edit the code to find the maximum of Norm[G] here.

$\endgroup$
2
  • 1
    $\begingroup$ fn[t_?NumericQ] := Norm[MatrixExp[t {{0.9, I}, {I, -0.9}}]]; FindMaxValue[fn[t], {t, 1}] should work. See this. $\endgroup$ Commented Aug 31, 2017 at 14:13
  • $\begingroup$ Thank you. Yes, it can work. $\endgroup$
    – Qi Zhong
    Commented Aug 31, 2017 at 14:20

1 Answer 1

5
$\begingroup$
g = 9/10;
H = {{g, I}, {I, -g}};
G[t_] = MatrixExp[t*H];

Use exact values and simplify the Norm using ComplexExpand and FullSimplify to avoid any imaginary artifacts.

ng[t_] = Assuming[Element[t, Reals],
  Norm[G[t]] // ComplexExpand // FullSimplify]

(*  Sqrt[100 + 1/2 Sqrt[-1444 + (200 - 162 Cos[(Sqrt[19] t)/5])^2] - 
 81 Cos[(Sqrt[19] t)/5]]/Sqrt[19]  *)

Plot[ng[t], {t, 0, 20}, AspectRatio -> 1]

enter image description here

FindMaxValue[ng[t], {t, 4}]

(*  4.3589  *)

The exact value is

Maximize[{ng[t], 0 < t < 20}, t]

(*  {Sqrt[19], {t -> (5 π)/Sqrt[19]}}  *)

% // N

(*  {4.3589, {t -> 3.60365}}  *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.