# Homework Help: Fourier expansion between two different intervals

1. Aug 5, 2011

### LASmith

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

f(x) = x+1 for -1,x<0
x-1 for 0<x<1
0 for x=0

expand it in an appropriate cosine or sine series

2. Relevant equations

f(x) = a0/2 + $\sum$ [ancos (n$\pi$x/p) + bn sin (n$\pi$x/p)

a0 = 1/p $\int$f(x).dx

an = 1/p $\int$ f(x)cos (n$\pi$x/p).dx

bn = 1/p $\int$ f(x)sin (n$\pi$x/p).dx

3. The attempt at a solution

As there are two functions within this f(x), I am unsure of how to go ahead and do this.
I realise the overall function is odd, therefore would only need to expand the bn part of the Fourier series, however the individual functions are not odd.
How would I go about setting this up?

2. Aug 5, 2011

### Herr Malus

You'll need to break the integrals into two parts. The first will integrate x+1 from -1 to 0, the second will integrate x-1 from 0 to 1.

3. Aug 5, 2011

### HallsofIvy

$$\int_{-1}^1 f(x)dx= \int_{-1}^0 f(x)dx+ \int_0^1 f(x)dx$$

4. Aug 6, 2011

### LASmith

Can this only be done the long winded way of calculating a0, an and bn for each equation, therefore doing 6 integrals? Or will some cancel for being odd/even functions, which I cannot see at first glance?

Also would the value of 'p' in my 'relevant equations' be -1 for x+1 and 1 for x-1?

5. Aug 6, 2011

### vela

Staff Emeritus
In a sense, you always have to calculate an and bn. It's just that if you have an even or odd function, you can sometimes use tricks to simplify or avoid lengthy calculations. When you have an odd integrand O(x) and a symmetric interval [-a,a], you know that$$\int_{-a}^a O(x)\,dx = 0$$(You should be able to prove this.) If you have an even integrand E(x), you can say$$\int_{-a}^a E(x)\,dx = 2\int_{0}^a E(x)\,dx$$(Again, you should be able to prove this.)

In this problem, you want to write down the integrals for an and bn, take a look at the integrands, and see if either of the above apply. If they do, you can use them to simplify evaluating the integrals for an and bn.
You need to understand what the quantities that appear in a formula represent otherwise you're just guessing. So what does p represent in these formulas?

6. Aug 6, 2011

### LASmith

I thought p represented the value for which we integrate between, as all the examples so far have been where the limit is between p and -p, however, because these functions are between -1 and 0 & 0 and 1, I would presume it was the non-zero number, although I do not understand where the 1/p at the beginning of each integral comes from, so I guess that is where my miss-understanding occurs.

7. Aug 6, 2011

### vela

Staff Emeritus
The function f(x) defined on the interval [-1,1]. That's what determines what p is equal to. How f(x) is actually defined, in this case, piecewise, has nothing to do with p.

8. Aug 7, 2011

### LASmith

Therefore p will be 1 for both parts of the function, regardless of where the two parts of the function lie, between this interval?

9. Aug 7, 2011

### vela

Staff Emeritus
Yup. Take a0 for example. You get
\begin{align*}
a_0 &= \frac{1}{p}\int_{-p}^p f(x)\,dx \\
&= \frac{1}{1}\int_{-1}^1 f(x)\,dx \\
&= \int_{-1}^1 f(x)\,dx
\end{align*}
because a single period is over [-1,1]. Now when you substitute in for f(x), you would split the integral up because of the two pieces to get
\begin{align*}
a_0 &= \int_{-1}^1 f(x)\,dx \\
&= \int_{-1}^0 f(x)\,dx + \int_{0}^1 f(x)\,dx \\
&= \int_{-1}^0 (x+1)\,dx + \int_{0}^1 (x-1)\,dx
\end{align*}
Note that this isn't necessarily the way you'd calculate a0 since you're not taking advantage of the oddness of f(x). It was just to show that p doesn't depend on the fact that f(x) is made out of two or more pieces.