(i)
for
<br\>
(ii) Another version of IMVT
for all
<br\>
Ref: Lecture Notes p.5-1
<br\>
<br\>
Ref: Lecture Notes p.2-3
<br\>
(i)
<br\>
where,
m:=min f(x)
M:=max f(x)
<br\>
a) Integrating,
<br\>
b) Dividing by
<br\>
c) By Interm. Value Them,
There exists
<br\>
<br\>
(ii)
<br\>
where,
m:=min f(x)
M:=max f(x)
<br\>
a) Integrating,
<br\>
b) Dividing by
<br\>
c) By Interm. Value Them,
There exists
<br\>
d)
is strictly negative, so
<br\>
<br\>
(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,
a-1) Error for n=2,
<br\>
<br\>
b) n=4,
b-1) Error for n=4,
<br\>
<br\>
c) n=8,
c-1) Error for n=8,
<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
b) the Corrected Trap. rule
Where
<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
<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)