# Find the n th Fourier polynomial for f(x) = \begin{cases} x & -\pi x \leq 0,\\ -x & 0 x...

## Question:

Find the {eq}n {/eq} th Fourier polynomial for

{eq}f(x) = \begin{cases} x & -\pi < x \leq 0,\\ -x & 0 <x <\pi. \end{cases} {/eq}

Assume that {eq}f(x) {/eq} is periodic with period {eq}2\pi {/eq}.

## Fourier Polynomials:

If {eq}f(x) {/eq} is a function on the interval {eq}[-\pi,\pi] {/eq}, then the Fourier coefficients of {eq}f(x) {/eq} are defined to be the following numbers:

{eq}\begin{align*} a_k&=\frac{1}{\pi}\int_{-\pi}^\pi f(x)\cos(kx) \, dx\, ,&&k \ge 0\\ b_k&=\frac{1}{\pi}\int_{-\pi}^\pi f(x)\sin(kx) \, dx\, ,&&k \ge 1 \, . \end{align*} {/eq}

The {eq}n {/eq}th Fourier polynomial of {eq}f(x) {/eq} is defined to be the trigonometric polynomial

{eq}\displaystyle T_n(x)=\frac{a_0}{2}+\sum_{k=1}^n \left[a_k \cos(kx)+b_k\sin(kx)\right] \, . {/eq}

The trigonometric polynomial {eq}T_n(x) {/eq} gives an approximation to {eq}f(x) {/eq} over the interval {eq}[-\pi,\pi] {/eq}.

To find the {eq}n {/eq}th Fourier polynomial of {eq}f(x)=\begin{cases} x & -\pi < x < 0, -x & 0 < x < \pi\end{cases} {/eq}, we'll compute the Fourier coefficients of {eq}f {/eq}. First, we have:

{eq}\begin{align*} a_0&=\frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \, dx\\ &=\frac{1}{\pi} \int_{-\pi}^0 x \, dx + \int_0^\pi (-x) \, dx&&\text{(breaking the integral up using the piecewise definition of }f(x)\text{)}\\ &=\frac{1}{\pi} \left(\frac{1}{2}x^2\right|_{-\pi}^0 + \frac{1}{\pi}\left(-\frac{1}{2}x^2\right|_0^\pi&&\text{(evaluating the integrals)}\\ &=\frac{1}{\pi}\left(\frac{1}{2}(0^2)-\frac{1}{2}(-\pi)^2\right)+\frac{1}{\pi}\left(-\frac{1}{2}\pi^2+\frac{1}{2}0^2\right)\\ &=-\frac{1}{2}\pi-\frac{1}{2}\pi\\ &=-\pi \, . \end{align*} {/eq}

Next, for any {eq}k > 0 {/eq}, we have:

{eq}\begin{align*} a_k&=\int_{-\pi}^\pi f(x) \cos(kx) \, dx\\ &=\int_{-\pi}^0 x \cos(kx) \, dx+\int_0^\pi (-x \cos(kx)) \, dx&&\text{(breaking the integral up using the piecewise definition of }f(x)\text{)}\\ &=\int_{-\pi}^0 x \cos(kx) \, dx-\int_0^\pi x \cos(kx) \, dx \, . \end{align*} {/eq}

To proceed, we'll compute the indefinite integral of {eq}x \cos(kx) {/eq}, using integration by parts. We let {eq}u=x {/eq} and {eq}dv=\cos(kx) \, dx {/eq}; then {eq}du=dx {/eq} and we can take {eq}v=\frac{1}{k}\sin(kx) {/eq}. We therefore have:

{eq}\begin{align*} \int x \cos(kx) \, dx &= x\left(\frac{1}{k}\sin(kx)\right)-\int \frac{1}{k}\sin(kx) \, dx&&\text{(integrating by parts as above)}\\ &=\frac{x}{k}\sin(kx)-\int \frac{1}{k} \sin(kx) \, dx\\ &=\frac{x}{k}\sin(kx)-\frac{1}{k^2}(-\cos(kx)) + C&&\text{(evaluating the remaining integral)}\\ &=\frac{x}{k}\sin(kx)+\frac{1}{k^2}\cos(kx) + C \, . \end{align*} {/eq}

Returning to the original definite integral, we have:

{eq}\begin{align*} \int_{-\pi}^0 x \cos(kx) \, dx - \int_0^\pi x\cos(kx) \, dx&=\left(\frac{x}{k}\sin(kx)+\frac{1}{k^2}\cos(kx)\right|_{-\pi}^0-\left(\frac{x}{k}\sin(kx)+\frac{1}{k^2}\cos(kx)\right|_0^\pi&&\text{(evaluating the integrals using the antiderivative computed above)}\\ &=\left[\frac{0}{k}\sin(k \cdot 0)+\frac{1}{k^2}\cos(k \cdot 0)-\frac{-\pi}{k}\sin(-k\pi)-\frac{1}{k^2}\cos(-k\pi)\right]-\left[\frac{\pi}{k}\sin(k\pi)+\frac{1}{k^2}\cos(k\pi)-\frac{0}{k}\sin(k \cdot 0)-\frac{1}{k^2}\cos(k \cdot 0)\right]\\ &=\frac{1}{k^2}-\frac{1}{k^2}(-1)^k+\frac{1}{k^2}(-1)^k+\frac{1}{k^2}&&\text{(because }\sin(k\pi)=0\text{ and }\cos(k\pi)=(-1)^k\text{)}\\ &=\frac{2}{k^2} \, . \end{align*} {/eq}

Finally, {eq}f(x) {/eq} is an even function, and so {eq}f(x)\sin(kx) {/eq} is an odd function for all {eq}k>0 {/eq}. It follows that {eq}\displaystyle b_k=\int_{-\pi}^\pi f(x) \sin(kx) \, dx {/eq} is the integral of an odd function over an interval which is symmetric around zero, so {eq}b_k=0 {/eq} for all {eq}k>0 {/eq}.

Putting all this together, the {eq}n {/eq}th Fourier polynomial is

{eq}\begin{align*} T_n(x)&=\frac{a_0}{2}+\sum_{k=1}^n \left(a_n \cos(kx)+b_n\sin(kx)\right)\\ &=\frac{-\pi}{2}+\sum_{k=1}^n \left(\frac{2}{k^2}\cos(kx)+0\sin(kx)\right)&&\text{(by the above Fourier coefficient calculations)}\\ &=-\frac{\pi}{2}+\sum_{k=1}^n \frac{2}{k^2} \cos(kx) \, . \end{align*} {/eq}

In summary, the {eq}n {/eq}th Fourier polynomial of {eq}f(x) {/eq} is {eq}\boxed{-\frac{\pi}{2}+\sum_{k=1}^n \frac{2}{k^2} \cos(kx)}\, {/eq}.