ODE $f''''(x)+f(x) = \cos{x} - \left( \sin{x} \right)^2$ with boundary conditions $f(0)=f(\pi); \quad \quad f'(0)=f'(\pi)$

$$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)$$