437/537 Homework #1

due at the beginning of class, Thursday, Sep 6, 2006

Problems are from Sauer's book unless problem number starts with "X".

0.0

X0. [10 points] Using the examples shown in class on Aug 28 as models, write an Octave/Matlab program to find an approximate solution to the equation cos(x) = x by the method of repeatedly replacing x by cos(x), starting with x = 0. Repeat enough times that the none of the digits shown changes from one step to the next.
Turn in hard copy of your ".m" file and of the output it generates. Also email your ".m" file to me with the Subject line "437_537_hw1". Name your file hw1_437_537_yourlastname.m (where "yourlastname" is your last name all in lower-case with no spaces).

Here are a few language features you might find useful:

	ofile = fopen("foo.dat","w");
	i=99; x=1/3;
	fprintf(ofile,'%8i %23.15f\n',i,x);
	fclose(ofile);

	% Anything on a line after a "%" is ignored by the interpreter
	while(true)	    % loop forever
		% do some computation setting a and/or b
		if a == b 
			break;
		end
	end

0.2

4. (f) [3 points] (Conversion from binary to base-10.)

0.3

X1. A floating point system similar to the IEEE system has: a sign bit, then a 2-bit exponent biased by 1, then a 2-bit mantissa. Assuming all bit-codes are used for numbers, and that the all-zeros code is used for 0. (If you know what denormalization means, assume it is NOT used.)
(a) [5 points] List all the non-negative machine numbers in this system. For each, give the bit-code, and the number it represents - in binary fixed-point form (e.g. 110.0101). Use this sheet for your answers.
(b) [1 point] The "machine epsilon" or &epsilonmach, defined to be the difference between 1 and the next larger machine number, is a very important characteristic of a floating point number system like this. What is &epsilonmach for this system?
(c) [1 point] How big is the "hole at zero" for this system, i.e. the gap between the smallest positive number and 0?

2 (a),(b) [3 points each] (Conversion from base-10 to binary, expression as 52-bit-mantissa floating point.) Extra: Also write in IEEE format, both binary and hex. (You can check your answers using Octave.)

7 (a) [2 points] (Explain why (7/3-4/3)-1 gives epsilon_mach.)

0.5

X2. (6 points) Use Taylor's theorem to determine (approximately) how far from 0 x can be while the approximation a(x) = - x^3/3! + x^5/5! to f(x) = sin(x)-x is accurate to 3 decimal digits (i.e. relative error < 0.5e-3).