Display only one eigenvalue of symbolic matrix
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Steven Lord
le 24 Fév 2020
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?
Réponses (1)
Christine Tobler
le 21 Fév 2020
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.
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!