Teaching Critical Points and Fermat’s Theorem with Sports

In this edition of Teaching Math with Sports, we look at applications of critical points and Fermat’s Theorem in sports. Throughout a Calculus course, most – if not all – students find themselves asking: why? Why am I learning this? Why is this useful? To me, Fermat’s theorem about critical points is the reason to learn about derivatives.

While one can motivate the study of Calculus through geometry and physics, the best and most immediate application of derivatives is optimization. From business to engineering to statistics, studying how to optimize some quantity in terms of another is of central interest. Fermat’s theorem about critical points relates derivatives to optimization problems.

In this article we look at two in-depth examples applying Fermat’s theorem about critical points to problems in sports. In both, we can see derivatives being applied to solve not-at-all-obscure sports problems.

Teaching critical points and Fermat's theorem with sports

To receive email updates when new articles are posted, please us the subscription form below!

Background Theory: Fermat’s Theorem and Critical Points

To me, the biggest mistake in teaching Calculus in high school and in college is the constant application to unrelatable and uninteresting physics problems. Nobody is going to be excited about a problem asking how quickly two cars are approaching each other if one leaves at a certain time heading due north while another leaves at a different time heading southwest. While these problems are simple and illustrative, they obscure the beauty of mathematics and its ability to solve real-world problems.

Fermat’s Theorem about critical points can help this motivation problem. Fermat’s theorem is about finding maxima and minima of functions. The applications can be quite compelling. For example, one can study how to set the optimal price of a good they’re selling using this theorem. We’re going to introduce two examples for how to solve optimization problems in sports.

Fermat’s theorem is extremely simple. Fermat’s theorem says that a differentiable function has its extrema (maximum points and minimum points) at points where the derivative is zero. Therefore, to optimize a function over some open interval, take the derivative and solve for where it equals 0. If the function has any points over which it is not differentiable, those should also be checked. The set of such critical points give a set of candidate points the could be the maximizers or minimizers of the function.

Example 1: Optimal Launch Angle

Baseball was one of the first sports to undergo an analytics revolution. Two of the newest pet metrics when analyzing hitting prospects is their exit velocity and their launch angle. Exit velocity is easy to understand. Hitting the ball harder results in

  • Longer distance traveled (and, therefore, more home runs)
  • Quicker required reaction times by fielders to catch line drives
  • Higher likelihood of ground balls getting past the defender

Each of these translates to a better at-bat. But what about launch angle? Why do we care about what angle the ball leaves the bat?

There are many reasons we may care about launch angle. First of all, fly balls have a higher chance of evading defenders. However, launch angle also relates to the distance the ball travels. Moreover, we can model this relationship mathematically and use derivatives, Fermat’s theorem, and critical points to figure out the optimal launch angle.

Changing the launch angle in baseball is a great application of critical points and Fermat's theorem in sports

If the ball leaves the bat at too shallow an angle, it doesn’t have enough time to travel far even though its horizontal velocity is high. This is the blue curve above. If the ball leaves the bat at too high an angle, it sacrifices too much horizontal velocity even though the flight time is high. This is the green curve above. There is an optimal point somewhere in the middle.

Here is the mathematical model we’ll use to analyze this setting. This formula assumes no wind resistance (which is a big deal! The results here change dramatically when wind resistance comes into play) and can be derived with simple free-body diagrams.

Let v,g=9.8,\text{ and } \theta denote the exit velocity, gravitational constant, and launch angle, respectively. Then, the horizontal distance traveled is given by the formula x = \frac{2 v^2 \sin\theta\cos\theta}{g} . Since we want to optimize over the launch angle \theta , Fermat’s theorem suggests taking the derivative with respect to \theta .

Doing so results in the derivative \frac{dx}{d\theta} = \frac{2v^2\cos 2\theta}{g} . The critical points of this equation are when the derivative is zero. For each critical point, we must use, e.g. the second derivative test, to determine whether our candidate points are maxima or minima. Doing so results in an optimal launch angle of 45^o .

