For Question 12, this formula was used to find the coefficients in the Fourier series, whereas for Question 13, this formula was used. The difference is that for one, the inside of the sin and cos functions was just (nx), whereas for the other it was (nπx/L). I'm confused about the different representations of the formulas used and when to use each.
Is it because the goal is to have (π) in your inside function when integrating the sin and cos functions? So when the function already has bounds in terms of (π) you use (nx), and when it is not in terms of (π), you use (nπx/L)?
The e^x function was integrated between (-π,π) and the formulas had (nx). The (2-x) function was integrated between (-2,2) and the formula had (nπx/L).
I've seen that when you have (π) inside the sin and cos functions, the integration simplifies quicker.
The functions $\{1,\cos(nx),\sin(nx)\}$ for $n \ge 1$ can be used to expand a function $f$ on $[-\pi,\pi]$, for example. That expansion $\frac{a_0}{2}+\sum_{n=1}^{\infty}a_n\cos(nx)+b_n\sin(nx)$ is defined on $\mathbb{R}$, and it is periodic with period $2\pi$. So, only the function on $[-\pi,\pi)$ or $(-\pi,\pi]$ is determined by $f$; the values elsewhere are determined by periodicity. If you want to expand on $[-l,l]$, then you adjust the arguments to give a period of $2l$, such as $\{ 1,\cos(n\pi x/l),\sin(n\pi x/l)\}$. That way $nx$ at $\pm \pi$ is the same as $n\pi x/l$ at $\pm l$. The resulting series is periodic with period $2l$. If you write $f$ on $[-l,l)$ as
$$ f \sim \frac{a_0}{2}+\sum_{n=1}^{\infty}a_n\cos(n\pi x/l)+b_n\sin(n\pi x/l), $$
then
$$ \int_{-l}^{l}f(x)dx = \frac{a_0}{2}\int_{-l}^{l}dx = a_0l \\ \int_{-l}^{1}f(x)\cos(n\pi x/l)dx=a_n\int_{-l}^{l}\cos^2(n\pi x/l)dx \\ \int_{-l}^{l}f(x)\sin(n\pi x/l)dx=b_n\int_{-l}^{l}\sin^2(n\pi x/l)dx. $$ If you think about it for a bit, using $\cos^2+\sin^2=1$ gives
$$ \int_{-l}^{l}\cos^2(n\pi x /l)dx=\int_{-1}^{1}\sin^2(n\pi x/l)dx \\ =\frac{1}{2}\int_{-1}^{l}\cos^2(n\pi x/l)+\sin^2(n\pi x/l)dx=l $$ So, for $n > 0$, $$ a_n = \frac{1}{l}\int_{-l}^{l}f(x)\cos(n\pi x/l)dx, \\ b_n = \frac{1}{l}\int_{-l}^{l}f(x)\sin(n\pi x/l)dx, $$ and
$$ a_0 = \frac{1}{2l}\int_{-l}^{l}f(x)dx. $$