Consider the periodic and hybrid function defined as $$f(t)=x, 0\le x \le 1$$ and $$f(t)=1$$ $$1\le x\le 2$$
Attempt:
I need to calculate Cn $$C_n=\frac{1}{2}\int_0^1 xe^{-in\pi x}dx+\frac{1}{2}\int_1 ^2 1.e^{-in\pi x}dx$$ After evaluating this integral I get $$C_n=\frac{2+in\pi}{2n^2 \pi^2}, n:odd$$
$$C_n=\frac{i}{8n\pi}, n:even$$
I'm confused now because I was expecting Cn to be purely imaginary because the function is odd...but what I have here is Cn containining real and imaginary numbers when n is odd
Can someone please validate my work? Thank you
By computing the Fourier coefficients in this manner, you've implicitly assumed that your function $f(x)$, which was defined on the interval $[0,2]$, has been periodically continued outside of that interval. But in that case, the behavior for $-1<x<0$ is $f(x)=1$ not $f(x)=x$. Hence the function is not odd.
To make this more visible, I've plotted your function along with its Fourier expansion (using modes $n=-10$ to $10$). The agreement is good near the center of the interval, but Gibbs phenomenon is evident near the edge.
$\hspace{4cm}$
Suppose we now look how the Fourier expansion behaves on the interval $[-2,4]$:
$\hspace{4cm}$
What we see is that the periodic continuation of the interval $[0,2]$ results in a sawtooth wave relative to the line $f(x)=1$. This clarifies the source of the Gibbs phenomenon, and makes clear that this function is neither even nor odd. Consequently we shouldn't be surprised that the $c_n$ are all in general complex.