Homework Help: Help solving fourier cosine series related problem

1. Feb 4, 2016

RJLiberator

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

I am doing #9.

2. Relevant equations

3. The attempt at a solution
I've been looking at a lot of similar problems on the internet. The main difference between this one and them is that this one has an interval of [0,4] while they often have intervals of [0,pi] or [-pi,pi]

In my class, we discussed using change of variables to make it into some form.

I thought maybe I could work with [-2,2] and call it an even function letting [-2,2] f(x) = 1.

But I didn't get anywhere with this.

It's, once again, one of these problems where once I get the first step, I feel like I will be off to the races.

The answer to this problem is:
(4/pi)∑[(-1)^(n+1)/(2n-1)]*[cos[(2n-1)*pi*x/4]]

2. Feb 4, 2016

RJLiberator

Here's some of my further work.

We wish to represent this as a cosine series.

f(x) = 1 = ∑a_n*cos(n*pi*x/L)

a_n = 2/L integral from 0 to L of f(x) * cos(n*pi*x/L)dx
= 2/L integral from 0 to L cos(n*pi*x/L) dx
= (2/L)*(L/(n*pi))*[sin(n*pi*x/L)] from 0 to L

= 2/L *L/(n*pi) * sin((n*pi)-0)

The problem here is, is that sin(n*pi) is always equal to 0.

:/

3. Feb 4, 2016

RJLiberator

I think I am on to something.

So, in my post above, I solved only half of the problem (I think) from 0 to 2.

But, f(x) = -1 from 2 < x < 4
so we solve the other half, similarly

2/L *L/(n*pi) * sin((n*pi)-sin(n*pi/2))
= 2/(n*pi)*(-sin(n*pi/2))

Here, sin(n*pi/2) is either 1 or -1 (when odds) or 0 (when even)

So if we add the two (or subtract, not sure which one yet) solutions together we get
0 +/- (-2/(n*pi))(-1)^n
where n is odd

the sum starts to look like the answer from the book when we make the switch from n to 2n+1 for the summation so that all n values become odd.

2/pi ∑[(-1)^(n+1)/(2n+1)]*[cos[(2n+1)*pi*x/4]]

4/pi∑[(-1)^(n+1)/(2n-1)]*[cos[(2n-1)*pi*x/4]]

Not sure if this is at all correct, but it's looking closer and closer like the solution. Not sure how I got 2/pi instead of 4/pi and the - and + signs are killing me.

4. Feb 4, 2016

vela

Staff Emeritus
Doesn't the problem ask you for a sine series? You want to extend the function for x<0 so that f(-x) = f(x).

This is right for the cosine series, but you're assuming here that $n\ne 0$. You need to consider that case separately.

5. Feb 4, 2016

vela

Staff Emeritus
Oh, you're doing #9. Never mind. ;)

6. Feb 4, 2016

RJLiberator

If n equals 0 we have sin(n*pi) = 0 and an n in the denominator. That's no good!

a_0 = 2/pi based on
1/pi* integral from 0 to 2 of 1

(from the definition of cosine a_0)

Was I correct in my latest post suggesting that I should also look at the 2 <x < 4 part and add/subtract that to the 0 part ?

7. Feb 4, 2016

vela

Staff Emeritus
Remember $a_0$ is the average value of the function, so in this case, you expect $a_0=0$. For a constant function f(x)=1, you would have gotten $a_0=1$.

To answer your question, yes, you have to integrate over the entire cycle.
$$a_n = \frac 2L \int_0^4 f(x)\cos\left(\frac{2\pi n}{L} x\right)\,dx = \frac 2L \int_0^2 f(x)\cos\left(\frac{2\pi n}{L} x\right)\,dx + \frac 2L \int_2^4 f(x)\cos\left(\frac{2\pi n}{L} x\right)\,dx$$ You just need to evaluate the integral piecewise since f(x) is defined piecewise.

8. Feb 4, 2016

RJLiberator

Are you sure that the cosine function takes on the argument of (2*pi*n*x / L) instead of just pi*n*x/L ?

I have not seen that on other websites .

9. Feb 4, 2016

RJLiberator

In the second term, I would think L aka the length, would be equal to 2 and not 4.
If this is true, then we have 0 + 0 and this doesn't make any sense to me.
However, If L = 4 then I am on my way to the solution, but I don't understand why it would equal 4.

10. Feb 4, 2016

vela

Staff Emeritus
I made a mistake. You're right. For the general Fourier series, you're expanding in multiples of the fundamental frequency $\frac{2\pi}{T}$, where $T$ is the period.

Here, the function is defined from 0 to $L$, but you're extending it to an even function defined on $[-L,L]$ so $T=2L$.

11. Feb 4, 2016

RJLiberator

Ah, so L does equal 2 but since we are extending it, 2*2 = 4 and now I can solve it.

:).

12. Feb 4, 2016

vela

Staff Emeritus
No, $L=4$ and $T=8$. Look at the interval the original function is defined on.