# How can I write the fourier series for this piecewise defined function?

I am given a $$2 \pi$$ periodic function $$f$$:

$$f(x) = \begin{cases} x+\pi, & -\pi \le x < -\frac{\pi}{2} \\ \frac{\pi}{2}, & -\frac{\pi}{2} \le x <\frac{\pi}{2} \\ x-\pi, & \frac{\pi}{2} \le x <\pi \end{cases}$$

I want to determine the fourier series:

$$\frac{a_0}{2}+\sum_{n=0}^\infty a_n \cos{(nx)}+\sum_{n=1}^\infty b_n \sin{(nx)}$$

where $$a_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos{(nx)}dx$$ and $$b_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\sin{(nx)}dx$$.

Since $$f$$ is even and $$[-\pi,\pi]$$ is a symmetric interval, all the $$b_n$$ will be zero. I tried to calculate $$a_n$$ by integrating piecewise over the interval and (without writing out all the calculations) I got:

$$a_n=\frac{2 \sin{(\frac{n\pi}{2})}}{n}$$

I have two problems now:

1. $$a_0$$ seems to be undefined according to this definition
2. I know that for $$n \space \text{even}$$ $$a_n=0$$. However, I can't really find a nice expression for $$n \space \text{odd}$$. Is there anyway I can rewrite it (maybe eliminate the $$\sin{nx}$$ from the term)?
• You can use linearity of FT together with box and triangle functions whose transforms you should learn by heart if you haven't already. – mathreadler Jul 6 at 17:30

If $$a_{n} = \frac{2\sin(\frac{n \pi}{2})}{n}$$ then note that

$$\sin(\frac{n \pi}{2}) = 1, -1,1, \cdots$$ for odd n. So the first few expressions are

$$a_{1} = \frac{2}{1} = 2 , a_{3} = \frac{-2}{3} , a_{5} = \frac{2}{5}$$

Note that $$a_{0}$$ is given by the following equation for that interval

$$a_{0} = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \textrm{d}x$$

Alternatively, you can see that

$$a_{n} = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos(n x) \textrm{d}x$$

and $$\cos(nx) = 1$$ for $$n =0$$.

• Is there any way to condense that into a closed-form formula? Somthing like $(-1)^k$ (which would be wrong in this case because it yields a negative for the $a_1$ term.) Also, how do I deal with $a_0$? Do I use the limit ? – qmd Jul 6 at 15:14
• Probably. $a_{0} = \int_{-\pi}^{\pi} f(x) \textrm{d}x$ so it is equal to $2\pi^{2} + \pi^{2} - 2\pi^{2}$ which is $\pi^{2}$ there should be $\frac{1}{\pi}$ too. Then $a_{0} = \pi$ I think – воитель Jul 6 at 15:21
• @qmd the general term is $$a_n=\frac{2(-1)^{(n-1)/2}}{n}$$ apart from $a_0=\pi$. – Peter Foreman Jul 6 at 18:07
• @PeterForeman Exactly what I was looking for. Thanks for your help! – qmd Jul 7 at 8:46
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 24, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}