Conasm Mass Notes Unit 3

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Unit 4

Interpolation and approximation


Consider a function y=f(x) as x takes value x0,x1,x2,…,xn, let the corresponding values of y be
y0,y1,y2,…,yn

The process of estimating the value of y for any intermediate value of x is called interpolation

However, the method of computing the value of y for a given value of x lying outside the table of
values of x is known as extrapolation

Finite difference operators

Forward differences (Δ)

Backward differences ()

Central differences (δ)

Forward difference table

X y Δy Δ ^2 y Δ ^3 y
X0 y0 Y1-y0=Δ y0 Δ y1-Δ y0=Δ ^2 Δ ^2 y1 - Δ ^2
y0 y0 = Delta ^3 y0
X1 y1
X2 y2 Y2-y1=Δ y1 Δ y2 - Δ y1 = Δ ^2
y1
X3 y3 Y3-y2=Δ y2
This difference table is called forward difference table or diagonal difference table

The first term in the table, i.e., y0 is called the leading term

The differences Δ y0, Δ^2 y0 and Δ^3 yy0 is called the leading differences

Here, Δ is called the forward difference operator

Q: construct a forward difference table for the following values of x and y

X 0.1 0.3 0.5 0.7 0.9 1.1 1.3


Y 0.003 0.067 0.148 0.248 0.370 0.518 0.697
Δy 0.064 0.081 0.100 0.122 0.148 0.179
Δ^2 y -0.010 -0.008 -0.005 -0.002 -0.001
Δ^3 y 0.002 0.003 0.003 0.001
Δ^4 y 0.001 0.000 -0.002
Δ^5 y -0.001 -0.002
Δ^6 y -0.001
Q: construct a forward difference table for the following values

X,.2,.4,.6,.8,1.1

Y,.032,.041,.067,.140,.290

Q: express Δ ^2 y0 and Δ^3 y0 in terms of the values of the function y


Δ^2 y0=Δ y1-Δ y0

¿ y 2− y 1−( y 1− y 0 )
¿ y 2− y 1− y 1+ y 0
¿ y 2−2 y 1+ y 0
3 2 2
Δ y 0=Δ y 1−Δ y 0
¿ Δ y 2− Δ y 1−( y 2−2 y 1+ y 0 )

¿ ( ( y 3− y 2 )− ( y 2− y 1 ) ) −( y 2−2 y 1+ y 0 )

¿ ( y 3− y 2− y 2+ y 1 )−( y 2−2 y 1+ y 0 )
¿ ( y 3−2 y 2+ y 1 ) −( y 2−2 y 1+ y 0 )
¿y3y-3y2+3y1-y0
Backward differential table

X,x0,x1,x2,x3

Y,y0,y1,y2,y3

∇ y ,y1-y0=∇y1,y2-y1=∇y2,y3-y2=∇y2,y4-y3=∇y3
2
∇y
3
∇y
Q: the sales in a particular department from the last 5 years in the following table

Year,1974,1976,1978,1980,1982

Sales,40,43,48,52,57

Estimate the sales for the year 1979

Backward table

x,1974,1976,1978,1980,1982

y,40,43,48,52,57

Δ y 3,5,4,5
2
Δ y ,2,-1,1
3
Δ y , -3,2
4
Δ y ,5
x−xn
p=
h
x=1979
xn=1982
h=2
1979−1982
p=
2
1979−1982
¿ =−1.5
2
p ( p+1 ) 2
y ( x )= yn+ p ∇ yn+ ∇ yn\
2!
Lagrange’s interpolation formula

