Uploaded by Ahmed Ali

Lecture 6

advertisement
Lecture (6)
1
Engineering Mathematics (5)
Numerical Analysis
PHM2111
Prof. Dr. Nasser H. Sweilam
nsweilam@sci.cu.edu.eg
PHM2111 week (7)
Fall 2020, 2/12/2020
Outline
2
ο‚— Direct Method of Interpolation
ο‚— Interpolation and Polynomial approximation
(Newton Divided differences )
ο‚— Interpolation and Polynomial approximation
(Lagrange Interpolation )
PHM2111 week (7)
Fall 2020, 2/12/2020
What is Interpolation?
3
A function 𝑦 = 𝑓 π‘₯ is given only at discrete points such
as π‘₯0 , 𝑦0 , π‘₯1 , 𝑦1 , . . . . . . , π‘₯𝑛−1 , 𝑦𝑛−1 , π‘₯𝑛 , 𝑦𝑛 .
How does we find the value of y at any other value of π‘₯?
Well, a continuous function 𝑓 π‘₯ may be used to represent
the 𝑛 + 1 data values with 𝑓 π‘₯ passing through the 𝑛 + 1
points. Then we can find the value of 𝑦 at any other value
of π‘₯. This is called interpolation.
Of course, if π‘₯ falls outside the range of π‘₯ for which the
data is given, it is no longer interpolation but instead is
called extrapolation.
PHM2111 week (7)
Fall 2020, 2/12/2020
Interpolation
4
Figure 1 Interpolation of discrete data
PHM2111 week (7)
Fall 2020, 2/12/2020
Direct Method
5
The direct method of interpolation is based on the following
premise. Given 𝑛 + 1 data points, fit a polynomial of order 𝑛 as
given below
𝑦 = π‘Ž0 + π‘Ž1 π‘₯+. . . +π‘Žπ‘› π‘₯ 𝑛
(1)
through the data, where π‘Ž0 , π‘Ž1 . . . , π‘Žπ‘› Are 𝑛 + 1 real constants.
Since 𝑛 + 1 values of 𝑦 are given at 𝑛 + 1 values of π‘₯, we can
write 𝑛 + 1 equations. Then the 𝑛 + 1 Constants π‘Ž0 , π‘Ž1 . . . , π‘Žπ‘›
can be found by solving the 𝑛 + 1
simultaneous linear
equations. To find the value of 𝑦 at a given value of π‘₯, simply
substitute the value of π‘₯ in Equation 1.
But, it is not necessary to use all the data points. How does we then
choose the order of the polynomial and what data points to use? This
concept and the direct method of interpolation are best illustrated using
examples.
PHM2111 week (7)
Fall 2020, 2/12/2020
Example 1 The upward velocity of a rocket is given
as a function of time in Table 1.
6
t (s)
V(t) (m/s)
0
10
15
20
22.5
30
0
227.04
362.78
517.35
602.97
901.67
Table 1 Velocity as a
function of time.
Determine the value of the
velocity at 𝒕 = πŸπŸ” seconds
using the direct method of
interpolation first order
polynomial.
PHM2111 week (7)
Fall 2020, 2/12/2020
Solution
For first order polynomial interpolation (also called linear interpolation), the
velocity given by
0
1
Since we want to find the velocity at 𝒕 = πŸπŸ” , and we are using a first order
polynomial, we need to choose the two data points that are closest to 𝒕 = πŸπŸ”
that also bracket 𝒕 = πŸπŸ” to evaluate it. The two points are 𝒕0 = 𝟏5 and
𝒕1 = 20 . Then π’•πŸŽ = πŸπŸ“, 𝒗 π’•πŸŽ = πŸ‘πŸ”πŸ. πŸ•πŸ– &
π’•πŸ = 𝟐𝟎, 𝒗 π’•πŸ = πŸ“πŸπŸ•. πŸ‘πŸ“
Gives
𝒗 πŸπŸ“ = π’‚πŸŽ + π’‚πŸ πŸπŸ“ = πŸ‘πŸ”πŸ. πŸ•πŸ–
𝒗 𝟐𝟎 = π’‚πŸŽ + π’‚πŸ 𝟐𝟎 = πŸ“πŸπŸ•. πŸ‘πŸ“
Writing the equations in matrix form, we have
1 15 οƒΉ a0 οƒΉ 362.78οƒΉ
οƒͺ1 20οƒΊ οƒͺ a οƒΊ ο€½ οƒͺ517.35οƒΊ

 1  

