I am trying to understand the Hamilton-Jacobi equation without the framework of the canonical transformations. Even on the case of a 1D free particle I'm getting stuck.
The system starts at fixed coordinate $q_0$ at time $t_0$. Hamilton's Principal Function $S(q,t)$ is defined as the action, integrated along the path that satisfies the equations of motion (Hamilton's equations) and takes the system from $q_0$ at time $t_0$ to $q$ at time $t$. In my understanding, as $q$ and $t$ vary the initial velocity has to adjust so that the system lands on $q$ at time $t$.
Writing out the action integral and comparing the various path integrals as I perturb $q$ and $t$ I can show that this function $S(q,t)$ satisfies: $$ \frac{\partial S}{\partial t}(q,t) = - H(q,p,t),\\ \frac{\partial S}{\partial q}(q,t) = p, $$ where $H$ is the Hamiltonian and $p$ is the momentum of the system when it's reached $q$ at time $t$ (i.e. $p$ is a function of $q$ and $t$).
Therefore, the Hamilton-Jacobi equation for $S$ is $$ \frac{\partial S}{\partial t} + H(q,\frac{\partial S}{\partial q},t) = 0. $$
For a 1D free particle the Hamiltonian is $H(q,p,t)=p^2/2m$ and the HJ equation is $$ \frac{\partial S}{\partial t} + \frac{1}{2m} \left(\frac{\partial S}{\partial q}\right)^2=0. $$
The solution of the PDE is $$ S(q,t) = \pm \sqrt{2mE} q - Et + C, $$ for some constants $E$ and $C$. Aaand I'm already confused: $$ H(q,t) = -\partial S / \partial t = E = \mathrm{constant}, $$ the same constant for any $q$ and $t$. But this can't be right. If the particle ends up at $q=1$ at $t=1$ it should have a lower energy than if it ends up at $q=100$ at $t=1$, since it must be traveling faster in the latter case.
For this situation we know the right answer: assuming $q_0=0$ and $t_0=0$, the speed of the particle is $q/t$ (constant along its trajectory) and the Lagrangian integrated along the path to $q,t$ is $S(q,t) = \frac{1}{2} m \frac{q^2}{t}$.
How do I make sense of this seeming contradiction about the constant energy as a function of $q$ and $t$?
Also, at the end of the day how do we get the solution for the motion of the particle from the HJ equation (i.e. something like $q = \pm \sqrt{\frac{2E}{m}} t$)? I've seen reference to taking a partial derivative of $S$ with respect to $E$, but that's a mystery to me as well.