(i)
∫
a
b
w
(
x
)
⋅
f
(
x
)
d
x
=
f
(
ξ
)
∫
a
b
w
(
x
)
d
x
{\displaystyle \int _{a}^{b}w(x)\cdot f(x)dx=f(\xi )\int _{a}^{b}w(x)dx}
for
w
(
x
)
≥
0
{\displaystyle w(x)\geq 0}
<br\>
(ii) Another version of IMVT
w
(
x
)
<
0
{\displaystyle w(x)<0}
for all
x
∈
[
a
,
b
]
{\displaystyle x\in [a,b]}
<br\>
Ref: Lecture Notes p.5-1
<br\>
<br\>
Ref: Lecture Notes p.2-3
<br\>
(i)
m
⋅
w
(
x
)
≤
f
(
x
)
⋅
w
(
x
)
≤
M
⋅
w
(
x
)
{\displaystyle m\cdot w(x)\leq f(x)\cdot w(x)\leq M\cdot w(x)}
<br\>
where,
m:=min f(x)
M:=max f(x)
<br\>
a) Integrating,
m
⋅
∫
a
b
w
(
x
)
d
x
≤
∫
a
b
w
(
x
)
⋅
f
(
x
)
d
x
≤
M
⋅
∫
a
b
w
(
x
)
d
x
{\displaystyle m\cdot \int _{a}^{b}w(x)dx\leq \int _{a}^{b}w(x)\cdot f(x)dx\leq M\cdot \int _{a}^{b}w(x)dx}
<br\>
b) Dividing by
1
∫
a
b
w
(
x
)
d
x
{\displaystyle {\frac {1}{\int _{a}^{b}w(x)dx}}}
m
≤
1
∫
a
b
w
(
x
)
d
x
∫
a
b
w
(
x
)
⋅
f
(
x
)
d
x
⏟
Z
≤
M
{\displaystyle m\leq \underbrace {{\frac {1}{\int _{a}^{b}w(x)dx}}\int _{a}^{b}w(x)\cdot f(x)dx} _{Z}\leq M}
Z
=
1
∫
a
b
w
(
x
)
d
x
∫
a
b
w
(
x
)
⋅
f
(
x
)
d
x
{\displaystyle Z={\frac {1}{\int _{a}^{b}w(x)dx}}\int _{a}^{b}w(x)\cdot f(x)dx}
<br\>
c) By Interm. Value Them,
There exists
ξ
∈
[
a
,
b
]
a
t
f
(
ξ
)
=
Z
{\displaystyle \xi \in [a,b]atf(\xi )=Z}
<br\>
∴
f
(
ξ
)
=
1
∫
a
b
w
(
x
)
d
x
∫
a
b
w
(
x
)
⋅
f
(
x
)
d
x
{\displaystyle \therefore f(\xi )={\frac {1}{\int _{a}^{b}w(x)dx}}\int _{a}^{b}w(x)\cdot f(x)dx}
<br\>
(ii)
m
⋅
|
w
(
x
)
|
≤
f
(
x
)
⋅
|
w
(
x
)
|
≤
M
⋅
|
w
(
x
)
|
{\displaystyle m\cdot \left|w(x)\right|\leq f(x)\cdot \left|w(x)\right|\leq M\cdot \left|w(x)\right|}
<br\>
where,
m:=min f(x)
M:=max f(x)
<br\>
a) Integrating,
m
⋅
∫
a
b
|
w
(
x
)
|
d
x
≤
∫
a
b
|
w
(
x
)
|
⋅
f
(
x
)
d
x
≤
M
⋅
∫
a
b
|
w
(
x
)
|
d
x
{\displaystyle m\cdot \int _{a}^{b}\left|w(x)\right|dx\leq \int _{a}^{b}\left|w(x)\right|\cdot f(x)dx\leq M\cdot \int _{a}^{b}\left|w(x)\right|dx}
<br\>
b) Dividing by
1
∫
a
b
|
w
(
x
)
|
d
x
{\displaystyle {\frac {1}{\int _{a}^{b}\left|w(x)\right|dx}}}
m
≤
1
∫
a
b
|
w
(
x
)
|
d
x
∫
a
b
|
w
(
x
)
|
⋅
f
(
x
)
d
x
⏟
Z
≤
M
{\displaystyle m\leq \underbrace {{\frac {1}{\int _{a}^{b}\left|w(x)\right|dx}}\int _{a}^{b}\left|w(x)\right|\cdot f(x)dx} _{Z}\leq M}
Z
=
1
∫
a
b
|
w
(
x
)
|
d
x
∫
a
b
|
w
(
x
)
|
⋅
f
(
x
)
d
x
{\displaystyle Z={\frac {1}{\int _{a}^{b}\left|w(x)\right|dx}}\int _{a}^{b}\left|w(x)\right|\cdot f(x)dx}
<br\>
c) By Interm. Value Them,
There exists
ξ
∈
[
a
,
b
]
a
t
f
(
ξ
)
=
Z
{\displaystyle \xi \in [a,b]atf(\xi )=Z}
<br\>
d)
w
(
x
)
{\displaystyle w(x)}
is strictly negative, so
f
(
ξ
)
=
1
(
−
1
)
⋅
∫
a
b
w
(
x
)
d
x
⋅
(
−
1
)
⋅
∫
a
b
w
(
x
)
⋅
f
(
x
)
d
x
{\displaystyle f(\xi )={\frac {1}{{\cancelto {}{(-1)}}\cdot \int _{a}^{b}w(x)dx}}\cdot {\cancelto {}{(-1)}}\cdot \int _{a}^{b}w(x)\cdot f(x)dx}
<br\>
∴
f
(
ξ
)
=
1
∫
a
b
w
(
x
)
d
x
⋅
∫
a
b
w
(
x
)
⋅
f
(
x
)
d
x
{\displaystyle \therefore f(\xi )={\frac {1}{\int _{a}^{b}w(x)dx}}\cdot \int _{a}^{b}w(x)\cdot f(x)dx}
<br\>
(8) Taylor, Trap and Simpson Rule
edit
I
=
∫
0
1
e
x
−
1
x
d
x
{\displaystyle I=\int _{0}^{1}{\frac {e^{x}-1}{x}}dx}
(i) Taylor series exp. fn <br\>
(ii) Comp. Trap. rule <br\>
(iii) Comp. Simpson rule <br\>
<br\>
Ref: Lecture Notes p.6-5
<br\>
(i) <br\>
a) n=2,
I
2
=
(
1
(
1
!
⋅
1
)
+
1
(
2
!
⋅
2
)
)
=
1.25
{\displaystyle I_{2}=\left({\frac {1}{(1!\cdot 1)}}+{\frac {1}{(2!\cdot 2)}}\right)=1.25}
a-1) Error for n=2,
1
(
2
+
1
)
!
⋅
(
2
+
1
)
≤
I
−
I
2
≤
e
(
2
+
1
)
!
⋅
(
2
+
1
)
)
=
0.055556
≤
I
−
I
2
≤
0.151016
{\displaystyle {\frac {1}{(2+1)!\cdot (2+1)}}\leq I-I_{2}\leq {\frac {e}{(2+1)!\cdot (2+1))}}=0.055556\leq I-I_{2}\leq 0.151016}
<br\>
<br\>
b) n=4,
I
4
=
(
1
(
1
!
⋅
1
)
+
1
(
2
!
⋅
2
)
+
1
(
3
!
⋅
3
)
+
1
(
4
!
⋅
4
)
)
=
1.3159722222223
≈
1.31597
{\displaystyle I_{4}=\left({\frac {1}{(1!\cdot 1)}}+{\frac {1}{(2!\cdot 2)}}+{\frac {1}{(3!\cdot 3)}}+{\frac {1}{(4!\cdot 4)}}\right)=1.3159722222223\approx 1.31597}
b-1) Error for n=4,
1
(
4
+
1
)
!
⋅
(
4
+
1
)
≤
I
−
I
2
≤
e
(
4
+
1
)
!
⋅
(
4
+
1
)
)
=
0.001667
≤
I
−
I
2
≤
0.00453
{\displaystyle {\frac {1}{(4+1)!\cdot (4+1)}}\leq I-I_{2}\leq {\frac {e}{(4+1)!\cdot (4+1))}}=0.001667\leq I-I_{2}\leq 0.00453}
<br\>
<br\>
c) n=8,
I
4
=
(
1
(
1
!
⋅
1
)
+
1
(
2
!
⋅
2
)
+
1
(
3
!
⋅
3
)
+
1
(
4
!
⋅
4
)
+
1
(
5
!
⋅
5
)
+
1
(
6
!
⋅
6
)
+
1
(
7
!
⋅
7
)
+
1
(
8
!
⋅
8
)
)
=
1.3179018152401
≈
1.3179
{\displaystyle I_{4}=\left({\frac {1}{(1!\cdot 1)}}+{\frac {1}{(2!\cdot 2)}}+{\frac {1}{(3!\cdot 3)}}+{\frac {1}{(4!\cdot 4)}}+{\frac {1}{(5!\cdot 5)}}+{\frac {1}{(6!\cdot 6)}}+{\frac {1}{(7!\cdot 7)}}+{\frac {1}{(8!\cdot 8)}}\right)=1.3179018152401\approx 1.3179}
c-1) Error for n=8,
1
(
8
+
1
)
!
⋅
(
8
+
1
)
≤
I
−
I
2
≤
e
(
8
+
1
)
!
⋅
(
8
+
1
)
)
=
3.06192
×
10
−
7
≤
I
−
I
2
≤
8.32317
×
10
−
7
{\displaystyle {\frac {1}{(8+1)!\cdot (8+1)}}\leq I-I_{2}\leq {\frac {e}{(8+1)!\cdot (8+1))}}=3.06192\times 10^{-7}\leq I-I_{2}\leq 8.32317\times 10^{-7}}
<br\>
(ii) <br\>
This one can be calculated by the Comp. Trap. rule or the Corrected Trap. rule but it is hard to define the first term, X0 .
Thus, some math-codes are required.
<br\>
=Find the true value of I=
MATLAB Code
clc ;
clear all ;
format long
F =@( x )( exp ( x ) - 1 ) ./ x ;
I = quad ( F , 0 , 1 )
I = 1.317902151956861 %Assumption: This is the true valuse of I
<br\>
a) the Comp. Trap. rule
∫
a
b
f
(
x
)
d
x
=
b
−
a
2
n
∗
[
f
(
x
0
)
+
2
f
(
x
1
)
+
2
f
(
x
2
)
+
.
.
.
.
.
.
.
.
.
+
2
f
(
x
n
−
1
)
+
f
(
x
n
)
]
{\displaystyle \int _{a}^{b}f(x)dx={\frac {b-a}{2n}}*[f(x_{0})+2f(x_{1})+2f(x_{2})+.........+2f(x_{n-1})+f(x_{n})]}
b) the Corrected Trap. rule
∫
a
b
f
(
x
)
d
x
=
b
−
a
2
n
∗
[
f
(
x
0
)
+
2
f
(
x
1
)
+
2
f
(
x
2
)
+
.
.
.
.
.
.
.
.
.
+
2
f
(
x
n
−
1
)
+
f
(
x
n
)
]
−
h
2
12
∗
[
f
′
(
b
)
−
f
′
(
a
)
]
{\displaystyle \int _{a}^{b}f(x)dx={\frac {b-a}{2n}}*[f(x_{0})+2f(x_{1})+2f(x_{2})+.........+2f(x_{n-1})+f(x_{n})]-{\frac {h^{2}}{12}}*[f^{'}(b)-f^{'}(a)]}
Where
h
=
(
b
−
a
)
n
{\displaystyle h={\frac {(b-a)}{n}}}
<br\>
<br\>
c) Results of Comp. Trap. rule
n
In
En
2
1.328291728
-0.010389576
4
1.320504619
-0.002602468
8
1.318553087
-0.000650935
16
1.318064905
-0.000162753
32
1.317942841
-4.06892*10-5
64
1.317912324
-1.0172*10-5
128
1.317904695
-2.54263*10-6
256
1.317902787
-6.3528*10-7
Where
En = The true value of I (=1.317902152) - In
<br\>
Finally, the value of n=128 is closer to the true value with about 10-6 order.
<br\>
d) Example of MATLAB Code (n=2)
clc ;
clear all ;
format long
X = eps : 0.5 : 1 ;
Y =( exp ( X ) - 1 ) ./ X ;
Z = trapz ( X , Y )
<br\>
(iii) <br\>
This one can be calculated by the Comp. Simpson rule but it is also hard to define the first term, X0.
Thus, some math-codes are required.
<br\>
<br\>
a) the Comp. Simpson rule
∫
a
b
f
(
x
)
d
x
=
b
−
a
3
n
∗
[
f
(
x
0
)
+
4
f
(
x
1
)
+
2
f
(
x
2
)
+
.
.
.
.
.
.
.
.
.
+
2
f
(
x
n
−
2
)
+
4
f
(
x
n
−
1
)
+
f
(
x
n
)
]
{\displaystyle \int _{a}^{b}f(x)dx={\frac {b-a}{3n}}*[f(x_{0})+4f(x_{1})+2f(x_{2})+.........+2f(x_{n-2})+4f(x_{n-1})+f(x_{n})]}
<br\>
<br\>
b) Results of Comp. Simpson rule
n
In
En
2
1.318008666
-0.000106514
4
1.317908917
-6.76473*10-6
8
1.317902576
-4.24046*10-7
16
1.317902178
-2.60589*10-8
Where
En = The true value of I (=1.317902152) - In
<br\>
Finally, the value of n=4 is closer to the true value with about 10-6 order.
<br\>
c) MATLAB Source Code
function y = simpson ( f,a,b,n)
%SIMPSON Simpson's rule integration with equally spaced points
%
% y=SIMPSON(f,a,b,n) returns the Simpson's rule approximation to
% the integral of f(x) over the interval [a,b] using n+1 equally
% spaced points. The input variable f is a string containing the
% name of a function of one variable. The function f(x) must accept
% a vector argument and return the vector of values of the function.
%
% NOTE: n must be even.
h =( b - a ) / n ;
x = linspace ( a , b , n + 1 );
fx = feval ( f , x );
y = h / 3 * ( fx ( 1 ) + 4 * sum ( fx ( 2 : 2 : n )) + 2 * sum ( fx ( 3 : 2 : n - 1 )) + fx ( n + 1 ));
<br\>
<br\>
d) Example of MATLAB Code (Run, n=2)
clear all
format long
z = simpson (@( x ) ( exp ( x ) - 1 ) ./ x , eps , 1 , 2 )
<br\>
--Heejun Chung 17:43, 27 January 2010 (UTC)