# Integration for Fourier coefficient

1. May 18, 2015

### earthloop

1. The problem statement, all variables and given/known data

I am trying to work out the Fourier coefficient $a_{n}$ for :

Mathematics is not my strong point and I would appreciate some help. The answer that wolfram spits out it lovely and neat and I am struggling to get my answer to it.

2. Relevant equations

3. The attempt at a solution
Apologies for the messy scan, its the best I can do without typing out ALL my working out in LaTeX.
I am really trying to improve my mathematics, so any suggestions on making my expressions neater, or techniques I may have missed, please do let me know.

#### Attached Files:

File size:
3 KB
Views:
169
• ###### Untitled-1.jpg
File size:
53.2 KB
Views:
64
Last edited by a moderator: May 7, 2017
2. May 18, 2015

### BvU

Hello EL,

What Fourier series does Wolfram find ? If I fill in n=1 in the expression in the link I don't think I get a useful coefficient.
It may be lovely and neat, but is it the correct answer for what you are after ?

You are looking for $a_n$, using

for a function that is defined from $0$ to $2\pi$. (Which is also the range you ask Wolfram to integrate over).

But you also post

Does this mean you already know $b_n=0$ or will the sine series come later ?

3. May 19, 2015

### earthloop

Hi BvU,

The wolfram link I gave is just for the $a_{n}$. It is indeterminate at $a_{1}$ and zero for all even numbers thereon. This is fine and to be expected. I have not got round to starting $b_{n}$, I would like to get $a_{n}$ to a workable expression( of $n$) first. At this moment I am not concerned with the fourier series, just the integral mathematics in working out $a_{n}$. Have you had a chance to look at my working out for $a_{n}$, does it seem like its on the right track?

Thanks again

4. May 19, 2015

### BvU

Hello again,

I find it hard to believe a Fourier coefficient can be indeterminate, so I don't think that the elegant result you got from Wolfram is what you where looking for. Check their function "Fourier cos series" (instead of int, and you also remove the *cos etc at the end).

I can't read your jpg and If I could, then I still can't point to places where I would have questions or remarks. How about if you TeX the first step(s) of what you are trying to do, so we can go over things like:
what you are trying to integrate
continuation of the function outside [0,2pi]
limits
a few simple cases (n = 1, 2, ...)
generalization

5. May 19, 2015

### earthloop

This is the example I am following about the a1 being indeterminate....

Here is the first leg of the calculations :

$\displaystyle a_{n} = \frac{V}{\pi}\int_{\frac{\pi}{2}}^{\pi}\sin(\omega t)\cos(n\omega t) \delta\omega t + \frac{V}{\pi}\int_{\frac{3\pi}{2}}^{2\pi}\sin(\omega t)\cos(n\omega t)\delta\omega t$

So in the first step I have evaluated that between 0 and pi/2 the function equals zero and is omitted, same as with pi to 3pi/2. V has been brought outside the integral.

$\displaystyle \frac{V}{2\pi}\int_{\frac{\pi}{2}}^{\pi}\sin(\omega t+n\omega t)+\sin(\omega t -n\omega t)\delta\omega t + \frac{V}{2\pi}\int_{\frac{3\pi}{2}}^{2\pi}\sin(\omega t+n\omega t)+\sin(\omega t -n\omega t)\delta\omega t$

In step two I have used the "product to sum" identity
$\displaystyle \sin\alpha\cos\beta = \frac{1}{2}[\sin(\alpha+\beta)+\sin(\alpha-\beta)]$

$\displaystyle u=\omega t \pm n\omega t \\ \delta u = n \pm 1 \\ \delta\omega t = \frac{\delta u}{n\pm 1}\\ \\ \frac{V}{2\pi}\Big[-\frac{\cos(\omega t + n \omega t)}{n+1} - \frac{\cos(\omega t - n \omega t)}{n-1} \Big]_{\frac{\pi}{2}}^{\pi} + \frac{V}{2\pi}\Big[-\frac{\cos(\omega t + n \omega t)}{n+1} - \frac{\cos(\omega t - n \omega t)}{n-1}\Big]_{\frac{3\pi}{2}}^{2\pi} \\$

Step 3 I have integrated by parts

