\documentstyle[12pt]{article}
\textwidth 16cm
\textheight 23cm
\topmargin 0cm
\evensidemargin 0cm
\oddsidemargin 0cm
\parindent=0pt
\parskip=10pt
\begin{document}


\begin{center}
\Large \bf
Numerieke methoden in de natuurwetenschappen \\
\large 
\end{center}
\vspace{0.4cm}
\noindent 
{\bf Ex.~2: Least square fitting , application to numerical differentiation }\\
Only points 2.a, 2.b, 2.c are compulsory.

\begin{description}
\item[2.a]
Consider the function $f(x)=x  e^x$. Obtain approximations to its first 
derivative for $x=2$ by use of the forward, backward and central difference
formulae for $N$ values (you choose $N$, e.g. 20) of the step size $h$ from $h$=1. to $h$=0.05. 
To visualize how the approximations
improve as a function of $h$, plot the error (we know the analytical solution)
or the relative error $(f_{appr}^{'}(x) -f_{exac}^{'}(x))/f_{exac}^{'}(x)$
as a function of $h$. 
Use logarithmic plots to show that the order of the error is different for 
forward/backward  and for central difference.
\item[2.b] Make a subroutine to make a least square fitting of a series 
of $N$ points 
to a straight line $a_1x+a_0$ to be used to answer the next point 2.c. 
Fortran90 is particularly suited to calculate 
the quantities of the type $\Sigma_i x_i$ appearing in the expression of $a_0$ 
and $a_1$. 
\item[2.c] use the least square fit subroutine to verify the order of the error
and the value of the coefficient multiplying $h^n$.
\item[2.d] extend the above subroutine to make a fit to a parabola 
$a_2x^2+a_1x+a_0$. 
\item[2.e] Study the effect of rounding errors for $h \rightarrow 0$. Define 
all quantities as real*4, which should give 6 digits precision.

\end{description}
\end{document}