Challenge Question 1: How would you show that 45^o is a global maximum?

Example 2: NBA Shot Selection and Expected Points

In the last few years, the NBA has undergone a massive shift in playstyle. Spearheaded by the Warriors and the Rockets, teams are taking significantly more three point shots. The James Harden-Chris Paul-PJ Tucker Rockets team thrived by taking as many open and corner threes as possible. Why? Even the talking heads have this one right: the value of a three point shot is better than every other shot excluding uncontested shots at the rim.

We can actually prove this fact mathematically using Fermat’s theorem and the concept of critical points. The goal in this problem is to maximize the expected points on a given possession based on shot selection. To do this optimization using Calculus, we need to discern a functional relationship between expected points and the distance from which the shot is taken. The first step is to estimate shooting accuracy by distance.

One option to modeling shooting accuracy is to use the logistic curve, commonly used in logistic regression to model probabilities which are based in a continuous way on some other parameter. However, looking at the probability of making a shot by distance, the logistic curve does not appear to be a good model here. To read further about logistic regression, see this article about sports analytics and historical betting trends.

Instead, using this source we estimate NBA shooting accuracy using a piecewise linear function. We model shooting accuracy as a function of distance from the basket f(d) as follows:

Case 1: f(d)=0.8 - 0.1d, 0\leq d \leq 4

Case 2: f(d) = 0.4, 4\leq d \leq 20

Case 3: f(d) = 0.4 - 0.01(d-20), 20\leq d \leq 30

We are interested in which shot in the NBA is worth the most points on average, though. To compute expected points from our accuracy function f(d) , we multiply by 2 for shots from within 22 feet and by 3 for shots 22 feet or further away. The result is an expected-points-by-distance function P(d) of the form:

Case 1: P(d) = 1.6 -0.2d, 0 \leq d \leq 4

Case 2: P(d) = 0.8, 4 \leq d \leq 20

Case 3: P(d) = 0.8-0.02(d-20), 20 \leq d \leq 22

Case 4: P(d) = 1.2 - 0.03(d-20), 22 \leq d \leq 30

There are two types of critical points. First, a point where the derivative is 0 is a critical point. Second, a point where a function is not differentiable is a critical point. Some authors consider endpoints to be critical points, some don’t. Regardless, endpoints need to be checked as well. In order to find global maxima, we need to check all critical points.

The set of critical points for this function are x = 0,4,20,22,30 as well as all x \in [4,20] . Checking each of these points reveals that shots from 0 feet and from 22 feet are the best shots in basketball (they are local maxima when it comes to expected points).

This perfectly describes why the Houston Rockets entire offense is “layups and threes”. Layups are the most valuable shot. However, if a layup is unavailable – as it often is – the best bet is to take an open 3. This application of Fermat’s Theorem and critical points perfectly explains how the modern NBA has developed to where it is.

Challenge Question 2: How would the NBA game change if a four point line was added somewhere between 22 and 30 feet from the hoop?

Challenge Question Answers

  1. There are in general two ways to prove that a point is a global maximizer/minimizer. First, one can exploit concavity or convexity properties to argue that there exists only one local extrema and therefore this must be a global extrema. In our case, though, there are multiple local maxima and minima. Therefore, each one must be plugged into the objective function to evaluate. Luckily, though, the sine and cosine functions are periodic so this task is trivial in our example. Notice that multiple angles lead to the same objective function. Why is that?
  2. It would be interesting. Wherever the 4 point line was placed would become another “local maximum” for expected points. However, at-the-rim layups will remain the best overall value. Therefore, I predict the four point line would only be used in one of three scenarios. (a) If the rim and the three point line are closely guarded, then the 4 point line will be the next best shot. (b) At the end of games, expected points may not be the best metric to determine the value of a shot. For example, if you’re down 4 with one second left, 2 and 3 point shots have no value. (c) If you have somebody – a Step Curry type – who shoots accurately enough, the accuracy function f(d) would need to be changed. Perhaps in this setting the four point line becomes a global maxima.