$\displaystyle \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(\pi + n \pi)}{n+1} - \frac{\cos(\pi - n \pi)}{n-1} \Big] - \Big[-\frac{\cos(\frac{\pi}{2} + n \frac{\pi}{2})}{n+1} - \frac{\cos(\frac{\pi}{2} - n \frac{\pi}{2})}{n-1} \Big]\Bigg] + \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(2\pi + n 2\pi)}{n+1} - \frac{\cos(2\pi - n 2\pi)}{n-1} \Big] - \Big[-\frac{\cos(\frac{3\pi}{2} + n \frac{3\pi}{2})}{n+1} - \frac{\cos(\frac{3\pi}{2} - n \frac{3\pi}{2})}{n-1} \Big]\Bigg]$

step 4 expanding out the limits

$\displaystyle \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(\pi)\cos(n\pi)- \sin(\pi)\sin(n\pi)}{n+1} - \frac{\cos(\pi)\cos(n\pi)+ \sin(\pi)\sin(n\pi)}{n-1} \Big] - \Big[-\frac{\cos(\frac{\pi}{2})\cos(n\frac{\pi}{2})- \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n+1} - \frac{\cos(\frac{\pi}{2})\cos(n\frac{\pi}{2})+ \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n-1} \Big]\Bigg] + \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(2\pi)\cos(n2\pi)- \sin(2\pi)\sin(n2\pi)}{n+1} - \frac{\cos(2\pi)\cos(n2\pi)+ \sin(2\pi)\sin(n2\pi)}{n-1} \Big] - \Big[-\frac{\cos(\frac{3\pi}{2})\cos(n\frac{3\pi}{2})- \sin(\frac{3\pi}{2})\sin(n\frac{3\pi}{2})}{n+1} - \frac{\cos(\frac{3\pi}{2})\cos(n\frac{3\pi}{2})+ \sin(\frac{3\pi}{2})\sin(n\frac{3\pi}{2})}{n-1} \Big]\Bigg]$

step 5 i have used the sum and difference formula:
$\displaystyle\cos(\alpha\pm\beta) = \cos\alpha\cos\beta \mp \sin\alpha\sin\beta$

$\displaystyle \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(\pi)\cos(n\pi)}{n+1} - \frac{\cos(\pi)\cos(n\pi)}{n-1} \Big] - \Big[-\frac{- \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n+1} - \frac{ \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n-1} \Big]\Bigg] + \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(2\pi)\cos(n2\pi)}{n+1} - \frac{\cos(2\pi)\cos(n2\pi)}{n-1} \Big] - \Big[-\frac{- \sin(\frac{3\pi}{2})\sin(n\frac{3\pi}{2})}{n+1} - \frac{ \sin(\frac{3\pi}{2})\sin(n\frac{3\pi}{2})}{n-1} \Big]\Bigg]$

step 6 I have cancelled out the zero cosine and sine terms

$\displaystyle \frac{V}{2\pi}\Bigg[\Big[\frac{\cos(n\pi)}{n+1} + \frac{\cos(n\pi)}{n-1} \Big] - \Big[\frac{\sin(n\frac{\pi}{2})}{n+1} + \frac{ \sin(n\frac{\pi}{2})}{n-1} \Big]\Bigg] + \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(n2\pi)}{n+1} - \frac{\cos(n2\pi)}{n-1} \Big] - \Big[-\frac{ \sin(n\frac{3\pi}{2})}{n+1} + \frac{ \sin(n\frac{3\pi}{2})}{n-1} \Big]\Bigg]$

Step 7 cancelled out the 1 and -1 terms

$\displaystyle \frac{V}{2\pi}\Bigg[\frac{2n\cos(n\pi)-2n\sin(n\frac{\pi}{2})-2n\cos(n2\pi)+2\sin(n\frac{3\pi}{2}))}{n^2-1}\Bigg]$

step 8 consolidated

Here is where I am stuck to carry on....
inputting my last expression into a wolfram table reveals ....LINK

Somewhere I have made a mistake!

Thanks again
EL

6. May 19, 2015

### SammyS

Staff Emeritus
You left out a factor of n from the coefficient of the last sine term in the numerator.

It should be $\ 2n\sin(n\frac{3\pi}{2}) \$.

To find a_1, simply put n = 1 in the integral expression. Then evaluate that.

