0% found this document useful (0 votes)
24 views6 pages

Numerical Method-Trang-1

Numerical Method hcmut Notes - Phương pháp số đề cương 1
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)
24 views6 pages

Numerical Method-Trang-1

Numerical Method hcmut Notes - Phương pháp số đề cương 1
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/ 6

Numerical Method

1. Numerical Integration
1.1. Trapezoidal Rule
𝑏
𝑓(𝑏) + 𝑓(𝑎)
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 ≈ (𝑏 − 𝑎)
𝑎 2

Error:

−(𝑏 − 𝑎)3 ′′
𝐸𝑎 = ̅̅̅̅
𝑓
12
𝑏
̅̅̅̅ 𝑓 ′′ (𝑥)
𝑓 ′′ = ∫ 𝑑𝑥
𝑎 𝑏−𝑎

Example 1.1: Use trapezoidal rule to numerically integrate the function (a = 0 to b = 2)


𝑓(𝑥) = 0.2 + 25𝑥 + 3𝑥 2
Solution: 𝑓(0) = 0.2; 𝑓(2) = 62.2
𝑓(𝑏) + 𝑓(𝑎)
𝐼 = (𝑏 − 𝑎) = 62.4
2
The exact solution is
𝑏 2
25 2 2
∫ 𝑓(𝑥)𝑑𝑥 = ∫ 0.2 + 25𝑥 + 3𝑥 2 𝑑𝑥 = (0.2𝑥 + 𝑥 + 𝑥 3 ) | = 58.4
𝑎 0 2
0
The relative error is:
58.4 − 62.4
ε0 = | | ∙100% = 6.85%
58.4
Multiple-application trapezoidal rule
Divide [𝒂, 𝒃] into n segments of equal width h
𝑏−𝑎
ℎ=
𝑛

𝑓(𝑥0 ) + 2 ∑𝑛−1
𝑖=1 𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑛 )
𝐼 ≈ (𝑏 − 𝑎)
2𝑛
Error:

−(𝑏 − 𝑎)3 ′′
𝐸𝑎 = ̅̅̅̅
𝑓 (𝑥)
12𝑛2
Example 1.1: Use 2-segments trapezoidal rule to numerically integrate the function [𝒂, 𝒃] =
[𝟎, 𝟐]; 𝑓(𝑥) = 0.2 + 25𝑥 + 3𝑥 2
Solution:
𝑏−𝑎
𝑛 = 2; ℎ = =1
𝑛
𝑓(0) = 0.2; 𝑓(1) = 28.2; 𝑓(2) = 62.2
𝑓(𝑥0 ) + 2 ∑𝑛−1
𝑖=1 𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑛 )
𝐼 ≈ (𝑏 − 𝑎) = 59.4
2𝑛
Error:
2
∫ 6𝑑𝑥
𝑓 ′′ = 0
𝑓 ′′ (𝑥) = 6, ̅̅̅̅ =6
2−0
(2 − 0)3
𝐸𝑎 = − 6 = −1
12 ∙ 22
The exact solution is 59.4 − 1 = 58.4, The relative error is 1.71%
1.2. Simpson’s Rule
Multiple-application Simpson’s rule:

𝑏 𝑚 𝑚−1

∫ 𝑓(𝑥)𝑑𝑥 ≈ [𝑓0 + 𝑓2𝑚 + 4 ∑ 𝑓2𝑘−1 + 2 ∑ 𝑓2𝑘 ]
𝑎 3
𝑘=1 𝑘=1

Error:
−(𝑏 − 𝑎)5 (4)
𝐸𝑎 = 𝑓̅
180𝑛4

Where 𝑓 ̅(4) is the average fourth derivative for the interval. (Don’t be mistaken with 𝒇𝟒 )
𝑏
𝑓 (4) (𝑥)
𝑓 ̅(4) = ∫
𝑎 𝑏−𝑎
Example 1.2: with 𝑛 = 4, estimate the integral and error of
𝑓(𝑥) = 0.2 + 25𝑥 − 200𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
From 𝑎 = 0 to 𝑏 = 0.8. The exact integral is 1.640533
0.8−0
Solution: ℎ = = 0.2
4
k x f(x) 0.2
𝐼≈ [0.2 + 0.232 + 4(1.288 + 3.464) + 2(2.456)] = 1.623467
0 0 0.2 3
1 0.2 1.288 𝐸𝑡 = 1.623467 − 1.640533 = 0.017067
2 0.4 2.456 0.017067
3 0.6 3.464 𝜀𝑡 = = 1.04%
1.640533
4 0.8 0.232

0.8 48000𝑥−21600
Error: 𝑓 (4) = 48000𝑥 − 21600; 𝑓 ̅(4) = ∫0 0.8−0
= −2400

−0.85
Estimated error is 𝐸𝑎 = 180∙44 (−2400) = 0.017067

Note: Tactics to estimate the integral using Simpson's Rule: First, draw a table with
variables k, x, and f(x), incrementing by step h. Second, substitute the first and last 𝑓(𝑥) (𝒇𝟎
and 𝒇𝟐𝒎 ), and then replace all the odd and even 𝑓(𝑥) values according to k in the equation.
Finally, use CASIO to compute the sum.
1.3. Newton – Cotes Method
1
Given function 𝑃(𝑥), numerically integrate ∫−1 𝑃(𝑥)𝑑𝑥
𝑛

𝐼 ≈ ∑ 𝑤𝑖 𝑃(𝑥𝑖 )
𝑖=0

