0% found this document useful (0 votes)
5 views49 pages

Lec 11 12 Integration Differetions

The document discusses numerical methods, focusing on cubic splines and numerical integration techniques such as the Trapezoidal Rule and Simpson's Rule. It outlines the derivation of cubic splines for interpolating data points and provides examples of applying these methods to estimate values. Additionally, it covers the approximation of definite integrals and the analysis of errors associated with these numerical methods.

Uploaded by

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

Lec 11 12 Integration Differetions

The document discusses numerical methods, focusing on cubic splines and numerical integration techniques such as the Trapezoidal Rule and Simpson's Rule. It outlines the derivation of cubic splines for interpolating data points and provides examples of applying these methods to estimate values. Additionally, it covers the approximation of definite integrals and the analysis of errors associated with these numerical methods.

Uploaded by

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

Numerical Methods

Lec 11-12
Assistant Professor
Akram Abdul Mawjood Dawood

April 2025
Cubic Splines

Objective: to derive a third order polynomial for


each interval between data points.
Terms: Interior knots and end points
3 2
f i ( x )= a i x +bi x +c i x +d i

For n+1 data points:


• i = (0, 1, 2, …n),
• n intervals,
• 4n unknown constants (a’s, b’s ,c’s and d’s)
Alternative technique to get Cubic Splines

● The second derivative within each interval [xi-1, xi ] is a straight line.


(the 2nd derivatives can be represented by first order Lagrange
interpolating polynomials.

A straight line
x− x i x− x i− 1
f ''( x )= f '' ( xi− 1 ) + f ''( xi ) connecting the first
i i x i− 1− x i i xi − x i− 1 knot f’’(xi-1) and the
second knot f’’(xi)

The second derivative at any point x within the interval


Cubic Splines

● The last equation can be integrated twice


2 unknown constants of integration can be evaluated
by applying the boundary conditions:
1. f(x) = f (xi-1) at xi-1
2. f(x) = f (xi) at xi

Unknowns:

i = 0, 1,…, n
Cubic Splines

• For each interior point xi (n-1): f 'i− 1 ( x i )= f i ( x i )


'

( x i− x i− 1 ) f '' ( x i− 1 )+2( x i+1 − x i− 1 ) f ''( x i )


6
''
+( x i+1 − x i ) f ( x i+1 )=
x i+1 − x i
[ f ( x i+1 )− f ( xi ) ]

6
+
x i − x i− 1
[ f ( x i− 1 )− f ( x i ) ]

This equation result with n-1 unknown second


derivatives where, for boundary points:
f˝(xo) = f˝(xn) = 0
Cubic Splines - Example

Fit the following data with cubic splines


Use the results to estimate the value at x=5.

x 3.0 4.5 7.0 9.0


f(x) 2.5 1.0 2.5 0.5

Solution:
➢ Natural Spline:
f '' ( x 0 )= f '' (3 )= 0, f '' ( x 3 )= f '' (9 )= 0
Cubic Splines - Example
➢ For 𝟏𝒔𝒕 interior point (x1 = 4.5)
x 3.0 4.5 7.0 9.0
f(x) 2.5 1.0 2.5 0.5
- x i − x i− 1= x 1− x 0= 4. 5− 3. 0= 1. 5
- x i+1− xi− 1= x 2− x 0= 7− 3. 0= 4
- x i+1− xi = x 2− x 1= 7− 4. 5= 2. 5
Apply the following equation:
( x i− x i− 1 ) f '' ( x i− 1 )+2( x i+1 − x i− 1 ) f ''( x i )+( x i+1− x i ) f ''( xi+1 )
6 6
¿
xi+1 − x i [ f ( xi+1 )− f ( x i ) ] +
x i− xi− 1 [ f ( xi− 1 )− f ( xi ) ]
Cubic Splines - Example

'' '' 6 '' 6


1. 5f (3 )+2× 4f (4 . 5)+2 . 5f (7 )= (2 . 5− 1 )+ (2 . 5− 1 )
2.5 1 .5
Since f '' (3)= 0
8f ''( 4.5)+2.5f '' (7)= 9.6 .............. (eq.1)
➢ For 2nd interior point (x2 = 7 )

x 3.0 4.5 7.0 9.0


f(x) 2.5 1.0 2.5 0.5
x i − x i− 1 = x 2− x 1 = 7− 4. 5= 2. 5
x i+1− xi− 1= x 3− x1= 9− 4. 5= 4. 5
x i+1− xi = x3− x 2= 9− 7= 2
Cubic Splines - Example
Apply the following equation:

( x i− x i− 1 ) f '' ( x i− 1 )+2( x i+1 − x i− 1 ) f ''( x i )+( x i+1− x i ) f ''( xi+1 )


6 6
¿
xi+1 − x i [ f ( xi+1 )− f ( x i ) ] +
x i− xi− 1 [ f ( xi− 1 )− f ( xi ) ]

'' '' 6 '' 6


2 . 5f ( 4. 5)+2× 4 .5f (7)+2f (9 )= (0. 5− 2 . 5)+ (1− 2. 5)
2 2. 5
''
Since f (9)= 0
'' ''
2.5f (4.5)+9f (7)=− 9.6 ............. ( equ 2)
Cubic Splines - Example
Solve the two equations:
8f ''i ( 4 . 5 )+ 2 . 5f ''i ( 7 )= 9 . 6
2 . 5f ''i ( 4 . 5 )+9f i'' ( 7 )= − 9 . 6
¿}¿
'' ''
¿ yeild f ( 4 . 5 )= 1 . 67909 , f ( 7 )= − 1 . 53308 ¿

