User:Egm4313.s12.team11.sheider/R.7.4: K 2011 p.482 pb. 12

Problem Statement
Find the Fourier series of the given function which is assumed to have a period of $$ 2 \pi \!$$. Show the details of your work.

Sketch or graph the partial sums up to that including $$ cos(5x) \!$$ and $$ sin(5x) \!$$

Given:

$$f(x) = |x| \!$$

Solution
The Fourier series of a function with a period of $$ p = 2\pi \!$$ is defined:

$$ f(x) = a_{0} + \sum_{n=1}^{\infty } (a_{n}cos(nx) + b_{n}sin(nx))\!$$

Where:

$$ a_{0} = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) dx \!$$

$$ a_{n} = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) cos(nx) dx \!$$

$$ b_{n} = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) sin(nx) dx \!$$

This particular function given in the problem can be also defined in a piecewise manner over this interval, namely:

$$ f(x) = \left\{\begin{matrix} -x \text{ if } -\pi \leq x \leq 0\\x \text{ if } 0 \leq x \leq \pi \end{matrix}\right. \!$$

Calculating the first term $$ a_{0} \!$$:

$$ a_{0} = \frac{1}{2\pi} \left ( \int_{-\pi}^{0} -x dx + \int_{0}^{\pi} x dx \right) \!$$

$$ a_{0} = \frac{1}{2\pi} \left ( \left [\frac{-x^2}{2} \right ]_{-\pi}^{0} + \left [\frac{x^2}{2} \right ]_{0}^{\pi} \right)\!$$

$$ a_{0} = \frac{1}{2\pi} \left ( - \left(\frac{-\pi^2}{2}\right ) + \left (\frac{\pi^2}{2}\right)\right) \!$$

$$ a_{0} = \frac{1}{2\pi} (\pi^2) \!$$

$$ a_{0} = \frac{\pi}{2} \!$$

Calculating the coefficient $$ a_{n} \!$$:

$$ a_{n} = \frac{1}{\pi} \left( \int_{-\pi}^{0} -x cos(nx) dx + \int_{0}^{\pi} x cos(nx) dx \right ) \!$$

$$ a_{n} = \frac{1}{\pi} \left( - \int_{-\pi}^{0} x cos(nx) dx + \int_{0}^{\pi} x cos(nx) dx \right ) \!$$

Using integration by parts with the following substitutions:

$$ u = x \!$$ and therefore $$ du = dx \!$$

$$ dv = cos(nx)dx \!$$ and therefore $$ v = \frac{1}{n}sin(nx) \!$$

This yields for the integral:

$$ a_{n} = \frac{1}{\pi} \left( -\left[\frac{1}{n} x sin(nx) - \int \frac{1}{n}sin(nx)dx \right]_{-\pi}^{0} + \left[\frac{1}{n} x sin(nx) - \int \frac{1}{n}sin(nx)dx \right]_{0}^{\pi} \right ) \!$$

$$ a_{n} = \frac{1}{\pi} \left( -\left[\frac{1}{n} x sin(nx) + \frac{1}{n^2}cos(nx) \right]_{-\pi}^{0} + \left[\frac{1}{n} x sin(nx) + \frac{1}{n^2}cos(nx) \right]_{0}^{\pi} \right ) \!$$

$$ a_{n} = \frac{1}{\pi} \left( -\left[\frac{1}{n^2} - \left (\frac{1}{n} (-\pi) sin(-n\pi) + \frac{1}{n^2}cos(-n \pi) \right) \right] + \left[\frac{1}{n} \pi sin(n\pi) + \frac{1}{n^2}cos(n\pi) - \frac{1}{n^2} \right] \right ) \!$$

Note that for all n = 1,2,3... : $$ sin(n\pi) = 0 \!$$ as $$ sin(\pi) = sin(2\pi) = sin(3\pi) ... = 0 \!$$ therefore these terms are evaluated as zero, which yields:

$$ a_{n} = \frac{1}{\pi} \left( -\left[\frac{1}{n^2} - \left (0 + \frac{1}{n^2}cos(-n \pi) \right) \right] + \left[0 + \frac{1}{n^2}cos(n\pi) - \frac{1}{n^2} \right] \right ) \!$$

$$ a_{n} = \frac{1}{\pi} \left( -\frac{1}{n^2} + \frac{1}{n^2}cos(-n \pi) +  \frac{1}{n^2}cos(n\pi) - \frac{1}{n^2} \right ) \!$$

Note that $$ cos(-x) = cos(x) \!$$ therefore:

$$ a_{n} = \frac{1}{\pi} \left( -\frac{1}{n^2} + \frac{1}{n^2}cos(n \pi) +  \frac{1}{n^2}cos(n\pi) - \frac{1}{n^2} \right ) \!$$

$$ a_{n} = \frac{1}{\pi} \left( -\frac{2}{n^2} + \frac{2}{n^2}cos(n \pi) \right ) \!$$

$$ a_{n} = \frac{1}{\pi} \left (\left ( -\frac{2}{n^2} \right )(1 - cos(n \pi) \right )\!$$

$$ a_{n} = -\frac{2}{n^2\pi} \left (1 - cos(n \pi) \right )\!$$

To evaluate the term $$ (1-cos(n\pi)) \!$$:

Note that $$ cos(n\pi) = -1 \!$$ for odd n values as $$ cos(\pi) = cos(3\pi) = cos(5\pi) ... = -1 \!$$

And that $$ cos(n\pi) = 1 \!$$ for even n values as $$ cos(2\pi) = cos(4\pi) = cos(6\pi) ... = 1 \!$$.

Therefore, it can be concluded that for odd n values:

$$ (1-cos(n\pi)) = 1-(-1) = 2 \!$$

And for even n values:

$$ (1-cos(n\pi) = 1-(1) = 0 \!$$

Therefore, for the coefficient $$ a_{n} \!$$, all even terms will equal zero while all odd terms will have a multiplier of 2, this yields (for all odd n values):

$$ a_{n} = -\frac{4}{n^2\pi} \text{ for  } n = 1,3,5... \!$$

Calculating the coefficient $$ b_{n} \!$$:

$$ b_{n} = \frac{1}{\pi} \left( \int_{-\pi}^{0} -x sin(nx) dx + \int_{0}^{\pi} x sin(nx) dx \right ) \!$$

$$ b_{n} = \frac{1}{\pi} \left( - \int_{-\pi}^{0} x sin(nx) dx + \int_{0}^{\pi} x sin(nx) dx \right ) \!$$

Using integration by parts with the following substitutions:

$$ u = x \!$$ and therefore $$ du = dx \!$$

$$ dv = sin(nx)dx \!$$ and therefore $$ v = \frac{-1}{n}cos(nx) \!$$

This yields for the integral:

$$ b_{n} = \frac{1}{\pi} \left( -\left[\frac{-1}{n} x cos(nx) - \int \frac{-1}{n}cos(nx)dx \right]_{-\pi}^{0} + \left[\frac{-1}{n} x cos(nx) - \int \frac{-1}{n}cos(nx)dx \right]_{0}^{\pi} \right ) \!$$

$$ b_{n} = \frac{1}{\pi} \left( -\left[\frac{-1}{n} x cos(nx) + \frac{1}{n^2}sin(nx) \right]_{-\pi}^{0} + \left[\frac{-1}{n} x cos(nx) + \frac{1}{n^2}sin(nx) \right]_{0}^{\pi} \right ) \!$$

$$ b_{n} = \frac{1}{\pi} \left( -\left[0 - \left (\frac{-1}{n} (-\pi) cos(-n\pi) + \frac{1}{n^2}sin(-n \pi) \right) \right] + \left[\frac{-1}{n} \pi cos(n\pi) + \frac{1}{n^2}sin(n\pi) - 0 \right] \right ) \!$$

Note that for all n = 1,2,3... : $$ sin(n\pi) = 0 \!$$ as $$ sin(\pi) = sin(2\pi) = sin(3\pi) ... = 0 \!$$ therefore these terms are evaluated as zero, which yields:

$$ b_{n} = \frac{1}{\pi} \left( -\left[0 - \left (\frac{-1}{n} (-\pi) cos(-n\pi) + 0 \right) \right] + \left[\frac{-1}{n} \pi cos(n\pi) + 0 \right] \right ) \!$$

$$ b_{n} = \frac{1}{\pi} \left( \left[\frac{1}{n} (\pi) cos(-n\pi) \right] + \left[\frac{-1}{n} \pi cos(n\pi) \right] \right ) \!$$

Note that $$ cos(-x) = cos(x) \!$$ therefore:

$$ b_{n} = \frac{1}{\pi} \left( \frac{1}{n} \pi cos(n\pi) + \frac{-1}{n} \pi cos(n\pi)  \right ) \!$$

$$ b_{n} = \frac{1}{\pi} \left( 0 \right ) \!$$

$$ b_{n} = 0 \!$$ Therefore there will be no $$ sin(nx) \!$$ terms in the Fourier representation. In conclusion, the Fourier series representation for the given function is as follows:

$$ f(x) = \frac{\pi}{2} - \frac{4}{\pi} cos(x) - \frac{4}{3^2 \pi} cos(3x) - \frac{4}{5^2 \pi} cos(5x) + ... \!$$

$$ f(x) = \frac{\pi}{2} - \frac{4}{\pi}\left (cos(x) + \frac{1}{9} cos(3x) + \frac{1}{25} cos(5x) + ... \right ) \!$$

A graph of the function, and the Fourier series for $$ n = 1,3,5 \!$$ is shown below:



--Egm4313.s12.team11.sheider (talk) 06:00, 22 April 2012 (UTC)