# Homework Help: Fourier Series Concept Help!

1. May 6, 2009

### hydralisks

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

Compute the fourier sine series for the given function:

f(x) = -1 0<x<1

2. Relevant equations

http://mathworld.wolfram.com/FourierSineSeries.html

3. The attempt at a solution

I got:

bn = 2 * integral( (-1) * sin(npix) dx) from 0 to 1
= 2*(-1)^n/(npi)

however, the answer in the back of the book turns n=2k-1
I don't get why it does this! For most of the problems I've done so far, n has always just been n, why did they suddenly replace it with 2k-1?
How do I know when I should set n equal to something and when not to? How do I know what n should be equal to?

2. May 6, 2009

### Pengwuino

You did not do your integral correctly. Also, there is no reason to multiply the integral by 2. Redo the integration and you'll see why the index is 2n-1 (since n and k are both simply indices) instead of just n.

3. May 6, 2009

### hydralisks

In that case, I do not know how to do the integral. I'm not sure what's wrong, here's a step by step:

bn = 2 * integral (-1 * sin(n pi x) dx) limits 0 to 1
= -2 * [-cos(n pi x) / (n pi)] from 0 to 1
= 2 * (cos(n pi)/(n pi)
= 2 * (-1)^n / (n pi)

4. May 6, 2009

### Pengwuino

Remember, Cos[n*pi*0] isnt 0 :)

Also, so that there is no confusion, you will see that half the terms of the summation disappear so remember to write your final summation with that in mind (namely, the denominator in the summation will not be simply n*pi.)

5. May 6, 2009

### hydralisks

AH! Too much frustration has made me delusional!

bn = (2/(n pi)) * (cos(n pi) - 1)

I still don't get the correct answer as the book

f(x) = sum of bn * sin(n pi x) according to the formula

f(x) = (-4/pi) * sum of ( (1/(2k-1)) * sin(2k-1)*pi x)

6. May 6, 2009

### Pengwuino

Well think about it, $$Cos(n\pi ) - 1 = ( - 1)^n - 1$$ which is 0 for n = even, -2 for n=odd. $$B_n$$ is 0 for every other term which introduces that 2k-1. Thus your $$B_n$$ can be reduced to odd n's (that is, say $$B_n = 0$$ for even values of n and $$B_n = \frac{{ - 2}}{{n\pi }}$$ for odd n). You can rewrite n in terms of that new index, 2k-1 so that you can keep your fourier series as a sum from 1 to infinity in your final product.

7. May 6, 2009

### hydralisks

Sorry I'm kinda slow but you totally lost me. Unfortunately my book doesn't really explain this part.

So is my answer "correct" but the book's answer is just a different way to write it?

If not, is my fourier series no longer a sum from 1 to infinity? If not, what is it and why did it change?

Also, I don't understand the even and odd stuff, why is that important? Why do I need to change cosine to (-1)^n?

And finally, how exactly did you get (2k-1) from all of that?

Sorry for all of the questions but I'm quite confused!

8. May 6, 2009

### Pengwuino

Ok made a mistake earlier, you do multiply by 2, i forgot the function was constant. Here's what's going on:

$$\begin{array}{l} f(x) = \sum\limits_{n = 1}^\infty {B_n \sin (n\pi x)} \\ B_n = 2\int_0^1 { - 1\sin (n\pi x)dx} \\ B_n = 2\left[ {\frac{{\cos (n\pi x)}}{{n\pi }}} \right]_0^1 \\ B_n = 2\frac{{\cos (n\pi ) - \cos (0)}}{{n\pi }} \\ B_n = 2\frac{{( - 1)^n - 1}}{{n\pi }} \\ \end{array}$$

But you know cos(n*pi) = (-1)^n so you know for every even n, $$B_n = 0$$ and for every odd n,$$B_n = 2\frac{{ - 2}}{{n\pi }}$$ Which means your fourier series looks like

$$f(x) = \sum\limits_{n = 1}^\infty {2\frac{{( - 1)^n - 1}}{{n\pi }}\sin (n\pi x)}$$

However, since only the odd n's exist in this series, you can write the series as

$$f(x) = \sum\limits_{n = 1,odd}^\infty {-4\frac{1}{{n\pi }}} \sin (n\pi x)$$

Which can be written out in a hopefully more helpful way...