The first interval (i=1), apply for the equation:


f ''( x i− 1 ) f ''( xi )
i 3 3
f i ( x )= (xi − x ) + i (x− x i− 1)
6 (x i − x i− 1 ) 6 (xi − xi− 1 )

+
[ f i ( xi − 1 ) f i'' ( x i− 1 ) (x i − x i− 1 )
x−x
i

i− 1 6
x − x
] [
( i ) x−x
+
f i( xi )
i i− 1

f ''( x i ) (x i − x i− 1 )
6
i
]
(x− x i− 1 )

f 1 ( x)= 0 ( xi − 3 ) +
1. 67909
3
6(1. 5)
3 2 . 5 0(1.5 )
( x− 3) +
1.5

6 [ 1. 5 ]
1 1. 67909(1. 5)
(4. 5− x )+ −
6
( x− 3) [ ]
f 1 ( x )= 0 .186566 ( x− 3 )3 +1 .6667 (4 . 5− x )+0 . 24689( x− 3 )
Cubic Splines - Example
The 2nd interval (i =2), apply for the equation:

f 2 ( x )=
1 . 67909
6 (2 .5 )
3 − 1 .53308
(7− x) +
6(2 .5 )
3 1
( x− 4 .5 ) + [ −
2 .5 6
− 1. 67909(2 . 5)
]
(7− x )

+[ 2. 5 − 1 . 53308(2 . 5)

2. 5 6 ]
( x− 4 . 5)

f 2 ( x )= 0. 111939(7− x )3 − 0 . 102205 ( x− 4 .5 )3 − 0 . 29962(7− x )+1. 638783 ( x − 4 . 5)

The 3rd interval (i =3),


f 3 ( x)= − 0 .127757 (9− x) 3 +1. 761027 (9− x )+0. 25 ( x− 7 )

For x = 5: f 2 ( x)= f 2(5)= 1. 102886


Numerical Integration
Objectives
◼ Approximate a definite integral using the Trapezoidal
Rule.

◼ Approximate a definite integral using Simpson’s Rule.

◼ Analyze the approximate errors in the Trapezoidal Rule


and Simpson’s Rule.

12
The Trapezoidal Rule

13
The Trapezoidal Rule
One way to approximate a definite integral is to use
n trapezoids, as shown in Figure 1.

In the development of this method,


assume that f is continuous and
positive on the interval [a, b].

So, the definite integral

represents the area of the region


Figure 1
bounded by the graph of f and the
x-axis, from x = a to x = b. 14
The Trapezoidal Rule
First, partition the interval [a, b] into n subintervals, each of
width ∆x = (b – a)/n, such that

Then form a trapezoid for each


subinterval (see Figure.2).

Figure.2 15
The Trapezoidal Rule
The area of the ith trapezoid is

This implies that the sum of the areas of the n trapezoids

16
The Trapezoidal Rule
Letting you can take the limits as to
obtain

The result is summarized in the following theorem.

17
The Trapezoidal Rule

18
Example 1 – Approximation with the Trapezoidal Rule

Use the Trapezoidal Rule to approximate

Compare the results for n = 4 and n = 8, as shown in


Figure .3.

Figure. 3
19
Example 1 – Solution
When n = 4, ∆x = π/4, and you obtain

20
Example 1 – Solution cont’d

When and you obtain

21
Simpson’s Rule

22
Simpson’s Rule
One way to view the trapezoidal approximation of a definite
integral is to say that on each subinterval you approximate f
by a first-degree polynomial.

In Simpson’s Rule, named after the English mathematician


Thomas Simpson (1710–1761), you take this procedure
one step further and approximate f by second-degree
polynomials.

Before presenting Simpson’s Rule, we list a theorem for


evaluating integrals of polynomials of degree 2 (or less).
23
Simpson’s Rule

24
Simpson’s Rule
To develop Simpson’s Rule for approximating a definite
integral, you again partition the interval [a, b] into
n subintervals, each of width ∆x = (b – a)/n.