v t  ο€½ a  a t
Solving the above two equations gives π‘Ž0 = −100.93, π‘Ž1 = 30.914
At 𝒕 = πŸπŸ”
𝑣 𝑑 = −100.93 + 30.914𝑑
→ 𝑣 16 = 393.7 m/s
PHM2111 week (7)
7
Fall 2020, 1/11/2020
Example 2 use table 1 in the pervious example to determine the value
of the velocity at 𝒕 = πŸπŸ” seconds using the direct method of interpolation
second order polynomial.
8
For second order polynomial interpolation (also called quadratic interpolation), the
velocity is given by
2
vt  ο€½ a0  a1t  a2 t
Since we want to find the velocity at 𝒕 = πŸπŸ” , and we are using a second order
polynomial, we need to choose the three data points that are closest to 𝒕 = πŸπŸ” that
also bracket 𝒕 = πŸπŸ” to evaluate it. The three points are
Then
t 0 ο€½ 10, t1 ο€½ 15, and t 2 ο€½ 20
v10 ο€½ a0  a1 10  a2 10 ο€½ 227.04
2
v15 ο€½ a0  a1 15  a2 15 ο€½ 362.78
2
v20 ο€½ a0  a1 20  a2 20 ο€½ 517.35
2
PHM2111 week (7)
Fall 2020, 2/12/2020
Writing the three equations in matrix form, we have
1 10 100 οƒΉ a0 οƒΉ 227.04οƒΉ
οƒͺ1 15 225οƒΊ οƒͺ a οƒΊ ο€½ οƒͺ362.78οƒΊ
οƒͺ
οƒΊοƒͺ 1 οƒΊ οƒͺ
οƒΊ
οƒͺ1 20 400 οƒͺa 2  οƒͺ517.35
Solving the above three equations gives π‘Ž0 = 12.05, π‘Ž1 = 17.733, π‘Žπ‘›π‘‘ π‘Ž2
= 0.3766
Hence
vt  ο€½ 12.05  17.733t  0.3766t 2 , 10 ο‚£ t ο‚£ 20
At 𝑑 = 16
v16 ο€½ 12.05  17.73316  0.376616
2
ο€½ 392.19 m/s
Example 3:- use table 1 in the pervious example to determine the value
of the velocity at 𝒕 = πŸπŸ” seconds using the direct method of interpolation
third order polynomial.
v 16  ο€½ ο€­4.2540  21.266 16   0.13204 16   0.0054347 16  ο€½ 392.06 m/s
2
PHM2111 week (7)
9
3
Fall 2020, 2/12/2020
Comparison Table
10
Order of
Polynomial
𝑣 𝑑 = 16 m/s
1
2
3
393.7
392.19
392.06
Absolute Relative
---------- 0.38410 % 0.033269 %
Approximate Error
PHM2111 week (7)
Fall 2020, 2/12/2020
Newton’s Divided Difference Polynomial Method
11
• Linear Interpolation
• Quadratic Interpolation
PHM2111 week (7)
Fall 2020, 2/12/2020
1- Linear Interpolation
12
The simplest form of interpolation is to connect two data points with
a straight line. This technique, called linear interpolation,
f1  x  ο€­ f  x0  f  x1  ο€­ f  x0 
ο€½
x ο€­ x0
x1 ο€­ x0
which can be rearranged to yield
f  x1  ο€­ f  x0 
f1  x  ο€½ f  x0  
 x ο€­ x0 
