# Integral of $x^2\ln(x)$ using Simpson's rule

This is my homework question: Calculate $\int_{0}^{1}x^2\ln(x) dx$ using Simpson's formula. Maximum error should be $1/2\times10^{-4}$

For solving the problem, I need to calculate fourth derivative of $x^2\ln(x)$. It is $-2/x^2$ and it's maximum value will be $\infty$ between $(0,1)$ and I can't calculate $h$ in the following error formula for using in Simpson's formula.

$$-\frac{(b-a)}{180}h^4f^{(4)}(\eta)$$

How can I solve it?

-
The maximum value will not be $\infty$--for one thing, that isn't a value, per se, and for another, $-2/x^2$ is strictly increasing in the interval $(0,1]$, so its maximum will be achieved at 1. Note also that $b=1$, $a=0$, and $h=(b-a)/n=1/n$ is the length of the subintervals into which you're splitting $[0,1]$. Hopefully that's enough to get you unstuck. – Cameron Buie May 14 '12 at 6:24
Glad I could help out. – Cameron Buie May 14 '12 at 6:58
Unfortunately, this isn't correct. One cares about the absolute value of the derivative. – mixedmath May 14 '12 at 7:03
The error bound in Simpson's formula has an absolute value around the $4$th derivative. So I don't think your approach will work directly. Possibly you could estimate the integral on $[0,\epsilon]$ and then use the error bound on $(\epsilon,1)$. – copper.hat May 14 '12 at 7:05
@CameronBuie: I see, & I don't want to focus too much on the terminological aspect. But regardless of how $f(0)$ is defined here, this is an ordinary Riemann integral, meaning that the integral exists according to the definition of the Riemann integral of a bounded function on a bounded interval. My understanding of the usual use of the term "improper integral" is that either the function or the interval is unbounded, and hence the Riemann integral doesn't technically exist, although of a value of the integral can be obtained by taking a limit of proper Riemann integrals. – Jonas Meyer May 18 '12 at 6:41

I will expand on copper.hat's comment. Let $f(x)=x^2\ln(x)$ on $(0,1]$, and $f(0)=0$. Note that $f$ is continuous on $[0,1]$. The first derivative of $f$ is $f'(x)=x+2x\ln(x)$. The only critical point in $(0,1)$ is at $x=1/\sqrt{e}$, and $f$ is decreasing on the interval $[0,1/\sqrt{e}]$. Therefore if $0<c<1/\sqrt{e}$, then $cf(c)<\int_0^cf(x)dx<0$. You can choose $c$ such that $|cf(c)|<\frac{1}{4}\times 10^{-4}$. This leaves the estimate of the integral $\int_c^1f(x)dx$, and on the interval $[c,1]$ you have $|f^{(4)}(x)|\leq |f^{(4)}(c)|=\frac{2}{c^2}$, so to choose your $h$ you can solve the inequality $\frac{(1-c)}{90c^2}h^4<\frac{1}{4}\times 10^{-4}$.

For example, $c=0.01$, $h=0.01$ would work. Simpson's rule can then be applied on the entire interval with $h=0.01$, because the error on each of $[0,0.01]$ and $[0.01,1]$ will be less than $\frac{1}{4}\times 10^{-4}$, meaning that the total error will be less than $\frac{1}{2}\times 10^{-4}$ (in absolute value).

-

As already noticed, $f(x)$ is not $C^4$ on the closed interval $[0,1]$, and a direct estimate on the error in Simpson's method is troublesome. One way to handle things is to remove the left end point as described by Jonas Meyer. Another way to handle weak singularities as these is to start with a change of variables.

For this particular integral, you can check that the substitution $x = t^a$ for $a$ large enough will turn the integrand into a $C^4$ function. For example, $a = 2$ gives $x = t^2$, $dx = 2t\,dt$, so

$$\int_0^1 x^2 \ln(x)\,dx = \int_0^1 t^4 \ln(t^2)\,2t\,dt= 4\int_0^1 t^5\ln(t)\,dt.$$

Let $g(t) = t^5\ln(t)$. You can check that $g(t)$ is $C^4$ on $[0,1]$. (Extended to $g(0) = 0$, of course.) Furthermore $|g^{(4)}(t)| \le 154$ on $[0,1]$. Simpson's rule on $g$ now works (reasonably) well.

-