Problem Set 8

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

D.

Schwendeman
Numerical Computing

Problem Set 8

Due:
Monday, 4/21/14

1. Find the coefficients of the quadrature using Lagrange basis and consider
Z

3h

f (x)dx = 1 f (0) + 2 f (h) + 3 f (3h) + E


0

(a) Find the interpolating polynomial.


It is straight forward to write down the Lagrange interpolation for function f (x) that
fits data (0, f (0)), (h, f (h)), (3h, f (3h)).
1 (x) =

(xh)(x3h)
(0h)(03h)

(xh)(x3h)
3h2

2 (x) =

(x0)(x3h)
(h0)(h3h)

x(x3h)
2h2

3 (x) =

(x0)(xh)
(3h0)(3hh)

x(xh)
6h2

f(x) = f (0)1 (x) + f (h)2 (x) + f (3h)3 (x)


(b) Integrate the interpolation polynomial to get the coefficients.
Careful calculations would yield the following:
R 3h
1 = 0 1 (x)dx = 0
R 3h
2 = 0 2 (x)dx = 49 h
R 3h
3 = 0 3 (x)dx = 34 h
2. Consider the following
Z

3h

f (x)dx = 1 f (0) + 2 f (2h) + E


0

(a) Find the coefficients 1 2 such that the quadrature is exact for zeroth and first order
polynomial.
It is not hard to come up with the following:

1 + 2 = 3h,
01 + 2h2 =

forf (x) = 1
9h2
2

, forf (x) = x

(b) Find the positive integer p and constant C.


It is again not hard to come up with the following:

E = 9h3 4h2 = 0,

81 4 9
9
E = h h8h3 = h4

4
4
4

243
9
63

5
4
E =
h h16h = h5 ,
5
4
5

for f (x) = x2
for f (x) = x3
for f (x) = x4

From the above calculation we can see that E = 0 for f (x) = 1, x, x2 , and therefore
p = 2.
3
5
4 000
000
Also, when f (x) = x3 E = 63
5 h = Ch f (x) and f (x) = 6 C = 8
3. Text exercises 4 and 5, page 278
We shall combine the two questions in each case.
Note that for question 4, we shall use the formula
b

f (x)dx =

f(
1

(b a)t + b + a b a
)
dt
2
2

And for the Gaussian Quadrature using three nodes, we shall use the formula, for the
converted integral
Z
1

f (x)dx 1 f (x1 ) + 2 f (x2 ) + 3 f (x3 ),


1

where 1 = 95 , 2 = 0, 3 =
a

R4

R1

R1

R3

x
dx
x2 +9

x3
0 x2 +1 dx

0
1

xex dx =

R1

5
9

q
q
and x1 = 35 , x2 = 0, x3 = 35 .

4t+4
dt
4t2 +8t+13

t3 +3t2 +3t+1
1 4(t2 +2t+5) dt

R1

R1
1

x2 ln xdx =

t+1 t+1
2 dt
4 e

R1

1 (t

1.999825193

0.153406998

0.999994630

+ 2)2 ln t + 2dt 6.9986778

4. Estimate the subintervals needed so that the absolute error in the numerical quadrature
is less than 104 .
Note that
f (x) =

x
1
2
f 0 (x) =
f 00 (x) =
2
x+1
(x + 1)
(x + 1)3

E=|

(2 ( 12 ) 2
(b a) 2 00
2
h f ()| = |
h
|
24
24
( + 1)3

Note that E attains maximum at = 12 , and therefore,


E=|

5
2

24

h2

5
2
4
3
2
|
<
10

h
<
7.746

10

m
=
> 322.75 m = 323
h
( 12 + 1)3

5. Coding forSimpsons Rule.


The code is as follows

The exact solution is 0.27320770837919 and one can verify that our code works pretty
well for all three values of m.

You might also like