Exact solution $\int_0^1 u'v'=v(1/2)$ This question concerns a variational form of the Laplace equation with homogeneous Dirichlet boundary conditions: $$-u''=f \text{ on } [0,1], u(0)=u(1)=0.$$

Let $V=H^1_0(\Omega), \Omega=[0,1]$ and $f\in H^{-1}(\Omega)$ . Solve
$$u\in H_0^1(\Omega) \text{  such that   } \int_{0}^1 u'v'=f_i(v) \text{ for all } v\in H_0^1(\Omega)$$
  for 
i )
  $f_1(v)=\int_0^1 v(x)dx, v\in H_0^1(\Omega)$
ii)
  $f_2(v)=v(\frac12), v\in H_0^1(\Omega)$

For the first one I integrated by parts to get $-\int_0^1 u''v=\int_0^1 v$ so $u''=-1$ and $u(x)=-x^2/2+x/2$ using the boundary conditions. How can I tackle the second one?
 A: Integrating by parts suggests that you  want to find $u\in H_0^1(\Omega)$ such that
$$
-\int_0^1 u''v = v(1/2).
$$
Intuitively, this suggests that $u$ must be some $H_0^1$ function whose second distributional derivative is $u''(x) = -\delta(x-\frac{1}{2})$, where $\delta$ denotes the Dirac delta distribution. It remains to find such a function.
One function whose distributional derivative is $-\delta(x-\frac{1}{2})$ is
$$
u_1' = -1_{[\frac{1}{2},1]}(x),
$$
the indicator function of the interval $[\frac{1}{2},1]$ (with a minus sign).
Integrating this function gives
$$
u_1(x) = -\int_0^x 1_{[\frac{1}{2},1]}
=
\begin{cases}
C_1 & 0\leq x\leq\frac{1}{2},\\
-x+\frac{1}{2} + C_1 & \frac{1}{2}\leq x \leq 1.
\end{cases}
$$
This is almost great, but unfortunately this function fails to satisfy the boundary conditions $u_1(0) = u_1(1) = 0$ for any choice of $C_1$.
However, this can be fixed, as there is another function whose distributional derivative is $-\delta(x-\frac{1}{2})$, namely
$$
u_2'(x) = 1_{[0,\frac{1}{2}]}(x).
$$
Integrating this function gives
$$
u_2(x) = \int_0^x 1_{[0,\frac{1}{2}]}
=
\begin{cases}
x + C_2 & 0\leq x\leq\frac{1}{2},\\
\frac{1}{2} + C_2 & \frac{1}{2}\leq x \leq 1.
\end{cases}
$$
$u_2$ has the same problem as $u_1$ in terms of satisfying the boundary conditions.
However, a linear combination of them might eliminate this problem.
Since $u_1$ and $u_2$ both solve
$$
-\int_0^1 u''v = v(1/2),
$$
any convex combination $u = au_1 + bu_2$ with $a+b = 1$ will yield another solution to the variational equation.
To keep things simple, let us take a simple average: $u = \frac{1}{2}(u_1 + u_2)$.
Then
$$
u(x)
=
\begin{cases}
\frac{1}{2}(x + C_1 + C_2) & 0 \leq x \leq \frac{1}{2},\\
\frac{1}{2}(-x + 1 + C_1 + C_2) & \frac{1}{2}\leq x \leq 1.
\end{cases}
$$
To satisfy the boundary conditions we take $C_1 + C_2 = 0$; then
$$
u(x)
=
\begin{cases}
\frac{1}{2}x & 0 \leq x \leq \frac{1}{2},\\
\frac{1}{2}(1-x) & \frac{1}{2}\leq x \leq 1.
\end{cases}
$$
This is an $H_0^1(\Omega)$ solution to the variational equation, as you can now readily check.
A: Here is another approach:
First, we test the weak formulation with $v \in H_0^1((0,1/2))$, i.e., $v = 0$ on $[1/2,1)$. Then,
$$\int_0^{1/2} u' \, v' \, \mathrm{d}x = 0.$$
Since $v'$ is an arbitrary function with zero mean on $(0,1/2)$, we get that $u'$ must be constant on $(0,1/2)$, i.e., $u$ is affine on $(0,1/2)$. Similarly, we can check that $u$ is affine on $(1/2,1)$.
Since $u$ is continuous on $[0,1]$ and has zero boundary conditions, this already implies
$$
u(x) = c \, (1/2 - |x - 1/2|)$$
for some constant $c \in \mathbb R$ and it remains to find $c$. This can be achieved by using a single test function $v$ with $v(1/2) \ne 0$ or by using $v = u$ as a test function.
