Solution (source code)

= Solution

For $n\ne0$, split the <Green's function> integral at $s=x$. Writing $\ell(x)=x^{-n}-2^n$ and $r(x)=x^{-n}-1$ gives
$$
u(x)=\frac{r(x)\int_{1/2}^{x}(1-2^ns^n)\,ds+\ell(x)\int_x^1(1-s^n)\,ds}{n(2^n-1)}.
$$
For $n\ne-1$, the two <integrals> are
$$
I_1=x-\frac12-\frac{2^n}{n+1}\left(x^{n+1}-2^{-n-1}\right),\qquad I_2=1-x-\frac{1-x^{n+1}}{n+1}.
$$
Substitution and simplification yield
$$
\boxed{u(x)=\frac1{n+1}\left[x-1+\frac{x^{-n}-1}{2(2^n-1)}\right],\qquad n\ne0,-1.}
$$
At $x=1$ both contributions vanish. At $x=1/2$ the bracket is $-1/2+(2^n-1)/[2(2^n-1)]=0$. The <differential operator> kills $x^{-n}-1$ and sends $x/(n+1)$ to $1/x$, so this also verifies the inhomogeneous equation.

The exceptional integer is $\boxed{n=-1}$, because then the <integrals> contain $s^{-1}$. In this case
$$
I_1=x-\frac12-\frac12\log(2x),\qquad I_2=1-x+\log x,
$$
and the <Green's function> integral becomes
$$
\begin{aligned}
u(x)&=2\left[(x-1)\left(x-\frac12-\frac12\log(2x)\right)+\left(x-\frac12\right)(1-x+\log x)\right]\\
&=\boxed{x\log x+(1-x)\log2}.
\end{aligned}
$$
Here $L=d^2/dx^2$, and $u''=1/x$. Explicitly $u(1)=0$ and $u(1/2)=-(\log2)/2+(\log2)/2=0$. Thus both exceptional and nonexceptional formulas satisfy the required <boundary conditions>.