Last edited: May 19, 2015
7. May 19, 2015

### earthloop

Hi SammyS,

I got the $- \frac{2\, \sin\!\left(\frac{3\, n\, \mathrm{pi}}{2}\right)}{\left(n^2 - 1\right)}$ from simplifying the previous part of the expression $\frac{\sin\!\left(\frac{3\, n\, \mathrm{pi}}{2}\right)}{\left(n + 1\right)} - \frac{\sin\!\left(\frac{3\, n\, \mathrm{pi}}{2}\right)}{\left(n - 1\right)}$
Simplifying gives :
$- \frac{2\, \sin\!\left(\frac{3\, n\, \mathrm{pi}}{2}\right)}{\left(n^2 - 1\right)}$

added back into the expression and corrected ...
$\displaystyle \frac{V}{2\pi}\Bigg[\frac{2n\cos(n\pi)-2n\sin(n\frac{\pi}{2})-2n\cos(n2\pi)-2\sin(n\frac{3\pi}{2}))}{n^2-1}\Bigg]$
Sadly this does not yield the results I am looking for, but it seems closer.
I see I have missed the last minus sign, but I don't see how it can equal $2n\sin(n\frac{3\pi}{2})$.
Do you mean to say that I have made a mistake previous to this?

thanks

8. May 19, 2015

### SammyS

Staff Emeritus
I think I was mainly looking at patterns, but now that you mention it: There is an error going from step 5 to step 6..

In eqach of the two groups of expressions with sin() , the sines have opposite sign. That is what cancels n & gives a two.

So in step 6, that first sin() expression should not have a coefficient n, just 2 .

9. May 19, 2015

### earthloop

Sorry I am not following you, can you show me more visually what you mean?

10. May 19, 2015

### earthloop

1. The problem statement, all variables and given/known data
I am trying to work out the Fourier coefficient $a_{n}$for :

2. Relevant equations

3. The attempt at a solution

$\displaystyle a_{n} = \frac{V}{\pi}\int_{\frac{\pi}{2}}^{\pi}\sin(\omega t)\cos(n\omega t) \delta\omega t + \frac{V}{\pi}\int_{\frac{3\pi}{2}}^{2\pi}\sin(\omega t)\cos(n\omega t)\delta\omega t$

So in the first step I have evaluated that between 0 and pi/2 the function equals zero and is omitted, same as with pi to 3pi/2. V has been brought outside the integral.

$\displaystyle \frac{V}{2\pi}\int_{\frac{\pi}{2}}^{\pi}\sin(\omega t+n\omega t)+\sin(\omega t -n\omega t)\delta\omega t + \frac{V}{2\pi}\int_{\frac{3\pi}{2}}^{2\pi}\sin(\omega t+n\omega t)+\sin(\omega t -n\omega t)\delta\omega t$

In step two I have used the "product to sum" identity
$\displaystyle \sin\alpha\cos\beta = \frac{1}{2}[\sin(\alpha+\beta)+\sin(\alpha-\beta)]$

$\displaystyle u=\omega t \pm n\omega t \\ \delta u = n \pm 1 \\ \delta\omega t = \frac{\delta u}{n\pm 1}\\ \\ \frac{V}{2\pi}\Big[-\frac{\cos(\omega t + n \omega t)}{n+1} - \frac{\cos(\omega t - n \omega t)}{n-1} \Big]_{\frac{\pi}{2}}^{\pi} + \frac{V}{2\pi}\Big[-\frac{\cos(\omega t + n \omega t)}{n+1} - \frac{\cos(\omega t - n \omega t)}{n-1}\Big]_{\frac{3\pi}{2}}^{2\pi} \\$

Step 3 I have integrated by parts

$\displaystyle \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(\pi + n \pi)}{n+1} - \frac{\cos(\pi - n \pi)}{n-1} \Big] - \Big[-\frac{\cos(\frac{\pi}{2} + n \frac{\pi}{2})}{n+1} - \frac{\cos(\frac{\pi}{2} - n \frac{\pi}{2})}{n-1} \Big]\Bigg] + \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(2\pi + n 2\pi)}{n+1} - \frac{\cos(2\pi - n 2\pi)}{n-1} \Big] - \Big[-\frac{\cos(\frac{3\pi}{2} + n \frac{3\pi}{2})}{n+1} - \frac{\cos(\frac{3\pi}{2} - n \frac{3\pi}{2})}{n-1} \Big]\Bigg]$

