0% found this document useful (0 votes)
18 views16 pages

Numerical Lab - Tanmoy

The document describes the concepts and working of the bisection method, false position method, and Newton-Raphson method for finding the root of an equation. It provides the general working rules, formulas, and numerical examples for each method. Sample MATLAB code is also given to implement the methods to find the root of equations.

Uploaded by

Tanmoy Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views16 pages

Numerical Lab - Tanmoy

The document describes the concepts and working of the bisection method, false position method, and Newton-Raphson method for finding the root of an equation. It provides the general working rules, formulas, and numerical examples for each method. Sample MATLAB code is also given to implement the methods to find the root of equations.

Uploaded by

Tanmoy Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Concept of Bisection Method:

𝑦 = 𝑓 (𝑥)
1st approximated 𝐵(𝑏 , 𝑓 ( 𝑏 ) ) Here, is negative.
root So, the actual root, lies between
Now, replace the value of ‘a’ such that
𝑎 +𝑏 𝑓 (𝑏)
𝑥1 =
2 Hence,
a 𝑥𝑟 𝑓 ( 𝑥 𝑟 )=0
𝑥
𝑓 (𝑥 1)
𝑓 (𝑎)
𝐶 (𝑥 1, 𝑓 (𝑥1 ))
𝐴(𝑎 , 𝑓 ( 𝑥 ) )
is negative
Concept of Bisection Method:
1st approximated
𝑦 = 𝑓 (𝑥) root
𝐵(𝑏 , 𝑓 ( 𝑏 ) ) Here, is positive.
So, the actual root, lies between
𝑎 +𝑏 𝐶 (𝑥 1, 𝑓 (𝑥1 )) Now, replace the value of ‘a’ such that
𝑥1 =
2
𝑓 (𝑏)
Hence,
𝑓 ( 𝑥 1)
a 𝑥𝑟
𝑥
𝑓 ( 𝑥 𝑟 )=0

𝑓 (𝑎)

𝐴(𝑎 , 𝑓 ( 𝑥 ) )
is positive
Bisection Method:
Working Rule:
1. Let be the given equation. Find two number ‘a’ and ‘b’ such that and . Alternately, we also can say that .

2. Find 1st approximate root by using the following formula of bisection method-

Calculate and examine the sign of

2.1 If < 0, The root lies between and . Now, . Hence, the 2nd approximate root is given by-

2.2 If 0, The root lies between and . Now, Hence, the 2nd approximate root is given by-

Calculate and repeat step 2.1 and 2.2 until achieving the required accuracy of the root.
Numerical Example: Find the root of the equation using bisection method correct up to 3 decimal points.

Solution:

Let,
Step 1: Find ‘a’ and ‘b’ such that and

So,
Step 2: Find the 1st approximated root using formula and calculate
==1.5
And f(x1)=1.53-1.5-1=15/8 which is positive

Step 3: As 0, The root lies between and . Now, Hence, b=1.5 and a=1. So, the 2nd approximate root will be
=1.25
Now, f(x2)= -19/64
Step 4: As 0, The root lies between and . Now, Hence, a=1.25 and b=1.5. So, the 2nd approximate root will be
=1.375
The same process is repeated and the successive approximations are
x4=1.3125, x5=1.34375, x6=1.328125
Sample MATLAB code for Bisection Method:
clc
clear all
f=input('please enter the equation=');
a=input('Please enter the value of a=');
b=input('Please enter the value of b=');
fprintf('f(a)=%.5f,f(b)=%.5f\n',f(a),f(b))
n=input('please enter how many times loop continue= ');
e=input('Enter tolerance=');

if f(a)*f(b)>0
disp('The root does not lie in the interval')
end

if f(a)*f(b)<0
for i=1:n
c=(a+b)/2;
if abs(a-c)<e || abs(b-c)<e
break
end
if f(a)*f(c)<0
b=c;
end
if f(a)*f(c)>0
a=c;
end
end
fprintf(' root x = %f\n',c)
end
Concept of False Position Method:
Slope of CA= Slope of CB
𝑦 = 𝑓 (𝑥)
𝐵(𝑏 , 𝑓 ( 𝑏 ) )

𝑓 (𝑏)
)¿

¿
, 0

