this document about numerical methods, Study notes of Mathematics

In this document has matlab programming

Typology: Study notes

2021/2022

Available from 06/29/2024

rupes-saha
rupes-saha 🇧🇩

1 / 71

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47

Partial preview of the text

Download this document about numerical methods and more Study notes Mathematics in PDF only on Docsity!

Iteration Method(theory):

Let f(x)=0 -------------(1)

Be the given equation can be written as

x= (x) …………..(2) ,where |'(x) |<

consider the first approximation root is 𝑥

1

=a

and the second approximation root 𝑥

2

putting x= 𝑥

1

in right hand side of

equation (2),we get

2

1

Similarly, 𝑥

3

2

2

𝑛− 1

Iteratiom method(problem):

Find the root of the equation 𝑥

3

  • 𝑥 − 1 = 0 by using the iteration method.

Solution:

Let f(x)= 𝑥

3

Here, f(0)= - 1<

f(1)= 1>

so the root lies between 0 and 1

then the first approximation

0

0 + 1

2

Now from equation (1)

Iteration method(program):

clc

all clear

g=@(x) x.^3+x-1;

f=@(x) 1/(x.^2+1);

df=@(x) - 2*x/(x.^2+1)^2;

x=input('Enter the initial value: ');

t=input('Tolerence:');

n=input('Enter the iteration number:');

while(df(x)>1)

fprintf('There is no root');

end

for i=1:n

x1=f(x);

fprintf('\n x%d= %.4f\n',i,x1);

if abs(x1-x)<t

break;

end

x=x1;

end

fprintf('\n\n The root is %f',x1);

x=-20:0.01:20;

plot(x,g(x),'b','linewidth',2)

hold on

plot(x1,f(x1),'or')

hold on

plot([-5,5],[0,0])

hold on

plot([0,0],[-5,5])

legend('f(x)=x.^3+x-1','root');

xlabel('x-axis','fontsize',14);

ylabel('y-axis','fontsize',14);

grid on

hold off

output:

ans =

logical

The curve AB cut the x-axis at Q point.The approximation root equation (1) is

OQ.

Let A[a,f(a)] B[b,f(b)] be the extremities of the chord AB.Now the equation of

the chord AB.

y-f(a)=

𝑓(𝑏)−𝑓(𝑎)

( 𝑏−𝑎

)

To find OQ put y=

0 - f(a)=

𝑓(𝑏)−𝑓(𝑎)

( 𝑏−𝑎

)

(x-a)= -

𝑓(𝑎)(𝑏−𝑎)

𝑓(𝑏)−𝑓(𝑎)

(x-a)=

𝑓(𝑎)(𝑎−𝑏)

𝑓(𝑏)−𝑓(𝑎)

x=a+

𝑓(𝑎)(𝑎−𝑏)

𝑓(𝑏)−𝑓(𝑎)

x=

𝑎𝑓(𝑏)−𝑏𝑓(𝑎)

𝑓

( 𝑏

) −𝑓(𝑎)

This is the required equation.

False position method(math):

Find a root of the equation 𝑥

3

− 3 𝑥 − 5 = 0 by the method of false position.

Solution:

Let f(x)=𝑥

3

Since f(2)= - 3<

f(3)= 13>

The root lies between 2 and 3.

0

2 × 13 − 3 × (− 3 )

Now f (𝑥

0

) = f (2.18756) = - 1.095<

False position method(program):

clc

clear all

f=@(x)x.^3-3*x-5;

x1=input('Enter the upper interval a=');

x2=input('Enter the lower interval b=');

t=input('Tollerence T=');

fx1=f(x1);

fx2=f(x2);

if (fx1*fx2>0)

disp('There are no roots');

elseif(fx1*fx2<0)

disp('There is a root');

for i=1:

m=((x1fx2)-(x2fx1))/(fx2-fx1);

fm=f(m);

fprintf('\n %f %f %f \n',i,m,fm);

if abs(fm)<t

break

end

if(fx1*fm<0)

x2=m;

else

x1=m;

end

end

end

fprintf('\n\n The root is %f',x1)

hold on

grid on

plot(x,f(x),'m','linewidth',5)

plot(m,f(m),'o')

plot([-5,5],[0,0])

plot([0,0],[-5,5])

legend('f(x)=x.^3-3*x-5;');

xlabel('x-axis','fontsize',14);

ylabel('y-axis','fontsize',14);

hold off

