Solution (source code)

= Solution
{c}

The <Sobolev space> and <norm> are
$$
H^1(a,b)=\{v\in L^2(a,b):v'\text{ exists weakly and belongs to }L^2(a,b)\},\qquad
\|v\|_{H^1}^2=\|v\|_2^2+\|v'\|_2^2.
$$
In one dimension these functions have continuous representatives and well-defined endpoint traces. <integration by parts> gives the weak problem: find $u\in H^1(a,b)$ such that $a(u,v)=\ell(v)$ for all $v\in H^1(a,b)$, where
$$
a(u,v)=\int_a^b(u'v'+x^2uv)\,dx+u(a)v(a)+u(b)v(b),\qquad
\ell(v)=\int_a^bfv\,dx+A v(a)+B v(b).
$$
Indeed the integration boundary term is $-u'(b)v(b)+u'(a)v(a)$; substituting $u'(a)=u(a)-A$ and $u'(b)=B-u(b)$ gives the two positive boundary terms on the left.

If $0\notin[a,b]$, put $m=\min_{[a,b]}x^2>0$. Then $a(v,v)\geq\|v'\|_2^2+m\|v\|_2^2\geq\min(1,m)\|v\|_{H^1}^2$. If $0\in[a,b]$, the supplied <trace> inequality gives
$$
\|v\|_{H^1}^2\leq(1+\widetilde c)\bigl(\|v'\|_2^2+v(a)^2+v(b)^2\bigr)\leq(1+\widetilde c)a(v,v).
$$
Thus the form is \b[coercive in both cases]. The <trace> theorem and boundedness of $x^2$ give continuity of $a$ and $\ell$, and the <Lax-Milgram theorem> gives <existence> and <uniqueness>.