Weak solution to ODE I have to find a weak solution to
$$(a(x)u')' - u = x,\\ a(x) = \begin{cases}1 \qquad x<\frac 12\\ 4\qquad x>\frac 12\end{cases}$$
with $x\in(0,1)$ and $u$ vanishing at the boundaries, i.e. $u(0)=u(1)=0$.
I'm slightly lost on how to approach this problem. I've tried to multiply the equation with a test function $\varphi$ that also vanishes at the boundary and then integrating, which yielded
$$\int_0^1[a(x)u'\varphi'+u\varphi+x\varphi]\text{d}x = 0$$
However, I'm not sure how to proceed or if it makes more sense to approach the problem differently. Any help is appreciated.
 A: I am not sure what you are referring to when you talk about weak solutions, but if I understand the rest of the question correctly, you are asking for a differentiable function $u:(0,1/2)\cup(1/2,1)\rightarrow\mathbb{R}$ satisfying $(au')'(x)-u(x)=x$ with $a$ as defined above.
If so, then simply note that $u''(x)-u(x)=x$ on $(0,1/2),$ and $4u''(x)-u(x)=x$ on $(1/2,1).$
For the former case, we have that $u''(x)-u(x)=u''(x)-u'(x)+u'(x)-u(x)=[u'-u]'(x)+[u'-u](x)=x.$ Let $v=u'-u,$ so that $v'(x)+v(x)=x.$ Let $e_a(x):=\exp(ax).$ Hence $e_1(x)v'(x)+e_1(x)v(x)=(e_1\cdot{v})'(x)=xe_1(x)=xe^x.$ As such, $$\lim_{a\to0}\int_a^t(e_1\cdot{v})'(x)=(e_1\cdot{v})(t)-\lim_{a\to0}(e_1\cdot{v})(a)=e^tv(t)-\lim_{a\to0}e^av(a)$$ $$=e^tv(t)-\lim_{a\to0}u'(a)-u(a)$$ and $$\lim_{a\to0}\int_a^txe^x\,\mathrm{d}x=(t-1)e^t-\lim_{a\to0}(a-1)e^a=(t-1)e^t+1.$$ This means $$e^tv(t)=(t-1)e^t-1-\lim_{a\to0}u'(a)-u(a)$$ which is equivalent to $$v(t)=t-1-\left[1+\lim_{a\to0}u'(a)-u(a)\right]e^{-t}.$$ This means $$u'(t)-u(t)=t-1-\left[1+\lim_{a\to0}u'(a)-u(a)\right]e^{-t},$$ which is equivalent to  $$e_{-1}(t)u'(t)-e_{-1}(t)u(t)=(e_{-1}\cdot{u})'(t)=(t-1)e^{-t}-\left[1+\lim_{a\to0}u'(a)-u(a)\right]e^{-2t}.$$ Hence $$e^{-t}u(t)-\lim_{a\to0}e^{-a}u(a)=\lim_{a\to0}ae^{-a}-te^{-t}+\left[1+\lim_{a\to0}u'(a)-u(a)\right]\frac{e^{-2t}}2-\left[1+\lim_{a\to0}u'(a)-u(a)\right]\lim_{a\to0}\frac{e^{-2a}}2=\left[1+\lim_{a\to0}u'(a)-u(a)\right]\frac{e^{-2t}}2-te^{-t}-\left[1+\lim_{a\to0}u'(a)-u(a)\right]\frac12=e^{-t}u(t)-\lim_{a\to0}u(a).$$ This equivalent to $$u(t)=\left[1+\lim_{a\to0}u'(a)-u(a)\right]\frac{e^{-t}}2-\left[1+\lim_{a\to0}u'(a)-u(a)\right]\frac{e^t}2-t+\left[\lim_{a\to0}u(a)\right]e^t=-\left[1+\lim_{a\to0}u'(a)-u(a)\right]\sinh(t)-t+\left[\lim_{a\to0}u(a)\right]e^t.$$
For the latter case, the derivation of the solution is similar. I will leave it to you to figure it out.
