# How to expand the Fourier series for $f(x)=\max \{0, \frac{\pi}{2}-\lvert x\rvert \}$?

My Question: My Goal is to determine the Fourier series for $$f(x)=\max \{0, \frac{\pi}{2}-\lvert x\rvert \} \quad$$ for $$x \in [-\pi, \pi ]$$ This function is $$2\pi$$-periodic.

My Approach: i found out, $$f(x)$$ is an even function, because its graph is symmetric to the y-axis. The Expression: $$\frac{\pi}{2}-\lvert x \rvert$$ has to "zeros":

$$\frac{\pi}{2}-\lvert x \rvert = 0$$
$$\frac{\pi}{2}= \lvert x \rvert$$
$$x_{0}=-\frac{\pi}{2}$$
$$x_{1}=+\frac{\pi}{2}$$

the graph must look somehow like that.. so the function is linear all over the Intervall: But now Comes the hard stuff. I'm stuck in building the Fourier series for $$f(x)$$ The integral should be builded maybe this way, but i am not sure if if am right:

$$\int (\frac{\pi}{2}-x)\cdot \cos (nx)\ dx = \frac{\pi}{2n}\sin (nx) - \frac{x}{n}\sin (nx) - \frac{1}{n^2}\cos (nx)$$

What do you think, is that right? And what would be the next step? My textbook doesn't describes the further calculation.

p.s. edits for improving language and latex

• The function is even. So $b_n=0$ for all $n$. And to compute $a_n$, you can restrict to $[0,\pi]$ and multiply by $2$. May 11 '13 at 17:54

Hint: Consider the $2\pi$ continuation of $$f(x)=\begin{cases} 0 & x\in\left[-\pi, -\frac{\pi}{2}\right] \\ \frac{\pi}{2}+x & x\in \left[-\frac{\pi}{2}, 0\right] \\ \frac{\pi}{2}-x & x\in\left[0,\frac{\pi}{2}\right] \\ 0 & x\in\left[\frac{\pi}{2}, \pi\right]\end{cases}$$

Edit: As your function is even, each $b_n=0$. Also, the integral can be computed by integrating from $0$ to $\pi$ and multiplying the result by 2.

• This is still false, for more serious reasons. The function is $0$ on $[\pi/2,\pi]$ and $[-\pi,-\pi/2]$. But look at the graph the OP posted. I think he/she is aware of what the function is. May 11 '13 at 17:58
• No problem. I did not downvote, but yet I think your answer is not particularly helpful as it is, given that the OP seems to know that. I suggest you add that $b_n=0$, since the function is even. And that $a_n=\frac{2}{\pi}\int_0^\pi f(x)\cos(nx)dx=\frac{2}{\pi}\int_0^{\pi/2}(\pi/2-x)\cos (nx) dx$. May 11 '13 at 18:17
• @BarachObama Thank you for the edit Barach. I was going to write something similarly.
– user77356
May 11 '13 at 18:29

Since the function is even, the coefficients of $\sin nx$ are all zero. The constant term is the average value of the function on $[-\pi,\pi]$: $$\frac{1}{2\pi}\int_{-\pi}^\pi f(x)\,dx\;=\; \frac{1}{2\pi}\left(\frac{\pi^2}{4}\right) \;=\; \frac{\pi}{8}$$ (The integral here was evaluated using the formula for the area of a triangle.)

The coefficient of $\cos nx$ is given by the formula $$a_n \;=\; \frac{1}{\pi}\int_{-\pi}^\pi f(x)\,\cos nx\;dx$$ Since $f(x)$ is nonzero only on $[-\pi/2,\pi/2]$, this is the same as $$a_n \;=\; \frac{1}{\pi}\int_{-\pi/2}^{\pi/2} f(x)\,\cos nx\;dx$$ Moreover, since $f(x) \cos nx$ is an even function, we can restrict to $[0,\pi/2]$ and double the integral: $$a_n \;=\; \frac{2}{\pi}\int_0^{\pi/2} f(x)\,\cos nx\;dx \;=\; \frac{2}{\pi}\int_0^{\pi/2} \left(\frac{\pi}{2} - x\right)\,\cos nx\;dx$$ The integral on the right can be evaluated using integration by parts. The result is: $$a_n \;=\; \begin{cases}\dfrac{2}{\pi n^2} & \text{if }n\equiv 1,3\pmod{4}, \\[6pt] \dfrac{4}{\pi n^2} & \text{if }n\equiv 2\pmod 4, \\[6pt] 0 & \text{if }n\equiv 0 \pmod{4}.\end{cases}$$ Thus $$f(x) \;=\; \frac{\pi}{8} + \frac{2}{\pi}\cos x + \frac{1}{\pi}\cos 2x + \frac{2}{9\pi}\cos 3x + \frac{2}{25\pi}\cos 5x + \frac{1}{9\pi}\cos 6x + \cdots.$$ In summation form, $$f(x) \;=\; \frac{\pi}{8} \,+\, \sum_{k=0}^\infty \frac{2}{\pi(2k+1)^2} \cos\bigl((2k+1)x\bigr) \,+\, \sum_{k=0}^\infty \frac{1}{\pi(2k+1)^2} \cos\bigl((4k+2)x\bigr).$$ By the way, the following animation shows thee convergence of this Fourier series for the first twelve terms: • thanks alot, as you know, according to rules, you can get the bounty tomorrow May 13 '13 at 16:21
• I'm happy to help! May 13 '13 at 16:32