Information Technology Reference
In-Depth Information
p
2
(
x
)
f
(
x
)
x
a
c
b
Fig. 1.8
A polynomial of degree 2 that approximates a function f.x/
Set n
D
2 and use (
1.46
) to approximate the integral in (
1.45
). Compute the
relative error.
(d) Implement the composite midpoint rule (
1.46
) and use your program to try to
estimate c and ˛ such that the error of the scheme is approximately ch
˛
.You
should probably consider Sect.
1.4
first.
(e) In the midpoint rule we used the constant f
aCb
2
to approximate f on the
interval Œa; b. Of course, the constant is trivial to integrate. The next level of
complexity is to approximate f by a straight line. Read the derivation given in
Sect.
1.3.1
again and use the trapezoidal rule (1.10) to approximate the integral
in (
1.45
). Compute the relative error and compare the result with the one you
obtained in (b) above.
(f) Simpson's
11
rule.
Define
1
2
.a
C
b/
c
D
(1.47)
and let p
2
.x/ be a polynomial of degree
2 that interpolates f at the points a,
c and b,seeFig.
1.8
.
More precisely, we want to find p
2
D
p
2
.x/ such that
p
2
.x/
D
A
C
Bx
C
Cx
2
;
(1.48)
where the constants A, B and C are chosen such that
11
This is probably not the Simpson you have heard of. Thomas Simpson, 1710-1761, worked on
interpolation and numerical methods for integration.