What am I missing in this code I am trying to find roots of a System of Equation?

1 回表示 (過去 30 日間)
I am trying to find values of θ and γ for a system of equation where x(1)=θ and x(2)=γ in the code.
The equations are;
I am using the code below but I couldn't find the correct answer. The answer for
The code works, but I get different values for different x intervals, and none of them are correct. (In this case 97.90)
What am I missing?
a(1,1) is the partial differential of with respect to θ
a(1,2) is the partial differential of with respect to γ
a(2,1) is the partial differential of with respect to θ
a(2,2) is the partial differential of with respect to γ
b(1) is
b(2) is
clc;clear;
x=[-1 0.8]; err=[0.01 0.01];
niter1=10;
niter2=50;
err=transpose(abs(err));
for n=1:niter2
x
%Error Equations---------------------------
a(1,1)=-0.2*sin(x(1))+0.2*((1-0.25*sin(x(1))^2)^(-1/2))*(-0.5*sin(x(1))*cos(x(1))); a(1,2)=0;
a(2,1)=0.2*cos(x(1)); a(2,2)=-0.4*cos(x(2));
b(1)=0.2*cos(x(1))+0.4*sqrt(1-0.25*sin(x(1))*sin(x(1)))-0.32;
b(2)=0.2*sin(x(1))-0.4*sin(x(2));
%----------------------------------------------
bb=transpose(b);eps=inv(a)*bb;x=x+transpose(eps);
if n>niter1
if abs(eps)<err
break
else
disp ('Roots are not found')
end
end
end

採用された回答

Walter Roberson
Walter Roberson 2020 年 5 月 26 日
x=x+transpose(eps)
That should be subtraction rather than addition.
  1 件のコメント
Ömer Faruk AKSOY
Ömer Faruk AKSOY 2020 年 5 月 26 日
First I want to thank you for the answer it worked fine and I find the correct answer. But can I ask why it should be substruction? I have solved many problems doing addition and they worked well and I find the correct answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by