## HomeWork ONE

1. 1.8

a , where machine epsilon , is the base of the system and is lowest possible value of exponent.

b with being maximum value of exponent,

c

2. 1.8

a

Here we divided numerator and denominator by to avoid overflow.

b

Here we divided numerator and denominator by to avoid overflow.

c

d

Here we divided numerator and denominator by to avoid overflow.

e

 x = [1:1000]; y = (1+log(1+exp(-x))); sum(y)


f

 (37)

g

Calculate

Since , and , and , and using the fact that even number raised to the power of 10 is even, and odd number raised to teh power of 10 is odd, we obtain

3. 1.20 Homer states

Is it true?

a If Horner right,

should be 0, yet Matlab returns

b If Horner is right,

should be zero, yet Matlab returns .

c If Horner is right,

should be , yet Matlab returns

d If Horner is right,

should be zero, yet Matlab returns

e The product of two digit numbers may have up to digits. Therefore may have up to 48 digits, which is longer then Matlab's 16 digits. Therefore we can not use doubles in Matlab to either prove or disprove this conjecture.

Note that can be explicitly calculated on a computer with inifinite precision (check out vpa command in matlab), because it is an integer. Using the “sym” command, or Mathematica allows us to get the answer:

4. 1.24 Here we deal with

for small values of . Expanding we obtain

This is very close to the example we studied in class, so all information can be taken directly from lecture notes

5. 1.27

(a) For some large integer value of the increment will be too small to change the sum. In other words the increment will be less than machine precision over two. At that time values of and will be the same, and the sum will stop changing.

(b)

s=1;ss=0;k=1;while s~=ss k=k+1;ss=s;s=s+1/k^2;end;s

returns the value of

This is 16 digits. To round it to 12 digits, use round(ans,12), which returns

which is the 12 digits of the answer.

Since the answer is between and , the floating point numbers are machine epsilon apart. Therefore the algorith stops when , or at the integer that is closest to .

Comparing the result of the code to we see the error of about , so there are correct 8 digits.

(c) In the previous example we have seen that making calculations that are accurate to 16 digits, we get an answer that is correct to 8 digits.

One way to increase accuracy is to use the “vpa” command as follows:

s=1;ss=0;k=1;while s~=ss k=k+1;ss=s;s=vpa(s+1/k^2,20);end;s


Alternatively, here is one more idea to check out. If the result is correct to digits, it means that the effective epsilon of the result is . Therefore the computer has obtained the correct result for

 (38)

We than may compute a separate sum for between the value in (40) and the new value of

 (39)

6. (a)

The number of flops to compute is . The proposed algorithm will use flops for even and for odd .

(b)

Since computer operates in binaries, the proposed formula for takes advantage of binary representation. The trick is to decompose the in the sum of powers of two, and calculate each power of two by using the shortcut of (a), and then add the result.

The proposed algorithm will use 11 flops instead of 28.

(c)

Number of flops here is 14. Since 100 is even, the algorithm in (a) will use flop.

(d)

Using the Table 1.3 we compute the total flops to be . This number is independent, so it works faster for large and significantly faster for very large .

Old Problems

a

Use Taylorâ€™s theorem to show that

 (40)

Denoting and using

we obtain

Since , we obtain (41).

b Why

 (41)

This is due to “rounding to nearest”, is rounded to , and is either or . In other words, the distance between a number and its floating point representation is less than half a distance between nearest two floaing point numbers.

c

Since and , we get . More precisely, . Use this together with (41) and (42) to get

 (42)

d This question implies that

 (43)

If this property is not satisfied, then the result can not be obtained.

To obtain this result, write

then use (44).

Author's note: in (d) the right hand side shoule be and in (e) the right hand side should be .

e The RHS can be rewritten as

Now use to obtain the desired result.

f Using we get . Picture shows that accuracy is obtained at , i.e. . In other words the estimate is optimistic.