Clear Filters
Clear Filters

i Checked calculation and found The solution does not accord with the equation

1 view (last 30 days)
i used the matlab to solve the nolinear equation and put the solution in and found The solution does not accord with the equation
codes are as this
function program
function F = root2d(x)
%syms equa1sub equa2sub equa3sub equa4sub equa5sub equa6sub;
equa1sub =x(1)+484533722967603/281474976710656+(4153907340440276559918386333329/10141204801825835211973625643008+43872868936278563423508777924017/40564819207303340847894502572032*i)*x(4)-31910460946994608903643004387955/166153499473114484112975882535043072*x(5)+35907622679629336125438914937027/340282366920938463463374607431768211456*x(6);
equa2sub =x(2)+2179336774425063/9007199254740992-(2329631036423340670360942191305/53099476611423827671670350413824+6151292551464022570539684130455/53099476611423827671670350413824*i)*x(4)+1230493617143412223713722747795/1205242255167036818169426968838144*x(5)-139908178482254182174291657953/1085297737296852063790297074655821824*x(6);
equa3sub =x(3)-2179336774425063/36028797018963968+(17783443026132371529472841155/1491110427947729683792430891008+6151292551464022570539684130455/195335466061152588576808446722048*i)*x(4)+8613455320003885565996059234565/100800544111222430647960069182849024*x(5)+7228589221583132745671735660905/18787405208694330145359816318357864448*x(6);
equa4sub =x(4)+(1160967565235845/562949953421312+5122727319147305/18014398509481984*i)*(-2659506518368929/2251799813685248-43918910449825605755648012145/51854957628343581710615576576*x(2)+17710809864611394710166972861235/18312699943233055179075791880192*x(3));
equa5sub =x(5)+7314742574589651/281474976710656+14883446107327026008787450489355/16091720173204913572666146816*x(2)+15630005759314515809316534852965/48065444999324050258617434112*x(3);
equa6sub =x(6)-8743945551921635/549755813888-40127679390402942495192578739/308460169349260713656320*x(2)+6967229325491925089773435036915/4271761374342152099725312*x(3);
F(1)=equa1sub;
F(2)=equa2sub;
F(3)=equa3sub;
F(4)=equa4sub;
F(5)=equa5sub;
F(6)=equa6sub;
main program
clc;
clear all;
close all;
fun = @root2d;
%x0 = [0,0,0,0,0,0];
x0 = [1,1,1,1,1,1];
%x =fsolve(fun,x0)
x=vpa(fsolve(fun,x0),5)';
alpha0=x(1)
alpha1 = x(2)
alpha2 =x(3)
a0 = x(4)
a1 = x(5)
a2 = x(6)
solutions are as this
Optimization terminated: norm of relative change in X is less
than max(options.TolX^2,eps) and sum-of-squares of function
values is less than sqrt(options.TolFun).
alpha0 =
-3.0311-.40115*i
alpha1 =
-1.4434+.83345*i
alpha2 =
-.89752e-1+.49208e-1*i
a0 =
.28084+1.3447*i
a1 =
1338.2-786.87*i
a2 =
-25475.+28166.*i
>>
but when i put the solution in and found The solution does not accord with the equation
why

Answers (2)

Walter Roberson
Walter Roberson on 30 Dec 2018
You have
x=vpa(fsolve(fun,x0),5)';
which takes the solution returned by fsolve, takes the complex conjugate transpose, and truncates it to 5 decimal places. The truncated complex conjugates are not good solutions.
Remember, in MATLAB ' is complex conjugate transpose, not simple transpose.
Note: your functions are linear and so could be solved using \
  2 Comments
dcydhb dcydhb
dcydhb dcydhb on 31 Dec 2018
but if i use vpa
i get
alpha0 =
-3.0311 + 0.4012i
if you don't use vpa,you just get
x =
1.0e+004 *
Columns 1 through 4
-0.0003 + 0.0000i
which has a big difference

Sign in to comment.


