
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An assignment for the cmsi 186: programming laboratory course, focusing on riemann integration. Students are required to write a class called math.riemann that estimates the area under a user-given curve using the riemann integration technique. The curve can be a polynomial or one of three other functions. The assignment involves writing error messages, creating a table of estimates, and providing examples of function usage.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!
Spring 2008
With this assignment, we move from arithmetic to calculus — specifically, Riemann integration, a technique for estimating the area under a curve.
Write a class called math.Riemann that estimates the area under a curve for a user-given range, using the algorithm described in class. The curve can be one of a “function library” which you will provide; at a minimum, your program should support polyno- mials of arbitrary degree, plus at least three other functions (examples/ideas on the right). math.Riemann shall accept three sets of arguments, identified by the order in which they are given:
- The first argument is a name that uniquely identi- fies the function to use. - Zero or more arguments after the function name supply any additional information needed by the function (and they thus depend on the function). - The last two arguments of the command indicate the range over which the area over the function’s curve is to be estimated. The range may be given with either the upper or lower bound first. As always, math.Riemann should display a helpful error message if the given arguments are somehow invalid (e.g., unsupported function names, incorrect/missing additional information, non- numeric arguments, etc.). The output of math.Riemann shall be a table show- ing one line for each iteration/refinement of your estimate, starting with a single rectangle (i.e., deltaX = upperBound – lowerBound ) and continuing until the difference between the previous and succeeding estimates falls within ±0.01% of each other, after which the program should stop. The table should include columns for the iteration number, deltaX , the estimated area, and the % difference from the previous estimate. When invoked with --help as the first argument (i.e., java math.Riemann --help ), the program should dis- play a message describing how it should be used, including a complete list of the functions that it supports, stating the names to use and the addi- tional information that they require.
The following examples illustrate a number of pos- sibilities which you may implement.