step 4 expanding out the limits

$\displaystyle \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(\pi)\cos(n\pi)- \sin(\pi)\sin(n\pi)}{n+1} - \frac{\cos(\pi)\cos(n\pi)+ \sin(\pi)\sin(n\pi)}{n-1} \Big] - \Big[-\frac{\cos(\frac{\pi}{2})\cos(n\frac{\pi}{2})- \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n+1} - \frac{\cos(\frac{\pi}{2})\cos(n\frac{\pi}{2})+ \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n-1} \Big]\Bigg] + \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(2\pi)\cos(n2\pi)- \sin(2\pi)\sin(n2\pi)}{n+1} - \frac{\cos(2\pi)\cos(n2\pi)+ \sin(2\pi)\sin(n2\pi)}{n-1} \Big] - \Big[-\frac{\cos(\frac{3\pi}{2})\cos(n\frac{3\pi}{2})- \sin(\frac{3\pi}{2})\sin(n\frac{3\pi}{2})}{n+1} - \frac{\cos(\frac{3\pi}{2})\cos(n\frac{3\pi}{2})+ \sin(\frac{3\pi}{2})\sin(n\frac{3\pi}{2})}{n-1} \Big]\Bigg]$

step 5 i have used the sum and difference formula:
$\displaystyle\cos(\alpha\pm\beta) = \cos\alpha\cos\beta \mp \sin\alpha\sin\beta$

$\displaystyle \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(\pi)\cos(n\pi)}{n+1} - \frac{\cos(\pi)\cos(n\pi)}{n-1} \Big] - \Big[-\frac{- \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n+1} - \frac{ \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n-1} \Big]\Bigg] + \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(2\pi)\cos(n2\pi)}{n+1} - \frac{\cos(2\pi)\cos(n2\pi)}{n-1} \Big] - \Big[-\frac{- \sin(\frac{3\pi}{2})\sin(n\frac{3\pi}{2})}{n+1} - \frac{ \sin(\frac{3\pi}{2})\sin(n\frac{3\pi}{2})}{n-1} \Big]\Bigg]$

step 6 I have cancelled out the zero cosine and sine terms

$\displaystyle \frac{V}{2\pi}\Bigg[\Big[\frac{\cos(n\pi)}{n+1} + \frac{\cos(n\pi)}{n-1} \Big] - \Big[\frac{\sin(n\frac{\pi}{2})}{n+1} + \frac{ \sin(n\frac{\pi}{2})}{n-1} \Big]\Bigg] + \frac{V}{2\pi}\Bigg[\Big[-\frac{\cos(n2\pi)}{n+1} - \frac{\cos(n2\pi)}{n-1} \Big] - \Big[-\frac{ \sin(n\frac{3\pi}{2})}{n+1} + \frac{ \sin(n\frac{3\pi}{2})}{n-1} \Big]\Bigg]$

Step 7 cancelled out the 1 and -1 terms

$\displaystyle \frac{V}{2\pi}\Bigg[\frac{2n\cos(n\pi)-2n\sin(n\frac{\pi}{2})-2n\cos(n2\pi)-2\sin(n\frac{3\pi}{2}))}{n^2-1}\Bigg]$

step 8 consolidated

Here is where I am stuck to carry on.... I I have made a mistake somewhere because inputting my expression doesn't yield the same results as the answer given in the old thread.
Maths isn't my strong point and I would love to know where I have gone wrong.

Thanks again
EL

11. May 19, 2015

### Staff: Mentor

12. May 19, 2015

### SammyS

Staff Emeritus
The part of step 5 I was referring to is:
$\displaystyle \ - \left[-\frac{- \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n+1} - \frac{ \sin(\frac{\pi}{2})\sin(n\frac{\pi}{2})}{n-1} \right] \$

What you should have for the corresponding part of step 6 is:
$\displaystyle \ - \left[\frac{\sin(n\frac{\pi}{2})}{n+1} - \frac{ \sin(n\frac{\pi}{2})}{n-1} \right] \$

