Filter löschen
Filter löschen

How to calculate an exact solution: non-linear equation with multiple variables

2 Ansichten (letzte 30 Tage)
In order to diagonalization of 3x3 matrix, I'm using 'fsolve' command. (there are 3 solutions for each matrix element of diagoanl)
However, it shows the deviation between the calculation solution and the real solution. Even it is reduced by change the initial value.
It means fsolver could show the exact value, I guess...
(I tried setting the option such as 'FunctionTolerance', 'StepTolerance', there was no effect.)
-------------------------------------------
Coef=readmatrix('coef.txt');
v1=0;
T_eff=Coef(v1,1); A_eff=Coef(v1,2); eps_eff=Coef(v1,3); alp_eff=Coef(v1,4); B_eff=Coef(v1,5); D_eff=Coef(v1,6); p_eff=Coef(v1,7); q_eff=Coef(v1,8); A_D_eff=Coef(v1,9); gamma_eff=Coef(v1,10); H_eff=Coef(v1,11);
Eg=zeros(100,3);
for J=0:1:50;
x=N*(N+1);
W11=T_eff-A_eff+eps_eff-alp_eff+B_eff*(x+1)+0.25+q_eff*x+0.5*(1-1)*(q_eff+p_eff)-A_D_eff*(x+1)-D_eff*(x^2+4*x+1)-H_eff*(x^3+9*x^2+9*x+1);
W12=-(B_eff+(0.25-0.5)*q_eff+(0.125-1/4)*p_eff-0.5*A_D_eff-2*D_eff*(x+1)-0.5*gamma_eff+H_eff*(3*x^2+10*x-1))*sqrt(2*x);
W13=-(2*D_eff+0.25*q_eff-2*H_eff*(3*x-1))*sqrt(x*(x-2));
W21=W12;
W22=T_eff-2*eps_eff+B_eff*(x+1)+0.25*q_eff*(1-1)*x+0.5*(q_eff+p_eff)-D_eff*(x^2+6*x-3)+H_eff*(x^3+15*x^2-5*x+5);
W23=-(B_eff+0.25*q_eff+0.125*p_eff+0.5*A_eff-2*D_eff*(x-1)-0.5*gamma_eff+H_eff*(3*x^2-2*x+3))*sqrt(2*(x-2));
W31=W13;
W32=W23;
W33=T_eff+A_eff+eps_eff+B_eff*(x-3)+0.25*q_eff*(x-2)+A_D_eff*(x-3)-D_eff*(x^2-4*x+5)+H_eff*(x^3-3*x^2+5*x-7);
E_mat=@(E)det([W11-E(1) W12 W13; W21 W22-E(2) W23; W31 W32 W33-E(3)]);
E0=[W11,W22,W33];
options=optimoptions('fsolve','Display','iter','FunctionTolerance',0,'StepTolerance',0);
[E,fval]=fsolve(E_mat,E0,options);
E_ans(J+1,:)=det([W11-E_B W12 W13; W21 W22-E_B W23; W31 W32 W33-E_B]); %test line for checking the deviation
end
---------------------------------------------
No Solution Found
fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the default value of the function tolerance.
------------------------------------------
determinant error is below just 1e-5, however, I want to exact value.

Akzeptierte Antwort

Torsten
Torsten am 10 Aug. 2022
Use "eig", not "fsolve".
  3 Kommentare
Torsten
Torsten am 12 Aug. 2022
You have one equation
det([W11-E(1) W12 W13; W21 W22-E(2) W23; W31 W32 W33-E(3)]) = 0
for three unknowns E(1), E(2) and E(3).
I doubt this is what you want.
The three eigenvalues solve
Det_err1 = det([W11-eig_val(1,1) W12 W13; W21 W22-eig_val(1,1) W23; W31 W32 W33-eig_val(1,1)] = 0
Det_err2 = det([W11-eig_val(1,2) W12 W13; W21 W22-eig_val(1,2) W23; W31 W32 W33-eig_val(1,2)] = 0
Det_err3 = det([W11-eig_val(1,3) W12 W13; W21 W22-eig_val(1,3) W23; W31 W32 W33-eig_val(1,3)] = 0
JongGu Han
JongGu Han am 12 Aug. 2022
Bearbeitet: JongGu Han am 12 Aug. 2022
oh, it's poor mistake.
Thank you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Linear Model Identification finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by