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

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) = \left\{\begin{matrix} -x \text{ if } -\pi < x < 0\\\pi - x \text{ if } 0 < x < \pi \end{matrix}\right. \!$$

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 \!$$

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

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

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

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

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

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

$$ a_{0} = 0 \!$$

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

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

Using integration by parts with the following substitutions for the integral $$ \int_{-\pi}^{0} x cos(nx) dx \!$$:

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

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

Using integration by parts with the following substitutions for the integral $$ \int_{0}^{\pi} (\pi - x) cos(nx) dx \!$$:

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

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

This yields for the overall expression:

$$ 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} (\pi - 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} (\pi - 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^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} - 0 - \frac{1}{n^2}cos(-n \pi) \right] + \left[-\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} (\pi - x) sin(nx) dx \right ) \!$$

Using integration by parts with the following substitutions for the integral $$ \int_{-\pi}^{0} x sin(nx) dx \!$$:

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

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

Using integration by parts with the following substitutions for the integral $$ \int_{0}^{\pi} (\pi - x) sin(nx) dx \!$$:

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

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

This yields for the overall expression:

$$ 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}(\pi - 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}(\pi- 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^2}sin(n\pi) - \left( \frac{-1}{n}\pi \right) \right] \right ) \!$$

$$ b_{n} = \frac{1}{\pi} \left( - \frac{1}{n} \pi cos(-n\pi) - \frac{1}{n^2}sin(-n \pi) - \frac{1}{n^2}sin(n\pi) + \frac{1}{n}\pi   \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( - \frac{1}{n} \pi cos(-n\pi) -0 - 0 + \frac{1}{n}\pi   \right ) \!$$

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

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

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

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

$$ b_{n} = \frac{1}{n} \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 $$ b_{n} \!$$, all even terms will equal zero while all odd terms will have a multiplier of 2, this yields (for all odd n values):

$$ b_{n} = \frac{2}{n} \text{ for  } n = 1,3,5... \!$$

In conclusion, the Fourier series representation for the given function is as follows:

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

$$ f(x) = \frac{4}{\pi} \left (cos(x) + \frac{1}{9} cos(3x) + \frac{1}{25} cos(5x) + ... \right ) + 2 \left (sin(x) + \frac{1}{3} sin(3x) + \frac{1}{5} sin(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)