12 Optimizing a physical system

 

This chapter covers

  • Building and visualizing a simulation for a projectile
  • Finding maximal and minimal values for a function using derivatives
  • Tuning simulations with parameters
  • Visualizing spaces of input parameters for simulations
  • Implementing gradient ascent to maximize functions of several variables

For most of the last few chapters, we’ve focused on a physical simulation for a video game. This is a fun and simple example to work with, but there are far more important and lucrative applications. For any big feat of engineering like sending a rocket to Mars, building a bridge, or drilling an oil well, it’s important to know that it’s going to be safe, successful, and on budget before you attempt it. In each of these projects, there are quantities you want to optimize. For instance, you may want to minimize the travel time for your rocket, minimize the amount or cost of concrete in a bridge, or maximize the amount of oil produced by your well.

To learn about optimization, we’ll focus on the simple example of a projectile− namely, a cannonball being fired from a cannon. Assuming the cannonball comes out of the barrel at the same speed every time, the launch angle will decide the trajectory (figure 12.1).

Figure 12.1 Trajectories for a cannonball fired at four different launch angles

12.1 Testing a projectile simulation

12.1.1 Building a simulation with Euler’s method

12.1.2 Measuring properties of the trajectory

12.1.3 Exploring different launch angles

12.1.4 Exercises

12.2 Calculating the optimal range

12.2.1 Finding the projectile range as a function of the launch angle

12.2.2 Solving for the maximum range

12.2.3 Identifying maxima and minima