# Fourier series (sine,cosine)

#### Kuma

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

Given f(x) = 2x+1 periodic from -pi<x<pi. Find the fourier series from (-pi to pi) as well as the sine series from [0, pi] and cosine series from (0,pi)

2. Relevant equations

3. The attempt at a solution

So since f(x) is periodic it is odd, so then a0 and ak = 0.

for bk:

bk = 1/pi int f(x) sin kx from -pi to pi.
skipping forward, I get bk = [(-1)^ k][-4/k]

now im a bit confused about the sine and cosine series. I thought if f(x) was odd then it turns into a sine series automatically so isn't it basically the same thing as what I got?

And the cosine series should just be 0?

Related Calculus and Beyond Homework News on Phys.org

#### vela

Staff Emeritus
Science Advisor
Homework Helper
Education Advisor
So since f(x) is periodic it is odd, so then a0 and ak = 0.
f isn't odd. For example, f(1) = 3 while f(-1) = -1. Clearly, f(1) ≠ -f(-1).

now I'm a bit confused about the sine and cosine series. I thought if f(x) was odd then it turns into a sine series automatically so isn't it basically the same thing as what I got?

And the cosine series should just be 0?
The idea is to restrict f to the domain [0, π] and then extend it so that it's an even or odd function on the interval [-π, π]. In other words, when -π≤x<0, you have f(x) = ±f(|x|).

#### Kuma

f isn't odd. For example, f(1) = 3 while f(-1) = -1. Clearly, f(1) ≠ -f(-1).

The idea is to restrict f to the domain [0, π] and then extend it so that it's an even or odd function on the interval [-π, π]. In other words, when -π≤x<0, you have f(x) = ±f(|x|).
I thought when you have f(x+p) when its periodic it is just equal to f(x)?
Regardless I got ak and a0 as 0 even when I used f(x) = 2x+1

And shouldn't it be f(x) = f(-x)?

if x E [0,pi] then f(x) = 2x +1 and if x E [-pi,0], f(-x) = 2x+1??

Last edited:

#### vela

Staff Emeritus
Science Advisor
Homework Helper
Education Advisor
I thought when you have f(x+p) when its periodic it is just equal to f(x)?
If p is the period, then yes. But what does that have to do with anything about f being even or odd?

Regardless I got ak and a0 as 0 even when I used f(x) = 2x+1
All I can say is you got the wrong answer since you haven't shown your work.

And shouldn't it be f(x) = f(-x)?
Yes, if f is an even function.

if x E [0,pi] then f(x) = 2x +1 and if x E [-pi,0], f(-x) = 2x+1??
No, that's not right. Take $x=+\pi/2 \in [0,\pi]$ so $f(\pi/2) = \pi+1$. Now take $x=-\pi/2 \in [-\pi,0]$. You're saying $f(-x) = 2x+1$, but you have
$$f(-x) = f(-(-\pi/2)) = f(\pi/2) = \pi+1$$ whereas
$$2x+1 = 2(-\pi/2) + 1 = -\pi + 1.$$ Clearly, f(-x) ≠ 2x+1.

#### Kuma

Ok I figured it out. For the fourier series I got ak and a0 as 0? But for the cosine series i did this
F(x) = f(x) for 0<x<pi
F(x) = -f(-x) for -pi<x<0

where f(x) = 2x+1

that results in an even function so I solved for a0 and ak from there.

#### vela

Staff Emeritus
Science Advisor
Homework Helper
Education Advisor
How are you getting a0=0 for the regular Fourier series?

#### Kuma

Oh yeah I made a calculation error i believe.

ao = 1/2pi int from pi to -pi 2x+1 dx
= 1/2pi (x^2 + x) from pi to -pi
= 1/2pi [pi^2 + pi - ((-pi)^2 -pi]
= 1

ak = 1/pi int 2x+1 cos kx dx from -pi to pi

u = 2x+1 dv = cos kx
du = 2 dx v = 1/k sin kx

x from -pi to pi
=1/pi[(2x+1 sin kx)/k) - 2/k int (sin kx) from -pi to pi]

= 1/pi[0 - 2/k (-1/k cos kx from -pi to pi)]
= 1/pi[2/k^2 (cos kx from -pi to pi)] = 0

that right?

#### vela

Staff Emeritus
Science Advisor
Homework Helper
Education Advisor
Looks good.

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving