Home Run

from Essential Mathematica for Students of Science
© James J. Kelly, 1998
Last revised: January, 2006

Introduction

Air resistance has a very important effect upon the trajectory of a batted baseball, but the equations of motion cannot be solved analytically when damping is included (except for very special cases).  Therefore, we use this relatively simple physical problem to illustrate the use of NDSolve for systems of coupled nonlinear differential equations and some useful programming techniques for Mathematica.

We consider two types of drag forces.  When a small spherical object moves through a viscous fluid at relatively low speeds, such that the fluid exhibits a steady streamline flow around the object, Stoke's theory suggests that the resistive force is \(TraditionalForm\`F\&⇀\  = \ \(-α\)\ v\&⇀\) with α = 6  π η r, where η is the coefficient of viscosity and r is the radius of the object.  For objects with other shapes the drag coefficient will have a different form and may depend upon the orientation of the object relative to its velocity.  For larger objects or larger speeds, air drag is better approximated by a quadratic expression of the form \(TraditionalForm\`F\&⇀\  = \ \(-β\)\ v\ v\&⇀\).  The coefficient can be estimated by assuming that the fluid within the cylindrical volume swept by the object must be given enough kinetic energy to reach the same velocity as the object, from which we expect β = (π/2) ρ (r^2) C where ρ is the density of the fluid and C ≤ 1 is a correction factor for the fraction of the fluid that flows around the object without attaining the same velocity.  The parameters η and C depend upon the nature of the fluid, the shape and texture of the object, and other effects which are difficult to predict accurately.

Initialization

ClearAll["Global`*"];
Off[General::spell, General::spell1];
$TextStyle = {FontFamily -> "Times", 
          FontSize -> 12};

Needs["Utilities`Notation`"];
Needs["Miscellaneous`PhysicalConstants`"];
Needs["Miscellaneous`Units`"]

Off[Symbolize::"boxSymbolExists"];

Symbolize[(Subscript[x, 0])];   Symbolize[(Subscript[y, 0])];
Symbolize[(Subscript[v, 0])];   Symbolize[(Subscript[θ, 0])];
Symbolize[(Subscript[v, x0])]; Symbolize[(Subscript[v, y0])];

Equations of motion

Ideal trajectory

The ballistic trajectory in the absence of air resistance can be written immediately in closed form.  In addition to the initial conditions, we include an argument parameters which is intended to be a list of replacement rules specifying physical parameters m and g.  Although m is irrelevant to the ideal trajectory, it will be needed for resisted motion.

freeTrajectory[(Subscript[x, 0]) : _, (Subscript[y, 0]) : _, (Subscript[v, 0]) : _, (Subscript[θ, 0]) : _,  
          parameters_]  := {(Subscript[x, 0]) + (Subscript[v, 0]) Cos[(Subscript[θ, 0])] t, 
            (Subscript[y, 0]) + (Subscript[v, 0]) Sin[(Subscript[θ, 0])] t - ((g (t^2))/2)}  /. 
          parameters;

Baseball with air resistance

The equations for the motion of a projectile in a uniform gravitational field (flat earth approximation) subject to air resistance, including both linear and quadratic velocity dependencies are:

equationsOfMotion={m x''[t]==-(α + β v[t]) x'[t],m y''[t]==-m g-(α + β v[t]) y'[t]}/.v[t]->(Sqrt[((x'[t])^2)+((y'[t])^2)]);

It is convenient to express the initial velocity in terms of speed and angle.  The following functions translates these initial conditions into the Cartesian components of velocity and includes the initial position also in the form of a set of equations that can be given to NDSolve.

ic[(Subscript[x, 0]) : _,  (Subscript[y, 0]) : _, (Subscript[v, 0]) : _, (Subscript[θ, 0]) : _]={x[0] == (Subscript[x, 0]),y[0] == (Subscript[y, 0]),x'[0]==(Subscript[v, 0]) Cos[(Subscript[θ, 0])],y'[0]==(Subscript[v, 0]) Sin[(Subscript[θ, 0])]};

