This post captures my notes on the following problem from the last post:

Problem: Suppose that you are standing on the outer bank of a moat surrounding a castle, and you wish to secretly deliver a message, attached to a large rock, to your spy inside the castle. A wall h=11 meters high surrounds the castle, which is in turn surrounded by the moat which is d=19 meters wide. At what angle should you throw the rock in order to have the best chance of clearing the wall?

Solution: A projectile thrown from the origin with initial speed at an angle has a trajectory described by

Setting and and solving for and , we find the following expression for the required initial speed as a function of the throwing angle:

We can minimize this required initial speed by maximizing the denominator. Differentiating and setting equal to zero yields

Keeping in mind that the throwing angle is between 0 and 90 degrees, we can rewrite this expression as

where is the angle of the line of sight to the top of the wall. The geometric interpretation of this result is: to have the best chance of clearing the wall, throw at an angle halfway between the line of sight to the top of the wall and the vertical. In the original problem, this optimal throwing angle is about 60.03 degrees.

Recall, however, that this analysis assumes negligible effects of air resistance. This is a safe assumption for a relatively heavy rock at human-throwable speeds, but not for a baseball. If we apply this same analysis to Jackie Bradley, Jr.’s throw from home plate over the center field wall, 420 feet away and 17 feet high, we get an optimal throwing angle of about 46.2 degrees, with a minimum initial speed of only about 80.9 miles per hour, which is not terribly difficult to achieve.

To more accurately model the trajectory of a thrown (or batted) baseball, we must incorporate the effects of not only drag, which slows the ball down, but also the Magnus force, which “lifts” the ball causing it to “rise” and/or curve. The references below describe several interesting experiments tracking thrown and hit baseballs, including some useful approximation formulas for accurately modeling these trajectories, yielding my estimate from the last post that Bradley must have thrown the ball at over 105 miles per hour, with an optimal throwing angle of just a little over 30 degrees.

Since this is the sort of problem that I think is excellent for students to attack via computer simulation, following are the relevant formulas and constants collected in one place for them to use:

The acceleration of a thrown or batted baseball due to gravity, drag, and lift is given by

Yes, I think so. I am not familiar with lsode(), but it looks like it’s similar to MATLAB’s ODE solvers, which would also work. (MATLAB’s also have “events” which can terminate integration early when specified conditions are satisfied, such as “the ball reaches the wall,” or “the ball hits the ground.” Octave may have something similar?)

Note, however, that simple Euler integration will work just fine here as well, as long as your step size is small– I’m thinking like a teacher here, where (1) it’s much easier to explain v+=a*dt, and (2) if you’re actually animating/visualizing the entire trajectory, then you need a small step size anyway.