Given
![\displaystyle\int_a^bf(x)\,\mathrm dx](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Cint_a%5Ebf%28x%29%5C%2C%5Cmathrm%20dx)
you can evaluate the integral by first expanding
![f(x)](https://tex.z-dn.net/?f=f%28x%29)
as a series, say
![\displaystyle\int_a^b\sum_{n\ge0}c_nx^n\,\mathrm dx](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Cint_a%5Eb%5Csum_%7Bn%5Cge0%7Dc_nx%5En%5C%2C%5Cmathrm%20dx)
then interchange the order of integration/summation (provided Fubini's theorem holds; it usually will, so no need to worry greatly about this aspect) to write
![\displaystyle\sum_{n\ge0}c_n\int_a^bx^n\,\mathrm dx](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Csum_%7Bn%5Cge0%7Dc_n%5Cint_a%5Ebx%5En%5C%2C%5Cmathrm%20dx)
Then evaluating the integral yields
![\displaystyle\sum_{n\ge0}c_n\frac{x^{n+1}}{n+1}\bigg|_{x=a}^{x=b}](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Csum_%7Bn%5Cge0%7Dc_n%5Cfrac%7Bx%5E%7Bn%2B1%7D%7D%7Bn%2B1%7D%5Cbigg%7C_%7Bx%3Da%7D%5E%7Bx%3Db%7D)
![\displaystyle\sum_{n\ge0}c_n\frac{b^{n+1}-a^{n+1}}{n+1}](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Csum_%7Bn%5Cge0%7Dc_n%5Cfrac%7Bb%5E%7Bn%2B1%7D-a%5E%7Bn%2B1%7D%7D%7Bn%2B1%7D)
Given an appropriate sequence
![c_n](https://tex.z-dn.net/?f=c_n)
, you would then be able to evaluate the integral exactly, or at the very least find a partial sum that approximates the value of the integral to within a specified degree of accuracy.
Here's an example that demonstrates the procedure. Suppose we want to evaluate the definite integral
![\displaystyle\int_0^1\sin\pi x\,\mathrm dx](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Cint_0%5E1%5Csin%5Cpi%20x%5C%2C%5Cmathrm%20dx)
Recall that
![\sin x=\displaystyle\sum_{n\ge0}\frac{(-1)^nx^{2n+1}}{(2n+1)!}](https://tex.z-dn.net/?f=%5Csin%20x%3D%5Cdisplaystyle%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5Enx%5E%7B2n%2B1%7D%7D%7B%282n%2B1%29%21%7D)
so that we can write the definite integral as
![\displaystyle\int_0^1\sin\pi x\,\mathrm dx=\int_0^1\sum_{n\ge0}\frac{(-1)^n(\pi x)^{2n+1}}{(2n+1)!}\,\mathrm dx=\sum_{n\ge0}\frac{(-1)^n\pi^{2n+1}}{(2n+1)!}\int_0^1x^{2n+1}\,\mathrm dx](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Cint_0%5E1%5Csin%5Cpi%20x%5C%2C%5Cmathrm%20dx%3D%5Cint_0%5E1%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5En%28%5Cpi%20x%29%5E%7B2n%2B1%7D%7D%7B%282n%2B1%29%21%7D%5C%2C%5Cmathrm%20dx%3D%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5En%5Cpi%5E%7B2n%2B1%7D%7D%7B%282n%2B1%29%21%7D%5Cint_0%5E1x%5E%7B2n%2B1%7D%5C%2C%5Cmathrm%20dx)
Integrating yields
![\displaystyle\int_0^1x^{2n+1}\,\mathrm dx=\frac{x^{2n+2}}{2n+2}\bigg|_{x=0}^{x=1}=\frac1{2n+2}](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Cint_0%5E1x%5E%7B2n%2B1%7D%5C%2C%5Cmathrm%20dx%3D%5Cfrac%7Bx%5E%7B2n%2B2%7D%7D%7B2n%2B2%7D%5Cbigg%7C_%7Bx%3D0%7D%5E%7Bx%3D1%7D%3D%5Cfrac1%7B2n%2B2%7D)
and so we're left with
![\displaystyle\sum_{n\ge0}\frac{(-1)^n\pi^{2n+1}}{(2n+2)(2n+1)!}=\sum_{n\ge0}\frac{(-1)^n\pi^{2n+1}}{(2n+2)!}](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5En%5Cpi%5E%7B2n%2B1%7D%7D%7B%282n%2B2%29%282n%2B1%29%21%7D%3D%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5En%5Cpi%5E%7B2n%2B1%7D%7D%7B%282n%2B2%29%21%7D)
The trick now is to evaluate the sum. Well, recall that
![\cos x=\displaystyle\sum_{n\ge0}\frac{(-1)^nx^{2n}}{(2n)!}](https://tex.z-dn.net/?f=%5Ccos%20x%3D%5Cdisplaystyle%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5Enx%5E%7B2n%7D%7D%7B%282n%29%21%7D)
Our sum closely resembles this power series. In our sum, we have odd powers of
![\pi](https://tex.z-dn.net/?f=%5Cpi)
in the numerator, but even factorials in the denominator. We can adjust for this by simply multiplying by
![\dfrac\pi\pi](https://tex.z-dn.net/?f=%5Cdfrac%5Cpi%5Cpi)
:
![\displaystyle\sum_{n\ge0}\frac{(-1)^n\pi^{2n+1}}{(2n+2)!}=\frac1\pi\sum_{n\ge0}\frac{(-1)^n\pi^{2n+2}}{(2n+2)!}](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5En%5Cpi%5E%7B2n%2B1%7D%7D%7B%282n%2B2%29%21%7D%3D%5Cfrac1%5Cpi%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5En%5Cpi%5E%7B2n%2B2%7D%7D%7B%282n%2B2%29%21%7D)
Now, our denominators take the form
![2!,4!,6!,\ldots](https://tex.z-dn.net/?f=2%21%2C4%21%2C6%21%2C%5Cldots)
, while the cosine series proceeds with
![0!,2!,4!,\ldots](https://tex.z-dn.net/?f=0%21%2C2%21%2C4%21%2C%5Cldots)
- in other words, our sum skips the first term of the cosine series. We can adjust for this as well, by adding and subtracting the same term of
![1](https://tex.z-dn.net/?f=1)
. In terms of our summand, we can get
![-1](https://tex.z-dn.net/?f=-1)
by plugging in
![n=-1](https://tex.z-dn.net/?f=n%3D-1)
, so we can write
![\displaystyle\frac1\pi\left(-1+1+\sum_{n\ge0}\frac{(-1)^n\pi^{2n+2}}{(2n+2)!}\right)=\frac1\pi\left(1+\sum_{n\ge-1}\frac{-1)^n\pi^{2n+2}}{(2n+2)!}\right)](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Cfrac1%5Cpi%5Cleft%28-1%2B1%2B%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5En%5Cpi%5E%7B2n%2B2%7D%7D%7B%282n%2B2%29%21%7D%5Cright%29%3D%5Cfrac1%5Cpi%5Cleft%281%2B%5Csum_%7Bn%5Cge-1%7D%5Cfrac%7B-1%29%5En%5Cpi%5E%7B2n%2B2%7D%7D%7B%282n%2B2%29%21%7D%5Cright%29)
Then shifting the index by 1 so that it starts at
![n=0](https://tex.z-dn.net/?f=n%3D0)
gives
![\displaystyle\frac1\pi\left(1+\sum_{n\ge0}\frac{(-1)^{n+1}\pi^{2n}}{(2n)!}\right)](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Cfrac1%5Cpi%5Cleft%281%2B%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5E%7Bn%2B1%7D%5Cpi%5E%7B2n%7D%7D%7B%282n%29%21%7D%5Cright%29)
and now our sum exactly resembles to the negated cosine series evaluated at
![x=\pi](https://tex.z-dn.net/?f=x%3D%5Cpi)
.
![\displaystyle\frac1\pi\left(1+\underbrace{\sum_{n\ge0}\frac{(-1)^{n+1}\pi^{2n}}{(2n)!}}_{-\cos\pi}\right)=\frac1\pi(1-\cos\pi)=\frac1\pi(1-(-1))=\frac2\pi](https://tex.z-dn.net/?f=%5Cdisplaystyle%5Cfrac1%5Cpi%5Cleft%281%2B%5Cunderbrace%7B%5Csum_%7Bn%5Cge0%7D%5Cfrac%7B%28-1%29%5E%7Bn%2B1%7D%5Cpi%5E%7B2n%7D%7D%7B%282n%29%21%7D%7D_%7B-%5Ccos%5Cpi%7D%5Cright%29%3D%5Cfrac1%5Cpi%281-%5Ccos%5Cpi%29%3D%5Cfrac1%5Cpi%281-%28-1%29%29%3D%5Cfrac2%5Cpi)
We can verify that this result is correct: