1
$\begingroup$

I am looking to plot the real part of the maximum eigenvalue of matrix A as a function of x and y. Thanks

A[x_, y_, z_]:={{-6000000 \[Pi] + 12000000 \[Pi] z_, 0, 0, 6000000 \[Pi] y_, 0, 6000000 \[Pi] x_, 0, 0}, {0, -6000000 \[Pi] - 12000000 \[Pi] z_, -6000000 \[Pi] y_, 0, -6000000 \[Pi] x_, 0, 0, 0}, {0, 6000000 \[Pi] y_, -6000000 \[Pi] + 12000000 \[Pi] z_, 0, 0, 0, 0, 6000000 \[Pi] x_}, {-6000000 \[Pi] y_, 0, 0, -6000000 \[Pi] - 12000000 \[Pi] z_, 0, 0, -6000000 \[Pi] x_, 0}, {0, 6000000 \[Pi] x_, 0, 0, -3600000 \[Pi], 0, 0, 0}, {-6000000 \[Pi] x_, 0, 0, 0, 0, -3600000 \[Pi], 0, 0}, {0, 0, 0, 6000000 \[Pi] x_, 0, 0, -3600000 \[Pi], 0}, {0, 0, -6000000 \[Pi] x_, 0, 0, 0, 0, -3600000 \[Pi]}};


maxEigenvalueReal[x_, y_, z_] := Re[Max[Eigenvalues[A[x, y, z]]]];

DensityPlot[maxEigenvalueReal[3, y, z], {y, 0, 2}, {z, 0, 5}]
$\endgroup$

1 Answer 1

3
$\begingroup$
$Version

(* "13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)" *)

Clear["Global`*"]

There should not be any patterns (e.g., x_) on the RHS of the definition for A

A[x_, y_, 
   z_] := {{-6000000 π + 12000000 π z, 0, 0, 6000000 π y, 0, 
    6000000 π x, 0, 
    0}, {0, -6000000 π - 12000000 π z, -6000000 π y, 
    0, -6000000 π x, 0, 0, 0}, {0, 
    6000000 π y, -6000000 π + 12000000 π z, 0, 0, 0, 0, 
    6000000 π x}, {-6000000 π y, 0, 
    0, -6000000 π - 12000000 π z, 0, 0, -6000000 π x, 0}, {0, 
    6000000 π x, 0, 0, -3600000 π, 0, 0, 0}, {-6000000 π x, 0, 0, 
    0, 0, -3600000 π, 0, 0}, {0, 0, 0, 6000000 π x, 0, 
    0, -3600000 π, 0}, {0, 0, -6000000 π x, 0, 0, 0, 
    0, -3600000 π}};

Eigenvalues[A[3, 3, 3]]

enter image description here

Since the Eigenvalues are complex, I assume that you want the eigenvalue with the greatest magnitude

maxEigenvalueReal[x_, y_, z_] := 
  Re[MaximalBy[Eigenvalues[A[x, y, z]], Abs][[1]]];

DensityPlot[maxEigenvalueReal[3, y, z],
 {y, 0, 2}, {z, 0, 5},
 PlotPoints -> 50,
 MaxRecursion -> 5,
 PlotLegends -> Automatic]

enter image description here

Alternatively, if you want the eigenvalue with the maximum real part

maxEigenvalueReal[x_, y_, z_] := 
  Re[MaximalBy[Eigenvalues[A[x, y, z]], Re][[1]]];

DensityPlot[maxEigenvalueReal[3, y, z],
 {y, 0, 2}, {z, 0, 5},
 PlotPoints -> 50,
 MaxRecursion -> 5,
 PlotLegends -> Automatic]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you, dear friend, for your response. Just one more question, please: does this code search for the real value of the maximum eigenvalue and plot it as a function of the variables mentioned here, or should I manually look for the maximum eigenvalue? $\endgroup$ May 4 at 23:59
  • 1
    $\begingroup$ It is meaningless to talk about the maximum of complex numbers, they are not ordered. You need to specify whether you want the maximum magnitude or maximum real part or maximum imaginary part or some other scalar function of complex numbers. The second argument of the MaximalBy in the code specifies what is being used to order the eigenvalues. The first example used Abs (magnitude), the second example used the real part. $\endgroup$
    – Bob Hanlon
    May 5 at 1:36
  • $\begingroup$ great thank you very much $\endgroup$ May 5 at 9:16

Your Answer

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

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