Problem 1. What is the numerical value of the composite trapezoid

advertisement
Problem 1. What is the numerical value of the composite trapezoid rule applied
to the function f (x) = x−1 using the points 1, 43 and 2.
Solution: The basic trapezoid rule is
b−a
(f (a) + f (b)).
(1)
T (f, a, b) =
2
To find the numerical value we apply this basic rule to two subintervals [1, 4/3] and
[4/3,2]. Then we sum the results:
1
T (f, 1, 4/3) = [1 + 3/4]
6
1
T (f, 4/3, 2) = [3/4 + 1/2]
3
The result then is:
Z 2
1
87
1
.
x−1 dx ≈ T (f, 1, 4/3) + T (f, 4/3, 2) = [1 + 3/4] + [3/4 + 1/2] =
6
3
24
1
R1
Problem 2 Compute approximate value of 0 (x2 +1)−1 dx by using the composite trapezoid rule with three points. Then compare the actual value of the integral.
Next determine the error formula and numerically verify an upper bound on it.
Z
Solution: As in the previous problem, we have that
1
(x2 + 1)−1 dx ≈ T (f, 0, 1/2) + T (f, 1/2, 1) =
0
The error formula is
Z
b
f (x)dx − T (f, h) =
E=
a
1
31
1
(1 + 4/5) + (4/5 + 1/2) =
.
4
4
40
b − a 2 00
h f (ξ).
12
In our case we have a = 0, b = 1, h = 1/2,
f 00 (ξ) = 2
ξ2 − 1
.
(ξ 2 + 1)2
A bound on the error then is
2
x −1 1
≤ 1 .
max 2
|E| ≤
48 x∈[0,1] (x2 + 1)2 24
Problem 3.(Continuation) Having computed R(1, 0) from the previous problem,
compute R(2, 0) by using the formula:
n−1
2X
1
f (a + (2k − 1)h),
R(n, 0) = R(n − 1, 0) + h
2
k=1
where h = 2
−n
(b−a). Solution: Just apply the formula (h = 1/4, because n = 2)
and use the result from the previous problem.
31 1
+ (f (1/4) + f (3/4))
80 4
31 1
+ (16/17 + 16/25) = 0.782794117647059
80 4
R(2, 0) =
=
1
2
composite trapezoid rule is used to compute the integral
R 2 Problem 4. If the −2
sin
xdx
with
h
=
10
give a realistic bound on the error
−1
Solution: This is straightforward application of the formula for the error:
Z b
b − a 2 00
h f (ξ).
f (x)dx − T (f, h) =
(2)
E=
12
a
The bound of the second derivative is 1. Therefore the final result will be:
10−4
3 2
h ×1=
|E| ≤
12
4
Problem 5. By the Romberg algorithm, approximate
Z 2
4
dx
1
+
x2
0
by evaluating R(1, 1).
4
24
1
= 4.8
=
R(0, 0) = (2 − 0) 4 +
2
1 + 22
5
According to (1) page 211,
Solution:
1
a+b
1 2
1
4
2
1
R(0, 0) + (b − a)f (
) = × 5 + (2)
= 5 = 4.4
2
2
2
2 4
2
1+1
2
Using the extrapolation formula (2) page 211, we have
R(1, 0) =
1
4 2
1 2
6
4
R(1, 0) − R(0, 0) = × 5 − × 5 = 15 = 4.267
3
3
3 2
3 4
4
Problem 6. Show that the system of equations
R(1, 1) =
x1 + 4x2 + αx3
=
6
2x1 − x2 + 2αx3
αx1 + 3x2 + x3
=
=
3
5,
possesses a unique solution when α = 0, no solution when α = −1, and infinitely
many solutions when α = 1. Also investigate the homogeneous case when the
right-hand side is replaced by 00 s.
Solution: After one step of Naive Gauss elimination we obtain the following
equivalent system:
x1 + 4x2 + αx3
0x1 − 9x2 + 0x3
=
=
6
−9
0x1 + (3 − 4α)x2 + (1 − α2 )x3
=
5 − 6α
From the second equation we have x2 = 1 and putting x2 = 1 in the first and the
third equation we obtain
x1 + αx3
=
2
(1 − α )x3
=
2(1 − α)
2
Now,
for α = 0 : x1 = 2, x2 = 1, x3 = 2.
3
for α = −1 : no solutions (0x3 = 4).
for α = 1 : infinite number of solutions (0x3 = 0).
The homogeneous case:
From the second equations we get x2 = 0 and putting x2 = 0 in the first and the
third equation we obtain
x1 + αx3
(1 − α2 )x3
=
=
0
0
for α = 0 : x1 = x2 = x3 = 0
for α = −1 :infinite number of solutions (0x3 = 0
for α = 1 : infinite number of solutions (0x3 = 0).
Problem 7. A Gaussian quadrature rule for the interval [−1, 1] can be used on
an interval [a, b] by applying a suitable linear transformation. Approximate:
Z 2
2
e−x dx
0
using the two-point Gaussian rule on [−1, 1] (i.e. n = 1) as follows:
Z 1
1
1
f (x)dx ≈ f (− √ ) + f ( √ )
3
3
−1
Solution: This is a straightforward application of the Gaussian rule after changing
the variable from [0, 2] to [−1, 1]. The change of variable is as follows: x = t + 1,
note that dt = dx. Then the integral takes the form:
Z 1
Z 2
2
2
1
1
e−x dx =
e−(t+1) dt ≈ exp(−(1 − √ )2 ) + exp(−(1 + √ )2 ).
(3)
3
3
0
−1
Problem 8. Construct a rule of the form
Z 1
1
1
f (x)dx ≈ αf (− ) + βf (0) + γf ( ),
2
2
−1
that is exact for all polynomials of degree 2.
Solution: We need only to make the rule exact for the basic polynomials 1, x
and x2 . Then it will be exact for all polynomials of degree ≤ 2 because every such
polynomial is represented as a sum of basic polynomials multiplied by constants (i.e.
every polynomial of degree ≤ 2 is a linear combination of the basic polynomials).
This means that for these three fixed particular polynomials (1, x and x2 ) we
need to determine α β and γ, such that ≈ becomes = in these three cases. This
gives us the following system of equations:
Z
1
1dx =
α+β+γ
xdx
−
−1
Z 1
Z
=
−1
1
x2 dx =
−1
γ
α
+ 0β +
2
2
γ
α
+ 0β +
4
4
Computing the integrals on the left hand side gives the following system of
equations for α, β and γ:
4
α+β+γ = 2
α γ
= 0
− +
2
2
2
α γ
+
=
.
4
4
3
Solving this system gives: α = γ = 4/3, β = −2/3.
Problem 9 How many storage locations are needed for a system of n linear
equations if the coefficient matrix has banded structure in which aij = 0 for |i−j| ≥
k + 1?
Solution: For k = 1 the matrix is a tridiagonal matrix. For k=2 the matrix
is a pentadiagonal matrix. For a general k a matrix with the above property is a
banded matrix with k super diagonals and k subdiagonals. Thus, the number of
storage locations is:
n + 2(n − 1) + 2(n − 2) + · · · 2(n − k) = n + 2kn − 2(1 + 2 + · · · + k) =
k(k + 1)
= n + 2kn − k(k + 1).
2
Problem 10 Using naive Gaussian elimination, factor the matrix A in the form
A = LU , where L is a unit lower triangular matrix and U is an upper triangular
matrix.
(a)






3 0 3
1
0 0
3 0 3
1 0 , U = 0 −1 3
A = 0 −1 3 Answer: L =  0
1 3 0
1/3 −3 1
0 0 8
n + 2kn − 2
(b)

1
0
A=
3
0


0 1/3 0
1 0
0 1
1
3 −1
 Answer: L = 
3 −3
−3 0
6
2
4 −6
0 2
0
0
1
−1/4


0
1
0
0
, U = 
0
0
1
0

0 1/3
0
1 3
−1 

0 8
3 
0 0 −13/4
Download