The function $f(x)$ is $2$-periodic and $f(x)=(x+1)^2, \ -1<x<1.$ Expand $f$ in terms of a complex Fourier series and find a $2$-periodic solution to the equation
$$2y''-y'-y=f(x).$$
$a_0$ is trivially found to be $4/3$ and for $a_n$ I get
$$a_n=\int_{-1}^{1}(x+1)^2\cos(\pi n x)dx.$$
I have 2 questions:
In order to calculate the above integral so that the series become complex, should I just substitute $\cos(\pi n x)=(e^{i\pi n x}+e^{-i\pi n x})/2$ and then use integration by barts on the 4 out of 6 terms that pop up after I expand the integrand. This sounds a bit tedious, is there any trick/shortcut to this or do I simply need to bite the sour apple?
I don't understand what I should do on the second part regarding the differential equation. should I simply solve for $y(x)?$ I've never solved an ODE where the RHS is a complex sum.
EDIT 1: After jmerry's answer, I calculated that
$$c_n=e^{-i\pi n}\left(\frac{2i\pi^2 n^2+2\pi n-i+ie^{2i\pi n}}{\pi^3 n^3}\right),$$
and Wolfram Alpha agrees with that answer. Now I want to express $f(x)$ as a sum with a simplified summand. I have that
$$f(x)=\sum_{n=-\infty}^{n=\infty}c_n e^{in\pi x}=\sum_{n=-\infty}^{n=\infty}e^{-i\pi n}\left(\frac{2i\pi^2 n^2+2\pi n-i+ie^{2i\pi n}}{\pi^3 n^3}\right) e^{in\pi x}.$$
However, the answer in the book is
$$f(x)=\frac{4}{3}+\frac{2}{\pi^2}\sum_{n=-\infty}^{n=\infty}\frac{(-1)^n(1+i\pi n)}{n^2}e^{i\pi n x}, \quad n\neq 0.$$
I assume that the first term, $4/3$ is just $c_0$. However, this answer seems to suggest that
$$c_n=e^{-i\pi n}\left(\frac{2i\pi^2 n^2+2\pi n-i+ie^{2i\pi n}}{\pi^3 n^3}\right) =\frac{2(-1)^n(1+i\pi n)}{\pi^2n^2},$$
can someone show me how this is?
EDIT 2: Ok I also figured out the question I had in Edit 2. Now all that remains is the differential equation.
It is tedious, but that's just the way things are. This is not a particularly nice function in the ways that matter.
However, you do appear to have misunderstood the question. It's asking for a complex Fourier series - which means that it'll all be in terms of exponentials, not sines and cosines. It's $\sum_{n=-\infty}^{\infty} c_n e^{in\pi x}$, and $c_n=\frac12\int_{-1}^1 e^{-in\pi x}f(x)\,dx$. As such, integrating against that exponential, there will only be three terms in the integral for each coefficient, not six.
The relation of this to the real Fourier series (sines and cosines) you're familiar with? $c_n$ and $c_{-n}$ are linear combinations of $a_n$ and $b_n$, and vice versa.
Regarding the differential equation - this is a standard use for transform methods. Apply the transform to both sides, turning the differential equation into an algebraic equation. Solve that algebraic equation, and then invert the transform to find the solution to the original differential equation.
Complex numbers aren't going to be a problem. The calculus of complex-valued functions of a real variable looks just like that for real-valued functions, except we've got a little more flexibility in arithmetic.
Do you know what the Fourier series for $f'$ or $f''$ is in terms of the series for $f$?
[Edit in response to comment]
Yes, the $\frac43$ term is just $c_0$.
OK, simplifying that expression for $c_n$. First, $e^{2\pi in}$? That's just $1$. Periodicity. That kills the constant terms in your numerator, after which you can factor out a common $\pi n$ between the numerator and denominator. As for the $e^{-\pi i n}$ factor in front? That's $(-1)^n$, a much less unwieldy expression. Apply those, and you get the form in the book. It looks like the Wolfram Alpha answer didn't assume that $n$ was an integer, leading to the inconvenient form.