Day 2: Numerical Integration
Exercise
Write a Java program to compute the definite integral of a given function using numerical methods.
Introduction
For those unfamiliar with calculus and, specifically, integrals, all you need to know for this exercise is that the definite integral of a function determines the area under that function's curve. Numerical integration allows for the approximation of this area without determining the indefinite integral (or antiderivative) of the function. An antiderivative is another function which is obtained by manipulating the original function in a specific way.
Algorithm
- Choose a method of numerical integration to implement:
- Implement the core functionality using a text-based interface for I/O.
- Build a GUI to wrap your implementation.
Resources
- Main.java (text-based interface)
- Integral (Wikipedia)
- Numerical Integration (Wikipedia)
Hints
- Use postfix expressions instead of infix to keep your implementation simple.
- Simpson's rule is the most straight forward approximation as it does not require summation.
- The Trapezoidal rule and Composite Simpson's rule both require using one or more for loops.