05 June 2017

Triathlon math - Which event affects your time the most?

This weekend two friends and I had a blast doing the relay version of the Rock Hall Sprint Triathlon (we so cleverly named ourselves Team U+1F4A9 -- you can find our results here if you can figure out the name). I was really excited for my first open-water event since I started swimming consistently a few years ago, and my first ever swim race! I finished the 750 m-long swim leg in 17:45 -- a little slower than my pool times, but at least I finished, and I know that for next time I have to practice swimming in a straight line. Devin turned out a solid time for the bike course, and Carolyn finished the run 1:30 under her prediction, so all in all we had a really fun and successful triathlon.

Biting my medal to see if it's really made from real gold

During the long drive home, Devin and I got into a debate over whether the swim, the bike, or the run improve your time the most when you increase your pace. Our guess was that it's the bike, since it just takes up so much more time. Once I got home, I decided to model it and see if our guess holds up. Heads up - I use some basic calculus.

The total time it takes to complete a triathlon is just the sum of the times it takes to complete the three stages. Since the time it takes to cover a distance is distance / speed, this equation gave me my starting point.
\[ \mathrm{Total~time} = \frac{d_{\mathrm{swim}}}{v_{\mathrm{swim}}} + \frac{d_{\mathrm{bike}}}{v_{\mathrm{bike}}} + \frac{d_{\mathrm{run}}}{v_{\mathrm{run}}} \] For a given race, the different distances are fixed. For example, for our race, the swim was 750 m (0.75 km), the bike was 15 miles (24.14 km), and the run was 5k. The variables here are the three velocities - how fast you choose to take each leg. For our purposes, the average speed is perfectly fine (velocity and speed are interchangeable). The first question is: How does the total time change, if you take the different legs at different speeds? For these we want the partial derivatives: \[ \frac{\partial T}{\partial v_i} = - \frac{d_i}{v_i^2} \] (replace i with swim, bike, or run - it's the same for all of them. There are two takeaways here: First, the time you save depends on the distance you're covering. This makes intuitive sense, and is the reasoning behind our initial guess that the bike is the most important. However, there's a twist! The second takeaway is that the rate of change depends on the inverse of the velocity squared. This means that at slow speeds, a small change makes a big difference, but at high speeds, a small change makes very little difference. Going from 4 km/hr to 5 km/hr - reasonable swimming speeds - is a much bigger overall difference than going from 20 km/hr to 21 km/hr. In the plot here, look at how much steeper 1/x^2 is than 1/x at 5, and how much flatter it is around 20.
Here's what the derivatives look like for each event:


As we expected, the bike has the biggest derivate, meaning that it affects the time most. This is driven by the fact that d_bike is much larger than d_swim and d_run.
 
Here is the experiment I set up: Let's say you do the bike at velocity v1 one time, and velocity v2 the next. How much time did you gain? This is given by integrating \( \frac{\partial T}{\partial v_i} \) over the range of velocities, v1 to v2:
\[
dT = \int_{v_1}^{v_2} \frac{\partial T}{\partial v} dv
\]

We're all set up now! I picked a velocity range that covers reasonable values for the run, bike, and swim - 1 km/hr to 40 km/hr - and calculated the total time you would gain if you did a leg at one velocity and then again at another velocity, for all pairs of velocities. This is what that looks like:


The darkness of each pixel tells you how many minutes you would save for the Rock Hall Sprint Triathlon if you did it at Speed 1 (x-axis) versus if you did it at Speed 2 (y axis). Darker = saving more time, as you can see in the scale bars. The white diagonal shows that, intuitively, if you do an event twice at the same speed, you will get 0 difference in time. The pixels below the white diagonal technically correspond to Speed 1 being faster than Speed 2, so the pixel values should be negative (i.e. you took longer the second time than the first time). I just multiplied them by -1 to make it easier to plot; in any case, the graphs are symmetric about the diagonal.

There are a few things that stand out. All the graphs are on the same scale, so the fact that the bike is the darkest of the three tells you that, all things being equal (like, Speed 1 and Speed 2), the bike nets you the best decrease in time. This is just because \(d_{\mathrm{bike}}\) is the longest.

We also said that improving at the slow end of the range nets you more improvement than on the fast end of the range, and we see that here with left and bottom sides being the darkest. That's important! Realistic swimming speeds are going to be concentrated down in the lower left, whereas cycling speeds will be further up the diagonal into the relatively brighter regions.

It's hard to tell by eye which event has the darkest regions over the relevant speeds. In the next post, I'll take a closer look on how our predictions hold up once you actually start to compare realistic speeds and speed changes for each event.

No comments: