# Fourier series confusion

Find the Fourier series of

Question 1

$$f(x) =\begin{cases} 0&&\text{for -1 < x < 0}\\\\ x&&\text{for 0 \leq x \leq 1} \end{cases}$$

and

Question 2

$$f(x) = x + \pi,\; - \pi < x < \pi$$

Solutions

For Question 1, the solution is $$\begin{cases} a_0&= \frac{1}{2} \int_{0}^{1} x dx = 1/4\\ a_n& = \int_{0}^{1} x \cos(n \pi x) dx = \frac{(-1)^n - 1}{(\pi n)^2}\\ b_n&= \int_{0}^{1} x \sin(n \pi x) dx = \frac{(-1)^{n+1}}{(\pi n)} \end{cases}$$

Then, just use the formula $$f(x)=a_0 + \sum_{n=1}^{\infty} a_n \cos(n \pi x) + b_n \sin(n \pi x)$$

For Question 2 $$\begin{cases} a_0&= \frac{1}{2 \pi} \int_{- \pi}^{\pi} (x + \pi) dx = 2 \pi\\ a_n&= \frac{1}{\pi} \int_{- \pi}^{\pi} (x+\pi)\cos(n \pi x) dx = 0\\ b_n&= \frac{1}{\pi} \int_{- \pi}^{\pi} (x+\pi)\sin(n \pi x) dx = \frac{2(-1)^{n+1}}{n} \end{cases}$$ Then, use the same formula again with something different example: $$f(x) = a_0 + \sum_{n=1}^{\infty} a_n\cos(nx) + b_n \sin(nx)$$

Question

My question is how do you get the denominator like for the first one how does $$\frac{1}{2}$$ come from? And for the second one where does $$\frac{1}{\pi}$$ come from and why is it $$\cos(nx)$$ and $$\sin(nx)$$ instead of $$\cos(n \pi x)$$?

• None of these functions is periodic, it's only defined on a bounded interval. It's fine to tell the period is the length of this interval, but it's not mandatory, and it should be part of the question then. Sometimes you can complete the function as an even or odd periodic function, and this gives either a cosine or sine series, or complete $f$ to be a continuous and piecewise $C^1$ function, hence having a series that is everywhere equal to the function. – Jean-Claude Arbaut Apr 21 at 13:31

It's because the general formulas when the half-period is $$L$$ are
\begin{align} a_0 &= \frac{1}{2L}\int_{-L}^{L} f(x)\, dx \\ a_n &= \frac{1}{L}\int_{-L}^{L} f(x)\cos\left(\frac{n\pi x}{L}\right)\, dx, \quad n\ge 1 \\ b_n &= \frac{1}{L}\int_{-L}^{L} f(x)\sin\left(\frac{n\pi x}{L}\right)\, dx, \quad n\ge 1.\end{align}
Note that in the first example, the half-period is $$L=1$$, whereas in the second example, $$L=\pi$$.