# 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 $\int_0^1 sin(\pi x) \, dx$

The actual value of this integral in $2/\pi$. Applying the trapezoidal method to the integral results for a small step size $h$ results in: $h \frac{sin(\pi h)}{1 - cos(\pi h)}$. (I've checked this result and for small h, this is approximately equal to $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 $\int_a^b f(x) \, dx$ is $\epsilon(h) = h^2/12 ( f'(b) - f'(a) ) + O(h^4)$.

So I'm having trouble finding the taylor expansion of $h \frac{sin(\pi h)}{1 - cos(\pi h)}$, but i know the coefficent of the h^2 term should be $(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 $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 $1 - cos(\pi h)$, I was able to find the correct coefficients of $C_0, C_1, C_2...$ such that the right side equals that taylor expansion of $h sin(\pi h)$.

btw, $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)$