not
$\displaystyle \ - \left[\frac{\sin(n\frac{\pi}{2})}{n+1} + \frac{ \sin(n\frac{\pi}{2})}{n-1} \right] \$

13. May 20, 2015

### earthloop

Thanks for the continual effort SammyS!

The corrected final term is $\displaystyle \frac{V}{2\pi}\Bigg[\frac{2n\cos(n\pi)+2\sin(n\frac{\pi}{2})-2n\cos(n2\pi)-2\sin(n\frac{3\pi}{2}))}{n^2-1}\Bigg]$

Matlab simplifys this to $\frac{2\, v\, \sin\!\left(\frac{n\, \mathrm{pi}}{2}\right)\, \left(2\, {\sin\!\left(\frac{n\, \mathrm{pi}}{2}\right)}^2 + n\, \sin\!\left(\frac{3\, n\, \mathrm{pi}}{2}\right) - 1\right)}{\mathrm{pi}\, \left(n^2 - 1\right)}$

I'm not sure how this has been simplified, any ideas?

The new expression yields almost identical results to the compared answer, except my results are all negative.

my results:
n=1 gives indeterminate
n=3 gives -v/pi
n=5 gives -v/(3*pi)
n=7 gives -v/(3*pi)
n=9 gives -v/(5*pi)

In comparison to the "answer" table

Also... a comparison between the actual expression worked out by wolfram LINK

Compared with my final expression simplified in wolfram LINK

gives

I can see the differences are that one expression is negative, the other isn't (explaining why I have negative answers) and the top part of the expression, N is multiplied by the cos term, not the sin term.

So close!

I will have another thorough check of all my workings out later today, but do you have any insight into how I can simplify the final expression as much as possible, so that it resembles something like what matlab/wolfram spits out?

Thanks again

14. May 20, 2015

### SammyS

Staff Emeritus
I get the impression that you're stumped in two ways. One is the indeterminate nature of coefficient, a1 . The other is that you're not quite producing the correct values for the other coefficients.

Let's look at what's going on with a1.

I did suggest in a previous post, that you simply evaluate you're initial integral directly with a value of 1 inserted for n.
but...

Let's what it is about n = 1 that causes the general result you have to be in error. (the indeterminate thing)

It's just the (n-1) factor which produces the problem. So let's consider the following indefinite integral.
$\displaystyle\ \int \sin(\omega t -n\omega t)\delta\omega t$​

First of all, if n = 1, then the integrand becomes sin(0) which is zero, thus the definite integral resulting from this is zero.

If you consider the substitution, $\ u=\omega t - n\omega t\$, you get $\displaystyle\ \delta u = (1-n)\delta\omega t\$. (Maybe this is the source of your sign error.)

When you solve for $\ \delta\omega t\$, you get $\displaystyle\ \delta\omega t = \frac{\delta u}{1-n}\$.

See the problem if n = 1 ?

Last edited: May 20, 2015
15. May 20, 2015

### earthloop

Ok yes, got it, thanks for that! I can see how $a_{1}=-\frac{v}{pi}$. Sadly I haven't had a time today to check my expression, but I will tomorrow, I'm sure I will find the mistake!

Thanks again
EL

16. May 21, 2015

### earthloop

Ok I have managed to get the correct results, after correcting the substitution to 1-n and rewriting the expression. Thanks for your help!

I now have simplified the expression as much as I can to
$\displaystyle\frac{v\bigg(\cos(n\pi)+n\sin(n\frac{\pi}{2})-\cos(n2\pi)-n\sin(n\frac{3\pi}{2})\bigg)}{\pi(1-n^2)}$

Yet wolfram still simplifies it even more into :
$- \frac{2\, v\, \sin\!\left(\frac{n\, \mathrm{\pi}}{2}\right)\, \left(\sin\!\left(\frac{3\, n\, \mathrm{\pi}}{2}\right) - n\, \cos\!\left(n\, \mathrm{\pi}\right)\right)}{\mathrm{\pi}\, \left(n^2 - 1\right)}$

Any idea how it achieved this? A trig identity? I couldn't see where any would help me.

After this I'll be well prepared for working out $b_{n}$!!

Thanks again
EL

17. May 21, 2015

### SammyS

Staff Emeritus
Difference to product.

18. May 21, 2015

### earthloop

Ah ok got it now. Thanks very much for all the help!

EL