Skip to content
Tutorials Center
My learning

Topics

Lesson 39 of 39 ยท Projects and Practice

Project: Simulate a Bouncing Ball

Build a bouncing-ball simulation in Python that uses free fall, the coefficient of restitution and energy loss, then check it against exact formulas and plot the results.

In this project you will combine several ideas from the whole mechanics course into one program: free fall, impulses at the floor, the coefficient of restitution, energy loss, and total time before the ball comes to rest. You will build the model in steps, check it against exact formulas and then use it to answer questions.

The physics model

A ball is dropped from height hโ‚€. Between bounces, only gravity acts (we ignore air resistance), so the motion has constant acceleration โˆ’g. At each bounce, the ball's vertical velocity reverses and shrinks:

v_after = e ยท v_before (in magnitude), where e is the coefficient of restitution, 0 โ‰ค e < 1.

From the drop height we get the impact speed: vโ‚€ = โˆš(2 g hโ‚€). After the first bounce the ball leaves at eยทvโ‚€ and reaches a height hโ‚ = (e vโ‚€)ยฒ / (2g) = eยฒ hโ‚€. Each bounce multiplies the rebound height by eยฒ:

hโ‚™ = e^(2n) hโ‚€

The time of flight for a bounce that leaves at speed v is 2v/g (up and down). So the total time from the drop to the end of the infinite series of bounces is:

T_total = โˆš(2hโ‚€/g) ร— (1 + e)/(1 โˆ’ e)

(Falling the first time takes โˆš(2hโ‚€/g); each later bounce takes 2e^n โˆš(2hโ‚€/g), a geometric series.) Even though there are infinitely many bounces, they take a finite time to complete, like the paradox of Zeno resolved by a geometric sum.

For hโ‚€ = 1.0 m and e = 0.8: โˆš(2/9.81) = 0.4515 s, and (1.8)/(0.2) = 9, so T_total โ‰ˆ 4.06 s.

Step 1: bounce by bounce

The simplest simulation steps from bounce to bounce using exact formulas, with no time stepping.

Python Step 1: the bounce table

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

You should see the heights fall by the factor eยฒ = 0.64 each time, and the times creep toward the exact total.

Step 2: a time-stepping simulation

Real physics problems often have no neat formula, so we also learn to simulate. Here we advance time in small steps dt with the semi-implicit Euler method (update the velocity first, then the position) and handle the floor by reversing and scaling the velocity when the ball reaches y = 0.

Python Step 2: the time-stepping simulation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The simulated peak heights match the exact e^(2n) hโ‚€ values closely. The first list value is the starting height, 1.0 m. Small differences come from the finite time step. Reduce dt and they shrink.

Step 3: plot height against time

A picture of the motion shows the parabolic arcs and the shrinking bounces. The code below builds the curve from the exact formulas, one parabola per bounce.

Python Step 3: plot the motion

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 4: explore, then explain

Now use your model to answer questions. For each, make a prediction first.

  • What happens to the total time as e approaches 1? (Check the formula: the factor (1 + e)/(1 โˆ’ e) grows without limit.)
  • If the ball is dropped from a height four times larger, how does the total time change? (Time scales with โˆšhโ‚€, so it doubles.)
  • How many bounces until the rebound height is less than 1 cm for e = 0.8? You need 0.64โฟ < 0.01, so n > ln(0.01)/ln(0.64) โ‰ˆ 10.3: the 11th bounce.
Python Explore the effect of the coefficient of restitution

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The model is idealized: it ignores air resistance, spin, the ball's sideways motion and the real floor. A real ball also has a minimum bounce speed below which it effectively stops, so it stops a little sooner than the infinite series suggests. Treat the simulation as a model, not a measurement. If you try the experiment yourself, record your own data (drop height and rebound height), and compare it with e = โˆš(hโ‚‚/hโ‚).

Extensions

  • Add air resistance with a drag force proportional to vยฒ and compare the heights.
  • Add horizontal motion with a constant sideways velocity and plot the trajectory.
  • Add the energy graph: total mechanical energy versus time, showing sudden drops at each bounce.
flowchart TD
    A["Drop from h0"] --> B["Free fall: v = sqrt(2 g h)"]
    B --> C["Bounce: speed times e"]
    C --> D["Rise to e squared times previous height"]
    D --> B
    C --> E["Energy lost to heat and sound"]

The cycle of the bouncing ball. Each pass through the loop removes the fraction 1 โˆ’ eยฒ of the mechanical energy.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A ball with e = 0.8 is dropped from 1.0 m. How high does it rise after the first bounce?

    Height scales with the square of the speed, so hโ‚ = eยฒ hโ‚€ = 0.64 ร— 1.0 = 0.64 m.
  2. 2. What fraction of the ball's mechanical energy is lost in each bounce with e = 0.8?

    Energy is proportional to speed squared, so 64% is kept and 36% is lost per bounce.
  3. 3. Why does a ball with infinitely many bounces still stop after a finite time?

    Each flight lasts e times the previous one, so the total is a convergent geometric series.
  4. 4. Which method does the second simulation use to move the ball in time?

    It advances in steps of dt with semi-implicit Euler, reversing and scaling the velocity at the floor.

Summary

  • A bouncing ball combines free fall with a floor impulse that reverses and scales the velocity by e.
  • Rebound heights shrink by eยฒ per bounce: hโ‚™ = e^(2n) hโ‚€.
  • Total time for all bounces: โˆš(2hโ‚€/g) ร— (1 + e)/(1 โˆ’ e), finite although the bounces are infinite.
  • Exact formulas and a time-stepping simulation should agree; comparing them is a good test.
  • Models are idealizations; know what you have left out.

You have now covered forces, energy, momentum, circular motion and gravity. Return to the Physics: Mechanics course page to review the other chapters.