It seems to me that Hamiltonian formalism does not suit well for problems involving instantaneous change of momentum, like particle collisions with hard wall or hard sphere gas model. At least I could not apply it straightforwardly to the simplest possible problem of 1D particle hitting a wall:

```
│/ wall
│/
particle │/
───o────────┼────────────> x
│/
│/
│/
```

My attempt was quite direct. I took the Hamiltonian to be

$$H = \frac{p^2}{2m} + U(x)$$

with potential $U$ defined as

$$U(x) = \cases{ 0, \; x < 0, \\[.5em] K, \; x > 0, \\[.5em] E, \; x= 0.}$$

where $E$ is the particle energy and $K > E$. Hamiltonian equations should read as

$$\cases{\dot x = \frac{p}{m}, \\[.6em] \dot p = – \frac{d U}{d x}.}$$

It is not hard to integrate the first equation, but my attempts to integrate the second one did not lead to any meaningful result (that's why I do not share them here, it was a complete failure).

So I ask whether it is possible to obtain the solution to the problem by directly integrating Hamiltonian equations in the form above, without relying on general mechanical theorems/principles like energy conservation? Or is such an approach completely unsuitable for the task?

If so, what is the general (and elegant) approach to such systems?

There exist a related question on PSE "Hamiltonian function for classical hard-sphere elastic collision", but the setting is more cumbersome.

## Best Answer

Perhaps the simplest and most intuitive approach is to regularize the hard wall potential

$$V_0(x)~=~\left\{ \begin{array}{rcl} 0 &\text{for}& x<0 \cr\cr \infty &\text{for}& x>0\end{array}\right. $$

as

$$ \lim_{\varepsilon \to 0^+} V_{\varepsilon}(x) ~=~V_0(x).$$

For instance, one could choose the regularized potential as

$$ V_{\varepsilon}(x)~=~\frac{x}{\varepsilon}\theta(x).$$

This corresponds to constant velocity for $x<0$ and constant acceleration for $x>0$. Next write down a continuous solution for the position $x_{\varepsilon}(t)$ as a function of time $t$, say, for given pertinent initial conditions.

Finally, at the end of the calculation, one should remove the regularization $\varepsilon \to 0^+$ again, and check if the limit $$ \lim_{\varepsilon \to 0^+} x_{\varepsilon}(t)$$ makes physical sense.