To do that, we need to know the acceleration of the jumper over time.
Al-
though we compute acceleration in the slope function, it is not included in the
results.
It might be tempting to record the acceleration each time the slope function
runs, but we should not do that.
The ODE solver calls the slope function
many times with different values of
state
and
t
.
Because of the way the
solver works, not all of the states and times are actually part of the solution.
So recording acceleration while the solver is running would not work.
Instead, we can use the computed velocities to estimate acceleration as a func-
tion of time.
The
modsim
library provides
gradient
, which uses NumPy to estimate the
derivative of a
TimeSeries
. Here’s how it works:
a = gradient(results.v)
In the notebook for this chapter,
chap21.ipynb
, you can finish this problem
by finding the combination of
L
and
k
that allows the jumper to complete the
bungee dunk while minimizing the acceleration they experience. For instruc-
tions on downloading and running the code, see Section 0.4.

184
Chapter 21
Air resistance

Chapter 22
Projectiles in 2-D
In the previous chapter we modeled objects moving in one dimension, with
and without drag. Now let’s move on to two dimensions, and baseball!
In this chapter we model the flight of a baseball including the effect of air
resistance.
In the next chapter we use this model to solve an optimization
problem.
22.1
Baseball
To model the flight of a baseball, we have to make some modeling decisions.
To get started, we ignore any spin that might be on the ball, and the resulting
Magnus force (see
).
Under this assumption,
the ball travels in a vertical plane, so we’ll run simulations in two dimensions,
rather than three.
Air resistance has a substantial effect on most projectiles in air, so we will
include a drag force.
To model air resistance, we’ll need the mass, frontal area, and drag coefficient
of a baseball. Mass and diameter are easy to find (see
baseball
). Drag coefficient is only a little harder; according to
The Physics

186
Chapter 22
Projectiles in 2-D
of Baseball
1
, the drag coefficient of a baseball is approximately 0.33 (with no
units).
However, this value
does
depend on velocity. At low velocities it might be as
high as 0.5, and at high velocities as low as 0.28. Furthermore, the transition
between these regimes typically happens exactly in the range of velocities we
are interested in, between 20 m/s and 40 m/s.
Nevertheless, we’ll start with a simple model where the drag coefficient does
not depend on velocity; as an exercise at the end of this chapter, you will have
a chance to implement a more detailed model and see what effect is has on
the results.
But first we need a new computational tool, the
Vector
object.
22.2
Vectors
Now that we are working in two dimensions, we will find it useful to work with
vector quantities
, that is, quantities that represent both a magnitude and a
direction. We will use vectors to represent positions, velocities, accelerations,
and forces in two and three dimensions.