Starting from:

$30

MA 3457 / CS 4033 HW #5

MA 3457 / CS 4033
HW #5
1. (6 points) Quadrature Rules
Determine constants a, b, c, d, and e that will produce a quadrature formula as follows that has degree
of precision 4. (i.e. exact for a polynomial of degree 4 with arbitrary coefficients)
Z 1
−1
f(x)dx = af(−1) + bf(0) + cf(1) + df0
(−1) + ef0
(1)
2. (14 points total) Composite Integration
Here, let’s define n as the number of intervals. Note that the number of nodes will depend on whether
you are using Trapezoid Rule (integrals with upper and lower bounds xj+1 and xj ) and Simpson’s Rule
(integrals with upper and lower bounds xj+2 and xj ). In terms of defining the appropriate h, be careful
as to whether you are using number of nodes or number of intervals.
(a) (8 points) Create function files for composite trapezoid and composite Simpson’s rules. The main
file should be able to call these functions that have an input including the function along with the
upper bound b, lower bound a and either n or h.
(b) (2 points) Approximate the following integrals:
Z 5
0
p
1 + x
2dx
Z π
0
(2 + cos(x) sin(3x))dx
Note that the exact value for the first integral is (5/2)√
26 − (1/2) ln (−5 + √
26) and the exact
value for the second is 2π.
(c) (4 points) Create Tables similar to those below describe error and convergence. Discuss the
behavior of the error with regards to varying the total number of intervals n or number of points
NT ot (or as h decreases by a factor of 2).
Ntot Trap Simp
10
20
40
80
160
NTot (trap error)/h
2
(Simp error)/h
4
10
20
40
80
160
1

More products