Why my symbolic result of eigenvalue doesn't match my numeric result?

3 visualizzazioni (ultimi 30 giorni)
I have a set of three points, . As well as a matrix
[2, 0, 0]
[0, 2, 4*z2]
[0, 4*z2, 4*y2 + 2]
I need to find the eigenvalue of this matrix both symbolically and numerically after we substitude the y and z value in the matrix with the values in the provided points. However, if I plug in the numeric y and z value into the symbolic result I got from using
eigen = eig(eqn2ma)
It is different from first substituting the y and z into the matrix, then taking its eigenvalue.
This is the code
syms x y x1 y1 a x2 y2 z2 lamb
%{
%Q2
t=@(x,y) power(atan(x.*y),3)+power(sin(x),2);
star = 2*pi;
x = 0:0.01:star; % define range and mesh of x and y which will be shown in figure
y = -1:0.01:1;
[X, Y] = meshgrid(x, y);
figure
surf(X, Y, t(X,Y))
f = power(atan(x1*y1),3)+power(sin(x1),2);
f2 = diff(f,x1) == 0;
f3 = diff(f,y1) == 0;
[sx1,sy1] = vpasolve(f2,f3);%find the values of x and y of the minimum
extreme_values = subs(f, {x1,y1}, {sx1,sy1})%solve for the minimum
%}
%
%Q3
eqn = (x2^2)+2*x2+(y2^2)+2*y2*(z2^2)+(z2^2);
eqn1 = diff(eqn,x2)==0
eqn2 = diff(eqn,y2)==0
eqn3 = diff(eqn,z2)==0
[sx,sy,sz] = vpasolve(eqn1,eqn2,eqn3) %find the inflection points
vari = {x2, y2, z2};
eqn1ma = [diff(eqn,x2) diff(eqn,y2) diff(eqn,z2)];
eqn2ma = [a a a; a a a; a a a];
eqn2sol = zeros(3,3);
for i = 1:3
for j=1:3
eqn2ma(i,j)=diff(eqn1ma(1,j),vari(i));%create Hessian
end
end
eqn2ma
lambdia = [lamb 0 0; 0 lamb 0; 0 0 lamb];
eqn2malamb = eqn2ma-lambdia;
lamb0 = det(eqn2malamb);
S = solve(lamb0, lamb)
eigen = eig(eqn2ma)
for i = 1:3
for j = 1:3
for k = 1:3
eqn2sol(j,k)=subs(eqn2ma(j,k), {x2,y2,z2}, {sx(i,1),sy(i,1),sz(i,1)});
end
end
eqn2sol %ouput Hessian
eigenvalules = eig(eqn2sol)%find eigenvalue
end
Could you tell me why?
  2 Commenti
Steven Lord
Steven Lord il 31 Gen 2023
Which two quantities are you comparing and expecting to be the same? Please add semicolons to all the lines of code that lack them then at the end display the two quantities that you expected to be equal.
Torsten
Torsten il 31 Gen 2023
If you subs the {sx,sy,sz} in the symbolic expression "eigen", you will get the same numerical eigenvalues as you get from the line "eigenvalules = eig(eqn2sol)".
So I don't understand your point.

Accedi per commentare.

Risposte (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov il 31 Gen 2023
The reason for having three different eigen values can be explained with the followings:
Eigenvalues1 = eig([2 0 0; 0 2 0; 0 0 2]) % @ (-1 0 0)
Eigenvalues1 = 3×1
2 2 2
Eigenvalues2 = eig([2 0 0; 0 2 4*-sqrt(.5); 0 4*-sqrt(.5) 4*-.5+2]) % @ (-1 -.5 -sqrt(.5))
Eigenvalues2 = 3×1
-2.0000 2.0000 4.0000
Eigenvalues3 = eig([2 0 0; 0 2 4*sqrt(.5); 0 4*sqrt(.5) 4*-.5+2]) % @ (-1 -.5 sqrt(.5))
Eigenvalues3 = 3×1
-2.0000 2.0000 4.0000

Categorie

Scopri di più su Elementary Math in Help Center e File Exchange

Tag

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by