The complete set of equations is obtained by joining the equations of motion with the initial conditions and applying the replacement rules specifying the physical parameters.

eq1[(Subscript[x, 0]) : _,  (Subscript[y, 0]) : _, (Subscript[v, 0]) : _, (Subscript[θ, 0]) : _,  parameters_]  :=  
        Join[equationsOfMotion, ic[(Subscript[x, 0]),  (Subscript[y, 0]), (Subscript[v, 0]), (Subscript[θ, 0])]]  /. 
          parameters;

The trajectory is the two-dimensional vector solution of these differential equations and is expressed as a function of the initial conditions and physical parameters.

resistedTrajectory[(Subscript[x, 0]) : _, (Subscript[y, 0]) : _, (Subscript[v, 0]) : _, (Subscript[θ, 0]) : _, 
          parameters_] := {x[t], y[t]}  /. 
            NDSolve[eq1[(Subscript[x, 0]),  (Subscript[y, 0]), (Subscript[v, 0]), (Subscript[θ, 0]),  parameters], {x, 
                y}, {t, 0, 20}]  // Flatten;

Baseball parameters

Choose parameters that might be suitable for a baseball game at sea level.  SI units are employed.

baseballParameters = {g -> 9.8, 
          m -> 0.145, α -> 
            6  π η r, β -> (π/2) ρ (r^2) C} /. {r -> 0.0366, η -> 1.8 (10^(-5)), ρ -> 
            1.2,  C -> 0.3}

Going, going, gone!

Compute and plot a trajectory for a home run

The length of typical major-league home run is about 400 feet, or

Convert[400 Feet,  Meter] // N

A little bit of trial and error, or some knowledge of the game, suggests that an initial speed of about 120 mph is needed.

Convert[120 Mile/Hour,  Meter/Second] // N

It is useful to define a function which, given initial conditions and parameters, produces a plot that compares the trajectories with and without air resistance.  Note that we set AspectRatio->1 so that the trajectories will look correct; the default setting would distort the appearance of this plot.

\(\(plotResistedVsFreeTrajectories[\(x\_0\) : _, \ \(y\_0\) : _, \(v\_0\) : _, \(θ\_0\) : _, parameters_] := 
        ParametricPlot[
          Evaluate[{resistedTrajectory[x\_0, y\_0, v\_0, θ\_0, 
                parameters], 
              freeTrajectory[x\_0, y\_0, v\_0, θ\_0, 
                parameters]}], {t, 0, 10}, 
          PlotRange -> {{0, 250}, {0, 50}}, Frame -> True, 
          GridLines -> Automatic, AspectRatio -> Automatic, 
          FrameLabel -> {"x (m)", "y (m)", "Baseball with Air Resistance", " "}];\)\)

Thus, for typical initial conditions and baseball parameters, we find that air resistance reduces the range from near 250 m to about 130 m.  Without air resistance, the ballpark would need to be about twice as long!

plotResistedVsFreeTrajectories[0,  0, 50, 35 Degree, 
        baseballParameters];

Effect of resistance on velocity

Similarly, it is useful to define a function which, given initial conditions and parameters, graphically compares velocity components with and without air resistance.  The velocities are obtained simply by differentiating positions with respect to time.  For the purposes of illustration, we continue these trajectories for large times beyond the point where the ball returns to the ground.  We might imagine that the edge of the field is a cliff and that Wile E. Coyote is attempting to catch a well-struck ball.