$$f(x) ~2\frac{{ - 2}}{{1\pi }}\sin (1\pi x) + 2\frac{{ - 2}}{{3\pi }}\sin (3\pi x) + 2\frac{{ - 2}}{{5\pi }}\sin (5\pi x) + ...$$

Thus the change to n=2k-1 allows you to write it back in a fourier series form of

$$f(x) = \sum\limits_{k = 1}^\infty { - 4\frac{1}{{(2k - 1)\pi }}} \sin ((2k - 1)\pi x)$$

Last edited: May 6, 2009
9. May 6, 2009

### Pengwuino

Ok that shoudl be finally right, i keep making stupid mistakes :)

10. May 6, 2009

### hydralisks

It's starting to make a little more sense, thanks.

First off, is it just known that cos(npi) = (-1)^n?
Does sin(npi) equal anything useful then? I also see (-1)^(n+1) in some of the solutions, is there a "formula" for that as well?

So what if every even Bn did not = 0. How would I "combine" the odd and even summations to form a final answer?

Also, it seems like
$$f(x) = \sum\limits_{n = 1,odd}^\infty {2\frac{{( - 1)^n - 1}}{{n\pi }}\sin (n\pi x)}$$

is equal to
$$f(x) = \sum\limits_{k = 1}^\infty { - 4\frac{1}{{(2k - 1)\pi }}} \sin ((2k - 1)\pi x)$$

So both answers should be correct if I answered them on a test?

And, I see what the (2k-1) does and how it works here. However, how did you know to use n=2k-1 without "guessing"?

Thanks for all the help so far, I really appreciate it!

11. May 6, 2009

### Pengwuino

$$\cos (n\pi ) = \mathop { - 1}\nolimits^n$$ is fairly obvious if you look at the graph of cosine. At n=1, $$\cos (\pi) = -1$$, at n=2, $$\cos (2\pi) = 1$$ and so on and so forth. Now $$\sin (n\pi) = 0$$ always because at every integer pi, sine is 0.

Typically $$B_n$$ is not going to have this even and odd business going on, you're simply going to get $$B_n$$ equal to some function of n.

Both answers are correct, as you can see if you start expanding it out although the first one could be changed to simply -4 instead of -2*((-1)^n - 1) since you already say that n = odd.

12. May 6, 2009

### hydralisks

Thanks for all the help! I definitely get almost all of the content now but I still don't really understand how you know to equate n=2k-1, instead of n= something else
I know why 2k-1 works in this place but how do I think to use that when I'm doing the problem from scratch (without peeking at the answer first)

Also, I feel foolish to have to ask this, but I'm somehow integrating wrong for a different problem:

bn = (1/pi) * integral(x sin(nx) dx) from -pi to pi

I attempt to do this with substitution u=nx

therefore,

bn = 1/(n pi) * integral(u sinu du) from -n*pi to n*pi
= 1/(n pi)* [sinu - ucosu] from -npi to npi
= 1/(n pi)* (2sin(npi) - 2(npi)cos(npi)

However, doing the integral on my calculator, I get this: http://integrals.wolfram.com/index.jsp?expr=x*sin[nx]&random=false which is also my book's answer

13. May 6, 2009

### Cyosis

Integration by parts f(x)=x, g'(x)=sin(nx). Which you've already done at second glance. It looks like you didn't take du=ndx into account, that should give you the n^2.

Last edited: May 6, 2009
14. May 6, 2009

### Pengwuino

Well the only terms left are the n=1,3,5,7,9,11.... etc etc terms, but you like your series to be from some index = 1,2,3,4,5,6... and so on and so forth. How can you change your index to keep the original summation? Well If you let the index go as 2k-1, for k=1,2,3,4,5... you see that you retain the n= 2(1) - 1 = 1, 2(2) - 1 = 3, 2(3) -1 = 5... terms. When you're skipping odds or evens, the change of index will always be 2n plus or minus 1, depending which are skipped and where you start your index (1 or 0, although 1 is customary it seems).

For your second problem, you didn't plug in your limits correctly. Sin(u) = 0 in your limits and ucos(u) will be n*pi*cos(n*pi)+n*pi*cos(-n*pi). Also as noted, you're missing another n from either not substituting in for x correctly or not taking into account du=n*dx