# Thread: Taylor Expansion for Numerical Integration

1. ## Taylor Expansion for Numerical Integration

Hey,

I'm looking for the error of the Trapezoidal method applied to the integral $\displaystyle \int_0^1 sin(\pi x) \, dx$

The actual value of this integral in $\displaystyle 2/\pi$. Applying the trapezoidal method to the integral results for a small step size $\displaystyle h$ results in: $\displaystyle h \frac{sin(\pi h)}{1 - cos(\pi h)}$. (I've checked this result and for small h, this is approximately equal to $\displaystyle 2/\pi$. (to precision above 5 decimal places in MATLAB))

So now I have to check the error of the method, which in general, for an integral $\displaystyle \int_a^b f(x) \, dx$ is $\displaystyle \epsilon(h) = h^2/12 ( f'(b) - f'(a) ) + O(h^4)$.

So I'm having trouble finding the taylor expansion of $\displaystyle h \frac{sin(\pi h)}{1 - cos(\pi h)}$, but i know the coefficent of the h^2 term should be $\displaystyle (f'(b) -f'(a))/12 = \frac{-\pi}{6}$.

Thanks!!

2. ## Solved!

Okay, so after staring at this problem some more I got the right answer.

I assumed that $\displaystyle h\frac{sin(\pi h)}{1 - cos(\pi h)} = C_0 + C_1 h + C_2 h^2$ and by multiplying both sides by the taylor expansion of $\displaystyle 1 - cos(\pi h)$, I was able to find the correct coefficients of $\displaystyle C_0, C_1, C_2...$ such that the right side equals that taylor expansion of $\displaystyle h sin(\pi h)$.

btw, $\displaystyle h\frac{sin(\pi h)}{1 - cos(\pi h)} = \frac{2}{\pi} - \frac{\pi}{6}h^2 + \frac{\pi^3}{720}h^4 + O(h^6)$