Stephan
Stephan on 30 Dec 2018
Edited: Stephan on 30 Dec 2018
Hi,
this version works fine for me:
fun = @root2d;
x0 = [1,1,1,1,1,1];
x = fsolve(fun,x0)
result = fun(x)
function F = root2d(x)
%syms equa1sub equa2sub equa3sub equa4sub equa5sub equa6sub;
F(1) =x(1)+484533722967603/281474976710656+(4153907340440276559918386333329/10141204801825835211973625643008+43872868936278563423508777924017/40564819207303340847894502572032*i)*x(4)-31910460946994608903643004387955/166153499473114484112975882535043072*x(5)+35907622679629336125438914937027/340282366920938463463374607431768211456*x(6);
F(2) =x(2)+2179336774425063/9007199254740992-(2329631036423340670360942191305/53099476611423827671670350413824+6151292551464022570539684130455/53099476611423827671670350413824*i)*x(4)+1230493617143412223713722747795/1205242255167036818169426968838144*x(5)-139908178482254182174291657953/1085297737296852063790297074655821824*x(6);
F(3) =x(3)-2179336774425063/36028797018963968+(17783443026132371529472841155/1491110427947729683792430891008+6151292551464022570539684130455/195335466061152588576808446722048*i)*x(4)+8613455320003885565996059234565/100800544111222430647960069182849024*x(5)+7228589221583132745671735660905/18787405208694330145359816318357864448*x(6);
F(4) =x(4)+(1160967565235845/562949953421312+5122727319147305/18014398509481984*i)*(-2659506518368929/2251799813685248-43918910449825605755648012145/51854957628343581710615576576*x(2)+17710809864611394710166972861235/18312699943233055179075791880192*x(3));
F(5) =x(5)+7314742574589651/281474976710656+14883446107327026008787450489355/16091720173204913572666146816*x(2)+15630005759314515809316534852965/48065444999324050258617434112*x(3);
F(6) =x(6)-8743945551921635/549755813888-40127679390402942495192578739/308460169349260713656320*x(2)+6967229325491925089773435036915/4271761374342152099725312*x(3);
end
result is:
Equation solved, fsolve stalled.
fsolve stopped because the relative size of the current step is less than the
default value of the step size tolerance squared and the vector of function values
is near zero as measured by the default value of the function tolerance.
<stopping criteria details>
x =
1.0e+04 *
-0.0003 + 0.0000i -0.0001 - 0.0001i -0.0000 - 0.0000i 0.0000 - 0.0001i 0.1338 + 0.0787i -2.5475 - 2.8166i
result =
1.0e-10 *
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.0014 - 0.0001i 0.0000 + 0.1455i
Best regards
Stephan
  23 Comments
dcydhb dcydhb
dcydhb dcydhb on 3 Jan 2019
Edited: dcydhb dcydhb on 3 Jan 2019
without conj(x) there is more difference,and still i need the effective way to get the root of the 12 equations
dcydhb dcydhb
dcydhb dcydhb on 3 Jan 2019
Edited: dcydhb dcydhb on 3 Jan 2019
this time i use this
for K = 1 : 12
X(K) = sym( sprintf('x%d', K) );
end
[A, b] = equationsToMatrix(root2d(X), X);
%[A, b] = equationsToMatrix(root2d(X));
x = A\b;
xd = double(x);
vpa(x,10)
i put the root in the equation and get
equa1sub =
0.3873 + 2.6626i
equa2sub =
-0.0959 - 0.0103i
equa3sub =
0.0113 + 0.0775i
equa4sub =
-0.0118 - 0.0013i
equa5sub =
0.0029 + 0.0198i
equa6sub =
-0.0043 - 0.0005i
equa7sub =
-2.9789 - 0.5863i
equa8sub =
-5.7895e-008 -8.8981e-009i
equa9sub =
6.1587e-006 -8.7048e-006i
equa10sub =
0.0054 + 0.0038i
equa11sub =
38.2471 + 0.8511i
equa12sub =
1.4872e+003 +2.0583e+002i
>>
they are not zero so is the way effiective to solve the equation?

Sign in to comment.

Products


Release

R2007a

Community Treasure Hunt

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

Start Hunting!