# Homework Help: Can (1-cos(npi))=(-1)^(n+1)?

1. Dec 9, 2011

### RUrubee2

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

To find the Fourier series for

f(x)=
0, -2<x<0
x, 0≤x<1
1, 1≤x<2

2. Relevant equations

f(x)=a_0/2+Ʃ(from n=0 to ∞) (a_n*cos(npix/p) + b_n*sin(npix/p))

3. The attempt at a solution

So p=2, interval=[-2,2]

a_0=3/4,

a_n=(2/n^2pi^2)*(cos(npi/2)-1),

Here is my problem:

did the exercise twice and keep getting:

b_n=(2/n^2pi^2)(sin(npi/2)+(npi/2)*(1-cos(npi))

I have the solution:

b_n=(2/n^2pi^2)(sin(npi/2)+(npi/2)*(-1)^(n+1))

I know cos(npi)=(-1)^n

and I've been told sin(npi)=(-1)^(n+1)

My steps:

1) b_n=1/2[∫(from 0 to 1) x*sin(npix/2)dx + ∫(from 1 to 2) sin(npix/2)dx]

2) integration by parts for 1st integral and subsequent integration:

→ b_n=1/2[-(2x/npi)cos(npix/2)|(0 to 1) + (4/n^2pi^2)sin(npix/2)|(0 to 1) - (2/npi)cos(npix/2)|(1 to 2)]

3) I am left with:

b_n=1/2[(2/npi) + (4/n^2pi^2)sin(npi/2) - (2/npi)cos(npi)

after regrouping is where (1-cos(npi)) comes from.

Thus original question is:

Can (1-cosnpi)=(-1)^(n+1)? or am I mistaken somewhere?

Thank you

Last edited: Dec 9, 2011
2. Dec 9, 2011

### HallsofIvy

I don't know where you got "$sin(n\pi)= (-1)^{n+1}= 1- cos(n\pi)$". None of those equalities is correct.

$sin(n\pi)= 0$ for all n, not a power of -1. $cos(n\pi)= -1$ if n is odd, 1 if n is even so $cos(n\pi)= (-1)^n$ and $1+ cos(n\pi)$ is 2 if n is even, 0 if n is odd.

3. Dec 9, 2011

### RUrubee2

As I said, I "know cos(npi)=(-1)^n and I was told sin(npi)=(-1)^(n+1)" so I believe you that it is wrong. I imagine that that someone wanted to say sin(npi/2)=(-1)^(n+1)???

As for the "equalities", I was wondering, not stating, seeing as the equations "looked" similar.

Therefore, if all this is wrong, would it be possible for you to help me figure out where I went wrong?

I think it safe to say I will remove that "P.S." from the question so as not to confuse...

Last edited: Dec 9, 2011
4. Dec 9, 2011

### LCKurtz

Why would you imagine that? Try it with n = 0 or 2.

5. Dec 9, 2011

### LCKurtz

Your an is correct but I think your a0 should be -5/4.
I didn't check your remaining steps, but what about the integral from -2 to 0?

Last edited: Dec 9, 2011
6. Dec 9, 2011

### RUrubee2

The reason I "imagine" that is because I had some sort of logic in my head that said that if
sin(npi/2)=something, when n is an odd number than n+1 was gonna give me an odd number...
I see as I try to explain that it doesn't always work. But I had "sin(npi)=(-1)^(n+1) in my class notes which is a mistake and probably didn't help my understanding...

The thing is that in my school book. It keeps telling me things like "=(-1)^(n+1).
And a similar problem to my initial question just popped up again:

Expand f(x)=x, -2<x<2
x = Odd f(x)
Thus
b_n = ∫ (0 to 2) x*sin(npix/2)dx

When I do this, I get (-4/npi)cos(npi)

and it gives me (4/npi)(-1)^(n+1)

as in original post, I was getting: (1-cos(npi)) and the answer was (-1)^(n+1)

So is it when there is a negative in front that I have to do ^(n+1)???

Could someone please respond to the actual question about where (-1)^(N+1) comes from...

Last edited: Dec 9, 2011
7. Dec 9, 2011

### RUrubee2

@ LCKurtz
The answer in the book is 3/8 for a_0/2
And the -2 to 0 disappears 'cause the function is 0 on that interval
P.S. Thank you for trying to help me with the real question

8. Dec 9, 2011

### vela

Staff Emeritus
This is right.

This is wrong. You're making another error somewhere, which is causing you to mistakenly think that $1-\cos n\pi = (-1)^{n+1}$ must hold. You need to turn this around. The latter equality is obviously wrong, which means you must have made a mistake somewhere, so you should be looking for it.

It seems a bit strange that you're struggling with basic algebra when you're learning about Fourier series. There's nothing mysterious going on here:
$$-(-1)^n = (-1)(-1)^n = (-1)^{n+1}$$

9. Dec 9, 2011

### RUrubee2

My brain works in VERY mysterious ways, but thank you. That does clear things up.
I am working hard on trying to figure out where my mistake is.
I get confused when sometimes the answer is (-1)^(n+1)
and in other cases like:

b_n=(2/pi)∫(0 to pi)sin(nx)dx

I get (2/npi)(1-cos(npi))and the answer in that case is (2/pi)(1-(-1)^n)/n