x1 ο€­ x0
f1  x  ο€½ b0  b1  x ο€­ x0 
which is the Newton linear-interpolation formula. The notation
f1(x) designates that this is a first-order interpolating polynomial.
PHM2111 week (7)
Fall 2020, 2/12/2020
f  x1 
f1  x 
f  x0 
x0
PHM2111 week (7)
x1
13
Fall 2020, 2/12/2020
Example
14
The upward velocity of a rocket is given as a function of time in
Table 1. Find the velocity at t = 16 seconds using the Newton
Divided Difference method for linear interpolation.
𝑑(s
0
10
15
20
22.5
30
𝑣(𝑑 (m/s
0
227.04
362.78
517.35
602.97
901.67
at t = 16
PHM2111 week (7)
b0 ο€½ v(t0 ) ο€½ 362.78
b1 ο€½
v(t1 ) ο€­ v(t0 )
ο€½ 30.914
t1 ο€­ t0
v(t ) ο€½ b0  b1 (t ο€­ t 0 ) ο€½ 362.78  30.914(t ο€­ 15),
v(16) ο€½ 362.78  30.914(16 ο€­ 15) ο€½ 393.69 m / s
Fall 2020, 2/12/2020
2- Quadratic Interpolation
15
Given (π‘₯0 , 𝑦0 , (π‘₯1 , 𝑦1 , π‘Žπ‘›π‘‘ (π‘₯2 , 𝑦2
fit a quadratic interpolate
through the data.
f 2 ( x) ο€½ b0  b1 ( x ο€­ x0 )  b2 ( x ο€­ x0 )( x ο€­ x1 )
At π‘₯ = π‘₯0
b0 ο€½ f ( x0 )
At π‘₯ = π‘₯1
b1 ο€½
At π‘₯ = π‘₯2
PHM2111 week (7)
f ( x1 ) ο€­ f ( x0 )
x1 ο€­ x0
f ( x2 ) ο€­ f ( x1 ) f ( x1 ) ο€­ f ( x0 )
ο€­
x2 ο€­ x1
x1 ο€­ x0
b2 ο€½
x2 ο€­ x0
Fall 2020, 2/12/2020
Example
16
The upward velocity of a rocket is given as a function of time in
Table 1. Find the velocity at t = 16 seconds using the Newton
Divided Difference method for quadratic interpolation.
𝑑(s
0
10
15
20
22.5
30
𝑣(𝑑 (m/s
0
227.04
362.78
517.35
602.97
901.67
MATH206 week (7)
t0 ο€½ 10, t1 ο€½ 15 and t2 ο€½ 20
b0 ο€½ v(t0 ) ο€½ 227.4
b1 ο€½
v(t1 ) ο€­ v(t0 )
ο€½ 27.148
t1 ο€­ t0
v(t2 ) ο€­ v(t1 ) v(t1 ) ο€­ v(t0 )
ο€­
t2 ο€­ t1
t1 ο€­ t0
b2 ο€½
ο€½ 0.3766
t 2 ο€­ t0
Fall 2020, 2/12/2020
v(t ) ο€½ b0  b1 (t ο€­ t 0 )  b2 (t ο€­ t 0 )(t ο€­ t1 )
ο€½ 227.04  27.148(t ο€­ 10)  0.37660(t ο€­ 10)(t ο€­ 15),
at t = 16
v(16) ο€½ 227.04  27.148(16 ο€­ 10)  0.37660(16 ο€­ 10)(16 ο€­ 15) ο€½ 392.19
PHM2111 week (7)
17
Fall 2020, 1/11/2020
The Lagrange
interpolating polynomial
PHM2111 week (9)
18
Fall 2020, 2/12/2020
The Lagrange interpolating polynomial is given by
𝑛
𝑓𝑛 (π‘₯ =
𝐿𝑖 (π‘₯ 𝑓(π‘₯𝑖
𝑖=0
Where 𝑛 in 𝑓(π‘₯ stands for the π‘›π‘‘β„Ž order polynomial that
approximates the function 𝑦 = 𝑓(π‘₯ given at 𝑛 + 1 data
points as π‘₯0, 𝑦0 , π‘₯1, 𝑦1 , … , π‘₯𝑛, 𝑦𝑛 and
𝑛
π‘₯ − π‘₯𝑗
𝐿𝑖 π‘₯ =
,
π‘₯𝑖 − π‘₯𝑗
𝑗=0
𝑗≠𝑖
𝐿𝑖 π‘₯ is a weighting function that includes a product
of 𝑛 − 1 terms with terms 𝑗 = 𝑖 of omitted. The
application of Lagrange interpolation will be clarified using
an example.
PHM2111 week (7)
19
Fall 2020, 2/12/2020
For example
1) First order Lagrange interpolating polynomial [ we use only two
points (x0 , f(x0)) , (x1 , f(x1)) ]

1
x ο€­ xj

f1  x  ο€½ οƒ₯ f  xi  

i ο€½0 
j ο€½ 0 xi ο€­ x j
iο‚Ή j

1
οƒΆ
οƒ· ο€½  x ο€­ x1  f  x    x ο€­ x0  f  x 
0
1
οƒ·  x0 ο€­ x1 
x
ο€­
x


1
0
οƒ·
οƒΈ
2) second order Lagrange interpolating polynomial [ we use only 3
points (x0 , f(x0)) , (x1 , f(x1)) , (x1 , f(x2))]

οƒΆ
2
x
ο€­
x
x ο€­ x1  x ο€­ x2 

j οƒ·

f 2  x  ο€½ οƒ₯ f  xi  
ο€½
f  x0 

οƒ·
 x0 ο€­ x1  x0 ο€­ x2 
i ο€½0 
j ο€½ 0 xi ο€­ x j οƒ·
iο‚Ή j

οƒΈ
x ο€­ x0  x ο€­ x2 
x ο€­ x0  x ο€­ x1 



f  x1  
f  x2 
 x1 ο€­ x0  x1 ο€­ x2 
 x2 ο€­ x0  x2 ο€­ x1 
2
It is to be noticed that each term of the nth order Lagrange
interpolating polynomial of order n.
PHM2111 week (7)
20
Fall 2020, 2/12/2020
The nth order Lagrange interpolating polynomial is

οƒΆ
n
x
ο€­
x
j οƒ·
f n  x  ο€½ οƒ₯  f  xi  

οƒ·
i ο€½0 
j ο€½ 0 xi ο€­ x j οƒ·
iο‚Ή j

οƒΈ
x ο€­ x1  x ο€­ x2  ...  x ο€­ xn 

ο€½
f  x0 
 x0 ο€­ x1  x0 ο€­ x2  ...  x0 ο€­ xn 
n
x ο€­ x0  x ο€­ x2  ...  x ο€­ xn 


f  x1 
 x1 ο€­ x0  x1 ο€­ x2  ...  x1 ο€­ xn 
x ο€­ x0  x ο€­ x1  x ο€­ x3  ...  x ο€­ xn 


f  x2   ... 
 x2 ο€­ x0  x2 ο€­ x1  x2 ο€­ x3  ...  x2 ο€­ xn 
 x ο€­ x0  x ο€­ x1  x ο€­ x2  ...  x ο€­ xn ο€­1  f x
 n
 xn ο€­ x0  xn ο€­ x1  xn ο€­ x2  ...  xn ο€­ xn ο€­1 
PHM2111 week (7)
21
Fall 2020, 2/12/2020
Example:- Given the following data
x
1
4
6
f(x)
0
1.386294 1.791760
Use Lagrange interpolating polynomial of the first order and the
second order to evaluate f(2)
Solution
1st order Lagrange interpolating polynomial [ we use only two
points (1,0) , (4 , 1.386294) ]
1
1
i ο€½0
j ο€½0
iο‚Ή j
f1  x  ο€½ οƒ₯ f  xi  
x ο€­ xj
xi ο€­ x j
x ο€­ x1 
x ο€­ x0 


ο€½
f  x0  
f  x1 
 x0 ο€­ x1 
 x1 ο€­ x0 
x ο€­ 4
x ο€­ 1


ο€½
 0 
1.386294 
1 ο€­ 4 
 4 ο€­ 1
2 ο€­ 1

f1  2  ο€½
1.386294  ο€½ 0.4620981
 4 ο€­ 1
PHM2111 week (7)
22
Fall 2020, 1/11/2020
2nd order Lagrange interpolating polynomial [ we use only three
points (1,0) , (4 , 1.386294) , (6, 1.791760)]

οƒΆ
2 xο€­x
j οƒ·
f 2  x  ο€½ οƒ₯  f  xi  

οƒ·
i ο€½0 
j ο€½ 0 xi ο€­ x j οƒ·
iο‚Ή j

οƒΈ
x ο€­ x1  x ο€­ x2 
x ο€­ x0  x ο€­ x2 
x ο€­ x0  x ο€­ x1 



ο€½
f  x0  
f  x1  
f  x2 
 x0 ο€­ x1  x0 ο€­ x2 
 x1 ο€­ x0  x1 ο€­ x2 
 x2 ο€­ x0  x2 ο€­ x1 
2
x ο€­ 4  x ο€­ 6 
x ο€­ 1 x ο€­ 6 
x ο€­ 1 x ο€­ 4 



f2  x  ο€½
0 
1.386294  
1.791760 
1 ο€­ 4 1 ο€­ 6 
 4 ο€­ 1 4 ο€­ 6 
 6 ο€­ 1 6 ο€­ 4 
2 ο€­ 1 2 ο€­ 6 
2 ο€­ 1 2 ο€­ 4 


f2  2 ο€½
1.386294  
1.791760 
 4 ο€­ 1 4 ο€­ 6 
 6 ο€­ 1 6 ο€­ 4 
ο€½ 0.5658444
PHM2111 week (7)
23
Fall 2020, 2/12/2020
Example:- Consider the four points
x
f(x)
3.35
3.40
3.50
3.60
0.298507 0.294118 0.285714 0.277778
which satisfy the simple function y = f(x) = 1/x:
Use Lagrange interpolating polynomial of the first order, the second
order and the third order to evaluate f(3.44)
Solution
Let’s interpolate for y = f(3.44) using linear, quadratic, and cubic
Lagrange interpolating polynomials. The exact value is
y = 1/3.44 = 0.290698....
PHM2111 week (7)
24
Fall 2020, 2/12/2020
Linear interpolation using the two closest points, x = 3.40
and 3.50, yields
x ο€­ x1 
x ο€­ x0 


f1  x  ο€½
f  x0  
f  x1 
 x0 ο€­ x1 
 x1 ο€­ x0 
 x ο€­ 3.50  0.294118   x ο€­ 3.40  0.285714
f1  x  ο€½




 3.40 ο€­ 3.50 
 3.50 ο€­ 3.40 
f1  3.44  ο€½
 3.44 ο€­ 3.50  0.294118   3.44 ο€­ 3.40  0.285714 ο€½ 0.290756




 3.40 ο€­ 3.50 
 3.50 ο€­ 3.40 
PHM2111 week (7)
25
Fall 2020, 2/12/2020
Quadratic interpolation using the three closest points, x = 3.35, 3.40,
and 3.50, gives
f2  x  ο€½
 x ο€­ x1  x ο€­ x2  f x   x ο€­ x0  x ο€­ x2  f x   x ο€­ x0  x ο€­ x1  f x
 0
 1
 2
x
ο€­
x
x
ο€­
x
x
ο€­
x
x
ο€­
x
x
ο€­
x
x
ο€­
x
 0 1  0 2 
 1 0  1 2 
 2 0  2 1 
 x ο€­ 3.40  x ο€­ 3.50  0.298507   x ο€­ 3.35 x ο€­ 3.50  0.294118




 3.35 ο€­ 3.40  3.35 ο€­ 3.50 
 3.40 ο€­ 3.35 3.40 ο€­ 3.50 
 x ο€­ 3.35 x ο€­ 3.40  0.285714



 3.50 ο€­ 3.35 3.50 ο€­ 3.40 
f2  x  ο€½
3.44 ο€­ 3.40  3.44 ο€­ 3.50 
3.44 ο€­ 3.35  3.44 ο€­ 3.50 


f 2  3.44  ο€½
 0.298507  
 0.294118
 3.35 ο€­ 3.40  3.35 ο€­ 3.50 
 3.40 ο€­ 3.35  3.40 ο€­ 3.50 
 3.44 ο€­ 3.35 3.44 ο€­ 3.40  0.285714 ο€½ 0.290697



 3.50 ο€­ 3.35 3.50 ο€­ 3.40 
PHM2111 week (7)
26
Fall 2020, 2/12/2020
Cubic interpolation using all four points yields
x ο€­ x1  x ο€­ x2  x ο€­ x3 
x ο€­ x0  x ο€­ x2  x ο€­ x3 


f3  x  ο€½
f  x0  
f  x1 
 x0 ο€­ x1  x0 ο€­ x2  x0 ο€­ x3 
 x1 ο€­ x0  x1 ο€­ x2  x1 ο€­ x3 
 x ο€­ x0  x ο€­ x1  x ο€­ x3  f x   x ο€­ x0  x ο€­ x1  x ο€­ x2  f x

 2
 3
x
ο€­
x
x
ο€­
x
x
ο€­
x
x
ο€­
x
x
ο€­
x
x
ο€­
x
 2 0  2 1  2 3 
 3 0  3 1  3 2 
3.44 ο€­ 3.40  3.44 ο€­ 3.50  3.44 ο€­ 3.60 

f 3  3.44  ο€½
 0.298507 
 3.35 ο€­ 3.40  3.35 ο€­ 3.50  3.35 ο€­ 3.60 
 3.44 ο€­ 3.35  3.44 ο€­ 3.50  3.44 ο€­ 3.60  0.294118



 3.40 ο€­ 3.35  3.40 ο€­ 3.50  3.40 ο€­ 3.60 
3.44 ο€­ 3.35  3.44 ο€­ 3.40  3.44 ο€­ 3.60 


 0.285714 
 3.50 ο€­ 3.35  3.50 ο€­ 3.40  3.50 ο€­ 3.60 
3.44 ο€­ 3.35  3.44 ο€­ 3.40  3.44 ο€­ 3.50 


 0.277778
 3.60 ο€­ 3.35  3.60 ο€­ 3.40  3.60 ο€­ 3.50 
ο€½ 0.290698
PHM2111 week (7)
27
Fall 2020, 2/12/2020
The results are summarized below, where the results of
linear, quadratic, and cubic interpolation, and the errors.
Error (3.44) = f(3.44) - 0.290698
are tabulated. advantages of higher-degree interpolation
are obvious.
f(3.44) = 0.290756
= 0.290697
= 0.290698
PHM2111 week (7)
linear interpolation
Error = |0.000058|
quadratic interpolation
=| -0.000001|
cubic interpolation
=| 0.000000|
28
Fall 2020, 2/12/2020
NEWTON-COTES FORMULAS
29
The Newton-Cotes formulas are the most common numerical
integration schemes. They are based on the strategy of replacing a
complicated function or tabulated data with a polynomial that is easy
to integrate:
b
I ο€½  f  x dx 
a
PHM2111 week (7)
b
 f x dx
n
a
Fall 2020, 2/12/2020
Numerical Integration
MATH303 week (9)
30
Fall 2020, 2/12/2020
THE TRAPEZOIDAL RULE
31
The trapezoidal rule is the first of the Newton-Cotes closed
integration formulas. It corresponds to the case where the
polynomial in 𝐼 =
𝑏
𝑓
π‘Ž
π‘₯ 𝑑π‘₯ ≅
𝑏
𝑓
π‘Ž 𝑛
π‘₯ 𝑑π‘₯ is first-order:
(b, f(b))
(a, f(a))
a
PHM2111 week (7)
b
Fall 2020, 2/12/2020
b
b
a
a
f b ο€­ f  a 
f1  x  ο€½ f  a    x ο€­ a 
bο€­a
I ο€½  f  x  dx   f n  x  dx
f b ο€­ f  a 

οƒΉ
I ο€½  οƒͺ f a 
 x ο€­ a  οƒΊ dx
bο€­a

a 
b
x ο€½b
2

 f b ο€­ f  a  οƒΆ  x ο€­ a  οƒΉ
I ο€½ οƒͺ f a x  
οƒΊ
οƒ·
bο€­a
2
οƒͺ
 x ο€½ a

οƒΈ
2
2

 f b  ο€­ f  a  οƒΆ b ο€­ a  οƒΉ 
 f b  ο€­ f  a  οƒΆ  a ο€­ a  οƒΉ
I ο€½ οƒͺ f a b  
οƒΊ ο€­ οƒͺ f a a  
οƒΊ
οƒ·
οƒ·
bο€­a
2  οƒͺ
bο€­a
2 
οƒͺ

οƒΈ

οƒΈ
b ο€­ a οƒΉ


I ο€½ οƒͺ f  a  b ο€­ a    f  b  ο€­ f  a  
οƒΊ
2


  f b  f  a 
οƒΉ
I ο€½οƒͺ
 b ο€­ a 
2
οƒͺ

MATH303 week (9)
32
Fall 2020, 1/11/2020
PHM2111 week (7)
33
Fall 2020, 2/12/2020
MATH303 week (9)
34
Fall 2020, 2/12/2020
The Composite Trapezoidal Rule
35
One way to improve the accuracy of the trapezoidal
rule is to divide the integration interval from a to b into a
number of segments and apply the method to each segment.
The areas of individual segments can then be added to yield
the integral for the entire interval. The resulting equations
are called composite, or multiple-segment, integration
formulas.
If a and b are designated as x0 and xn, respectively, the total
integral can be represented as
I ο€½
x1
x2
xn
x0
x1
xnο€­1
 f x dx   f x dx  ...   f x dx
PHM2111 week (7)
Fall 2020, 2/12/2020
Substituting the
trapezoidal rule for
each integral yields
I ο€½h
f  x0   f  x1 
2
h
f  x1   f  x2 
2
 ...  h
f  xn ο€­1   f  xn 
2
h
I ο€½  f  x0   2 f  x1   2 f  x2   2 f  x3   ...  f  xn  
2
i ο€½ n ο€­1
h
οƒΉ
ο€½ οƒͺ f  x0   2 οƒ₯ f  xi   f  xn  οƒΊ
2
i ο€½1

MATH303 week (9)
36
Fall 2020, 2/12/2020
Estimating Error of the Trapezoidal Rule
37
𝑏−π‘Ž 3 ″
πΈπ‘Ž = −
𝑓 πœ‰
2
12 𝑛
𝑓″ πœ‰ =
PHM2111 week (7)
𝑏 ″
𝑓
π‘Ž
π‘₯ 𝑑π‘₯
𝑏−π‘Ž
Fall 2020, 2/12/2020
Example
Use the two-segment trapezoidal rule to estimate the integral
of f (x) = 0.2 + 25 x – 200 x2 + 675 x3 – 900 x4 + 400 x5
from a = 0 to b = 0.8. estimate the approximated error. And true
error recall that the exact value of the integral is 1.640533.
For n = 2
b ο€­ a 0.8 ο€­ 0
hο€½
x
f(x)
0
0.2
n
ο€½
2
0.4
2.456
ο€½ 0.4
0.8
0.232
h
i ο€½ n ο€­1
Iο€½
f  x0   2οƒ₯ i ο€½1 f  xi   f  xn  οƒΉ

2
0.4
ο€½
0.2+2 ο‚΄ 2.456+0.232 ο€½ 1.0688
2
Et ο€½ 1.640533 ο€­ 1.0688 ο€½ 0.57173
PHM2111 week (7)
38
ο₯ ο€½ 34.9%
t
Fall 2020, 2/12/2020
𝑓(π‘₯ = 0.2 + 25π‘₯ − 200π‘₯ 2 + 675π‘₯ 3 − 900π‘₯ 4 + 400π‘₯ 5
𝑓 ′ (π‘₯ = 25 − 400π‘₯ + 2025π‘₯ 2 − 3600π‘₯ 3 + 2000π‘₯ 4
𝑓 ″ (π‘₯ = −400 + 4050π‘₯ − 10800π‘₯ 2 + 8000π‘₯ 3
0.8
f ο‚’ο‚’   ο€½


ο€­400  4050 x ο€­ 10800 x 2  8000 x 3 dx
0
0.8 ο€­ 0
0.8
 ο€­400 x  2025 x ο€­ 3600 x  2000 x 
ο€­48
0
ο€½
ο€½
ο€½ ο€­60
0.8
0.8
2
Ea
b ο€­ a

ο€½ο€­
12 n 2
PHM2111 week (7)
3
3
4
0.83
f ο‚’ο‚’   ο€½ ο€­
ο€­60  ο€½ 0.64
2 
12 ο‚΄ 2
39
Fall 2020, 2/12/2020
Example
in the pervious example Use the four-segment
For
b ο€­ a 0.8 ο€­ 0
hο€½
ο€½
ο€½ 0.2
n
4
n=4
X
f(x)
0
0.2
0.2
1.288
0.4
2.456
0.6
3.464
0.8
0.232
h
i ο€½ n ο€­1
Iο€½
f  x0   2οƒ₯ i ο€½1 f  xi   f  xn  οƒΉ

2
0.2
0.2+2 ο‚΄ 1.288+2.456+3.464  +0.232  ο€½ 1.4848
ο€½
2
Et ο€½ 1.640533 ο€­ 1.4848 ο€½ 0.155733
ο₯ t ο€½ 9.5%
Ea
b ο€­ a

ο€½ο€­
12 n 2
MATH303 week (9)
3
0.83
f ο‚’ο‚’   ο€½ ο€­
ο€­60  ο€½ 0.16
2 
12 ο‚΄ 4
40
Fall 2020, 2/12/2020
Example
Use 4 –
1
−1
1
4−π‘₯ 2
hο€½
segment
multiple
trapezoidal
rule
to
evaluate
𝑑π‘₯ Then find the true error.
b ο€­ a 11
ο€½
ο€½ 0.5
n
4
X
f(x)
-1
0.57735
-0.5
0
0.516398 0.5
0.5
1
0.516398 0.57735
n ο€­1
h
οƒΉ
I ο€½ οƒͺ f  a   2οƒ₯ f  xi   f  b  οƒΊ ο€½ 1.05507
2
i ο€½1

1

ο€­1
1
4ο€­ x
2
dx ο€½
1
 ο€­1  x οƒΆοƒΉ
dx
ο€½
οƒͺs i n  2 οƒ· οƒΊ ο€½ 1.0472
 1
2
  ο€­1

 xοƒΆ
2 1ο€­  οƒ·
2οƒΈ
1
PHM2111 week (7)
1
41
Fall 2020, 2/12/2020
Assignment
1 1
0 1−π‘₯ 2
42
1.
Find the integral
by the Trapezoidal rule with 9 points.
2.
A particle of mass m moving through a fluid is subjected to a viscous
resistance R, which is a function of the velocity 𝑣. The relationship between
the resistance R, velocity 𝑣, and time t is given by the equation
𝑣1
𝑑=
𝑣0
π‘š
𝑑𝑣.
𝑅(𝑣
Suppose that 𝑅 𝑣 = −𝑣 𝑣 for a particular fluid, where R is in newtons and
𝑣 in π‘š/𝑠. If m = 5 kg and 𝑣0 = 12 π‘š/𝑠, approximate the time t required for
the particle to slow to 𝑣1 = 8 π‘š/𝑠 using Trapezoidal rule with 8 subintervals.
PHM2111 week (7)
Fall 2020, 2/12/2020
3. Use Lagrange interpolating polynomial to determine y at x = 8 to
the best possible accuracy.
4. Find Lagrange interpolating
polynomial to approximate a
function whose 5 data points
are given below. Use it to
estimate the value of the
function f(x) at x = 2.8.
PHM2111 week (7)
43
x
F(x)
2.0
0.85467
2.3
0.75682
2.6
0.43126
2.9
0.22364
3.2
0.08567
Fall 2020, 2/12/2020
5. Calculate f (3.4) using Lagrange interpolating polynomials of
order 1 through 3 and estimate the error for the 1st , 2nd and 3rd
order.
MATH206 week (9)
44
Fall 2020, 2/12/2020
Assignment
45
• Use Newton.s interpolating polynomial to determine y at x = 8 to
the best possible accuracy.
• Find Newton’s interpolating
polynomial to approximate a
function whose 5 data points are
given below. Use it to estimate
the value of the function f(x) at x
= 2.8.
MATH206 week (7)
x
F(x)
2.0
0.85467
2.3
0.75682
2.6
0.43126
2.9
0.22364
3.2
0.08567
Fall 2020, 1/11/2020
• Calculate f (3.4) using Newton.s interpolating polynomials of
order 1 through 3 and estimate the error for the 1st , 2nd and 3rd
order.
PHM2111 week (7)
46
Fall 2020, 2/12/2020
Download