This time, however, n required to be even, and the


subintervals are grouped in pairs such that

On each (double) subinterval [xi – 2, xi ], you can


approximate f by a polynomial p of degree less than or
equal to 2.
25
Simpson’s Rule
For example, on the subinterval [x0, x2], choose the
polynomial of least degree passing through the points
(x0, y0), (x1, y1), and (x2, y2), as shown in Figure.3.

26
Figure .3
Simpson’s Rule
Now, using p as an approximation of f on this subinterval,
you have, by Theorem 4.18,

Repeating this procedure on the entire interval [a, b]


produces the following theorem. 27
Simpson’s Rule

28
Example 2 – Approximation with Simpson’s Rule

Use Simpson’s Rule to approximate

Compare the results for n = 4 and n = 8.

29
Example 2 – Solution cont’d

When n = 4, you have

When n = 8, you have

30
Numerical Methods
Differentiation Integration

v v

dv
dt
t t
a y
b

a=
dv y= 
a
vdt
dt
t
31
Numerical Differentiation

▪ Estimate the derivatives (slope,


curvature, etc.) of a function by using
the function values at only a set of
discrete points
▪ Ordinary differential equation (ODE)
▪ Partial differential equation (PDE)

32
Numerical Differentiation

▪ Represent the function by Taylor


polynomials or Lagrange interpolation
▪ Evaluate the derivatives of the
interpolation polynomial at selected
nodal points

33
Numerical Differentiation
A Taylor series or Lagrange interpolation of points
can be used to find the derivatives. The Taylor
series expansion is defined as:

f ( xi ) = f ( x0 ) + x
df
+
(x )
2
d2 f
+
(x ) d 3 f
3
+
dx x =x0 2! dx 2 x =x0
3! dx 3
x =x0

x = xi − x0

f ( xi ) = f ( x0 ) + ( xi − x0 ) f ( x0 ) +
( xi − x0 )
2
f ( x0 ) +
( xi − x0 )
3
f ( x0 ) + 
2! 3!

34
First Derivative at a Point

f ( x )

i-2 i-1 i i+1 i+2

35
Numerical Differentiation

Use the Taylor series expansion to represent three


points about single location:

f ( xi +1 ) = f ( xi ) + ( xi +1 − x ) f ( x ) +
( xi +1 − xi )
2
f ( xi ) +  1
i i
2!
f ( xi ) = f ( xi ) 2
f ( xi-1 ) = f ( xi ) + ( xi −1 − x ) f ( x ) +
( xi −1 − xi )
2
f ( xi ) +  3
i i
2!

36
Numerical Differentiation

Assume that the data points are “equally


spaced” and the equations can be written as:

f ( xi +1 ) = f ( xi ) + (x ) f ( xi ) +
(x )
2
f ( x ) +
(x )
3
f ( xi ) +  1
i
2! 3!
f ( xi ) = f ( xi ) 2
f ( xi-1 ) = f ( xi ) − (x ) f ( xi ) +
(x )
2
f ( x ) −
(x )
3
f ( xi )  3
i
2! 3!

37
Forward Differentiation

For a forward first derivative, subtract eqn[2] from eqn[1]:


f (xi +1 ) − f (xi ) = (x ) f ( xi ) +
(x )
2
f ( x ) +
(x )
3
f ( xi ) + 
i
2! 3!
Rearrange the equation:
(x ) f (xi ) = f (xi+1 ) − f (x ) − (x )
2
f ( x ) −
(x )
3
f (xi ) + 
i i
2! 3!
 f ( xi +1 ) − f ( xi )  ( x ) ( x )
2

f  ( xi ) =  − f  ( xi ) − f  ( xi ) +
 x  2! 3!

38
Forward Differentiation

As the x gets smaller the error will get smaller


 f (xi +1 ) − f (xi ) 
f (xi ) =   − Error
 x 
The error is defined as:

Error =
(x ) f (x ) + (x ) 2
f (xi ) + 
i
2! 3!
39
Backward Differentiation

Subtract eqn[3] from eqn[2]:


 f (xi ) − f (xi-1 ) 
f (xi ) =   − Error
 x 
The error is defined as:

Error =
(x ) f (x ) + (x ) 2
f (xi ) + 
i
2! 3!
40
Central Differentiation

Subtract eqn[3] from eqn[1]:


 f (xi +1 ) − f (xi-1 ) 
f (xi ) =   − Error
 2x 
The error is defined as:

Error =
(x ) 2
f (xi ) + 
3!
41
Differential Error

42
Numerical Differentiation

1-43 43
Backward Difference & Centered Difference

44
Backward Difference & Centered Difference

45
Numerical Differentiation

46
Numerical Differentiation

47
FDA,BDA & CDA

48
Any Question

49

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy