Display only one eigenvalue of symbolic matrix
조회 수: 5 (최근 30일)
이전 댓글 표시
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
Steven Lord
2020년 2월 24일
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?
답변 (1개)
Christine Tobler
2020년 2월 21일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!