Expand the periodic function f(x)=sgn(cos x) in a Fourier
Expand the periodic function $f(x)=\operatorname{sgn}(\cos x)$ in a Fourier series.
Explanation of Method
$f$ is a $\pm1$-valued square wave, even (since $\cos$ is even), with jump discontinuities of size $2$ wherever $\cos x=0$. Only cosine terms appear; direct integration of $\cos(nx)$ over the two half-period pieces where $f=+1$ and $f=-1$ gives a coefficient that vanishes for even $n$ and alternates for odd $n$, recovering the Leibniz series at $x=0$.
- Identify the sign pattern of $\cos x$ and hence $f$ on one period.
- Compute $a_0$ and $a_n$ directly by splitting the integral at the sign changes.
- Check the result at $x=0$ against the Leibniz formula for $\pi$.
Step 1 · The sign pattern
On $[0,\pi]$: $f(x)=1$ for $x\in[0,\pi/2)$ and $f(x)=-1$ for $x\in(\pi/2,\pi]$. Since $\cos$ is even, $f$ is even, so $b_n=0$ for all $n$.
Step 2 · Computing $a_0$ and $a_n$
$$ a_0 = \frac2\pi\left[\int_0^{\pi/2}1\,dx-\int_{\pi/2}^\pi1\,dx\right] = \frac2\pi\left[\frac\pi2-\frac\pi2\right]=0. $$ $$ a_n = \frac2\pi\left[\int_0^{\pi/2}\cos(nx)\,dx-\int_{\pi/2}^\pi\cos(nx)\,dx\right] = \frac2{\pi n}\left[2\sin\frac{n\pi}2\right] = \frac4{\pi n}\sin\frac{n\pi}2. $$ Since $\sin\frac{n\pi}2=0$ for even $n$, and for $n=2k-1$: $\sin\frac{(2k-1)\pi}2=(-1)^{k-1}$: $$ a_{2k-1} = \frac{4(-1)^{k-1}}{\pi(2k-1)}, \qquad a_{2k}=0. $$ (Verified numerically: $a_1\approx1.2732=4/\pi$, $a_3\approx-0.42441=-4/(3\pi)$, $a_5\approx0.25465=4/(5\pi)$, matching exactly.)
Step 3 · Fourier series
$$ \boxed{\operatorname{sgn}(\cos x) = \frac4\pi\sum_{k=1}^\infty\frac{(-1)^{k-1}}{2k-1}\cos((2k-1)x) = \frac4\pi\left(\cos x-\frac{\cos3x}3+\frac{\cos5x}5-\cdots\right)} $$ At $x=0$: $\operatorname{sgn}(\cos0)=1$, giving $$ 1 = \frac4\pi\left(1-\frac13+\frac15-\cdots\right) \implies \frac\pi4 = 1-\frac13+\frac15-\cdots, $$ recovering the Leibniz formula for $\pi$ (as in Problem 324).
Summary Table
| Property | Value |
|---|---|
| Symmetry | even ⇒ $b_n=0$ |
| Coefficient | $a_{2k-1}=\dfrac{4(-1)^{k-1}}{\pi(2k-1)}$, $a_{2k}=0$ |
| At $x=0$ | recovers $\pi/4=1-1/3+1/5-\cdots$ |
Additional Notes
- This square wave has genuine jump discontinuities of size $2$ at $x=\pi/2+k\pi$, in direct contrast to Problem 322's continuous triangle wave $\arcsin(\sin x)$ — a useful pair for illustrating the difference between "corner" and "jump" singularities in Fourier analysis.
- The coefficients decay only like $1/n$, so Gibbs' phenomenon (overshoot near the jumps) is expected and pronounced, unlike the faster-converging series of Problems 325, 328–329.
- That evaluating at $x=0$ reproduces exactly the same Leibniz series as Problem 324's evaluation at $x=\pi/2$ is not a coincidence: both functions encode the same underlying alternating-odd-reciprocal structure, just via different generating functions.