N 𝒊 𝒘𝒊 Order m
2 −1, +1 1 1
0 4/3 3
3
−1, +1 1/3
−1/3, +1/3 3/4 3
4
−1, +1 1/4
0 12/45 5
5 −1/2, +1/2 32/45
−1, +1 7/45
−1/5, +1/5 50/144 5
6 −3/5, +3/5 75/144
−1, +1 19/144
N: number of points of integration; m: order of polynomial; w: factor
Table 1.1 one-dimensional Newton-Cotes method

2. Numerical Differentiation
2.1. First Order Derivatives
The first forward finite divided difference is
𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) ≈

The first backward finite divided difference is

𝑓(𝑥𝑖 ) − 𝑓(𝑥𝑖−1 )
𝑓 ′ (𝑥𝑖 ) ≈

The first centered finite divided difference is

𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖−1 )
𝑓 ′ (𝑥𝑖 ) ≈
2ℎ
In case that we consider 4 points
−𝑓(𝑥0 + 2ℎ) + 8𝑓(𝑥0 + ℎ) − 8𝑓(𝑥0 − ℎ) + 𝑓(𝑥0 − 2ℎ)
𝑓 ′ (𝑥0 ) ≈
12ℎ
Example 2.1: Estimate the centered first order derivative of 𝑓(𝑥) at 𝑥 = 0.5 and ℎ = 0.5
𝑓(𝑥) = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2
Solution:

𝑥𝑖 = 0.5 𝑓(𝑥𝑖 ) = 0.925


{𝑥𝑖−1 = 0 → { 𝑓(𝑥𝑖−1 ) = 1.2
𝑥𝑖+1 = 1 𝑓(𝑥𝑖+1 ) = 0.2
The first centered divided difference:
𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖−1 )
𝑓 ′ (𝑥𝑖 ) ≈ = −1.0
2ℎ
2.2. Second Order Derivatives
The second forward finite divided difference is

𝑓(𝑥𝑖+2 ) − 2𝑓(𝑥𝑖+1 ) + 𝑓(𝑥𝑖 )


𝑓 ′′ (𝑥𝑖 ) ≈
ℎ2
The second backward finite divided difference is

𝑓(𝑥𝑖 ) − 2𝑓(𝑥𝑖−1 ) + 𝑓(𝑥𝑖−2 )


𝑓 ′′ (𝑥𝑖 ) ≈
ℎ2
The second centered finite divided difference is

𝑓(𝑥𝑖+1 ) − 2𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑖−1 )


𝑓 ′′ (𝑥𝑖 ) ≈
ℎ2
Example 2.2: Evaluate the second centered derivatives of function 𝑓(𝑥) at 𝑥 = 0.5
and ℎ = 0.25
𝑓(𝑥) = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2

𝑥𝑖 = 0.5 𝑓(𝑥𝑖 ) = 0.925


𝑥𝑖−1 = 0.25 𝑓(𝑥𝑖−2 ) = 1.1035
𝑥𝑖−2 = 0 → 𝑓(𝑥𝑖−2 ) = 1.2
𝑥𝑖+1 = 0.75 𝑓(𝑥𝑖+1 ) = 0.6363
{ 𝑥𝑖+2 = 1 { 𝑓(𝑥𝑖+2 ) = 0.2
The second centered divided difference:
𝑓(𝑥𝑖+1 ) − 2𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑖−1 )
𝑓 ′′ (𝑥𝑖 ) = = −1.7632
ℎ2

3. Interpolation
3.1. Lagrange polynomial
The Lagrange polynomials associated with the nodes are defined to be
𝑛

𝐿𝑛 (𝑥) = ∑ 𝑦𝑘 𝐿𝑘𝑛 (𝑥)


𝑘=0

𝑘
𝑥 − 𝑥𝑗
𝐿𝑘𝑛 (𝑥) = ∏
𝑥𝑘 − 𝑥𝑗
𝑗=0,𝑗≠𝑘

3.2. Shape function


The four-node quadrilateral shown:

Shape functions (can obtain by using Lagrange polynomials) are:


1
𝑁1 = (1 − )(1 − )
4
1
𝑁2 = (1 + )(1 − )
4
1
𝑁3 = (1 + )(1 + )
4
1
𝑁4 = (1 − )(1 + )
4
We can obtain the coordinates of one specific point using shape functions:
𝑥 = 𝑁1 𝑥1 + 𝑁2 𝑥2 + 𝑁3 𝑥3 + 𝑁4 𝑥4
𝑦 = 𝑁1 𝑦1 + 𝑁2 𝑦2 + 𝑁3 𝑦3 + 𝑁4 𝑦4
3.3. The Jacobian matrix:
𝜕𝑓 𝜕𝑓
𝜕 𝜕𝑥
= 𝐽 𝜕𝑓
𝜕𝑓
{𝜕} {𝜕𝑦}

Here J denotes the Jacobian matrix of (𝑥, 𝑦) with respect to (, )


𝜕𝑥 𝜕𝑦
𝜕 𝜕
𝐽=
𝜕𝑥 𝜕𝑦
[𝜕 𝜕]
Similarity, we have:
𝜕𝑓 𝜕𝑓 𝜕 𝜕
𝜕𝑥 𝜕 𝜕x 𝜕x
{𝜕𝑓 } = 𝑗 {𝜕𝑓} where 𝑗 = [ 𝜕 𝜕]
𝜕𝑦 𝜕 𝜕y 𝜕y

Example 3.1:
Find shape function in this coordinate:

Applying the Lagrange polynomials, we have:


( − 0)( − 1) 1
𝑁1 (𝑥) = = ( − 1)
(−1 − 0)(−1 − 1) 2
[ − (−1)]( − 1)
𝑁2 (𝑥) = = −( + 1)( − 1)
[0 − (−1)](0 − 1)
[ − (−1)]( − 0) 1
𝑁3 (𝑥) = = ( + 1)
[1 − (−1)](1 − 0) 2

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