Today I've attended a Mathematical Methods for Physicist exam and I've found an ordinary differential equation that I could not solve.
The exercise asked to find a solution to the equation $$ f''''(x)+f(x) = \cos{x} - \left( \sin{x} \right)^2$$ with boundary conditions $$ f(0)=f(\pi); \quad \quad f'(0)=f'(\pi)$$
First of all, I've written $\sin^2{x}$ = $\frac{1}{2}-\frac{1}{2} \cos{2x}$; then I've tried to expand $f(x)$ in Fourier series between $0$ and $\pi$:
$$f(x)=\sum_{n=0}^{\infty} \left( a_n \cos{nx} + b_n \sin{nx}\right)$$
Then I've imposed the first boundary condition. Since $f(0)$ is just the sum of $a_n$, and $f(\pi)$ is the sum of $a_n (-1)^n$, the condition is fulfilled if only the even terms are non-zero; hence:
$$f(x) = \sum_{n=0}^{\infty} \left( a_{2n} \cos{2nx} + b_n \sin{nx} \right)$$ $$f'(x) = \sum_{n=0}^{\infty} \left( n b_n \cos{nx} - 2n \; a_{2n} \sin{2nx} \right)$$
At this point imposing the second boundary condition gave me a result specular to the first one (only even terms for $b_n$): $$f(x) = \sum_{n=0}^{\infty} \left( a_{2n} \cos{2nx} + b_{2n} \sin{2nx} \right)$$
Then I've finally substituted the expanded form of $f(x)$ into the differential equation in order to find the coefficients:
$$f''''(x)+f(x) = \sum_{n=0}^{\infty} \left( a_{2n} (16n^4+1) \cos{2nx} + b_{2n} (16n^4+1) \sin{2nx} \right) = \cos{x}-\frac{1}{2}+\frac{1}{2}\cos{2x}$$
And now I'm stuck... I can find the coefficients for $n=0$ and $n=1$, but I don't know what to do with the $\cos{x}$ term.
Thanks in advance for any help or suggestion you may give,
Lorenzo
$$f''''(x)+f(x) = \cos{x} - \left( \sin{x} \right)^2$$ Solve the homogeneous equation first: $$f''''(x)+f(x) = 0$$ the characteristic polynomial is $$r^4+1=0$$ Solve for $r$ then the solution is $$y_h=\sum_{i=1}^4c_ie^{r_ix}$$
For the particular solution $$f''''(x)+f(x) = \cos{x}-\frac{1}{2}+\frac{1}{2}\cos{2x}$$ Try $$y_p=A+B\cos x +C \cos(2x)$$ You find that $$A=-\dfrac 12$$ $$B\cos x+B \cos x= \cos x \implies B=\dfrac 12$$ $$16C\cos (2x)+C \cos (2x)= \dfrac 12 \cos (2x) $$ $$\implies C=\dfrac 1 {34}$$ So thatthe particular solution is: $$y_p=-\dfrac 12 + \dfrac 12 \cos x +\dfrac 1 {34}\cos(2x)$$