# Integration using trapezoid rule

I am trying to solve this expression using trapeze rule: $$\int_0^1 (1+x) \ln^2(1+x) \ dx$$

So at the beginning I am dividing into five equal parts:

0-0.2, 0.2-0.4, 0.4-0.6, 0.6-0.8, 0.8-1


After that I calculate the value for those points using my f(x) expression.

f(x) = (1 + x)ln^2(1+x)
f(0) = (1 + 0)ln^2(1+0) = 0
f(0.2) = (1 + 0.2)ln^2(1+0.2) = 0.0398
f(0.4) = (1 + 0.4)ln^2(1+0.4) = 0.1584
f(0.6) = (1 + 0.6)ln^2(1+0.6) = 0.3534
f(0.8) = (1 + 0.8)ln^2(1+0.8) = 0.6218
f(1) = (1 + 1)ln^2(1+1) = 0.9609


Now I am using this pattern to calculate the approximate value of the integral.

=0.2*(0.9609/2+0.0398+0.1584+0.3534+0.6218) = 0.3307


I wanted to check if value i got is correct, so i visited Wolfarm Alpha. I put there my expression and I got 2.57406 resault.

Which of these results is correct?

• See both the trapezoidal result and the exact using Wolfram Alpha. Results look pretty close, so you likely have an algebra issue. – Moo Dec 11 '17 at 17:57
• The actual result is $$\frac{3}{4}+2 \log ^2(2)-\log (4)\approx 0.324612$$ so you are right – Raffaele Dec 11 '17 at 18:40
• Your integral is clearly $\leq \int_{0}^{1}(1+x)x^2\,dx = \frac{7}{12}$ so $2.574\ldots$ has no chance of being a reasonable approximation. – Jack D'Aurizio Dec 11 '17 at 19:45

Technically speaking, there is nothing to solve in a expression or in a definite integral, they are not equations. Anyway, in order to find an accurate numerical approximation of $$I = \int_{0}^{1}(1+x)\log^2(1+x)\,dx$$ it is best to use Simpson's rule (instead of the trapezoid method) since $f(x)=(1+x)\log^2(1+x)$ essentially behaves like a quadratic polynomial on $[0,1]$. By picking $x_0=0,x_1=\frac{1}{4},x_2=\frac{1}{2},x_3=\frac{3}{4},x_4=1$ we have
$$I \approx \frac{f(x_0)+4\,f(x_1)+2\,f(x_2)+4\,f(x_3)+f(x_4)}{12}=\color{green}{0.3246}0549356\ldots$$ where the green digits agree with the exact value of the integral, $\frac{3}{4}+2\log^2(2)-2\log(2)$, which can be found by integration by parts. The given problem is equivalent to finding accurate numerical approximations for $\log(2)$: Beuker integrals provide an interesting approach.
$$\int_{0}^{1}\frac{x^5(1-x)^5}{1+x}\,dx = \frac{2329}{105}-32 \log(2)$$ and the LHS is $\leq\frac{1}{2^{10}}$, hence $\frac{2329}{3360}$ is an excellent approximation of $\log(2)$ and $$I \approx \frac{1832401}{5644800}=\color{green}{0.32461}7524\ldots$$
Wolfram Alpha gives $2\ln^2\left(2\right)-2\ln\left(2\right)+\dfrac{3}{4}\approx 0.3246116667165122$ for the value of the integral.