CPSC/MATH 402 Assignment #2

Due _________________________________________

Computer problem #1.10 on page 46 of the text asks you to write a "robust" program for solving a quadratic equation accurately. This means that your program should check for special cases (a = 0, for example), work for complex roots (a negative discriminant), and in other cases, it should choose the most accurate method of computing the roots (to avoid overflow, unnecessary underflow, and cancellation error). For this assignment, write the program as described in the text but so you can see that the way you implement the quadratic formula really matters also compute and print the roots you would get using both the standard formula and the alternative formula. So, your program should do the following:

Test your program thoroughly. The book gives some test values for you to use (by the way, you can input values such as 5 times 10154 using exponential notation -- 5e154).

Hand In