Not sure how to solve equations using newton-Raphson method

조회 수: 4 (최근 30일)
Matthew Worker
Matthew Worker 2020년 11월 16일
편집: John Kelly 2021년 4월 8일
Can anyone help me solve these two equation using newton-raphson method
5/2*cos(x(1))+3*cos(x(1)+x(2))-5
5/2*sin(x(1))+3*sin(x(1)+x(2))-2
  댓글 수: 3
Matthew Worker
Matthew Worker 2020년 11월 16일
iter = 0;
x = input('Enter intiial value ');
Dx = [10; 10];
C=[5; 2];
disp('Iter DC Jacobian matrix Dx x');
while max(abs(Dx)) >= 0.0001 & iter <10
iter=iter+1;
f = [5/2*cos(x(1))+3*cos(x(1)+x(2)); 5/2*sin(x(1))+3*sin(x(1)+x(2))];
DC = C -f;
J = [-5/2*sin(x(1)) -3*sin(x(1)+x(2))
5/2*cos(x(1)) 3*cos(x(1)+x(2))]
Dx=J\DC
x=x+Dx
end

댓글을 달려면 로그인하십시오.

채택된 답변

Monisha Nalluru
Monisha Nalluru 2020년 11월 19일
편집: John Kelly 2021년 4월 8일
From my understanding you are trying to solve the multi variable equations. The equation followed is
As a example
X0=[1;1]; %inital guess
toleX=1e-4; %tolerance
X = X0;
Xold = X0;
while true
[f,j]=systemequ(X);
X = X - inv(j)*f;
err = abs(X-Xold);
Xold = X;
if(err < toleX) %checking the error and tolerance
break
end
end
function [fval,jac]= systemequ(X) %funtion return f(Xn) and jacobian value
x=X(1);
y=X(2);
fval(1,1)=5/2*cos(x)+3*cos(x+y)-5;
fval(2,1)=5/2*sin(x)+3*sin(x+y)-2;
jac=[-5/2*sin(x) -sin(x+y);
5/2* cos(x) 3*cos(x+y)];
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Newton-Raphson Method에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by