Using a Newton Raphson approach to nonlinear systems to write aMatlab script and shows the results for two different functions
Solution
`Hey,
Note: Brother in case of any queries, just comment inbox I would be very happy to assist all your queries
clc
clear all
close all
f = @(x) log(x+4)-2;
g=@(x) 1/(x+4);
x0=1;
e=0.01e-4;
maxit=100;
x1=x0;
x0=0;
N=0;
err=[];
while 1
if abs(f(x1))>e
x0=x1;
x1=x0-(f(x0)/g(x0));
N=N+1;
else
break;
end
if(N==maxit)
break;
end
end
root=x1;
iter=N;
disp(‘So, final approximation is’)
(root)
fprintf(‘Number of iteration is %dn’,N);
fprintf(‘Approximate absolute relative error is%fn’,abs(x1-x0)/abs(x1));
Kindly revert for any queries
Thanks.
MATLAB R2018a ② ▼| rch Documentation Log In EDITOR Find Files Compare
OR
OR