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 CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by