필터 지우기
필터 지우기

Code for newton-rapshon ( x, y)

조회 수: 1 (최근 30일)
Cesar Castro
Cesar Castro 2021년 9월 21일
댓글: Gessica Rueda 2021년 9월 24일
Hello everyone
I am in a course of numerical methods, where I need to apply the newton raphson method for two variables, I have tried source codes, however I always receive an error. Someone could provide me with the solution and explain what happens?. Thank you.
Other methods ( root in 1)
x(1)^4+x(2)^4+2*x(1)^2*x(2)^2-4*x(1)+3
  댓글 수: 1
Gessica Rueda
Gessica Rueda 2021년 9월 24일
HI Cesar, call me, i can explain you,
kisses

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

답변 (1개)

Manan Jain
Manan Jain 2021년 9월 22일
function [root,ea,iter]=newtraph(func,dfunc,xr,es,maxit,varargin)
% newtraph: Newton−Raphson root location zeroes
% % [root,ea,iter]=newtraph(func,dfunc,xr,es,maxit,p1,p2,...):
% % uses Newton−Raphson method to find the root of func
% % input:
% % func = name of function
% % dfunc = name of derivative of function
% % xr = initial guess
% % es = desired relative error (default = 0.0001%)
% % maxit = maximum allowable iterations (default = 50)
% % p1,p2,... = additional parameters used by function
% % output:
% % root = real root
% % ea = approximate relative error (%)
% % iter = number of iterations
if nargin<3,
error('at least 3 input arguments required'),
end if
nargin<4|isempty(es),es=0.0001;
end if
nargin<5|isempty(maxit),maxit=50;
end iter = 0;
while (1) xrold = xr;
xr = xr func(xr)/dfunc(xr);
iter = iter + 1;
if xr ~= 0,
ea = abs((xr xrold)/xr) * 100;
end if
ea <= es | iter >= maxit,
break,
end
end
root = xr;
end

카테고리

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