Find Fourier sine and cosine series for the function $f(x)=1-x$ over the interval $[0,1]$.
Fourier sine and cosine series
For the cosine series we would use the $a_n$ formula. Therefore we start with
$$a_n = 2 \int_{0}^{1} (1-x) \cos(n\pi x)dx $$
Using IBP
$$ u = 1-x \quad v = \frac{1}{n\pi} \sin(n\pi x)$$
$$du = -1 \quad dv = \cos(n\pi x)$$
So
$$a_n = 2\left[\left[ (1-x)\frac{1}{n\pi}\sin(n\pi x) \right|_{0}^{1} - \int_{0}^{1} -\frac{1}{n\pi} \sin(n\pi x)dx\right]$$
$$\Rightarrow a_n=2\left[0-\int_{0}^{1} \frac{1}{n\pi}\sin(n\pi x) dx \right]$$
$$\Rightarrow a_n =2 \left[ -\frac{1}{n^2 \pi^2} \cos(n\pi x) \right|_{0}^{1}$$
$$a_n = 2 \left[ \frac{1}{n^2 \pi^2} \left[1 - (-1)^n\right] \right]$$
For evens the $a_n$'s go to zero therefore we need the odds.
$$a_n = \frac{4}{(2n+1)^2 \pi^2}$$
We also need to find $a_0$.
$$a_0=\int_{0}^{1}(1-x) dx$$
$$\Rightarrow a_0= \frac{1}{2}$$
So for the cosine series
$$u(x,t)=\frac{1}{4}+\sum_{1}^{\infty}\frac{4}{(2n+1)^2\pi^2}\cos(n\pi x)e^{-n^2\pi^2 t}$$
$$$$
For the sine series we would use the $b_n$ formula. Therefore we start with
$$b_n = 2 \int_{0}^{1} (1-x) \sin(n\pi x)dx $$
Using IBP
$$ u = 1-x \quad v = -\frac{1}{n\pi} \cos(n\pi x)$$
$$du = -1 \quad dv = \sin(n\pi x)$$
So
$$b_n = 2\left[\left[ (1-x)\frac{1}{n\pi}\cos(n\pi x) \right|_{0}^{1} - \int_{0}^{1} -\frac{1}{n\pi} \cos(n\pi x)dx\right]$$
$$\Rightarrow b_n=2\left[(1-x)(\frac{1}{n\pi}\cos(n\pi x))\right|_{0}^{1}-0$$
$$\Rightarrow b_n =2[\left[ -\frac{1}{n \pi} \cos(n\pi x)\right|_{0}^{1} - \left[x[-\frac{1}{n\pi}\cos(n\pi x)]\right|_{0}^{1} \ ]$$
$$\Rightarrow b_n =2 \left[ -\frac{1}{n \pi} [\cos(n\pi ) - 1] -[-\frac{1}{n\pi}\cos(n\pi)] \right]$$
$$\Rightarrow b_n =2 \left[ \frac{1}{n \pi} [1 - \cos(n\pi)] +\frac{1}{n\pi}\cos(n\pi) \right]$$
Therefore,
$$ b_n = \frac{2}{n\pi}$$
So for the sine series
$$u(x,t)=\sum_{1}^{\infty}\frac{2}{(n\pi})\sin(n\pi x)e^{-n^2\pi^2 t}$$
$$$$