How Do You Calculate the Fourier Series of a Piecewise Function with Period 4?

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
9 replies · 3K views
Nallyfish
Messages
6
Reaction score
0

Homework Statement



The function f has period 4 and is such that
f(x)=2+x, -2<x[itex]\leq0[/itex]
f(x)=2, 0<x<2

Sketch the graph of f for x∈[−4, 4] and obtain its Fourier series.


Homework Equations





The Attempt at a Solution



Okay so I've pretty much sketched the graph, but I've been thrown by the 2+x and I'm not sure what to do from this point onwards.

So a0=[itex]\frac{1}{2}[/itex][itex]\int^{2}_{0}2dx[/itex]=2

an=[itex]\frac{1}{2}[/itex][itex]\int^{2}_{0}2*cosnxdx[/itex]

So
an=[itex]\frac{sin2n}{n}[/itex]

And
bn=[itex]\frac{-(cos(2n)-1)}{n}[/itex]

Am I on the right lines...?
 
Last edited:
Physics news on Phys.org
Nallyfish said:

Homework Statement



The function f has period 4 and is such that
f(x)=2+x, -2<x[itex]\leq0[/itex]
f(x)=2, 0<x<2Okay so I've pretty much sketched the graph, but I've been thrown by the 2+x and I'm not sure what to do from this point onwards.

So a0=[itex]\frac{1}{2}[/itex][itex]\int^{2}_{0}2dx[/itex]=2

an=[itex]\frac{1}{2}[/itex][itex]\int^{2}_{0}2*cosnxdx[/itex]

So
an=[itex]\frac{sin2n}{n}[/itex]

And
bn=[itex]\frac{-(cos(2n)-1)}{n}[/itex]

Am I on the right lines...?

No, you aren't. You are given one period of a function whose period is 4. That is a two piece function defined on (-2,2). If you have graphed it you will know that it is neither even nor odd so you may not use the half-range formulas for the coefficients. The formula for an in this problem is

[tex]a_n = \frac{1}{2}\int_{-2}^{2}f(x)\cos(\frac{n\pi}{2}x)\, dx[/tex]

and similarly for bn. You have to break these intgrals up into (-2,0) and (0,2) and use the appropriate formula for f(x) in each.
 
Oh god, I'm an idiot. Thank you for that! Can't believe I did that.

So I now have

an=[itex]\frac{1}{2}[/itex][itex]\int^{0}_{-2}(2+x)cos(\frac{n\pi}{2})xdx[/itex]+[itex]\frac{1}{2}[/itex][itex]\int^{2}_{0}2cos(\frac{n\pi}{2})xdx[/itex]

= [itex]\frac{4sin(n\pi)}{n\pi}[/itex]

and bn= [itex]\frac{-2(ncos(n\pi))(\pi-sin(n\pi))}{n<sup>2</sup>\pi<sup>2</sup>}[/itex]
 
Sorry, I forgot to take the sines and cosines out

an=[itex]\frac{2}{n^{2}\pi^{2}}[/itex]

and

bn= 0

Is what I've got which I HOPE is correct.
This would make the Fourier series

f(x)=[itex]\frac{3}{2}[/itex]*[itex]\sum^{\infty}_{n=1}\frac{2}{n^{2}\pi^{2}}cos(\frac{(n\pi)x}{2})[/itex]
 
Nallyfish said:
Sorry, I forgot to take the sines and cosines out

an=[itex]\frac{2}{n^{2}\pi^{2}}[/itex]

and

bn= 0

Is what I've got which I HOPE is correct.
This would make the Fourier series

f(x)=[itex]\frac{3}{2}[/itex]*[itex]\sum^{\infty}_{n=1}\frac{2}{n^{2}\pi^{2}}cos(\frac{(n\pi)x}{2})[/itex]

That can't be correct because your original f(x) is neither even nor odd, and this answer is an even function. You can't have all the bn be zero.
 
I keep reaching different answers for my an and bn

My latest answers are

an= [itex]\frac{2(n+1)}{n^{2}\pi^{2}}[/itex]

and

bn= [itex]\frac{2(n\pi^{2}+\pi^{2}-1)}{n\pi}[/itex]
 
Nallyfish said:
I keep reaching different answers for my an and bn

My latest answers are

an= [itex]\frac{2(n+1)}{n^{2}\pi^{2}}[/itex]

and

bn= [itex]\frac{2(n\pi^{2}+\pi^{2}-1)}{n\pi}[/itex]

Those are both wrong and you haven't calculated a0. Here's what you should get for your constants:

[tex]a_n=\frac{(-1)^{n+1}+1}{\pi n^2}[/tex]
[tex]b_n=\frac{(-1)^{n+1}}{n}[/tex]
[tex]a_0=2-\frac{\pi}{4}[/tex]

Keep trying.
 
Those aren't correct. You should get
\begin{align*}
a_n &= (1+(-1)^{n+1})\frac{2}{n^2\pi^2} \\
b_n &= (-1)^{n+1}\frac{2}{n\pi}
\end{align*}
I think you dropped a factor of pi somewhere, LCKurtz.
 
I got a0= [itex]\frac{3}{2}[/itex]

Because I thought the formula was

[itex]\frac{1}{2L}[/itex][itex]\int^{L}_{-L}f(x)dx[/itex]

and L is 2 so

a0= [itex]\frac{1}{4}[/itex][[itex]\int^{0}_{-2}(2+x) dx + \int^{2}_{0}2 dx][/itex]

Which would give [itex]\frac{3}{2}[/itex]
 
vela said:
Those aren't correct. You should get
\begin{align*}
a_n &= (1+(-1)^{n+1})\frac{2}{n^2\pi^2} \\
b_n &= (-1)^{n+1}\frac{2}{n\pi}
\end{align*}
I think you dropped a factor of pi somewhere, LCKurtz.

Nallyfish said:
I got a0= [itex]\frac{3}{2}[/itex]

Because I thought the formula was

[itex]\frac{1}{2L}[/itex][itex]\int^{L}_{-L}f(x)dx[/itex]

and L is 2 so

a0= [itex]\frac{1}{4}[/itex][[itex]\int^{0}_{-2}(2+x) dx + \int^{2}_{0}2 dx][/itex]

Which would give [itex]\frac{3}{2}[/itex]

Yes, 3/2 is correct for a0. Vela's formulas for the coefficients are correct. I inadvertently used L = pi instead of L = 2 when I calculated the coefficients.