Display only one eigenvalue of symbolic matrix

Hey :)
How to ask matlab to display only one (the first, biggest in magnitude) eigenvalue of a symbolic matrix (well the matrix only contains one strictly positive variable)?
The thing is that I need to insert the scalar(!) eigenvalue further into a function.
I tried eigs(A,1) but I get the error: "Error using eigs>checkInputs (line 214) First argument must be a double matrix or a function."
So i assumed it is because of the one variable in the matix...
Any help would be appreciated :)
Edit: Maybe here my code:
clear
a = 1.0; b = 0.0; m = 25.0; V = 13.0; Ecut = 50.0; w = 1.5*sqrt(m/(a+9/4*b)); Nx = 100; Ny = 100; Nz = 100; k = 1;
T = 1;
syms kx ky kz real
syms D positive
E = eye(4);
U = [0 0 0 1; 0 0 -1 0; 0 1 0 0; -1 0 0 0];
Jx = 1/2*[0 sqrt(3) 0 0; sqrt(3) 0 2 0; 0 2 0 sqrt(3); 0 0 sqrt(3) 0];
Jy = 1i/2*[0 -sqrt(3) 0 0; sqrt(3) 0 -2 0; 0 2 0 -sqrt(3); 0 0 sqrt(3) 0];
Jz = 1/2*[3 0 0 0; 0 1 0 0; 0 0 -1 0; 0 0 0 -3];
P = (D*(Jy*Jz+Jz*Jy)+1i*D*(Jx*Jz+Jz*Jx))*U/sqrt(3);
h = (a*(kx*kx+ky*ky+kz*kz)-m)*E+b*(kx*Jx+ky*Jy+kz*Jz)^2;
H = [h P; ctranspose(P) -transpose(h)];
dsum = 0;
counter = 0;
for i = 1:Nx
for j = 1:Ny
for l = 1:Nz
kx = w*i/Nx;
ky = w*j/Ny;
kz = w*l/Nz;
if abs(a*(kx*kx+ky*ky+kz*kz)^2-m)<Ecut
dsum = dsum + 8.0*D*D/V-8.0*k*T*ln(2.0*cosh(max(eig(H))/(2.0*k*T)));
counter = counter + 1;
end
end
end
end
F = @(D)dsum;
D = [0,10];
x = fminsearch(F,D)

3 Comments

What would you expect to receive as the largest eigenvalue for this matrix?
syms x y
A = [x 0; 0 y];
eig(A)
Well but that is not the case as my matrix only depends on one symbolic variable which I defined to be positive(?)
Okay, then what about:
syms x positive
A = [x 0; 0 x^2]
eig(A)
The eigenvalues of A are x and x^2.
If x is less than 1, x is greater than x^2.
If x is greater than 1, x^2 is greater than x.
Which eigenvalue would you want the function that returns "the largest" eigenvalue to return?

Sign in to comment.

Answers (1)

The eigs function is not supported for symbolic values, as it is specifically based on getting a good approximation based on an iterative algorithm. For symbolic variables, only eig is provided, which computes all eigenvalues directly.
You can use max(eig(A)) to compute the largest eigenvalue for a symbolic matrix A. Note these computations can be very expensive for symbolic variables.

1 Comment

Thank you! Using max(eig(A)) unfortunately gives me the error : Error using sym/max (line 101)
Input arguments must be convertible to floating-point numbers. ..(?)

Sign in to comment.

Categories

Find more on Linear Algebra in Help Center and File Exchange

Tags

Asked:

on 21 Feb 2020

Commented:

on 24 Feb 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!