output:

  • Enter the initial value:
  • Tolerence:0.
  • Enter the iteration number:
    • x1= 1.
    • x2= 0.
    • x3= 0.
    • x4= 0.
    • x5= 0.
    • x6= 0.
    • x7= 0.
    • x8= 0.
    • x9= 0.
    • x10= 0.
    • x11= 0.
    • x12= 0.
    • x13= 0.
    • x14= 0.
    • x15= 0.
    • x16= 0.
    • x17= 0.
  • Enter the upper interval a=
  • Enter the lower interval b=
  • Tollerence T=0.
    • 1.000000 2.187500 - 1. There is a root
    • 2.000000 2.339844 0.
    • 3.000000 2.216064 - 0.
    • 4.000000 2.239273 - 0.
    • 5.000000 2.258130 - 0.
    • 6.000000 2.273451 - 0.
    • 7.000000 2.285900 0.
    • 8.000000 2.275785 - 0.
    • 9.000000 2.277682 - 0.
    • 10.000000 2.279223 0.
    • 11.000000 2.277971 - 0.
    • 12.000000 2.278 206 - 0.
    • 13.000000 2.278396 - 0.
    • 1 4.000000 2.278551 - 0.
    • 15.000000 2.278677 - 0.
    • 16.000000 2.278780 - 0.
    • 17.000000 2.278863 - 0.
    • 18.000000 2.278930 - 0.
    • 19.000000 2.278985 - 0.

0

(𝑎+𝑏)

2

In this case two possibilities will b

(1).f (𝑥

0

(2). f (𝑥

0

Now if (1) occure then 𝑥

0

is the root of the equation f(x)=0 and the

process will be terminated.

If (2) occure the root either lies between the 𝑥

0

and a or 𝑥

0

and b

Accordingly f(𝑥

0

) .f(a)<0 or 𝑓(𝑥

0

). 𝑓(b)<0 .So we have the second

approxition ,

1

(𝑥

0

+𝑎)

2

or 𝑥

1

( 𝑥

0

+𝑏

)

2

similar process of this method

Bisection method(math):

Find the root of the equation 𝑥

3

− 𝑥 − 1 = 0 by using bisection method.

Solution:

Let f(x)= 𝑥

3

f(1)=1- 1 - 1=-1<

and

f(2)=8- 2 - 1=5>

f(𝑥

6

)= f(1. 3203 ) =

3

The root lies between 1.3203 and 1. 3281

7

f(𝑥

7

)= f(1. 3242 ) = ( 1. 3242 )

3

The root lies between 1.3242 and 1. 3281

8

f(𝑥

8

)= f(1. 3261 ) = ( 1. 3261 )

3

The required root lies between 1.3242 and 1.3261.

Bisection method(program):

clc

clear all

f=@(x)x.^3-x-1;

x1=input('Enter the upper interval a=');

x2=input('Enter the lower interval b=');

t=input('Tollerence T=');

fx1=f(x1);

fx2=f(x2);

if (fx1*fx2>0)

disp('There are no roots');

else

disp('There is a root');

for i=1:

m=(x1+x2)/2;

fm=f(m);

fprintf('\n %f %f %f\n',i,m,fm);

if abs(fm)<t

break

end

if(fx1*fm<0)

x2=m;

else

x1=m;

end

end

end

fprintf('\n\n The root is %f',x1)

x1=-20:0.01:20;

hold on

grid on

plot(x1,f(x1),'m','linewidth',5)

plot(m,f(m),'o')

plot([-5,5],[0,0])

plot([0,0],[-5,5])

legend('f(x)=3x.^3+8x.^2+8*x+5;');

xlabel('x-axis','fontsize',14);

ylabel('y-axis','fontsize',14);

hold off

output:

Enter the upper interval a=

Enter the lower interval b=

Tollerence T=0.

There is a root

f(a) + hf'(a)=

hf'(a) = - f(a)

h= -

𝑓(𝑎)

𝑓′(𝑎)

So, the first approximation

1

𝑓(𝑎)

𝑓

( 𝑎

)

2

1

1

𝑓(𝑎

1

)

𝑓′(𝑎

1

)

𝑛+ 1

𝑛

𝑛

𝑓(𝑎

𝑛

)

𝑓′(𝑎

𝑛

)

By repeating this method we get the close approximation deseired root.

Newton-Raphson method(problem):

Solve for a real root of the eqution 𝑥

4

2

− 80 = 0 by using Newton -

Rophson method.

Solution:

Given equation

4

2

Let f(x)= 𝑥

4

2

f'(x)= 4𝑥

3

Here f(2) = - 60 <

f(3) = 10 >

The root lies between 2 and 3

The initial approximation value of the root ,

0

2 + 3

2

Now ,we get from Newton-Rophson method

1

0

𝑓(𝑥

0

)

𝑓′(𝑥

0

)

2

1

𝑓(𝑥

1

)

𝑓′(𝑥

1

)

3

2

𝑓(𝑥

2

)

𝑓′(𝑥

2

)

4

3

𝑓(𝑥

3

)

𝑓′(𝑥

3

)

5

4

𝑓(𝑥

4

)

𝑓′(𝑥

4

)

The required root is 2.

Newton-Rophson method(program)

clc

clear all

f=@(x)x.^4+x.^2-80;

df=@(x)4x.^3-2x;

x=input('Intial value=');

t=input('tollerence=');

n=input('Number of iteration=');

if df(x)==

fprintf('there is no root');

else

fprintf('there is root');

for i=1:n

x1=x-f(x)/df(x);

fprintf('\n x%d = %.4f\n',i,x1);

if (df(x1)==0)

fprintf('there is no root');

end

if(abs(x-x1)<t)