Create a matlab script to find the roots of following functi

Create a matlab script to find the roots of following function using newtons method f(x)=e^-x -3x^2

Solution

% Newton Raphson Method clear all close all clc % Change here for different functions f=@(x) e^-x-3*x^2 %this is the derivative of the above function df=@(x) e^-x-3*x*x % Change lower limit \'a\' and upper limit \'b\' a=0; b=1; x=a; for i=1:1:100 x1=x-(f(x)/df(x)); x=x1; end sol=x; fprintf(\'Approximate Root is %.15f\',sol) a=0;b=1; x=a; er(5)=0; for i=1:1:5 x1=x-(f(x)/df(x)); x=x1; er(i)=x1-sol; end plot(er) xlabel(\'Number of iterations\') ylabel(\'Error\') title(\'Error Vs. Number of iterations\')
Create a matlab script to find the roots of following function using newtons method f(x)=e^-x -3x^2Solution % Newton Raphson Method clear all close all clc % Ch

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site