CSE 232 Spring 2012 Computer Project #4 -- Mathematical Functions Assignment Overview: This assignment focuses on the design, implementation and testing of C++ functions which support mathematical operations on floating point values. You will develop two C++ source code modules (a library module and a driver module), as described below. It is worth 40 points (4% of course grade) and must be completed no later than 11:59 PM on Thursday, February 9. Assignment Specifications: 1) The library module will consist of the following functions: double absolute( double X ); double modulo( double X, double Y ); double factorial( unsigned N ); double power( double X, unsigned N ); double sine( double X ); double cosine( double X ); Function "absolute" will return the absolute value of its argument. Function "modulo" will return the remainder of the division of X by Y. Function "factorial" will return the factorial of N. Function "power" will return the value of X raised to the Nth power. Function "sine" will return the sine of X, where X is measured in radians. Function "cosine" will return the cosine of X, where X is measured in radians. 2) The functions in the library module will not perform any operations on input or output streams. 3) The functions in the library module will include appropriate error processing. a) Function "modulo" will return the "double" value Not-A-Number for all error conditions. b) Functions "factorial" and "power" will return the "double" value Infinity for all error conditions. c) Functions "sine" and "cosine" will return the "double" value Not-A-Number for all error conditions. 4) The functions in the library module will not use the following mathematical functions (declared in "cmath"): "fabs", "fmod", "pow", "sin" and "cos". 5) Your computation of the sine and cosine will use the power series approximation method (described below). 6) The driver module will consist of function "main" and any auxiliary functions that directly support "main". The driver module will demonstrate that each function in the library module is implemented correctly. All output displayed by the driver module will be appropriately formatted and labeled. Your driver module will not be interactive. If your driver module accepts any input, you will supply that input in a text file named "proj04.tests". Assignment Deliverables: The deliverables for this assignment include the following files: proj04.makefile -- your makefile which produces "proj04" proj04.library.cpp -- your implementation of the library module proj04.driver.cpp -- your implementation of the driver module proj04.tests -- your test cases (if needed by your driver module) Be sure to use the specified file names, and to submit your files for grading via the "handin" program. Assignment Notes: 1) For your convenience, the following file is available: /user/cse232/Projects/project04.library.h That file contains the declarations for the functions which are part of the library module. Any source code file which uses the library module should contain the following preprocessor directive: #include "/user/cse232/Projects/project04.library.h" 2) One method for computing the sine of a value is to approximate the value using a power series. Using "!" to represent the factorial function: 3 5 7 9 sine(X) = X - (X / 3!) + (X / 5!) - (X / 7!) + (X / 9!) - .... An individual term in this power series can be expressed as: k 2k+1 (-1) X ----------- (2k+1)! where "k" represents the position in the power series (k = 0, 1, 2, ....). Similarly, the cosine of a value can be approximated using the following power series: 2 4 6 8 cosine(X) = 1 - (X / 2!) + (X / 4!) - (X / 6!) + (X / 8!) - .... Expand each power series approximation until you reach a term whose absolute value is less than a specified epsilon (which is defined to be 1.0e-8 for this project). That term should not be included in the approximate value of the power series.