, 0)
¿1
(𝐶 𝑥 ¿

¿2
a 𝑥𝑟 𝑓 ( 𝑥 𝑟 )= 0

𝑥¿
𝑥
𝐸(

𝑓 (𝑎) 𝐷(𝑥 1, 𝑓 (𝑥1 ))


As . So, and
𝐴(𝑎 , 𝑓 ( 𝑎 ))
If . So, b and Then find the new value of
False Position Method:
Working Rule:
1. Let be the given equation. Find two number ‘a’ and ‘b’ such that and . Alternately, we also can say that .

2. Find 1st approximate root by using the following formula of bisection method-

Calculate and examine the sign of

2.1 If < 0, The root lies between and . Now, . Hence, the 2nd approximate root is given by-

2.2 If 0, The root lies between and . Now, Hence, the 2nd approximate root is given by-

Calculate and repeat step 2.1 and 2.2 until achieving the required accuracy of the root.
Numerical Example: Find out the root of the following function using False Position Method

Solve:

So, the root lies between 0 and 1. Let, and

0 1 -2 1.4597 0.5781 -0.1033


0.5781 1 -0.1033 1.4597 0.6060 -0.0041
0.6060 1 -0.0041 1.4597 0.6071
0.6071 1 1.4597 0.6071 -6.1954
Sample MATLAB code for False Position Method:
clc
clear all
f=input('please enter the equation=');
a=input('Please enter the value of a=');
b=input('Please enter the value of b=');
fprintf('f(a)=%.5f,f(b)=%.5f\n',f(a),f(b))
n=input('please enter how many times loop continue= ');
e=input('Enter tolerance=');

if f(a)*f(b)>0
disp('The root does not lie in the interval')
end

if f(a)*f(b)<0
for i=1:n
c=(a*f(b)-b*f(a))/(f(b)-f(a));
if abs(a-c)<e || abs(b-c)<e
break
end
if f(a)*f(c)<0
b=c;
end
if f(a)*f(c)>0
a=c;
end

end
fprintf(' root x = %f\n',c)
end
Concept of Newton-Raphson Method

y=f(x)

f(xo)
f(x1) Similarly,

xr
x 2 x1 xo x The generalized formula for Newton-Raphson
xo-x1
Method:
Newton-Raphson Method Working Rule:
1. Given, Find the initial approximate root such that is close to zero.
2. Find and .
3. First approximate root, can be found by the formula of Newton-Raphson method

4. Similarly, second approximate root, will be-

5. Hence, the general formula of Newton-Raphson method is given by the following expression-
Numerical Example: Find the root of the equation using bisection method correct up to 3 decimal points.

Solution: Given that,


or, =48
or,

Let, s
And
As the sign of f(3) is positive and
f(4) is negative, the root of the
Now, equation lies between 3 and 4 but
f(3) and f(4) >> 0

The sign of f(3.6) is negative and


f(3.7) is positive and f(3.6), f(3.7) are
close to zero. Thus, choosing 3.6 or
3.7 as xo, we will be able to find the
solution with less number of iteration
Let, xo=3.6, f(xo)=f(3.6)=1.334 and f’(xo)=f’(3.6)=38.88

1st approximate root,

Now, f(x1)=f(3.634567)=0.012910 and f’(x1)=f’(3.634567)=39.630231


2nd approximate root,

Now, f(x2)=f ()=0.000007 and f’(x2)=f’()=39.623122


3rd approximate root,
Sample MATLAB code for Newton Raphson Method:
clc
clear all
f=@(x) x^3-48;
df=@(x) 3*x^2;
x(1)=input('Enter the initial guess:');
n=input('Enter the number of iteration:');
e=input('Enter the value of tolerance:');

for i=1:n
x(i+1)=x(i)-(f(x(i))/df(x(i)));
if abs((x(i+1)-x(i)))<e
break
end

end

fprintf('The root is %f at iteration %d\n',x(i+1),i)


Sample MATLAB code for Newton Raphson Method (Generalized):
clc
clc
clear all

f=input('Enter the equation:')


X(1)=input('Enter the initial guess:');
n=input('Enter the number of iteration:');
e=input('Enter the value of tolerance:');

syms x %Creating variable named x


df=diff(f,x,1);% Differentiating f with respect to x once
dff=inline(df)% Writing df as a function of x i.e @x df

for i=1:n
X(i+1)=X(i)-(f(X(i))/dff(X(i)));
if abs((X(i+1)-X(i)))<e
break
end

end

fprintf('The root is %f at iteration %d\n',X(i+1),i)

You might also like