\documentclass[12pt]{article}

\usepackage{verbatim,moreverb}
\def\listingoffset{1em}
\def\listinglabel#1{\llap{\tiny\it\the#1}\hskip\listingoffset\relax}
\def\mylisting#1{{\fontsize{10}{11}\selectfont\listinginput[1]{1}{#1}}}
\def\myoutput#1{{\fontsize{10}{11}\selectfont\verbatimtabinput{#1}}}

\begin{document}
\noindent
Use Newton's method to calculate $\sqrt{2}$.
Define $f(x)=x^2-2$.
As shown in class, 
for any $x_0\in[1,\infty)$ the fixed point iteration
$$x_{n+1}=\phi(x_n)\quad\hbox{where}\quad
	\phi(x)=x-{f(x)\over f'(x)}\quad\hbox{and}\quad
	f'(x)=2x
$$
yields a sequence such that $x_n\to\sqrt 2$ as $n\to\infty$.
The program{\tt\ newton.c }computes the first 10 iteratates
of this sequence given $x_0=1$.

\mylisting{newton.c}

\noindent The output is

\myoutput{newton.out}

\noindent
which implies $\sqrt 2\approx 1.41421356237310$.

\end{document}
