[proofplan]
We first identify the adjoint domain by testing the adjoint relation against compactly supported smooth functions. This shows that any vector in $\operatorname{Dom}(S_0^*)$ has a [distributional derivative](/page/Distributional%20Derivative) of second order in $L^2(0,L)$, hence lies in the [Sobolev space](/page/Sobolev%20Space) $H^2(0,L)$, and the adjoint acts by the same differential expression $-d^2/dx^2$. Conversely, every $H^2$ function satisfies the adjoint relation because compactly supported test functions have no boundary terms. The boundary form is then obtained by two one-dimensional integrations by parts, first for smooth functions and then for $H^2$ functions by density and continuity of the trace maps.
[/proofplan]
[step:Identify the adjoint domain from the distributional second derivative]
Let $\mathcal{L}^1$ denote one-dimensional [Lebesgue measure](/page/Lebesgue%20Measure) on $(0,L)$. Let $u \in \operatorname{Dom}(S_0^*)$. By definition of the Hilbert-space adjoint, there exists a function $w \in L^2(0,L)$ such that
\begin{align*}
(S_0\phi,u)_{L^2(0,L)}=(\phi,w)_{L^2(0,L)}
\end{align*}
for every $\phi \in C_c^\infty(0,L)$. Expanding the inner products gives
\begin{align*}
\int_0^L -\phi''(x)\overline{u(x)}\,d\mathcal{L}^1(x)
=
\int_0^L \phi(x)\overline{w(x)}\,d\mathcal{L}^1(x).
\end{align*}
Equivalently, the distributional second derivative of $u$ exists as an $L^2$ function and satisfies
\begin{align*}
-u''=w
\end{align*}
in $\mathcal{D}'(0,L)$, where $\mathcal{D}'(0,L)$ denotes the space of [distributions](/page/Distribution) on the interval $(0,L)$. By the one-dimensional Sobolev [regularity theorem](/theorems/2750) for intervals, if $f \in L^2(0,L)$ and the second distributional derivative $f''$ is represented by an element of $L^2(0,L)$, then $f \in H^2(0,L)$. The hypotheses hold with $f=u$ because $u \in L^2(0,L)$ and $u''=-w \in L^2(0,L)$. Therefore $u \in H^2(0,L)$, and the representing vector is $w=-u''$. Hence
\begin{align*}
\operatorname{Dom}(S_0^*) \subset H^2(0,L),
\qquad
S_0^*u=-u''.
\end{align*}
[guided]
Let $u \in \operatorname{Dom}(S_0^*)$. The definition of the adjoint says that the map
\begin{align*}
\phi \in C_c^\infty(0,L) \mapsto (S_0\phi,u)_{L^2(0,L)} \in \mathbb{C}
\end{align*}
is represented by [inner product](/page/Inner%20Product) against a unique element of $L^2(0,L)$. Thus there is a function $w \in L^2(0,L)$ such that, for every [test function](/page/Test%20Function) $\phi \in C_c^\infty(0,L)$,
\begin{align*}
(S_0\phi,u)_{L^2(0,L)}=(\phi,w)_{L^2(0,L)}.
\end{align*}
Now substitute the definition $S_0\phi=-\phi''$. Since the $L^2$ inner product is linear in the first variable and conjugate-linear in the second variable, this becomes
\begin{align*}
\int_0^L -\phi''(x)\overline{u(x)}\,d\mathcal{L}^1(x)
=
\int_0^L \phi(x)\overline{w(x)}\,d\mathcal{L}^1(x).
\end{align*}
This identity is exactly the weak formulation of the statement that the [distributional derivative](/page/Distributional%20Derivative) of $u$ of second order is the $L^2$ function $-w$. More explicitly, conjugating the identity gives
\begin{align*}
\int_0^L -\overline{\phi''(x)}u(x)\,d\mathcal{L}^1(x)
=
\int_0^L \overline{\phi(x)}w(x)\,d\mathcal{L}^1(x),
\end{align*}
which says that $-u''=w$ in the sense of distributions on $(0,L)$.
The relevant one-dimensional Sobolev regularity fact for intervals is the following: if a function $f \in L^2(0,L)$ has second distributional derivative $f''$ represented by an element of $L^2(0,L)$, then $f \in H^2(0,L)$. This formulation is important because at this point we have proved exactly two facts about the present function: $u \in L^2(0,L)$, since $u$ is a vector in the [Hilbert space](/page/Hilbert%20Space), and $u''=-w \in L^2(0,L)$ in the distributional sense. The theorem supplies the missing first-derivative regularity as part of its conclusion, so it gives $u \in H^2(0,L)$. Since the representing vector in the adjoint relation is unique, we also obtain
\begin{align*}
S_0^*u=w=-u''.
\end{align*}
Thus every element of $\operatorname{Dom}(S_0^*)$ belongs to $H^2(0,L)$, and on this domain the adjoint is the differential operator $-d^2/dx^2$.
[/guided]
[/step]
[step:Show that every $H^2$ function lies in the adjoint domain]
Let $u \in H^2(0,L)$, and define the function
\begin{align*}
w:(0,L)\to \mathbb{C},\qquad x\mapsto -u''(x).
\end{align*}
Here $u''$ denotes the second [distributional derivative](/page/Distributional%20Derivative), represented by an element of $L^2(0,L)$. Then $w \in L^2(0,L)$. For every $\phi \in C_c^\infty(0,L)$, the definition of the distributional second derivative and the compact support of $\phi$ give
\begin{align*}
\int_0^L -\phi''(x)\overline{u(x)}\,d\mathcal{L}^1(x)
=
\int_0^L \phi(x)\overline{-u''(x)}\,d\mathcal{L}^1(x).
\end{align*}
Therefore
\begin{align*}
(S_0\phi,u)_{L^2(0,L)}=(\phi,w)_{L^2(0,L)}.
\end{align*}
Hence $u \in \operatorname{Dom}(S_0^*)$ and $S_0^*u=w=-u''$. Combining this with the previous step yields
\begin{align*}
\operatorname{Dom}(S_0^*)=H^2(0,L).
\end{align*}
[/step]
[step:Compute the boundary form for smooth functions]
First let $u,v \in C^\infty([0,L])$. Since $S_0^*u=-u''$ and $S_0^*v=-v''$, we have
\begin{align*}
(S_0^*u,v)_{L^2(0,L)}-(u,S_0^*v)_{L^2(0,L)}
=
\int_0^L -u''(x)\overline{v(x)}\,d\mathcal{L}^1(x)
-
\int_0^L u(x)\overline{-v''(x)}\,d\mathcal{L}^1(x).
\end{align*}
Thus
\begin{align*}
(S_0^*u,v)_{L^2(0,L)}-(u,S_0^*v)_{L^2(0,L)}
=
\int_0^L \left(-u''(x)\overline{v(x)}+u(x)\overline{v''(x)}\right)\,d\mathcal{L}^1(x).
\end{align*}
The integrand is the derivative of the function $B_{u,v}:[0,L]\to \mathbb{C}$ defined by
\begin{align*}
B_{u,v}(x)=-u'(x)\overline{v(x)}+u(x)\overline{v'(x)}.
\end{align*}
Indeed,
\begin{align*}
B_{u,v}'(x)
=
-u''(x)\overline{v(x)}-u'(x)\overline{v'(x)}
+u'(x)\overline{v'(x)}+u(x)\overline{v''(x)}.
\end{align*}
Hence
\begin{align*}
B_{u,v}'(x)
=
-u''(x)\overline{v(x)}+u(x)\overline{v''(x)}.
\end{align*}
Applying the [fundamental theorem of calculus](/theorems/632) on $[0,L]$ gives
\begin{align*}
\int_0^L B_{u,v}'(x)\,d\mathcal{L}^1(x)=B_{u,v}(L)-B_{u,v}(0).
\end{align*}
Therefore
\begin{align*}
(S_0^*u,v)_{L^2(0,L)}-(u,S_0^*v)_{L^2(0,L)}
=
-u'(L)\overline{v(L)}
+u(L)\overline{v'(L)}
+u'(0)\overline{v(0)}
-u(0)\overline{v'(0)}.
\end{align*}
[/step]
[step:Extend the boundary identity from smooth functions to $H^2(0,L)$]
Let $u,v \in H^2(0,L)$. By the standard density theorem for smooth functions in the one-dimensional [Sobolev space](/page/Sobolev%20Space) $H^2(0,L)$, choose sequences $(u_k)_{k=1}^\infty$ and $(v_k)_{k=1}^\infty$ in $C^\infty([0,L])$ such that $k \in \mathbb{N}$ indexes the approximants, where $\mathbb{N}$ denotes the positive integers and $C^\infty([0,L])$ denotes the space of functions whose derivatives of all orders extend continuously to $[0,L]$. We have
\begin{align*}
u_k \to u \quad \text{in } H^2(0,L)
\end{align*}
and
\begin{align*}
v_k \to v \quad \text{in } H^2(0,L).
\end{align*}
For each $k \in \mathbb{N}$, the smooth boundary identity gives
\begin{align*}
(S_0^*u_k,v_k)_{L^2(0,L)}-(u_k,S_0^*v_k)_{L^2(0,L)}
=
-u_k'(L)\overline{v_k(L)}
+u_k(L)\overline{v_k'(L)}
+u_k'(0)\overline{v_k(0)}
-u_k(0)\overline{v_k'(0)}.
\end{align*}
Since $S_0^*u_k=-u_k''$ and $S_0^*v_k=-v_k''$, convergence in $H^2(0,L)$ implies convergence of the left-hand side to
\begin{align*}
(S_0^*u,v)_{L^2(0,L)}-(u,S_0^*v)_{L^2(0,L)}.
\end{align*}
The one-dimensional [trace theorem](/theorems/60) for [Sobolev spaces](/page/Sobolev%20Space) gives continuous trace maps
\begin{align*}
\gamma_0:H^2(0,L)\to \mathbb{C}^2,\qquad f\mapsto (f(0),f(L))
\end{align*}
and
\begin{align*}
\gamma_1:H^2(0,L)\to \mathbb{C}^2,\qquad f\mapsto (f'(0),f'(L)).
\end{align*}
By continuity of the one-dimensional trace maps on $H^2(0,L)$, the right-hand side converges to
\begin{align*}
-u'(L)\overline{v(L)}
+u(L)\overline{v'(L)}
+u'(0)\overline{v(0)}
-u(0)\overline{v'(0)}.
\end{align*}
Passing to the limit proves the asserted boundary form for all $u,v \in H^2(0,L)$.
[/step]