Expand f(x)=cases cos x, x in(0,frac pi2), - cos x, x
Expand $f(x)=\begin{cases}\cos x, & x\in(0,\frac\pi2)\\-\cos x, & x\in(\frac\pi2,\pi)\end{cases}$ in a cosine series on $(0,\pi)$.
Explanation of Method
Direct integration over the two pieces gives $a_0=4/\pi$. For $a_n$, product-to-sum on $\cos x\cos(nx)$ splits into two elementary cosine integrals; $n=1$ is a special case (giving $a_1=0$ since the two half-interval contributions exactly cancel), and for $n\ge2$ the boundary terms combine using $\sin\frac{(n\mp1)\pi}2$, which vanishes for odd $n\mp1$ (i.e. even $n$) and alternates for odd $n$... in fact only even $n$ survive here.
- Compute $a_0$ by direct integration.
- Show $a_1=0$ directly.
- Compute $a_n$ for $n\ge2$, showing odd $n$ vanish and even $n=2k$ give a clean closed form.
Step 1 · Computing $a_0$
$$ a_0 = \frac2\pi\left[\int_0^{\pi/2}\cos x\,dx-\int_{\pi/2}^\pi\cos x\,dx\right] = \frac2\pi[(1-0)-(0-1)] = \frac4\pi. $$
Step 2 · The case $n=1$
Using $\cos^2x=\frac12(1+\cos2x)$: direct computation shows the contributions from $(0,\pi/2)$ and $(\pi/2,\pi)$ are equal and opposite, giving $a_1=0$.
Step 3 · Computing $a_n$ for $n\ge2$
Using $\cos x\cos(nx)=\frac12[\cos((n-1)x)+\cos((n+1)x)]$ and evaluating boundary terms at $x=0,\pi/2,\pi$ (where $\sin((n\pm1)\pi)=0$ always): $$ a_n = \frac2\pi\left[\frac{\sin\frac{(n-1)\pi}2}{n-1}+\frac{\sin\frac{(n+1)\pi}2}{n+1}\right]. $$ For odd $n\ge3$: both $(n-1),(n+1)$ are even, so both sines vanish and $a_n=0$. For even $n=2k$: both $(n\mp1)$ are odd, giving $\sin\frac{(2k-1)\pi}2=(-1)^{k-1}$ and $\sin\frac{(2k+1)\pi}2=(-1)^k$: $$ a_{2k} = \frac2\pi\left[\frac{(-1)^{k-1}}{2k-1}+\frac{(-1)^k}{2k+1}\right] = \frac{2(-1)^{k-1}}\pi\left[\frac1{2k-1}-\frac1{2k+1}\right] = \frac{4(-1)^{k-1}}{\pi(4k^2-1)}. $$
Step 4 · Fourier series
$$ \boxed{f(x) = \frac2\pi+\frac4\pi\sum_{k=1}^\infty\frac{(-1)^{k-1}}{4k^2-1}\cos(2kx)} $$ (Verified numerically at $x=0.3,1.0,1.5,2.0,2.8$: partial sums to $2000$ terms match $f(x)$ to 5+ significant figures.)
Summary Table
| Property | Value |
|---|---|
| $a_0/2$ | $2/\pi$ |
| $a_1$; odd $n\ge3$ | $0$ |
| $a_{2k}$ | $\dfrac{4(-1)^{k-1}}{\pi(4k^2-1)}$ |
Additional Notes
- The vanishing of $a_1$ is not a coincidence of symmetry but a direct algebraic cancellation between the two half-interval pieces — a useful reminder that "fundamental harmonic vanishes" can happen even without an obvious symmetry argument.
- Only even harmonics survive here, with coefficients decaying like $1/n^2$ — this pattern, and the underlying denominator $4k^2-1=(2k-1)(2k+1)$, is structurally identical to Problem 313's arctangent-series denominator, both arising from the same style of adjacent-integer partial-fraction cancellation.
- The sign change at $x=\pi/2$ in the original piecewise definition is exactly what breaks the "trivial" cosine expansion $\cos x=\cos x$ that would otherwise hold (as in Problem 331) — flipping the sign on half the interval forces a genuinely infinite series.