You can add the bouncing behavior using a mirroring method, where we relax the system and instead of bouncing the ball one allows it to cross to y<0 and changes the sign of the potential accordingly. It can be written as $H=\frac{p^2}{2m}+mg|y|$ where $|y|=y$ if $y>=0$ and $|y|=-y$ if $y<0$. Potential then looks like (for $m,g=1$) [![enter image description here][1]][1] Equation of motion becomes $\ddot y(t)=-mg\,sgn(y)$, where $sgn(y)$ is the sign function of y (a Heaviside-theta-like function). To allow equlilibrium at $y=0$ to exist, we can define $sgn(0)\equiv0$. Writing this in [Wolfram Alpha][2] (with $m=g=1$ for simplicity) gives the following graphs related to explicit solution $y(t)$ and phase diagram trajectories (similar to a spring but instead of $sin$/$cos$ functions, its smoothly connected parabolas): [![][3]][3] Inserting the [Hamiltonian][4] gives a better look at phase space appearance [![][5]][5] As for solutions, here's one: For given initial conditions $y_0>0$, $v_0$, the (downward-facing) initial parabolic trajectory is given by $y_{init}(t)=y_0+v_0t-\frac g2t^2$.$\,\,\,\,\,\,\,\,\,\,$(1) It will bounce for the first time when $y_{init}(t)=0$ with $t>0$ and the "last time" it "has bounced" is the other root. The difference between the two roots is the period of bouncing $T$, given by $T=\sqrt{v_0^2+2g\,y_0}$. Then, by using a sawtooth function of period $T$ $\tau(t)=t-T \lfloor t/T \rfloor$, the bouncing trajectory is $y(t)=y_{init}(\tau(t))$, with $y_{init}$ given by (1). For $C^2$ trajectories (and actual solutions to the above hamiltonian) the sign of the function should change every period. [1]: https://i.sstatic.net/2CjD4.png [2]: https://www.wolframalpha.com/input/?i2d=true&i=D%5By%2C%7Bt%2C2%7D%5D%3D-sgn%28y%29 [3]: https://i.sstatic.net/Clljq.gif [4]: https://www.wolframalpha.com/input/?i2d=true&i=plot+H%3DDivide%5BPower%5Bp%2C+2%5D%2C2%5D%2B%7Cy%7C [5]: https://i.sstatic.net/NrEXB.png