Y(x)=
( x−x 1 ) , ( x−x 2 ) , ( x−x 3 ) , … , ( x−xn ) ( x−x 0 ) , ( x−x 2 ) , ( x−x 3 ) , … , ( x−xn ) ( x−x 0 ) ,
y 0+ y 1+
( x 0−x 1 ) , ( x 0−x 2 ) , ( x 0−x 3 ) , … , ( x 0−xn ) ( x 1−x 0 ) , ( x 1−x 2 ) , ( x 1−x 3 ) , … , ( x 1−xn ) ( x 2−x 0 ) , ( x
Q: given the following data, evaluate f(3) using Lagrange’s interpolation formula

X,1,2,5

Y,1,4,10

( 3−2 ) , (3−5 ) ( 3−1 ) , ( 3−5 ) ( 3−1 ) , ( 3−5 )


Y(x)= y 0+ y 1+ y2
( 1−2 ) , (1−5 ) , ( 2−1 ) , ( 2−5 ) ( 5−1 ) , ( 5−2 )
( 3−2 ) , (3−5 ) ( 3−1 ) , ( 3−5 ) ( 3−1 ) , ( 3−5 )
= 1+ 4+ 10
( 1−2 ) , (1−5 ) , ( 2−1 ) , ( 2−5 ) (5−1 ) , (5−2 )
4
=(−0 ) .5∗1+ 4+ (−0 ) .3333∗10
3
¿ 1.5

Q: find y (3)

X,2,4,5,6

Y,1,4,8,12

Q: find Lagrange’s interpolation polynomial fitting the points y(1)=-3 y(3)=0 y(4)=30 y(6)=132

hence, find y(5)

divided difference

q: construct devided diffranse table for the following data

x,0,1,2,4

y,1,1,2,5
1−1
first difference, ,
1−0
second difference,

third difference,

nutan’s divided difference interpolation formula

y ( x )= y 0+ ( x−x 0 ) y [ x 0 , x 1 ] + ( x−x 0 ) ( x−x 1 ) y [ x 0 , x 1 , x 2 ] + ( x−x 0 )( x−x 1 ) ( x −x 2 ) y [ x 0 , x 1 , x 2 , x 3 ] + …+

Q: using ndf, find the quadratic equation for the following data

also, find y(2)

x,0,1,2

y,2,1,4

1−2
first difference, =−1,( 4−1 ) . ( 4−1 ) =1,
1−0
1−(−1 ) 1
second difference, =
4−0 2
y ( x )= y 0+ ( x−x 0 ) y [ x 0 , x 1 ] + ( x−x 0 ) ( x−x 1 ) y [ x 0 , x 1 , x 2 ] ,
1
2+ ( x−0 )−1+(x −0)(x−1)( )
2
¿ 2+ (−x ) +(x )(x−1)¿

¿ 2−x + x 2−x ( 12 )
( )()
2
x x
¿ 2−x + −
2 2
2
x 3
y ( x )= − x +2
2 2
Forward difference operator

Δ f ( x )=f ( x +h ) −f ( x )
Backward difference operator

¿ ( fx )=f ( x ) −f (x −h)

¿ ( yx )= y ( x )− y (x −h)
Central difference operater

δf ( x ) =f ( x +h2 )−f ( x−h


2 )
δy ( x )= y ( x +h2 )− y ( x−h
2 )
Shift operator €
nf ( x )
e =f ( x+ n )
Newton’s forward difference approximation

o ( h )=Δ fk=f k+1−f k

2 1
o ( h) = ¿
2
Central differences

We use this symbol \delta to represend central difference operator and subscript of \delta y for any
difference as the average of the subscripts of the 2 members of the difference

δ yi = y 1 −y 1
i+ i−
2 2

Numerical integration

Trapezoidal bool

suppose we want to integrate the function y=f(x) from a to b Trapezoidal bool we take T to be the
approximal value of the integral of x from a to b
b
h
T approximately = ∫ f ( x ) dx= [ y 0+2 ( y 1+ y 2+…+ y n−1) + yn ]
a 2

b−a
Where, h=
n
2
Q: use trapezoidal rule with n = 4 to estimate ∫ xdx
1

A=1

B=2
b 2

∫ f ( x ) dx=∫ xdx
a 1

b−a
h=
n
2−1
h= =0.25
4
x0=a=1

x1=x0+h=1+0.25

x2 = x1+h
1
q: evaluate ∫ x −1 dx with n = 4
2

−1

note, error in the trapezoidle rule error Type equation here .

Is of the order h2 (order (h2 )

1
Simson’s rule
3
b
1
According to Simson’s rule, the approximate value of the ∫ f ( x ) dx is given by
3 a

b
h
s=∫ f ( x ) dx = y 0 4 ( y 1+ y 3+ y 5+ … ) +2 ( y 2+ y 4+ y 6+… )+ yn
a 3

b−a
h= (the number n is even)
n
2
q: evaluate ∫ x dx with n = 4
2

a=1

b=2

n=4

2−1
h= =0.25
4
b 2

∫ f ( x ) dx=∫ x dx 2

a 1

X0=1

X1=1+0.25=1.25

X2=1.25+0.25=1.5

X3 = 1.5+0.25=1.75

X4 = 1.75+0.25 = 2
2
y ( x )=x
2 2
y 0= ( x 0 ) =1 =1
2 2
y 1=( x 1 ) =1.25 =1.5625
2
y 2=1.5 =2.25
2
y 3=1.75 =3.0625
2
y 4=2 =4
1
dx
Q: ∫
0 √ 1+ x3
2
Q: ∫ √ x dx , 8 intervals
1

3
Simson’s th rule
8
b
3
According to simson’s ’th rule the value of the ∫ f ( x ) dx is given by
8 a

b
sapproximatly=∫ f ( x ) dx=3 h/8 ¿
a

This rule can be applied only if the number of sub intervals is a multiple of 3
2
Q: evaluate ∫ √ x dx with n = 6
1

A=1

B=2
b 2

∫ f ( x ) dx=∫ √ x dx
a 1

2−1
h= =0.1666
6
x0=1

x1=1+0.1666=1.1666

x2=1.1666+0.1666=1.3332

x3=0.1666+1.3332=1.4998

x4=1.4998+0.1666=1.6664

x5=1.6664+0.1666=1.833

x6=1.833+0.1666=1.9996

y ( x )=√ x

y 0= √ 1=1
y 1=1.0800
y 2=1.1541
y 3=1.2246
y 4=1.2908
y 5=1.3538
y 6=1.4140
b

∫ f ( x ) dx=3 ( 0.1666
8 )
¿
a

4
Q: evaluate ∫ f ( x ) dx
a

4
From the following table find ∫ f ( x ) dx by simson’s 3/8 rule
a

X,1,2,3,4

Y,1,8,27,64

H=difference of x=1
b

∫ f ( x ) dx=¿
a

Q:

X,0,10,20,30,40,50,60

Y,47,

Error in Simson’s rule

−b−a
e= ¿
80
Error in the Simson’s rule is of the order h 4 o (h4 ))

You might also like