Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Therefore,
T h2 (2) h2
E
n (f ) ≤ ·2=
12 3
T h2
En (f ) ≤
3
How large should n be chosen in order to ensure that
≤ 5 × 10−6
T
E
n (f ) (1)
h2
≤ 5 × 10−6
3
This is equivalent to choosing h and n to satisfy
h ≤ .003873
2
n = ≥ 516.4
h
Thus n ≥ 517 will imply (1).
DERIVING THE ERROR FORMULA
Z xn
I (f ) = f (x) dx
x
Z 0x1 Z x2 Z xn
= f (x) dx + f (x) dx + · · · + f (x) dx
x0 x1 xn−1
h h
Tn (f ) = [f (x0 ) + f (x1 )] + [f (x1 ) + f (x2 )]
2 2
h
+ · · · + [f (xn−1 ) + f (xn )]
2
Then the error
Z b
EnT (f ) ≡ f (x) dx − Tn (f )
a
can be analyzed by adding together the errors over the subintervals
[x0 , x1 ], [x1 , x2 ], ..., [xn−1 , xn ]. Recall
Z α+h
h h3
f (x) dx − [f (α) + f (α + h)] = − f 00 (c)
α 2 12
Then on [xj−1 , xj ],
Z xj
h h3
f (x) dx − [f (xj−1 ) + f (xj )] = − f 00 (γj )
xj−1 2 12
with xj−1 ≤ γj ≤ xj . Combining these errors, we obtain
h3 00 h3
EnT (f ) = − f (γ1 ) − · · · − f 00 (γn )
12 12
This formula can be further simplified, and we will do so in two
ways.
Rewrite this error as
h3 n f 00 (γ1 ) + · · · + f 00 (γn )
EnT (f ) =−
12 n
Denote the quantity inside the brackets by ζn . This number
satisfies
min f 00 (x) ≤ ζn ≤ max f 00 (x)
a≤x≤b a≤x≤b
Since f 00 (x)
is a continuous function (by original assumption), we
have some number cn in [a, b] for which
f 00 (cn ) = ζn
Recall also that hn = b − a. Then
h3 n f 00 (γ1 ) + · · · + f 00 (γn )
T
En (f ) = −
12 n
2
h (b − a) 00
=− f (cn )
12
This is the error formula given on the first slide.
AN ERROR ESTIMATE
We now obtain a way to estimate the error EnT (f ). Return to the
formula
h3 h3
EnT (f ) = − f 00 (γ1 ) − · · · − f 00 (γn )
12 12
and rewrite it as
h2 00
EnT (f ) = − f (γ1 )h + · · · + f 00 (γn )h
12
The quantity
f 00 (γ1 )h + · · · + f 00 (γn )h
is a Riemann sum for the integral
Z b
f 00 (x) dx = f 0 (b) − f 0 (a)
a
By this we mean
Z b
00 00
f 00 (x) dx
lim f (γ1 )h + · · · + f (γn )h =
n→∞ a
Thus
f 00 (γ1 )h + · · · + f 00 (γn )h ≈ f 0 (b) − f 0 (a)
for larger values of n. Combining this with the earlier error formula
h2 00
EnT (f ) = − f (γ1 )h + · · · + f 00 (γn )h
12
we have
h2 0
EnT (f ) ≈ − f (b) − f 0 (a) ≡ EenT (f )
12
This is a computable estimate of the error in the numerical
integration. It is called an asymptotic error estimate.
Example
Consider evaluating
Z π
eπ + 1 .
I (f ) = e x cos x dx = − = −12.0703463163896
0 2
In this case,
f 0 (x) = e x (cos x − sin x) , f 00 (x) = −2e x sin x
00 00
max f (x) = f (.75π) = 14. 921
0≤x≤π
From
h2 (b − a) 00
EnT (f ) = − f (cn )
12
we have the error bound
T h2 π
En (f ) ≤ · 14.921 = 3.906h2 (2)
12
Also, we have the error estimate
h2 0 h2 π .
EenT (f ) = − f (π) − f 0 (0) = (e + 1) = 2.012h2 (3)
12 12
n Tn EnT Ratio Bound (2) EenT
2 -17.38925933 5.319 9.638 4.964
4 -13.33602285 1.266 4.20 2.409 1.241
8 -12.38216243 3.118E−1 4.06 6.024E−1 3.103E−1
16 -12.14800410 7.766E−2 4.02 1.506E−1 7.757E−2
32 -12.08974212 1.940E−2 4.00 3.765E−2 1.939E−2
64 -12.07519410 4.848E−3 4.00 9.412E−3 4.848E−3
128 -12.07155818 1.212E−3 4.00 2.353E−3 1.212E−3
256 -12.07064928 3.030E−4 4.00 5.822E−4 3.030E−4
In looking at the table, we see that the error EnT (f ) and the error
estimate EenT (f ) are quite close. Therefore
h2 π
I (f ) − Tn (f ) ≈ (e + 1)
12
h2 π
I (f ) ≈ Tn (f ) + (e + 1)
12
This last formula is called the corrected trapezoidal rule, CTn (f ).
The corrected trapezoidal rule is illustrated in the following table.
In general,
h2 0
f (b) − f 0 (a)
I (f ) − Tn (f ) ≈ −
12
h2 0
f (b) − f 0 (a)
I (f ) ≈ CTn (f ) := Tn (f ) −
12
This is the corrected trapezoidal rule. It is easy to obtain from the
trapezoidal rule, and in most cases, it converges more rapidly than
the trapezoidal rule.
ERROR FORMULA FOR SIMPSON’S RULE
Recall the general Simpson’s rule
Z b
h
f (x) dx ≈ Sn (f ) := [f (x0 ) + 4f (x1 ) + 2f (x2 )
a 3
+ 4f (x3 ) + 2f (x4 ) + · · ·
+ 2f (xn−2 ) + 4f (xn−1 ) + f (xn )]
5x 4 − 10x 2 + 1
f (4) (x) = 24
(1 + x 2 )5
max f (4) (x) = f (4) (0) = 24
0≤x≤1
Then
h4 (b − a) (4)
EnS (f ) = − f (cn )
180
h4 · 2 4h4
S
En (f ) ≤ · 24 =
180 15
How large should n be chosen in order to ensure that
En (f ) ≤ 5 × 10−6
S
This is true if
4h4
≤ 5 × 10−6
15
h ≤ .0658
n ≥ 30.39
Therefore, choosing n ≥ 32 will give the desired error bound.
Compare this with the earlier trapezoidal example in which
n ≥ 517 was needed.
For the asymptotic error estimate, we have
x2 − 1
f 000 (x) = −24x
(1 + x 2 )4
h4 000 h4 144 4 4
EenS (f ) ≡ − f (2) − f 000 (0) =
· = h
180 180 625 3125
√
INTEGRATING x
Consider the numerical approximation of
Z 1
√ 2
x dx =
0 3
In the following table, we give the errors when using both the
trapezoidal and Simpson rules.
n EnT Ratio EnS Ratio
2 6.311E −2 2.860E −2
4 2.338E −2 2.70 1.012E −2 2.82
8 8.536E −3 2.74 3.587E −3 2.83
16 3.085E −3 2.77 1.268E −3 2.83
32 1.108E −3 2.78 4.485E −4 2.83
64 3.959E −4 2.80 1.586E −4 2.83
128 1.410E −4 2.81 5.606E −5 2.83
√
The rate of convergence is slower because the function f (x) = x
is not sufficiently differentiable on [0, 1]. Both methods converge
with a rate proportional to h1.5 .
ASYMPTOTIC ERROR FORMULAS
For a numerical integration formula,
Z b Xn
f (x) dx ≈ wj f (xj )
a j=0
Een (f ) En (f ) − Een (f )
lim = 1 or lim =0
n→∞ En (f ) n→∞ En (f )
h2 0
EnT (f ) ≈ EenT (f ) ≡ − f (b) − f 0 (a)
12
h4 000
EnS (f ) ≈ EenS (f ) ≡ − f (b) − f 000 (a)
180
Example (cont.)
(b − a)2 0
f (b) − f 0 (a)
c =−
12
and for Simpson’s rule, p = 4 and
(b − a)4 000
f (b) − f 000 (a)
c =−
180
The formula
c
Een (f ) = p (4)
n
occurs for many other numerical integration formulas that we have
not yet defined or studied. In addition, if we use the trapezoidal or
Simpson rules with an integrand f (x) which is not sufficiently
differentiable, then (4) may hold with a p less than the ideal.
Example. Consider Z 1
I = x β f (x) dx
0
in which 0 < β < 1 and f (x) is a smooth function with f (0) 6= 0 .
Then the convergence of the trapezoidal rule can be shown to have
an asymptotic error formula
c
En ≈ Een = β+1 (5)
n
for some constant c dependent on β. A similar result holds for
Simpson’s rule, with 0 < β < 3, β not an integer. We can actually
specify a formula for c; but the formula is often less important
than knowing that (4) is valid for some c.
APPLICATION OF ASYMPTOTIC ERROR FORMULAS
Assume we know that an asymptotic error formula
c
I − In ≈ p
n
is valid for some numerical integration rule denoted by In . Initially,
assume we know the exponent p. Then imagine calculating both In
and I2n . With I2n , we have
c
I − I2n ≈ p p
2 n
This leads to
I − In ≈ 2p (I − I2n )
2p I2n − In I2n − In
I ≈ = I2n + p
2p − 1 2 −1
The formula
I2n − In
I ≈ I2n + (6)
2p − 1
is called Richardson’s extrapolation formula.
Examples
With the trapezoidal rule and with the integrand f (x) having two
continuous derivatives, p = 2 and
1
I ≈ T2n + (T2n − Tn )
3
With Simpson’s rule and with the integrand f (x) having four
continuous derivatives, p = 4 and
1
I ≈ S2n + (S2n − Sn )
15
Richardson’s error estimate
We can also use the formula (4)
c
Een (f ) = p
n
to obtain error estimation formulas:
I2n − In
I − I2n ≈ (7)
2p − 1
This is called Richardson’s error estimate. For example, with the
trapezoidal rule,
1
I − T2n ≈ (T2n − Tn )
3
and for Simpson’s rule,
1
I − S2n ≈ (S2n − Sn )
15
AITKEN EXTRAPOLATION
In this case, we again assume
c
I − In ≈
np
But in contrast to previously, we do not know either c or p.
Imagine computing In , I2n , and I4n . Then
c c c
I − In ≈ p , I − I2n ≈ p p , I − I4n ≈ p p
n 2 n 4 n
We can directly try to estimate I . Dividing
I − In I − I2n
≈ 2p ≈
I − I2n I − I4n
Solving for I , we obtain
(I − I2n )2 ≈ (I − In ) (I − I4n )
2
I (In + I4n − 2I2n ) ≈ In I4n − I2n
2
In I4n − I2n
I ≈
In + I4n − 2I2n
This can be improved computationally, to avoid loss of significance
errors.
2
In I4n − I2n
I ≈ I4n + − I4n
In + I4n − 2I2n
(I4n − I2n )2
= I4n −
(I4n − I2n ) − (I2n − In )
This is called Aitken’s extrapolation formula.
To estimate p, we use
I2n − In
≈ 2p
I4n − I2n
To see this, write
I2n − In (I − In ) − (I − I2n )
=
I4n − I2n (I − I2n ) − (I − I4n )
Then substitute from the following and simplify:
c c c
I − In ≈ p , I − I2n ≈ p p , I − I4n ≈ p p
n 2 n 4 n
Example
Consider the following table of numerical integrals.
n In In − In/2 Ratio
2 .28451779686
4 .28559254576 1.075E −3
8 .28570248748 1.099E −4 9.78
16 .28571317731 1.069E −5 10.28
32 .28571418363 1.006E −6 10.62
64 .28571427643 9.280E −8 10.84
What is its order of convergence? It appears
. .
2p = 10.84, p = log2 10.84 = 3.44
We could now combine this with Richardson’s error formula:
1
I − In ≈ p In − In/2
2 −1
For example,
1
I − I64 ≈ [9.280E − 8] = 9.43E − 9
9.84
PERIODIC FUNCTIONS
A function f (x) is periodic if the following condition is satisfied.
There is a smallest real number τ > 0 for which
f (x + τ ) = f (x), −∞ < x < ∞ (8)
The number τ is called the period of the function f (x). The
constant function f (x) ≡ 1 is also considered periodic, but it
satisfies this condition with any τ > 0. Basically, a periodic
function is one which repeats itself over intervals of length τ .
The condition (8) implies
f (m) (x + τ ) = f (m) (x), −∞ < x < ∞ (9)
for the mth -derivative of f (x), provided there is such a derivative.
Thus the derivatives are also periodic.
Periodic functions occur very frequently in applications of
mathematics, reflecting the periodicity of many phenomena in the
physical world.
PERIODIC INTEGRANDS
Consider the special class of integrals
Z b
I (f ) = f (x) dx
a
n Tn Tn − T 1 n
2
2 0.0
4 −0.72589193317292 −7.259E − 1
8 −0.74006131211583 −1.417E − 2
16 −0.74006942337672 −8.111E − 6
32 −0.74006942337946 −2.746E − 12
64 −0.74006942337946 0.0