# Plot of the real part of the maximum eigenvalue of matrix

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}]


\$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]]


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]


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]


• 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? Commented May 4, 2023 at 23:59
• 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. Commented May 5, 2023 at 1:36
• great thank you very much Commented May 5, 2023 at 9:16