Homework4, p. 42 #1, 3, 5; p. 48, 1bcd, 2, 5, 6

Computer problem #1, p. 43

tab=Flatten[Table[s 4^e,{e,-4,0},{s,16,63}]] 
Length[tab]
{Min[tab],Max[tab]}
ListPlot[Log[tab]]

p. 42, #1

problemNo1P42[x_]:=Floor[Log[10,Abs[x]]]
problemNo1P42[70083.2]
problemNo1P42[-70083.5]
problemNo1P42[.700836]

p. 42, #3: We can ask Mathematica to give us a picture of these numbers in base 2, but it doesn’t PROVE which ones are actually non-terminating. We can prove that 1/5 is non-terminating, however, so that if we multiply a non-terminating by a terminating we get a non-terminating -- barring cancellation.  We can also reduce our problem to considering only the numbers from .01 to .25 (how?).

Table[BaseForm[.01*i,2],{i,1,25,1}]

I can prove that 1/25 doesn’t terminate, as follows:

BaseForm[.04,2]
1/2^5(1+
1/2^2(1+
1/2^4(1+
1/2(1+
1/2(1+
1/2(1+
1/2^2(1+
1/2^2(1+
1/2(1+
1/2(1+
1/25))))))))))

p. 42, #5: People took this several ways -- the smallest integer that can be represented in IEEE single; the smallest value the format can store; or the smallest integer that can can’t be represented exactly (without error). The authors meant the latter. The point is this: when are we making errors, and when aren’t we? We need to know.

1+2^127*Sum[1/2^i,{i,0,23}](* can't be represented at all, as IEEE single -- overflows *)
(1+1/2^24)*2^24 (* requires too many binary digits in the significand or mantissa *)
BaseForm[16777216,2] (* 2^24 *)
BaseForm[16777217,2] (* 2^24 + 1 *)

p. 48, #1

N[Round[-12.345,10^-2]]
N[Round[12354,10^1]]
N[Round[12.34500001,10^-2]]

p. 48, #2