Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 47 ยท Ordinary Differential Equations

Projectile Motion with Air Drag

Simulate a projectile with quadratic air drag using scipy solve_ivp and event detection, find the best launch angle, check limits and terminal velocity, and see why drag skews the arc.

Without air, a projectile follows a perfect parabola and the best launch angle is 45 degrees. With air, the path is shorter, steeper on the way down, and the best angle drops below 45 degrees. There is no neat formula for any of this, which is exactly why you need a numerical method. This lesson builds a complete, checked drag simulation, the first full "problem" of the course.

Three projectile arcs launched at 30 m/s and 45 degrees: a dashed parabola without drag and two shorter arcs with increasing drag
Quadratic drag shortens the range and makes the descent steeper than the ascent. Range values were computed with RK4.

What you will learn

  • The physics of quadratic air drag and the model's assumptions.
  • How to set up the state vector and use solve_ivp with an event for ground impact.
  • How to verify the code with the no-drag limit and the terminal velocity.
  • How to find the optimal launch angle numerically.

Key terms

Quadratic drag: a force opposing the velocity with magnitude ยฝ ฯ C_d A vยฒ.

Drag coefficient C_d: a dimensionless number depending on shape (a few tenths for a ball in the regime considered here).

Terminal velocity: the speed at which drag balances gravity, v_t = โˆš(g/k).

Event: a condition (such as y = 0) that stops or marks the integration.

The model

A ball of mass m moves through air of density ฯ (about 1.2 kg/mยณ near sea level). Its cross-section is A. For fast motion of a smooth, non-spinning body, drag is quadratic in speed:

F_drag = โˆ’ยฝ ฯ C_d A |v| v

where v is the velocity vector, so the force points opposite to the motion. Dividing by m gives an acceleration โˆ’k |v| v with a single lumped constant

k = ฯ C_d A / (2 m) (units: 1/m)

The equations of motion for the state (x, y, v_x, v_y) are

xโ€ฒ = v_x, yโ€ฒ = v_y v_xโ€ฒ = โˆ’k |v| v_x v_yโ€ฒ = โˆ’g โˆ’ k |v| v_y, with |v| = โˆš(v_xยฒ + v_yยฒ).

Assumptions: constant air density, no wind, no spin (so no Magnus force), and a constant C_d. Real baseballs, golf balls and footballs violate some of these, so treat results as a model, not a prediction.

Setting up solve_ivp with an event

solve_ivp integrates until the end time you give it, but you want to stop when the ball lands. An event function returns a value that crosses zero at the moment of interest; setting terminal = True ends the run there, and direction = -1 triggers only on downward crossings. The solver locates the crossing precisely, so the landing point is not limited to the grid.

Python A baseball with and without drag

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.

Verification: three checks before you trust a number

  1. No-drag limit. With k = 0, the range must equal vโ‚€ยฒ sin 2ฮธ / g, the time of flight 2 vโ‚€ sin ฮธ / g, and the maximum height vโ‚€ยฒ sinยฒฮธ / (2g). If this fails, nothing else matters.
  2. Terminal velocity. For a vertical drop from rest the speed approaches โˆš(g/k), the value where k vยฒ = g.
  3. Tolerance test. Tighten rtol and see whether the result changes in the digits you plan to report.
Python Verification checks

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 best launch angle

With drag, the best angle is below 45 degrees because a flatter path spends less time in the air losing speed. A numerical scan finds it. For the baseball model at 40 m/s, scan angles from 10 to 80 degrees and pick the maximum range.

Python Range versus angle with and without drag

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 scan uses steps of 2 degrees, so the no-drag best angle appears as 46 rather than exactly 45. Each drag level moves the best angle further below 45 degrees.

Why the descent is steeper

On the way up, gravity and drag both slow the ball. On the way down gravity speeds it up but drag fights back. The result is an asymmetric arc: the descent angle is steeper than the launch angle. For a heavy drag the ball approaches terminal velocity and falls almost vertically at the end. This asymmetry is visible in the figure at the top of the lesson.

Common misconceptions

"Drag only reduces speed, so the shape stays a parabola." Drag is not constant, it depends on speed and direction, so the path is no longer a parabola.

"The optimal angle is 45 degrees." That is true only without drag, and only for launch and landing at the same height.

"A stricter tolerance fixes any error." It reduces numerical error only. If the model leaves out wind or spin, the result still differs from reality.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. In the model a = -k |v| v, what are the units of k?

    k |v|^2 must have units of acceleration (m/s^2), so k is 1/m.
  2. 2. What does terminal = True do for an event in solve_ivp?

    A terminal event ends the integration at the moment the event function crosses zero.
  3. 3. What should a drag code reproduce when k is set to zero?

    The k = 0 limit has a known exact answer, a perfect verification test.
  4. 4. The terminal velocity in the quadratic model is

    At terminal speed k v^2 = g, so v = sqrt(g / k).
  5. 5. With quadratic drag, the best launch angle for maximum range is

    A flatter trajectory loses less speed to drag.

Summary

  • Quadratic drag gives a = โˆ’g ลท โˆ’ k |v| v; there is no closed-form path.
  • Use solve_ivp with a terminal event to land precisely on the ground.
  • Verify with the no-drag formulas, terminal speed and tolerance checks.
  • Drag lowers the optimal angle below 45 degrees and makes the descent steeper.
  • The model is only as good as its assumptions: no wind, no spin, constant C_d.

Next: Chapter 3 Review