Solution (source code)

= Solution

Write the operator in <Sturm-Liouville form>:
$$
Lu=-\bigl((1+x^2)u'\bigr)'+x^2u.
$$
The natural solution space is the <Sobolev space> $H_0^1(0,1)$. Multiplication by a test function $v\in H_0^1(0,1)$ and integration by parts gives the symmetric bilinear form
$$
a(u,v)=\int_0^1
\left[(1+x^2)u'v'+x^2uv\right]dx.
$$
It is bounded and
$$
a(u,u)\geq\int_0^1|u'|^2dx
\geq C\|u\|_{H^1}^2
$$
by the <Poincaré inequality>. Thus $L$ is positive definite and $a$ is coercive. The <Lax-Milgram theorem> gives a unique weak solution of the variational problem
$$
\boxed{
\text{find }u\in H_0^1(0,1)
\text{ such that }
a(u,v)=\int_0^1fv\,dx
\quad\text{for every }v\in H_0^1(0,1).
}
$$