If we include turbulent drag, we get a good first approximation to the equation of motion of a 'real' baseball or golfball. Our equation is still only a first approximation because we have not attempted to deal with the effects of spin. Spin introduces a force transverse to the motion, and this can be good news or bad news. Golfers who hook or slice are well acquainted with the bad news. The good news is that spin provides lift. The lift enables a drive to be hit at a lower angle than otherwise, and this in turn increases the momentum transfer between the clubhead and the ball.
The example is too complex to act as an introduction to the Feynman algorithm in two dimensions - the example in the next section is better for that purpose. The program finds the minimum initial velocity a baseball requires to travel 450 feet before returning to the elevation from which it starts. In order to write Newton's law, we must first resolve the drag force into x and y components. (A common error at this point is to use the squares of the x and y velocities in the equations for the x and y accelerations.) The acceleration equations are coupled (the equation for the x acceleration includes the y velocity and conversely), and have no analytic solution. The acceleration equations in the program are not written in terms of the terminal velocity of a baseball, but the terminal velocity can be calculated from the given data, and is 34.7 m/s.
The program is complicated by the fact that we are trying to find the minimum velocity required for a specified horizontal range. Had we been given the initial velocity (magnitude and direction) and asked for the horizontal range, we would have only needed the Feynman algorithm. In our problem we have to try different initial speeds and launch angles until we find the combination that has the lowest initial speed for a range of 450 feet. We do this in two stages. For every trial initial speed, we vary the launch angle to find the one that maximizes the range. The routine that does this steps the angle up and down across the angle for maximum range in progressively smaller steps. (The procedure is something like a one-dimensional version of the Simplex algorithm used in the section on the analysis of ellipsometric data). When the optimum angle has been determined, the trajectory is plotted, and the initial velocity and launch angle are printed. The second stage, varying the velocity to find the value which gives a range of 450 feet, uses a bisection algorithm. The bisection algorithm starts with velocity values that bracket the desired range, and progressively narrows the difference between them until they differ by less than a specified amount. The "Motion" button shows (once the initial velocity has been found) how the ball moves with and without air resistance. (The second time the "Motion" button is pressed, the time interval is adjusted to show the motion in real time.)
A Grade 9 student wrote me asking for help in finding the effect of wind on the flight of a golfball. (I told him that I would have found it a very difficult problem when I was in Grade 9.) I took his numbers, a golfball hit at 100 mph in a 10-mph wind that could be a headwind, tailwind, or crosswind, assumed a launch angle of 37 degrees, and created the next example. If one works in a coordinate system moving with the wind, the baseball algorithm can be used for the golfball. The flight time and landing point in the moving frame are then used to find where the ball lands in a stationary frame. With no wind the ball travels 95 meters and lands at the center of the 30-meter diameter green circle.
The program can be adapted to answer another question: why does newsreel footage from the second world war show battleships firing their guns at elevations above forty-five degrees? As our program stands, it will never give an optimum angle above forty-five degrees. The answer lies in the very long range of the large guns on battleships, and the fact that air gets thinner as we go up. The variation in pressure with elevation in the atmosphere is governed by dp = -rg dy. If the temperature does not vary significantly, density is proportional to pressure, and we can write dr/r = -(rog/po) dy, and hence r = ro exp(-y/h), where h = 105/(9.8*1.212) = 8433 m. The program is easily modified to take the density variation in the atmosphere into account. The example finds the optimum launch angle (the one that requires the lowest initial velocity) to give an iron sphere 40 cm in diameter a horizontal range of 40 km. The red curve and initial velocity are for no air resistance. The 4 yellow curves and the final magenta curve and initial velocity are for an atmosphere whose density does not decrease with elevation. The yellow curves are for 1, 2, 3, and 4 times the launch velocity without air resistance. Note that the range for the 4th curve is just over half the desired range, and that initial velocity required for the full range is over 25 km/s. The four green and final blue curve and initial velocity are for a variable density atmosphere. The 3rd and 4th green curves bracket the desired range, and the initial velocity required for a 40 km range is a physically attainable 2.05 km/s. (The grid lines in the figure are 5 km apart.) The "Motion" button shows one projectile moving through air and another through vacuum, each launched at the angle for maximum range.