$\def\d{\mathrm{d}}$Find the weak derivative of the following function: $$u(x)=\begin{cases}x; & x\in(0,1]\\2; & x\in (1,2]\end{cases}.$$
We have,\begin{align*} \int_0^2v(x)\phi(x)\,\d x&=\int_0^2 u'(x)\phi(x)\,\d x=-\int_0^2 u(x)\phi'(x)\,\d x\\ &=-\int_0^1x\phi'(x)\,\d x-\int_1^22\phi'(x)\,\d x. \end{align*} Then how I can proceed to find the weak derivative of $u(x)$?
Integrate by parts once more on the first integral and evaluate the second:
$$-\phi(1)+\int_0^1\phi(x)dx+2\phi(1)=\phi(1)+\int_0^1\phi(x)dx.$$
So $v(x)=1$ on $[0,1)$, 0 on (1,2] and $\delta(x-1)$ at $x=1$. Explicitly:
$$v(x)=\delta(x-1)+1_{[0,1)}(x)$$