Complex Fourier series and half-range expansions

I need to find the complex Fourier series for $f(x) = x$, where $0 < x < 2\pi$. I tried to solve this in two different ways, first with even extension, and then with odd, but I did not get the right answer. I used the following formulas for $f$ and its coefficients: $f(x)=\sum_{n=-\infty}^{\infty} c_ne^{\frac{in\pi x}{L}}$ and $c_n=\frac{1}{2L}\int_{-L}^{L} f(x)e^{\frac{-in\pi x}{L}}dx$. Since i extended $f$, I got the period to equal $4\pi$ and therefore $L=2\pi$ Could anyone please tell me what I am doing wrong?

My computation with even extension:

I extend $f$, so that $f(x)=x$ for $x\in(0, 2\pi)$ and $f(x)=-x$ for $x\in(-2\pi, 0)$. I then find the coefficients: $c_n=\frac{1}{4\pi}\int_{-2\pi}^{2\pi} f(x)e^{\frac{-in x}{2}}dx = \frac{1}{4\pi}(-\int_{-2\pi}^{0}xe^{\frac{-in x}{2}}dx + \int_{0}^{2\pi}xe^{\frac{-in x}{2}}dx) = ... = \frac{2}{\pi n^2}((-1)^n-1)$. So I have $f(x)=\sum_{n=-\infty, n\neq0}^{\infty} \frac{2}{\pi n^2}((-1)^n-1) e^{\frac{inx}{2}}$. But this does not agree with the textbook's solution, which is $f(x)=\pi + i\sum_{n=-\infty, n\neq0}^{\infty} \frac{1}{n} e^{inx}$. I think that in the textbook's solution they used $2\pi$ as the period, while I used $4\pi$, but shouldn't both give the correct values of $x$ on $(0, 2\pi)?$

Let's do the following change of variables: $\theta = 2 \pi \left(x - {1 \over 2}\right)$. The function becomes $$f(x) = g(\theta) = {1 \over 2} + {\theta \over 2 \pi},$$ and its domain is $]-\pi, \pi[$. The geometric convenience of this is that $g$ can be thought of as a (discontinuous) function on the unit circle in the complex plane.
The $k$-th Fourier coefficient (where $k$ is an integer, positive, negative, or zero) is $$\int_{-\pi}^{\pi} g(\theta) \; e^{i k \theta} \; d\theta.$$ Try integrating this and compare to the what you were getting previously, using $L = 2 \pi$ (the length of the period).
• As far as I can tell, the exponent in your series should be $-i 2 \pi n x / L$. With $L = 2 \pi$, this exponent reduces to $-i n x$, not to half of this. – avs Jul 11 '16 at 19:02