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

Nallyfish
Messages
6
Reaction score
0

Homework Statement



The function f has period 4 and is such that
f(x)=2+x, -2<x\leq0
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=\frac{1}{2}\int^{2}_{0}2dx=2

an=\frac{1}{2}\int^{2}_{0}2*cosnxdx

So
an=\frac{sin2n}{n}

And
bn=\frac{-(cos(2n)-1)}{n}

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\leq0
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=\frac{1}{2}\int^{2}_{0}2dx=2

an=\frac{1}{2}\int^{2}_{0}2*cosnxdx

So
an=\frac{sin2n}{n}

And
bn=\frac{-(cos(2n)-1)}{n}

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

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

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=\frac{1}{2}\int^{0}_{-2}(2+x)cos(\frac{n\pi}{2})xdx+\frac{1}{2}\int^{2}_{0}2cos(\frac{n\pi}{2})xdx

= \frac{4sin(n\pi)}{n\pi}

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

an=\frac{2}{n^{2}\pi^{2}}

and

bn= 0

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

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

an=\frac{2}{n^{2}\pi^{2}}

and

bn= 0

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

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

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= \frac{2(n+1)}{n^{2}\pi^{2}}

and

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

My latest answers are

an= \frac{2(n+1)}{n^{2}\pi^{2}}

and

bn= \frac{2(n\pi^{2}+\pi^{2}-1)}{n\pi}

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

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

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= \frac{3}{2}

Because I thought the formula was

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

and L is 2 so

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

Which would give \frac{3}{2}
 
  • #10
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= \frac{3}{2}

Because I thought the formula was

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

and L is 2 so

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

Which would give \frac{3}{2}

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.
 
Back
Top