How can I show that applying Hamiltonian dynamics recovers the original wave equation? Problem
Consider the wave equation:
$$ \frac{\partial^2 u}{\partial t^2} = c^2 \frac{\partial^2 u}{\partial x^2}\tag{1}$$
with $ u = u(t, x)$ over domain $x \in [0, l] = \Omega$.  This can be represented as a Hamiltonian system with generalized coordinates $p = \dot{u}$ and $q = u$.
Then the Hamiltonian is defined as:
$$ \mathcal{H}(p, q) = \int_{\Omega}\left[ \frac{1}{2} p^2  + \frac{1}{2}c^2 \left(\frac{\partial q}{\partial x}\right)^2\right] \; dx \tag{2}$$
with dynamics $$\dot{q} = \frac{\delta \mathcal{H}}{\delta p }\quad\text{and}\quad\dot{p} = - \frac{\delta \mathcal{H}}{\delta q }.\tag{3}$$
(See 6.1 in https://arxiv.org/abs/1407.6118)
I am trying to recover the original form (1) using the Hamiltonian formulation above.
Here is what I've tried:
I have a background in mathematics, but less so in physics (other than an intro sequence that did not cover Hamiltonian mechanics). I am currently a graduate student trying to understand this derivation for my research.
I originally started by treating the dynamics for $\dot{q}$ and $\dot{p}$ as standard partial derivatives, but ran into a couple of issues; at which point I tried using the concept of the total variation, and was starting from this definition $$\delta \mathcal{H} = \frac{\partial \mathcal{H}}{\partial p} \delta p  + \frac{\partial \mathcal{H}}{\partial q} \delta q. \tag{4}$$
But I seem to be missing something and am getting stuck:

*

*the integral over $\Omega$ is still present in my derivation so it seems like the dynamics of $\dot{q}$ require integrating over the entire domain $\Omega$ - this seems wrong.

*When taking the derivative with respect to $q$, I obtain the term $\frac{\partial}{\partial q}\left( \left(\frac{\partial q}{\partial x}\right)^2\right)$ which I think should yield $ 2\left(\frac{\partial q}{\partial x}\right) \cdot \frac{\partial}{\partial q}\left(\frac{\partial q}{\partial x}\right)$. However I don't know exactly how to evaluate $\frac{\partial}{\partial q}\left(\frac{\partial q}{\partial x}\right)$ and this doesn't seem to lead to the right result.

Assistance with showing the derivation, or even just recommended readings/references would be greatly appreciated.
 A: 
$$ \frac{\partial^2 u}{\partial t^2} = c^2 \frac{\partial^2 u}{\partial x^2}\tag{1}$$


with $ u = u(t, x)$ over domain $x \in [0, l] = \Omega$.  This can be represented as a Hamiltonian system with generalized coordinates $p = \dot{u}$ and $q = u$.


the Hamiltonian is defined as:
$$ \mathcal{H}(p, q) = \int_{\Omega}\left[ \frac{1}{2} p^2  + \frac{1}{2}c^2 \left(\frac{\partial q}{\partial x}\right)^2\right] \; dx \tag{2}$$


with dynamics $$\dot{q} = \frac{\delta \mathcal{H}}{\delta p }\quad\text{and}\quad\dot{p} = - \frac{\delta \mathcal{H}}{\delta q }.\tag{3}$$


I am trying to recover the original form (1) using the Hamiltonian formulation above.

To orient yourself, recall the standard Hamiltonian equations of motion for a system with $N$ coordinates labeled by index $i$:
$$
\frac{\partial H}{\partial p_i} = \dot q_i
$$
$$
\frac{\partial H}{\partial q_i} = -\dot p_i\;.
$$
When we start to treat the index $i$ as continuous rather than discrete, we switch to a continuous label $x$ and we switch from a sum over $i$ to an integral over $x$. We also switch to saying that $H$ is a functional of $q(x)$ rather than a function of the $q_i$, etc.
The continuum generalization of Hamilton's equations of motion are:
$$
\frac{\partial H}{\partial p(x)} = \dot q(x)
$$
and
$$
\frac{\partial H}{\partial q(x)} = -\dot p(x)\;,
$$
where I am going to keep using the $\partial$ notation rather than the $\delta$ notation, even for functional derivative, but you can use whatever notation you like.
When we take the "functional derivative" we consider what happens to the functional $H$ when the function $q(x)$ is changed to $q(x)+\delta q(x)$ and we define the functional derivative $\frac{\partial H}{\partial q(x)}$ as:
$$
\delta H \equiv \int \frac{\partial H}{\partial q(x)}\delta q(x) dx + O(\delta q^2) \tag{5}
$$
For example, in your Hamiltonian, let $q \to q+\delta q$. Then
$$
H \to H + \int dx c^2\frac{\partial q}{\partial x}\frac{\partial \delta q}{\partial x} + O(\delta q^2) \tag{6}
$$
$$
= H - \int dx c^2\frac{\partial^2 q}{\partial x^2}\delta q + O(\delta q^2)\;, \tag{7}
$$
which shows that the functional derivative wrt q(x) is:
$$
\frac{\partial H}{\partial q(x)} = -c^2\frac{\partial^2 q}{\partial x^2}
$$
Similarly:
$$
\frac{\partial H}{\partial p(x)} = p(x) \equiv \dot q(x)
$$
Then, also using Hamilton's canonical equations, we see that:
$$
-c^2\frac{\partial^2 q}{\partial x^2} = \frac{\partial H}{\partial q(x)} = -\dot p(x) = -\ddot q(x)
$$
Or, cancelling the minus sign and switching back to $u=q$:
$$
c^2 \frac{\partial^2 u}{\partial x^2} = \ddot u
$$
