# Fourier series of $f(x)=1$ and $f(x)=x$

Would someone be kind enough to explain to me what would be the Fourier series of $f(x)=1$ and $f(x)=x$ on $[0,1]$?

See, all the equations I can find are for intervals of the type $[-L,L]$. Now I don't know what $f$ is on $[-1,0]$, so I can't tell if it's even or odd, nor how to use the formula given here, since I am not sure whether I can use $L=1$ as my interval isn't symmetric about 0.

Just need an short explanation for $f(x)=1$ and $f(x)=x$ so I can figure out the right way to use those equations. Also, I am asked to use series that contain only sine terms and only cosine terms. Does that mean I need to apply some kind of restriction or will it just come out that way regardless? Thanks.

-
If you are required to use only cosine terms, the resulting sum must be an even function. So if it has $f(x)=1$ on $[0,1]$, then it must also have $f(x)=1$ on $[-1, 0]$, and now you can use $[-1,1]$ as your $[-L, L]$. Similarly, sine is always odd, and a sum of sines is always odd, so if they sum up to $f(x) = x$ on $[0,1]$ then they must sum to $f(x)=x$ on $[-1, 0]$ as well. – MJD Nov 14 '13 at 1:32
OK, so when I compute the coeff. then I should use L=2, correct? But then I found online that for f(x)=1 on $[0,\pi]$, we only have $b_n = \frac{2}{\pi} \int_0^{\pi} \sin nx \, dx$, other terms vanish. Would the case where they'd use cosines instead (so $a_n$'s) yield the same result if integrated from -pi to pi? – Jen Nov 14 '13 at 1:44
Whatever you found online it fits what they are discussing, which might not be your problem. MJD is correct that you can integrate from -1 to 1. f(x) = 1 is even on that interval. Whatever Fourier series you get will converge for x when 0 < x < 1.You will have just cosine terms -- you don't have to force anything. f(x) = x is odd on -1 to 1, so again just compute that series and it will work on [0,1] as well. MJD gives an explanation for this case; more generally you should look at where Fourier series converge; Wikipedia has a good article. – Betty Mock Nov 14 '13 at 1:52
makes sense, thanks – Jen Nov 14 '13 at 1:57

Think f(x) as a piecewise defined function where:

$$f(x) = \left\{ \begin{array}{l l} 1 & \text{if }x \in [0,1] \\ 0 & \text{else} \end{array} \right.$$

In that case L, which is half the period by the way, is 1. As an example, here I'll write $a_m$:

$$a_m = \frac{1}{1} \left[ \int_{-1}^{0} 0 \cdot cos\left(\frac{m\pi x}{1}\right)\, dx + \int_{0}^{1} 1 \cdot cos\left(\frac{m\pi x}{1}\right)\, dx \right] = \\ =\int_{0}^{1}cos\left(\frac{m\pi x}{1}\right)\, dx$$

Similarly, you can calculate $b_n$ and get the complete serie.

Same thing with $f(x)=x$

-
You can do that, but the $a_m$ you get are not a complete Fourier series for the original $f$, which is not even, and so cannot be represented as a sum of cosines. Put another way, you can neglect the $b_m$ only if you know they are all zero because the function is even—but this one isn't. – MJD Nov 14 '13 at 2:28
ok then how does that agree with this (for the case where I would integrate from -1 to +1)? math.hawaii.edu/~marvin/402/exercise.solutions/SOL16.pdf page 6, part b. sorry this stuff is confusing me. – Jen Nov 14 '13 at 2:36
@MJD: Yes, I didn't write $b_n$ but it should be calculated in order to find the Fourier serie. I'm going to edit the answer and clarify that. – r_russo Nov 14 '13 at 14:53
@Jen: You mean that $f(x)$ is defined as 1 from -1 to 1? In that case $b_n = 0$ because $\int_{-L}^{L} f(x) \cdot \sin(n\pi/L \cdot x) \, dx = -\frac{2}{n\pi}\cos(n\pi/L \cdot x) = \frac{2}{n\pi} [\cos(n\pi) - \cos(n\pi)]$ – r_russo Nov 14 '13 at 15:36
I think you meant to use $\cos$ in your integrand since you are calculating the $a_n$'s. – gorgy Nov 14 '13 at 23:57