Programming Assignment One

Your work should be presented in the form of a typed report using clear and properly punctuated English. Where appropriate include full program listings and output. If you choose to work in a group of two, please turn in independently prepared reports.


\def\R{{\bf R}}
\hangindent\parindent
\item{1a.}  Given $x\in\R$ let $x^*$ denote the
floating point approximation of $x$.
Write a program 
to find the greatest $\delta_1$ such that
$$
	(x^*+\delta_1)^*=x^*.$$
You may use the bisection method
with initial interval of $[0,x^*]$.
Run your program 
for the values of $x^*$ given in 
the file{\tt\ file01.dat }using single 
precision floating point
and again using double precision.
\bigskip
\hangindent\parindent
\item{b.}  For $x\in\R$ fixed define
$$
	\delta_2=\min\big\{\,\delta:(x^*+\delta)^*=x^*\,\big\}.$$
Write a program to determine whether $\delta_1=-\delta_2$.
What happens theoretically when chopping
is used for $x^*$?  How about when rounding is used?
\bigskip
\hangindent\parindent
\item{c.}  Let $J$ be a bounded subset of $\R$.
Define $J^*=\{\,x^*:x\in J\,\}$
and $I=\{\,x: x^*\in J^*\,\}$.
The maximum
relative error
$$
	\epsilon=\max_{x\in I}{|x-x^*|\over |x|}
	\ge \max_{x\in I}{|x-x^*|\over |x^*|+|x-x^*|}
	= \max_{x^*\in J^*}{\delta\over |x^*|+\delta}
$$
where $\delta=\max\{\,\delta_1,-\delta_2\,\}$.
Since relative error is bounded by $5\times 10^{-n}$
where $n$ is the number of significant digits, then
$$
	n\le \log_{10}\bigg\{
		5\min_{x^*\in J^*}\Big( {|x^*|+\delta\over\delta}\Big)
		\bigg\}.
$$
Write a program to compute this upper bound for $n$
using both single and double precision floating point.
Take the values of $x^*$ given in{\tt\ file01.dat }as the set $J^*$.


\hangindent\parindent
\item{2a.}  Consider the quadratic equation
$$
	ax^2+bx+c=0.$$
Write a program to solve this equation using the quadratic formula
$$
	x={-b\pm\sqrt{b^2-4ac}\over 2a}$$
and compute the residual $r(x)=ax^2+bx+c$ for each solution.
Run your program for the values of $a$, $b$ and $c$ given in
the file{\tt\ file02.dat}.
\bigskip
\hangindent\parindent
\item{b.}  An alternative way of writing the quadratic formula is
$$
	x={2c\over -b \mp\sqrt{b^2-4ac}}$$
Write a program using single precision floating point to compare 
the residuals of the solutions obtained via
this formula with the previous one.
Determine when each formula
should be used and explain your conclusions theoretically.


Last updated: Mon Jan 22 12:30:01 PST 2001