# Fourier series for $f(x)=\sin(ax)$ where $a$ is not an integer?

I was wondering if anyone could help me with this fourier series problem?

Expand the following function in Fourier cosine series: $f(x) = \sin(ax)$ $(0\le x \le \pi)$ , where $a$ is not an integer.

The answer I came up with is:

$\frac{1-\cos(a\pi)}{\pi}\left(\frac{1}{a}+2a \sum_{n=1}^{\infty}\frac{\cos(2nx)}{a^2-4n^2}\right)$

But the book I'm working from got:

$\sin(ax)=\frac{1-\cos(a\pi)}{\pi}\left(1+2a \sum_{n=1}^{\infty}\frac{\cos(2nx)}{a^2-4n^2}\right) +2a\frac{1+\cos(a\pi)}{\pi}\sum_{n=0}^{\infty}\frac{\cos[(2n+1)x]}{a^2-(2n+1)^2}$ for $(0\le x\le \pi)$

Development in cosine series means your function has to be even, so you define $$f(x)=\sin(a|x|)$$ on $$[-\pi,\pi]$$, and complete on $$\Bbb R$$ by periodicity. Then, your function has period $$2\pi/a$$, is continuous an piecewise $$C^1$$, hence the Dirichlet conditions apply.

Compute the Fourier coefficients:

$$a_n=\frac{1}{\pi}\int_{-\pi}^\pi \sin(a|x|)\cos(nx) \mathrm dx=\frac{2}{\pi}\int_{0}^\pi \sin(ax)\cos(nx) \mathrm dx$$

You have the identity $$\sin(ax)\cos(nx)=\frac12[\sin(a+n)x+\sin(a-n)x]$$, thus

$$a_n=\frac{1}{\pi}\int_{0}^\pi (\sin(a+n)x+\sin(a-n)x) \mathrm dx \\=\frac1\pi\left(\frac{1-\cos(a+n)\pi}{a+n}+\frac{1-\cos(a-n)\pi}{a-n}\right) \\=\frac{2a}{\pi(a^2-n^2)}\left[1-(-1)^n\cos(a\pi)\right]$$

For the last simplification, notice that $$\cos(a+n)\pi=\cos(a-n)\pi=(-1)^n\cos(a\pi)$$.

Then, for $$x\in[0,\pi]$$,

$$\sin (ax)=\frac{a_0}{2}+\sum_{n=1}^\infty a_n\cos (nx)=\frac{1-\cos(a\pi)}{a\pi}+\frac{2a}{\pi}\sum_{n=1}^\infty \frac{1-(-1)^n\cos(a\pi)}{a^2-n^2}\cos (nx)$$

Apart from the constant term, it's the same as your book's answer, in a slightly different form. Either you mistyped the answer, either there is a typo in your book.