Numerical integration of $\int_0^2 \frac{1}{x+4}dx.$ I have homework problem. Determine the number of intervals required to approximate 
$$\int_0^2 \frac{1}{x+4}dx$$ to within $10^{-5}$ and computer the approximation using (a) Trapezoidal rule, (b) Simpson's rule, (c) Gaussian quadrature rule. I think the phrase "within $10^{-5}$,"means that the error term. 
I know that the m-point Newton-Cotes rule is defined by $$Q_{NC(m)}=\int_a^b p_{m-1}(x)dx,$$ where $p_{m-1}$ interpolates the function on $[a,b].$ So when $m=2,$ we call $Q_{NC(2)}$ trapezoidal rule, ans $Q_{NC(3)}$ is simpson's rule.
Can anyone explain what are these three rules and how I can proceed?? And what does $m$ represent?? Is it I am kind of lost in this class.. ans the text book is really really bad that I have no idea what it talks about...
 A: yes, $10^{-5}$ is the error term. That is
$$
|I-I^{\prime}|
$$ where $I$ is the exact integrand and  $I^{\prime}$ is an approximation. I will summarize the methods as follows
Trapezoid is given by $$\int_{a}^{b}f(x)\,dx=(b-a)\frac{f(a)+f(b)}{2}$$ It approximates the integral by approximating the area under the curve like a trapezoid.
Simpson is given by $$\int_{a}^{b}f(x)\,dx=\frac{(b-a)}{6}\left(f(a)+4f\left(\frac{a+b}{2}\right)+f(b)\right)$$ and it is really a quadratic interpolation to approximate the integral. 
Gaussian Quadrature is different in a sense that the integral is evlauted by picking certain points in interval with some weights. You an easily look up weights and points for GQ and it is given by $$\int_{-1}^{1} f(x)\,dx=\sum_{i=1}^{n} w_{i}f(x_{i})$$
For your exercise, start with a equally spaced points on the line and implement each of the above method. If the error is above the tolerance, increase the number of intervals and repeat the same process until the error is $\le 10^{-5}$.
This will be few lines of code in your preferred language.
A: It might also be asking you to use the remainder term formula.  I happen to remember that the remainder term for Simpson's rule using $n$ intervals (where here $n$ must be an even number) is $$ -\frac{(b-a)^5 f^{(4)}(\xi)}{180n^4}$$
where $a$ and $b$ are the limits of integration, $f$ is the integrand, and $\xi$ is between $a$ and $b$.  But this will only get you a lower bound for an $n$ that guarantees the error is less than $10^{-5}$.  There is a similar formula for the trapezoidal rule.
But I have absolutely no idea what it is for Gaussian quadrature!
