Lab 5 - Bisection Method Newton Raphson Method
Lab 5 - Bisection Method Newton Raphson Method
Class: BESE-13AB
Objectives
The purpose of this lab is to get familiar with Bisection Method and Newton Raphson Method
Tools/Software Requirement
Matlab R2016a or Online Matlab
Description
for i=2:1000
%write missing part of code by following and understanding the flow chart
% xnew(1)=0;
xnew(i)=xr;
if abs(xnew(i)-xnew(i-1)/xnew(i))<tol,break,end
end
str = ['The required root of the equation is: ', num2str(xr), '']
Description
For Newton Raphson method, the function must be differentiable. The formula for Newton
Raphson method is:
Main Steps
Lab Task # 1
The bisection method in mathematics is a root-finding method that repeatedly bisects an interval
and then selects a subinterval in which a root must lie for further processing. It is a very simple
and robust method, but it is also relatively slow.
Code:
for i = 2 : 1000
xr = (xu + xl) / 2;
xnew(1) = 0;
xnew(i) = xr;
outStr = ['Required root for the input equation is: ', num2str(xr), ''];
end
Lab Task #2
Implement Newton Raphson method as function. Take function, initial guess and tolerance as
input from user. Calculate its derivative and find its roots.
function newtonRaphson()
% Newton-Raphson method
for i = 1:100
f1 = f(x(1));
f1_der = d(x(1));
Z = x(1) - f1 / f1_der;
er = abs(Z - x(1));
if er < error
break;
end
x(1) = Z;
end
end
Deliverables
Submit single word file with matlab code and screen shot of Output.