# Fourier series of function defined differently on different parts of interval

I have two ask questions, I'll begin with a specific one:

Find the Fourier series of the following function: $f(x)=0$ when $x \in [-\pi,0]$, $f(x)=e^x$ when $x \in (0,\pi]$.

This is a book exercise but there's no answer key so I don't know if my suggestion is correct or what I should try to reach. Let's simply begin with the coefficient $a_0$ of the Fourier series of $f$:

$$a_0 := \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) dx$$

Split integration to $\int_{-\pi}^0$ and $\int_0^{\pi}$, whence

$$\pi a_0 = \int_{-\pi}^0 0 \cdot dx+\int_0^\pi e^x dx$$

Is this a correct way to begin, that will also work for $a_n,b_n$ where $n>0$?

My second question is, of course, if $f=g$ on $[-\pi,a]$ and $f=h$ on $(a,\pi)$, can one split up the calculation of $a_n$ (and analogously $b_n$) by simply calculating

$$\pi a_n = \int_{-\pi}^a f(x) \cos{(nx)}dx+\int_a^\pi f(x) \cos{(nx)}dx?$$

I don't find the answer here satisfying. Thank you.

• Yes, this is correct. – kmitov Jan 7 '14 at 4:56

Generally speaking, integrals (both in the Lebesgue and Riemann sense) are additive with respect to the interval of integration. In plain terms: if $a<b<c$, then $$\int_a^c F(x)\,dx = \int_a^b F(x)\,dx+\int_b^c F(x)\,dx \tag{1}$$ provided that the integrals on the right exist.
The formula (1) is particularly useful when $F$ behaves differently on the intervals $(a,b)$ and $(b,c)$. The computation of Fourier coefficients of a piecewise defined function $f$ is a commonly encountered case of the above.