Mathematics 172 – Numerical Analysis II Selected Solutions – Midterm Exam

I. B) Recall that x_{1}, …, x_{n} are the roots of p_{n}(x), the nth degree polynomial in an or-

thogonal family on [a, b]. In part A, we have seen that the approximate quadrature rule:

(1)  ∫_{a}^{b} f(x) dx ≐ c_{1}f(x_{1}) + ⋯ + c_{n}f(x_{n})

where

c_{i} = ∫_{a}^{b} \frac{∏_{k≠i}(x − x_{k})}{∏_{k≠i}(x_{i} − x_{k})} dx

has degree of precision at least 2n−1. Now consider f(x) = (x−x_{1})^{2}(x−x_{2})^{2} ⋯ (x− x_{n})^{2}, a polynomial of degree 2n. Applying (1), we get:

∫_{a}^{b} f(x) dx ≐ c_{1}f(x_{1}) + ⋯ + c_{n}f(x_{n}) = 0

But on the other hand, f(x) is continuous everywhere and f(x) > 0 at all x ≠ x_{i}. Hence ∫_{a}^{b} f(x) dx > 0. This means that (1) is not exact for f(x). Hence, the degree of precision of (1) is exactly 2n − 1, not 2n or larger.

C) By the change of variables u = \frac{5}{3}x − \frac{4}{3}, or x = \frac{3}{5}u + \frac{4}{5}, dx = \frac{3}{5}du, we can map the interval [.2, 1.4] = [\frac{1}{5}, \frac{7}{5}] to the interval [−1, 1]. Hence

∫_{.2}^{1.4} e^{−x^{2}}dx = ∫_{−1}^{1} e^{−( \frac{3}{5} u+ \frac{4}{5} )^{2}} \frac{3}{5} dx
≐ (.6) · (.34785485 · e^{−(.6·(−.86113631)+.8)^{2}} + .65214515 · e^{−(.6·(−.33998104)+.8)^{2}}
+ .65214515 · e^{−(.6·(.33998104)+.8)^{2}} + .34785485 · e^{−(.6·(.86113631)+.8)^{2}})
≐ .6465787

II. A) Euler’s Method – with 4 steps, h = .1:

\begin{aligned}w_{0} & = 2 \\ w_{1} & = 2 + f(0, 2)h = 2 + \frac{1}{2}(.1) = 2.05 \\ w_{2} & = 2.05 + f(.1, 2.05)h = 2.05 + \frac{1}{2.15}(.1) ≐ 2.0965116 \\ w_{3} & = 2.0965116 + f(.2, 2.0965116)h = 2.0965116 + \frac{1}{2.2965116}(.1) ≐ 2.1400559 \\ w_{4} & = 2.1400559 + f(.3, 2.1400559)h = 2.1400559 + \frac{1}{2.4400559}(.1) ≐ 2.1810386 \end{aligned}

B) Runge-Kutta Method – with 1 step, h = .4:

\begin{aligned}m_{1} & = f(0, 2) = .5 \\ m_{2} & = f(0 + \frac{h}{2}, 2 + \frac{m_{1}h}{2}) = f(.2, 2.1) = .4347826 \\ m_{3} & = f(0 + \frac{h}{2}, 2 + \frac{m_{2}h}{2}) = .4372624 \\ m_{4} & = f(0 + h, 2 + m_{3}h) = .3883639 \\ w_{1} & = w_{0} + (m_{1} + 2m_{2} + 2m_{3} + m_{4})h/6 = 2.1754969 \end{aligned}

C) If we apply one step of the Runge-Kutta method to an equation y′ = g(t) where the right hand side does not depend on y, then we get

m_{1} = g(t_{0})
m_{2} = g(t_{0} + \frac{h}{2})
m_{3} = g(t_{0} + \frac{h}{2})
m_{4} = g(t_{0} + h)
w_{1} = \frac{h}{6}(g(t_{0}) + 2g(t_{0} + \frac{h}{2}) + 2g(t_{0} + \frac{h}{2}) + g(t_{0} + h))

= \frac{h}{6}(g(t_{0}) + 4g(t_{0} + \frac{h}{2}) + g(t_{0} + h))

which is equivalent to the basic Simpson’s Rule. (Note: In the formula for Simpson’s Rule, we usually call one half of the length of the interval of integration h rather than letting h be the whole length as here. Hence the factor of \frac{h}{6} rather than \frac{h}{3}!)