# How to use the Fredholm alternative in an ODE

I have the following ordinary differential equation $$\frac{d^2u}{dx^2} + u = \cos x$$ A particular solution to this problem is $x\sin x$, so we can say that $$u(x) = c_1 \cos x + c_2 \sin x + \frac{1}{2}x\sin x$$ $c_1$ and $c_2$ depend on the boundary conditions. Given the boundary condition that $$u(\pi) = u(-\pi)$$ we get $u(x) = c_1 \cos x + c_2 \sin x + \frac{1}{2}x\sin x$. So there are infinitely many solutions.

Given the boundary condition that $$\frac{du}{dx}(\pi) = \frac{du}{dx}(-\pi)$$ we get the equation $c_2 - \frac{1}{2}\pi = c_2 + \frac{1}{2} \pi$. So this problem has no solutions due to the second boundary conditions.

Now my problem shows up. The Fredholm Alternative is stated here: http://librarum.org/book/422/314. It starts in paragraph 8.4.2.

'' If there are non-trivial homogeneous solutions $\phi_h(x)$, then the non homogeneous problem has $0$ of $\infty$ solutions. This depends on whether $$\int_{-\pi}^{\pi} \phi_h(x) cos(x) dx$$ equals zero or does not equal zero."

So my thought is that this problem must have different homogeneous solutions for the different boundary conditions, because for the first condition, the integral must equal $0$, and for the second condition the integral must not equal $0$. But I also see that this problem has the same homogeneous solution for both BC's. $(\sin x$ and $\cos x)$. What is going wrong?

to apply fredholm alternative, which says that for an adjoint(symmetric) operator $L$, either $Lu = f$ has a solution or $<f,v> = 1$ for all solutions $v$ of the homogeneous problem. in your case, $k cos(x)$ solves the homogeneous problem and $k \int_{-\pi}^{\pi} \cos x\cos x dx = 1$ for appropriate constant $k.$ this shows then that your problem is not solvable.
of course, you could just multiply the equation by $\cos x$ and integrate from $-\pi$ to $\pi$ and use integration by parts to obtain $0 = 1.$ this is what fredholm alternative really is.