CS3911 Reading List: Week 3

Textbook Material
Read the following materials
  • Section 1.2
  • The Accuracy slides is in the common directory: Accuracy.pdf.

Programming Material
Simple Programming Exercises Do these problems as soon as possible.
  • We discussed the way of using infinite series to compute EXP(X). See this page as well. Re-implement this program in which you compute each term with X**n/n!, where n! is the factorial of n. Compile this inefficient version and the version discussed in class. Then, run both programs with larger numbers (e.g., 10, 15, 30, etc) as input. What are the results of both programs? What trouble or troubles you will get?
  • The sine function also has an infinite series representation as follows:

    Using the more efficient EXP(X) program as an example, write a program that implements the sine function with the above infinite series. Test your program with small numbers (e.g., 3.14, -6, 10) as well as large numbers (e.g., 5000, 10000, 1234567, -98765, 9999999, -9998887). What are the results? Anything wrong? Keep in mind that the function value of sine is in [-1,1].

  • First note that sin(-x) = -sin(x). Thus, if x is negative, the result is the same as -sin(-x)! In the following, we shall assume x being non-negative.

    Second, since the sine function has a period of 2PI, where PI = 3.1415926....., we may rewrite this program to take advantage of this fact. More precisely, y = MOD (x, 2*PI) yields the same result as x does. In other words, we have sin(x) = sin(y) = sin(MOD (x, 2*PI)). In this way, a large x is reduced to a small number in [0,2*PI).

    We may go further. Since sin(x + PI) = -sin(x), x can be reduced to [0,PI). In the last step, the range of x has been reduced to [0,2*PI). If x >= PI, we have sin(x) = -sin(x - PI), where x - PI is in [0,PI), a small number between 0 and 3.14159... Note that you can obtain PI easily and accurately with cos-1(-1).

    Now, rewrite your sine program in which the input x is made non-negative and reduced to the range [0,PI). Then, use the same set of large numbers to testing this new version. Would this new version be better in terms of accuracy and trouble free?

Do the following problems
From our text
  • Problems P1.16 to P.1.20
Additional Practice Problems Do these problems as our class proceeds in this week.
  1. How would you evaluate the following expression for large x without losing significant digits? Compare your method with direct evaluation on a single precision (i.e. 6- to 7- digit) calculator for = 1088.03.

  2. Evaluate the following expression for large x and for x near zero.

  3. Evaluate the following expression when x is near zero.

  4. Show that if a is small compared to b

    can be re-written as follows:

    where g = (a/b)2. Now, will you be able to use this new version to solve ax2 + bx + c = 0 when b is much larger than a and c.

Food for Thought
This is an interesting but somewhat more difficult problem. Do it whenever it is possible (before Exam 1 will take place).

Let us consider a dramatic floating-point computation experiment.

The above shows a pentagon ABCDE. If we draw the five diagonals of this pentagon, we have a smaller pentagon inside the pentagon ABCDE. This smaller pentagon has its vertices in white color. Let us call the original pentagon P and the smaller pentagon in(P), because it is the result of "going" inside of pentagon P.

If we extend the sides of the given pentagon, they will intersect in five points, which define a new pentagon outside of the pentagon P. We call this new "outside" pentagon out(P), because it lies outside of pentagon P.

From this construction, we know that going out from in(P) should be P. Similarly, going in from out(P) should also be P. More precisely, we have P = out(in(P)) and P = in(out(P)). Let ink(P) denote executing the "going in" operation k times, and let outk(P) denote executing the "going out" operation k times. Then, the following should hold

P = outk(ink(P)) = ink(outk(P))

This means that going in k times followed by going out k times should yield pentagon P. Similarly, going out k times followed by going in k times should also yield pentagon P.

Now consider the following strange pentagon:

The vertices are as follows, where p is a very small value (e.g., 0.00005).

Vertex x y
A 0 1
B 0 0
C 1 0
D 1 + p 1
E 1 1 + p

Would the following operations still hold for very small p? What would be the main reason or reasons that can make the following false?

P = outk(ink(P)) = ink(outk(P))

You do not have to turn in your paper. What I really expect you to do is using these problems to gauge your understanding of the subject. So, do the problems after finish reading the above sections.