Obtaining a Numerical Quadrature Formula and
Using it to Find the Area under a
Curve
(also known as determining the definite
integral)
Design
and construct a computer program in one of the following
languages
(e.g., C, C++, C#, Java, Pascal, or Python).
Your program will use three different 5-point numerical
quadrature methods
(Closed Newton Cotes, Gaussian Quadrature,
and Lobatto Quadrature)
You
will employ each of these methods to solve each of the
following three problems to find the area under the
respective curves over the interval (-1, 1).
Be sure to follow the documentation and programming
style policies of the Computer Science Department.
See the following pdf for
more information on Numerical Quadrature:
https://sceweb.uhcl.edu/feagin/courses/quad.pdf
The following is a plot of the first function f(x) = 1 - sin(1 - x)
The
following is a plot of the second function f(x) =
sqrt(x + 1) + 1
The true area under the above curve is (to 20 digits) 3.8856180831641267317
The
following is a plot of the third function f(x) =
tanh(x+1)
The true area under the above curve is
(to 20 digits) 1.3250027473578644309
First, print out
the values of the weights and the nodes for each
quadrature formula,
Then for each function (or curve), print out your
approximation to the area under the curve,
the true value of the area, and the error in the
approximation for each of the three quadrature
formulae.
Write down (in your output file or in another file
submitted with your program) any conclusions that you can
make from these experiments.
Note: For
Lobatto quadrature, the nodes are x[1] = -1,
x[2] = -sqrt(3/7), x[3] = 0, x[4] =
sqrt(3/7), and x[5] = 1.
The weights are w[1] = 1/10, w[2] = 49/90, w[3] =
32/45, w[4] = 49/90, and w[5] = 1/10.
Note:
For
the 5-point Closed Newton-Cotes quadrature, the nodes
are x[1] = -1,
x[2] = -1/2,
x[3] = 0, x[4] = 1/2, and x[5] = 1 The weights are w[1] = 7/45,
w[2] = 32/45, w[3] = 12/45, w[4] = 32/45, and
w[5] = 7/45. The
5-point closed Newton-Cotes formula is also known as
Boole’s rule.