


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Math 151A Homework #6 – due Wednesday 12/06, in class
Show all your work!
Answer: Let f ∈ C^2 [a, b], n even, h = (b − a)/(n + 2) and xj = a + (j + 1)/h. Then we can apply the midpoint rule on each subinterval (see figure 4.9 in the book): ∫ (^) b
a
f (x)dx =
∑^ n/^2
j=
∫ (^) x 2 j+
x 2 j− 1
f (x)dx
∑^ n/^2
j=
2 hf (x 2 j ) + h^3 3
f ′′(ξj )
x 2 j− 1 < ξj < x 2 j+
= 2 h
∑^ n/^2
j=
f (x 2 j ) + h^3 3
∑^ n/^2
j=
f ′′(ξj )
Since f ∈ C^2 [a, b], the Extreme Value Theorem implies that f ′′^ assumes its maximum and mininmum value in [a, b]. Since min x∈[a,b] f ′′(x) ≤ f ′′(ξj ) ≤ max x∈[a,b] f ′′(x)
we have ( (^) n 2
min x∈[a,b]
f ′′(x) ≤
∑^ n/^2
j=
f ′′(ξj ) ≤
( (^) n 2
max x∈[a,b]
f ′′(x)
and
min x∈[a,b]
f ′′(x) ≤
n + 2
∑^ n/^2
j=
f ′′(ξj ) ≤ max x∈[a,b]
f ′′(x)
By the Intermediate Value Theorem, we see that there exists a μ ∈ (a, b) such that
f ′′(μ) =
n + 2
∑^ n/^2
j=
f ′′(ξj )
Thus we get ∫ (^) b
a
f (x)dx = 2 h
∑^ n/^2
j=
f (x 2 j ) + (n + 2)h^3 6 f ′′(μ)
= 2 h
∑^ n/^2
j=
f (x 2 j ) + (n + 2)h^2 (b − a) 6(n + 2)
f ′′(μ)
= 2 h
∑^ n/^2
j=
f (x 2 j ) +
(b − a) 6 h^2 f ′′(μ)
which is the Composite Midpoint rule.
− 1
f (x)dx ≈
∑^ n
i=
cif (xi)
where
ci =
− 1
∏^ n
j= j 6 =i
x − xj xi − xj
dx
and {xj } are the roots of the nth Legendre polynomial.
Show that for n = 1 this gives the midpoint rule ∫ (^) b
a
f (x)dx = (b − a)f
( (^) b + a 2
Answer: For n = 1 we have ∫ (^1)
− 1
f (x)dx ≈ c 1 f (x 1 )
where x 1 is the root of the first Legendre polynomial P 1 (x) = x (which is x 1 = 0), and c 1 is given by
c 1 =
− 1
j= j 6 =
x − xj xi − xj
dx =
− 1
dx = 2
This yields ∫ (^1)
− 1
f (x)dx ≈ 2 f (0)
To compute the integral ∫ (^) b
a
f (x)dx
we use the variable substitution u = 2(x − a)/(b − a) − 1, which means that
x = u b − a 2
b + a 2 and
dx = b − a 2
du
So then ∫ (^) b
a
f (x)dx = b − a 2
− 1
f
( (^) b − a 2 u + b + a 2
du
b − a 2 · 2 f
( (^) b − a 2
b + a 2
= (b − a)f
( (^) b + a 2
nrow(jmax) = temp; end
% Now do the actual elimination step for j = (i+1):(n) m(nrow(j),i) = A(nrow(j),i)/A(nrow(i),i); for k = (i+1):(n+1) A(nrow(j),k) = A(nrow(j),k) - m(nrow(j),i)*A(nrow(i),k); end
end end
% now backward substitution if A(nrow(n),n) == 0 printf("No unique solution exists.\n"); return; end x(n) = A(nrow(n),n+1)/A(nrow(n),n); for i = (n-1):-1: x(i) = A(nrow(i),n+1); for j = (i+1):n x(i) = x(i) - A(nrow(i),j)*x(j); end x(i) = x(i) / A(nrow(i),i); end x
And here is the output: octave:1> A = [3.03,-12.1,14,-119;-3.03,12.1,-7,120;6.11,-14.2,21,-139] A =
3.0300 -12.1000 14.0000 -119. -3.0300 12.1000 -7.0000 120. 6.1100 -14.2000 21.0000 -139.
octave:2> gepp x =
0.00000 10.00000 0.