CMSI 186 - Problem Set #4
Riemann Integration
Due Tuesday, March 24
Overview
For this assignment you will make a program for computing integrals using Riemann integration, as discussed in class.
Ground Rules
- Make Riemann.java, which can integrate various functions that are "built in" to the program. Here are some examples of how it might be invoked:
- java Riemann sin -0.27 +3.55 [integrates the sin function from x = -0.27 to x = +3.55]
- java Riemann poly 1.0 -2.1 3.2 -1.0 +5.0 [integrates the polynomial 1.0 - 2.1 x + 3.2 x ^ 2 from x = -1.0 to x = 5.0]
- java Riemann log 1.1 2.3 [integrates the (natural) log function from x = 1.1 to x = 2.3]
- java Riemann exp 2.0 3.5 [integrates the function e ^ x from x = 2.0 to x = 3.5]
- java Riemann sqrt 1.0 2.0 [integrates the function sqrt(x) from x = 1.0 to x = 2.0]
- In general, the program will be invoked like this:
java Riemann functionName additionalDescriptors lowerBound upperBound
- Note that some functions (e.g., polynomials) need the additional descriptors (for their coefficients), while other functions (like sin and sqrt) do not.
- If the program is invoked incorrectly, it should output a clear, detailed message that explains precisely how to use it.
- As always, a comprehensive set of tests should be written before you start coding the other key method(s). Since you need method main() to run your program, put the tests in another method, e.g., private static void runMyTests(), and design your program so that
runs the tests.
- Try to implement as many interesting functions as possible, including:
- polynomials of arbitrary degree (you must start with these);
- trig functions like sin, cos, tan;
- log and exponentiation functions;
- some composite functions, e.g., sqrt ( 1 + cos(x) ) or cos(x)cos(2x). Make sure that your lab report clearly explains how I am supposed to invoke these.
Revised: March 5, 2009