\magnification=\magstep1
\overfullrule = 0pt
\centerline{Mathematics 172 -- Numerical Analysis II}
\centerline{Selected Solutions -- Midterm Exam}
\bigskip
\noindent
I.
\item{B)}  Recall that $x_1, \ldots, x_n$ are the roots of $p_n(x)$,
the $n$th degree polynomial in an orthogonal family on $[a,b]$.  In part A, 
we have seen that the approximate quadrature rule:
$$\int_a^b f(x)\ dx \doteq c_1f(x_1) + \cdots + c_n f(x_n)\leqno(1)$$
where
$$c_i = \int_a^b {\prod_{k\ne i} (x - x_k) \over 
\prod_{k \ne 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 \cdots (x - x_n)^2$, a 
polynomial of degree $2n$.  Applying (1), we get:
$$\int_a^b f(x)\ dx \doteq c_1f(x_1) + \cdots + c_n f(x_n) = 0$$
But on the other hand, $f(x)$ is continuous everywhere 
and $f(x) > 0$ at all $x \ne x_i$.  Hence
$\int_a^b f(x)\ dx > 0$.  This means that (1) is {\it not exact\/} for $f(x)$.
Hence, the degree of precision of (1) is exactly $2n - 1$, not $2n$ or 
larger.
\bigskip
\item{C)}  By the change of variables $u = {5\over 3}x - {4\over 3}$, 
or $x = {3\over 5} u + {4\over 5}$, $dx = {3\over 5} du$, 
we can map the interval
$[.2,1.4] = [{1\over 5}, {7\over 5}]$ to the interval $[-1,1]$.
Hence
$$\eqalign{
\int_{.2}^{1.4} e^{-x^2} dx 
&= \int_{-1}^1 e^{ -({3\over 5} u + {4\over 5})^2 } {3\over 5}\ dx\cr
&\doteq (.6)\cdot 
(.34785485\cdot e^{-(.6\cdot (-.86113631) + .8)^2} + 
.65214515 \cdot e^{-(.6\cdot (-.33998104) + .8)^2} \cr
&\quad  + .65214515 \cdot e^{-(.6\cdot (.33998104) + .8)^2} + 
       .34785485\cdot e^{-(.6\cdot (.86113631) + .8)^2} )\cr
&\doteq .6465787\cr }$$
\bigskip
\noindent
II.
\item{A)}  Euler's Method -- with $4$ steps, $h = .1$:
$$\eqalign{w_0 &= 2\cr
w_1 &= 2 + f(0,2) h = 2 + {1\over 2}(.1) = 2.05\cr
w_2 &= 2.05 + f(.1,2.05)h = 2.05 + {1\over 2.15}(.1) \doteq 2.0965116\cr
w_3 &= 2.0965116 + f(.2,2.0965116)h = 2.0965116 + {1\over 2.2965116}(.1) \doteq
       2.1400559\cr
w_4 &=  2.1400559 + f(.3,2.1400559)h = 2.1400559 + {1\over 2.4400559}(.1) \doteq
2.1810386\cr}$$
\item{B)}  Runge-Kutta Method -- with $1$ step, $h = .4$:
$$\eqalign{
m_1 &= f(0,2) = .5\cr
m_2 &= f(0 + {h\over 2}, 2 + {m_1 h\over 2}) = f(.2,2.1) = .4347826\cr
m_3 &= f(0 + {h\over 2}, 2 + {m_2 h\over 2}) = .4372624\cr
m_4 &= f(0 + h, 2 + m_3 h) = .3883639\cr
w_1 &= w_0 + (m_1 + 2 m_2 + 2 m_3 + m_4)h/6 = 2.1754969\cr}$$
\item{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
$$
\eqalign{
m_1 &= g(t_0) \cr
m_2 &= g(t_0 + {h\over 2})\cr
m_3 &= g(t_0 + {h\over 2})\cr
m_4 &= g(t_0 + h)\cr
w_1 &= {h\over 6}(g(t_0) + 2 g(t_0 + {h\over 2}) + 2 g(t_0 + {h\over 2}) + 
g(t_0 + h))\cr
&= {h\over 6}(g(t_0) + 4 g(t_0 + {h\over 2}) + g(t_0 + h))\cr}$$
which is equivalent to the basic {\it 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 ${h\over 6}$ rather than ${h\over 3}$!)

\bye