Docsity

Math 151A HW #6: Composite Midpoint Rule, Gaussian Quadrature, Gaussian Elimination, Assignments of Mathematics

Toggle sidebar
bg1
Math 151A Homework #6 – due Wednesday 12/06, in class
Show all your work!
1. Composite midpoint rule
Derive the expression for the composite midpoint rule (theorem 4.6). The derivation is similar to
the derivation of the composite Simpson’s rule, which we did in class.
Answer:
Let f∈C2[a, b], neven, 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):
Zb
a
f(x)dx =
n/2
X
j=0 Zx2j+1
x2j−1
f(x)dx
=
n/2
X
j=0h2hf (x2j) + h3
3f00(ξj)ix2j−1< ξj< x2j+1
= 2h
n/2
X
j=0
f(x2j) + h3
3
n/2
X
j=0
f00(ξj)
Since f∈C2[a, b], the Extreme Value Theorem implies that f00 assumes its maximum and
mininmum value in [a,b]. Since
min
x∈[a,b]f00(x)≤f00(ξj)≤max
x∈[a,b]f00(x)
we have
n
2+ 1min
x∈[a,b]f00(x)≤
n/2
X
j=0
f00(ξj)≤n
2+ 1max
x∈[a,b]f00(x)
and
min
x∈[a,b]f00(x)≤2
n+ 2
n/2
X
j=0
f00(ξj)≤max
x∈[a,b]f00(x)
By the Intermediate Value Theorem, we see that there exists a µ∈(a, b) such that
f00(µ) = 2
n+ 2
n/2
X
j=1
f00(ξj)
Thus we get
Zb
a
f(x)dx = 2h
n/2
X
j=0
f(x2j) + (n+ 2)h3
6f00(µ)
= 2h
n/2
X
j=0
f(x2j) + (n+ 2)h2(b−a)
6(n+ 2) f00(µ)
= 2h
n/2
X
j=0
f(x2j) + (b−a)
6h2f00(µ)
which is the Composite Midpoint rule.
pf3
pf4

Partial preview of the text

Download Math 151A HW #6: Composite Midpoint Rule, Gaussian Quadrature, Gaussian Elimination and more Assignments Mathematics in PDF only on Docsity!

Math 151A Homework #6 – due Wednesday 12/06, in class

Show all your work!

  1. Composite midpoint rule Derive the expression for the composite midpoint rule (theorem 4.6). The derivation is similar to the derivation of the composite Simpson’s rule, which we did in class.

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. Gaussian quadrature According to theorem 4.7, we can approximate the integral of a function as ∫ (^1)

− 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

∏^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.