# Finding the Fourier Coefficients for mechanics homework

1. Mar 10, 2015

### \Theta

1. The problem statement, all variables and given/known data
Find the Fourier Coefficients for the triangular wave equation shown in this picture:

2. Relevant equations
$f(t)= a_0 + \sum_{n=1}^\infty a_{n}cos(n{\omega}t) + \sum_{n=1}^\infty b_{n}sin(n{\omega}t)$
$a_0 = \frac{1}{\tau}\int_{-\tau/2}^{\tau/2} f(t) \, dt$
$\omega = \frac{2\pi}{\tau}$
$a_n = \frac{2}{\tau}\int_{-\tau/2}^{\tau/2}f(t)cos(n\omega t) \, dt$
$b_n = \frac{2}{\tau}\int_{-\tau/2}^{\tau/2}f(t)sin(n\omega t) \, dt = 0, \forall n$, because it's an even function
3. The attempt at a solution
$\tau = 2$
$a_0 = \frac{1}{2}\int_{-1}^{1} 1-|t| \, dt= \frac{1}{2}[\int_{-1}^{0} 1+t \, dt+\int_{0}^{1} 1-t \, dt]=\frac{1}{2} [\frac{1}{2}+\frac{1}{2}]=\frac{1}{2} .$

$a_n = \frac{2}{2}\int_{-1}^{1}f(t)cos(n\omega t) \, dt= \int_{-1}^{0}(1+t)cos(n\omega t) \, dt + \int_{0}^{1}(1-t)cos(n\omega t) \, dt ,$
Which, when computed through many tiresome intermediate steps, gives:
$a_n= \frac{2}{n^2\pi^2}$, which differs from the answer in the textbook, $a_n= \frac{4}{n^2\pi^2}, n=1,3,5,7,...; a_n=0, n=2,4,6,8,10,...$

So my question is, have I set up the problem correctly and made a computational mistake somewhere along the way in my integrals? Or am I missing something in the setup of the problem and missing the point entirely? It's a *** problem in our textbook(aka the most difficult level) and it's also a "computer problem", so I'm sure my prof won't expect me to do a problem this laborious on a test, but I'd still like to know where I went sour.

Last edited: Mar 10, 2015
2. Mar 11, 2015

### Staff: Mentor

Are you sure about these equation? If yes, what is $\omega$?

3. Mar 11, 2015

### \Theta

Well, these are the generic formula for the Fourier Series for a function. $\omega = \frac{2\pi}{\tau}=\frac{2\pi}{2}=\pi$, I guess I wasn't as explicit about it but I considered it trivial.

4. Mar 11, 2015

### Staff: Mentor

There can be different conventions, so I just wanted to make sure that I understood.

You'll have to give the intermediate steps, because the first line is correct, but the last equality doesn't follow.

5. Mar 11, 2015

### \Theta

Oh, I see what you were asking. Sorry.

$a_n = \frac{2}{2}\int_{-1}^{1}f(t)cos(n\omega t) \, dt= \int_{-1}^{0}(1+t)cos(n\omega t) \, dt + \int_{0}^{1}(1-t)cos(n\omega t) \, dt ,$
$=\int_{-1}^{0}cos(n\omega t) \, dt +\int_{-1}^{0}tcos(n\omega t) \, dt +\int_{0}^{1}cos(n\omega t) \, dt -\int_{0}^{1}tcos(n\omega t) \, dt$
$= \int_{-1}^{1}cos(n\omega t) \, dt +\int_{-1}^{0}tcos(n\omega t) \, dt -\int_{0}^{1}tcos(n\omega t) \, dt$
$= \frac{sin(n{\pi}t)}{n\pi}|_{-1}^1+\int_{-1}^{0}tcos(n\omega t) \, dt -\int_{0}^{1}tcos(n\omega t) \, dt$
$= 0 +[\frac{tsin(n{\pi}t)}{n\pi}+\frac{cos(n{\pi}t)}{n^2\pi^2}|_{-1}^0-[\frac{tsin(n{\pi}t)}{n\pi}+\frac{cos(n{\pi}t)}{n^2\pi^2}|_{0}^1$
$=0 +[0+\frac{cos(n{\pi}t)}{n^2\pi^2}|_{-1}^0-[0+\frac{cos(n{\pi}t)}{n^2\pi^2}|_{0}^1$
$= 0 + \frac{1}{n^2\pi^2}+\frac{1}{n^2\pi^2}-\frac{1}{n^2\pi^2}+\frac{1}{n^2\pi^2}$
$=\frac{2}{n^2\pi^2}$

BTW, thanks a bunch for helping out DrClaude.

6. Mar 11, 2015

### \Theta

I think I see where I went wrong
Looks like it was just a silly case of the negative signs cancelling each other.
Should be:
$=0 +[0+\frac{cos(n{\pi}t)}{n^2\pi^2}|_{-1}^0-[0+\frac{cos(n{\pi}t)}{n^2\pi^2}|_{0}^1$
$=\frac{cos(n\pi)}{n^2\pi^2}+\frac{cos(n\pi)}{n^2\pi^2}+\frac{cos(n\pi)}{n^2\pi^2}+\frac{cos(n\pi)}{n^2\pi^2}$
$= \frac{4cos(n\pi)}{n^2\pi^2}$
$=\frac{4(-1)^n}{n^2\pi^2}$

Last edited: Mar 11, 2015
7. Mar 12, 2015

### Staff: Mentor

Getting closer, but that second line doesn't follow from the first.

8. Mar 12, 2015

### \Theta

$=0 +[0+\frac{cos(n{\pi}t)}{n^2\pi^2}|_{-1}^0-[0+\frac{cos(n{\pi}t)}{n^2\pi^2}|_{0}^1$
$=\frac{cos(0)}{n^2\pi^2} - \frac{cos(-n\pi)}{n^2\pi^2}-\frac{cos(n\pi)}{n^2\pi^2}+\frac{cos(0)}{n^2\pi^2}$
$=\frac{1}{n^2\pi^2} - \frac{cos(-n\pi)}{n^2\pi^2}-\frac{cos(n\pi)}{n^2\pi^2}+\frac{1}{n^2\pi^2}$
$=\frac{1}{n^2\pi^2} - \frac{cos(n\pi)}{n^2\pi^2}-\frac{cos(n\pi)}{n^2\pi^2}+\frac{1}{n^2\pi^2}$
$=\frac{1}{n^2\pi^2} +\frac{1}{n^2\pi^2}+\frac{1}{n^2\pi^2}+\frac{1}{n^2\pi^2}$ when n is odd
and $=\frac{1}{n^2\pi^2} - \frac{1}{n^2\pi^2}-\frac{1}{n^2\pi^2}+\frac{1}{n^2\pi^2}=0$ when n is even
So the Fourier series for the function would be:
$f(t)= a_0 + \sum_{n=1}^\infty a_{n}cos(n{\omega}t) + \sum_{n=1}^\infty b_{n}sin(n{\omega}t)$
$=\frac{1}{2}+\sum_{n=1}^\infty \frac{4}{(2n-1)^2\pi^2}cos((2n-1){\pi}t)$

That looks right. DrClaude, I definitely owe you one.

9. Mar 12, 2015

Case closed.