\(\(plotResistedVsFreeVelocities[\(x\_0\) : _, \ \(y\_0\) : _, \(v\_0\) : _, \(θ\_0\) : _, parameters_] := 

        Plot[Evaluate[{D[
                resistedTrajectory[x\_0, y\_0, v\_0, θ\_0, 
                  parameters], t], 
              D[freeTrajectory[x\_0, y\_0, v\_0, θ\_0, parameters], 
                t]\ }], {t, 0, 20}, 
          PlotRange -> {{0, 20}, {\(-100\), 50}}, 
          AspectRatio -> 1. , Frame -> True, 
          GridLines -> Automatic, 
          FrameLabel -> {"t (s)", "v (m/s)", "Velocity Components", " "}];\)\)

plotResistedVsFreeVelocities[0,  0, 50, 35 Degree, 
        baseballParameters];

In the absence of resistance, (Subscript[v, x]) is constant while (Subscript[v, y]) has a linear time dependence produced by constant acceleration.  However, air resistance eventually extinguishes the horizontal velocity and the ball falls vertically downward.  Furthermore, the vertical velocity eventually approaches a constant called the terminal velocity.  Evidently, the terminal velocity for a baseball is approximately 45 m/s.  It is interesting to observe that the terminal velocity is quite similar to the initial velocity needed for home run, although this is an accidental coincidence.

Dependence on initial angle

Everyone knows the optimal angle is 45° in the absence of air resistance.  The effect of air resistance upon the optimal angle can be easily investigated graphically.  We plot a table of trajectories and supply the iterator as an argument to the function.

\(\(plotAngleDependence[\(x\_0\) : _, \ \(y\_0\) : _, \(v\_0\) : _, 
          angles_, parameters_] := 
	
        ParametricPlot[
          Evaluate[
            Table[resistedTrajectory[x\_0, y\_0, v\_0, θ\_0, 
                parameters], \ angles]\ ], {t, 0, 10}, 
          PlotRange -> {{0, 150}, {0, 50}}, Frame -> True, 
          GridLines -> Automatic, AspectRatio -> Automatic, 
          FrameLabel -> {"x (m)", "y (m)", "Dependence on Initial Angle", " "}];\)\)

plotAngleDependence[0, 0, 
        50, {(Subscript[θ, 0]),  30  Degree,  50  Degree,  5 Degree},  
        baseballParameters];

The ideal angle is apparently near 40°; the angular shift is small for baseball but is larger for golf.  We leave more precise determination of this angle as an exercise.

Dependence of trajectories upon damping coefficients

Dependence on linear coefficient, with quadratic term neglected.

αParameters = {g -> 9.8, 
          m -> 0.145, β -> 0};
βParameters = {g -> 9.8, 
          m -> 0.145, α -> 0};

\(\(plotDamping[\(x\_0\) : _, \ \(y\_0\) : _, \(v\_0\) : _, \(θ\_0\) : _, parameters_, damping_, title_] := 
	
        ParametricPlot[
          Evaluate[
            Table[resistedTrajectory[x\_0, y\_0, v\_0, θ\_0, 
                parameters], \ damping]\ ], {t, 0, 10}, 
          PlotRange -> {{0, 300}, {0, 60}}, Frame -> True, 
          GridLines -> Automatic, AspectRatio -> Automatic, 
          FrameLabel -> {"x (m)", "y (m)", 
              title, " "}];\)\)

plotDamping[0, 0, 50,  
        40  Degree,  αParameters,  {α, 0, 0.1, 
          0.02}, "Linear Damping"];

The value of α needed to reduce the range to typical home run length is much larger than expected for a baseball.  Apparently quadratic damping dominates.

Dependence on quadratic coefficient, with linear term neglected.

plotDamping[0, 0, 50,  
        40  Degree,  βParameters,  {β, 0, 0.002, 
          0.0005}, "Quadratic Damping"];

How large would one need to build a baseball field on the moon?

Write a function which evaluates the range given the initial velocity and physical parameters.  Plot the range as a function of initial angle for typical baseball speeds.

Evaluate the dependence of home run hitting on altitude assuming the dominant effect is due to air density.  Compare Denver with a sea-level city.  Similarly, evaluate the dependence on temperature.