Professional Documents
Culture Documents
ME 361-Integration
ME 361-Integration
Numerical Integration
Given a complicated f(x) or a set of tabulated values, xi’s and corresponding f(xi)’s:
b
Question: For a given range, [a,b] f (x) dx = ?
a
Answer: Replace f (x) or the tabulated data with a simple function g(x) and
operate on g(x), instead
b b
f (x) g (x) , f (x) dx
a
g(x) dx
a
x i+1 x i+1
f(x) dx
xi
P (x) dx
xi
1
h
h f(x i ) + f(x i+1 ) - f(x i )
2
h
f(x i ) + f(x i+1 )
2
h
f i + f i+1
2
0
Trapezoidal Rule
Δx = h
h
f 0 2 f1 2 f 2 ... 2 f n-1 f n
xn
x
0
f (x) d x
2
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Second-degree
Polynomials, P2(x) x2 x2
f(x) dx
x0
P (x) dx
x0
2
s (s - 1) 2
P2 (x) = f0 + s Δf0 + Δ f0
2!
x - x0
s=
h
h
f 0 4 f1 2 f 2 ... 2 f n-2 4 f n-1 f n
xn
x0
f (x) d x
3
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
h - (x n - x 0 )3 ' '
f 2 f1 2 f 2 ... 2 f n-1 f n
xn
x 0
f (x) d x
2 0
E trap
12 n 2
f ( )
f (x) d x f 0 4 f1 2 f 2 ... 2 f n -2 4 f n -1 f n
xn h - (x n - x 0 )5 (4)
x0 3
E1/3
180 n 4 f ( )
3h
f0 3 f1 3 f 2 2 f3 ... 2 f n-3 3 f n-2 3 f n-1 f n
xn
x 0
f (x) d x
8
1710 - 1761
x f (x) Δf Δ2 f Δ3 f Δ4 f
0 1
- 0.632120559
1 0.367879441 0.399576401
- 0.232544158 - 0.252580458
2 0.135335283 0.146995943 0.1596613
- 0.085548215 - 0.092919158
3 0.049787068 0.054076785 0.05873611
- 0.031471429 - 0.034183048
4 0.018315639 0.019893738 0.021607807
- 0.011577692 - 0.012575241
5 0.006737947 0.007318497
- 0.004259195
6 0.002478752
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 1 2 3 4 5 6
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
6 6
Example: Find the integral
0
I = e x dx = f(x) dx
0
using forward-difference table
Note that Simpson’s 1/3 rule requires odd number of data points (even number of
panels), multiples of three, and that Simpson’s 3/8 rule requires even number of
data points (odd number of panels), multiples of four. Otherwise, use a combination
of the rules.
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Richardson’s Extrapolation
Trap-rule formula:
b - a b - a b - a ''
3
1 1 n 1
2 f a 2 f b f a + n i - 12 n 2 f ( )
b
I= a
f(x) dx
n i 1
Note that the error is roughly proportional to n2, where n is the number of panels.
Let’s denote the true integral by I*. Find I with trap rule using first with n1 number of
panels and then with n2 number of panels
b - a b - a
3 3
*
I = I n1 + E n1 = I n1 - f (1 )
''
I* = I n2 + E n2 = I n2 - f '' ( 2 )
12 n12 12 n 22
I* - I n2 = E n2 I* - I n2
E n2 * *
E n2
=> *
= => I - I n2 = I - I n1
*
I - I n1 = E n1 I - I n1 E n1 E n1
b - a
3
- f '' ( 2 ) 2 2
Take the ratio of E n2 12 n 2
n1 f '' ( 2 ) n1
= 2
=
b - a '' f (1 )
3 ''
two errors. E n1 n2 n2
- 2
f (1 )
12 n1
2
n1
I n2 - I n1
I* - I n2 I* - I n1 Solve for I*: I I n1 +
*
2
n2 n
1- 1
n2
3 3
x
3
Example: Find the integral I= - 2 x 2 + 7 x - 5 dx = f(x) dx
1 1
2
Exact solution: I = 20
3
3 - 1 1 1 1 25
In1 = f(1) + f(3) + f(2) = + + 9 = 22
2 2 2 2 2
3 - 1 1 1
In1 = f(1) + f(3) + f(1.5) + f(2) + f(2.5) = 21
4 2 2
21 - 22 2
I* 22 2
= 20 Why did we get the exact answer?
2 3
1-
4
1 b-a 2N - 1
b-a
TN , 1 N-1 , 1
2
T
2 N-1
i=1
f a + N
2
i
, i = 2
n = 2 N panels
1
n
Example: I = e- x dx N j=1 j=2 j=3
(Panels)
0
Accuracy T-T
Example:
The integral must be obtained, numerically. It is given in tabular form for different
values of x, from which Erf(1) = 0.84270
1.10
1.00
0.90
N =100
0.80
I = 0.73
0.70
0.60
0.50
0.40
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
1.10
1.00
0.90
0.80 N = 500
0.70
I = 0.81
0.60
0.50
0.40
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
b n
Newton-Cotes Formulae: I f (x) dx w
i0
i f (x i )
a
b n
I f (x) dx wi f (xi )
a i0
n b
Choose xi’s such that, the sum w i f (x i ) gives the integral f (x) dx
i0 a
1777 – 1855
Example f(x) = 3 x 2 + 2 x + 1
4 4
Iex = f(x) dx = 81 Itrap = f(x) dx = 81.375 with h = 0.5 => 6 panels
1 1
60
50
40
30
20
10
0
Prof. Dr. Faruk Arınç
1.0 1.5 2.0 2.5 3.0 3.5 4.0 Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
60
50
40
f(x) = 3 x 2 + 2 x + 1
30
f(x2)
20
10
f(x1)
0
1.0 1.5 2.0 2.5 3.0 3.5 4.0
4 N
Iex = f(x) dx = 81 I= w
i 1
i f(x i ) = Iex N=2 xi = ? wi = ?
1
Nodes and weights
Two functions, f(x) and g(x), both real-valued and continous, are called orthogonal
to each other with respect to a third (weighting) function, w(x), in the range [a,b] if
b
I w(x) f(x) g(x) dx
a
0
1
Examples: (1) sin(n x) sin(m x) dx
0
0 when n m
{sin(n x) , n = 1, 2, ... }
1 Fourier
(1) cos(n x) cos(m x) dx
0
0 when n m Series
{cos(n x) , n = 0, 1, ... }
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
French Mathematician
1768 -1830
w(x) Q (x) c
a
n 0 Q0 (x) + c1 Q1(x) + c 2 Q2 (x) + ... + c n Qn (x) + .... dx
cn = b
w(x) Q (x) dx
2
n
Prof. Dr. Faruk Arınç a Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Example
Expand the function f(x) = 1 in Fourier sine series in the range [0,1], i.e., find the
coefficients, an’s, in the orthogonal expansion
f(x) = a
0
n sin(n x)
1
1 2
sin n x dx = - [ cos n x 0 ] =
1
if n is odd
0
n n
=0 if n is even
4 4 4
Solution: f(x) = 1 = sin( x) + sin(2 x) + sin(3 x) + ....
3 5
Legendre polynomials, which form an infinite set, have this property when w(x) = 1
and the range [-1,+1]
1
P0(x) = 1 P1(x) = x P2 (x) (3 x 2 - 1)
2
1 1 1
P3 (x) (5 x 3 - 3 x) P4 (x) (35 x 4 - 30 x 2 3) P5 (x) (63 x 5 - 70 x 3 15 x)
2 8 8
Adrien-Marie Legendre
French mathematician
1752 – 1833
Legendre Polynomials
1
P0(x) = 1 P1(x) = x P2 (x) (3 x 2 - 1)
2
1 1 1
P3 (x) (5 x 3 - 3 x) P4 (x) (35 x 4 - 30 x 2 3) P5 (x) (63 x 5 - 70 x 3 15 x)
2 8 8
Chebyshev Polynomials
Russian mathematician
1821 - 1894
Laguerre Polynomials
1 2
L (x) 1
0
0 L (x) - x 1
0
1
L02 (x) (x 4 x 2)
2
1 1 4
L (x) (- x 3 9 x 2 18 x 6)
0
3
L04 (x) (x 16 x 3 72 x 2 96 x 24)
6 24
Hermite Polynomials
French mathematician
1834 – 1886
Charles Hermite
French mathematician
1822 - 1901
ORTHOGONAL POLYNOMIALS
1 w T k Tk dx if k 0
Chebyshev [- 1 , + 1] w(x) = -1
2
1-x 1
w Tk Tk dx
-1
2
if k 0
( k 1)
Laguerre [0 , ∞ ] w (x) = xα e-x w L k L k dx
0
k!
w (x) e
-x2
Hermite [- ∞ , +∞ ] w H k H k dx 2 k
k!
-
b +1 N
I f(x) dx = F(z) dz w
i1
i F(z i ) , N = 2, 3, ....
a -1
N
I w
i1
i F(z i ) if F z i is a polynomial of degree 2 N -1 or LESS
x=
b - a z+b+a
, dx =
b-a
dz
Change of Variable:
2 2
2x-b-a 2
Define a new independent variable: z = dz = dx
b-a b-a
b 1
Choose N
The nodes (xi) are the zeros of Legendre orthogonal polynomials, which are
orthogonal in the range, (-1, +1)
b 1 N
I = f(x) dx = F(z) dz w
i 1
i F(zi )
a 1
N ± zi wi
N ± zi wi
2 0.5773502692 1.0000000000
0.1834346425 0.3626837834
0.0000000000 0.8888888889
3 0.5255324099 0.3137066459
0.7745966692 0.5555555556 8
0.7966664774 0.2223810345
0.3399810436 0.6521451549
4 0.9602898565 0.1012285363
0.8611363116 0.3478548451
0.0000000000 0.3302393550
0.0000000000 0.5688888889
0.3242534234 0.3123470770
5 0.5384693101 0.4786286705
9 0.6133714327 0.2606106964
0.9061798459 0.2369268850
0.8360311073 0.1806481607
0.2386191861 0.4679139346
0.9681602395 0.0812743884
6 0.6612093865 0.3607615730
0.1488743390 0.2955242247
0.9324695142 0.1713244924
0.4333953941 0.2692667193
0.0000000000 0.4179591837
10 0.6794095683 0.2190863625
0.4058451514 0.3818300505
7 0.8650633667 0.1495513492
0.7415311856 0.2797053915
0.9739065285 0.0666713443
0.9491079123 0.1294849662
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
Examples:
4 2 4 Exact result
81 2 81 Exact result
Example
6 6 N 2
I = e dx = f(x) dx
-x
w
i 1
i F(zi ) = w 1 F(z1) + w 2 F(z 2 )
0 0
6 1
I = e dx = 3
-x
e -3(z+1)
dz 3
e -3(z1 +1)
+ e -3(z 2 +1)
0 1
1
z1,2 = = 0.5773502692 I 0.8706496
3
Iexact 0.9975212
22 N 1 N !
4
E f (2N) , - 1 1
(2 N 1) 2 N !
3
1 N
Gauss-Legendre f (x) dx w
i1
i f (x i )
-1
1 N
1
Gauss-Chebyshev 2
f (x) dx w i f (x i )
-1 1-x i1
N
Gauss-Laguerre e
-x
f (x) dx w
i1
i f (x i )
0
N
Gauss-Hermite e
- x2
f (x) dx w
i1
i f (x i )
-
N xi wi
2 0.577350269 1.00000000
0 0.888888889
Gauss-Legendre 3
0.774596669 0.555555556
0.339981043 0.652145155
4
0.861136312 0.347854845
1
i-
Gauss-Chebyshev x i cos 2 i 1, 2, ... N wi = for all i
N N
Prof. Dr. Faruk Arınç Fall 2020
ME – 361 NUMERICAL METHODS FOR ENGINEERS
N xi wi
N xi wi
2 0.70710 67811 0.88622 69255
0. 1.18163 59006
3
1.22474 48714 0.29540 89752
Gauss-Hermite
0.52464 76233 0.80491 40900
4
1.65068 01239 0.08131 28354
0. 0.94530 87205
5 0.95857 24646 0.39361 93232
2.02018 28705 0.01995 32421