Other wavy paths

I got some good replies on Mastodon after Saturday’s post. Longtime friend of the blog Nathan Grigg said he’s always assumed that GPS-measured lengths would be long because no matter how straight your path, the GPS error would make it zigzagged. Then wherami and thvedt pointed out that the official rules of these events say that the race’s distance is supposed to be measured along the shortest path. If the road is curving left, it should be measured along the left edge; if the road is curving right, it should be measured along the right edge. This makes sense, as you don’t want runners to be able to run less than the official distance.

As you can see from this Fitness app screenshot of my route, the 5k at the Morton Arboretum has both right and left curves, so the route measurement must be done carefully if it’s to be by the rules.

Morton Arboretum 5k route

I began thinking about calculating the length of a zigzag path along a road that went in a circuit. The simplest circuit is a circle, and I thought it would be easier to define my path as a sinusoid within the roadway. Like this:

Wavy path around a circle

Following the principle that you should walk before you run, I started with a simpler problem: a sinusoidal path along a straight road.

Wavy path along a straight road

Taking the length of the road as d and the width as w, I defined the wavy path as

y=w2(1cosnπxd)

where the x axis runs along the bottom edge of the road, and the y axis runs across the road.

A differential length of arc is

ds=dx2+dy2=1+(nπw2d)2sin2nπxddx

Integrating this from 0 to d gives us the length of the wavy path. This can be done through elliptic integrals, but I’ve never felt comfortable with them, so I just did it numerically, using d=5000, w=5, and plugging in different values of n until I got a result of 5070, which is, as you might recall, the distance my watch gave as I finished the race.

The answer I got was n=151.5. Here’s the Mathematica code that got me there:

Mathematica solution for straight road

This is slightly less than the n=167.9 I got in Saturday’s analysis, where I took the path to be a series of straight-line segments. The lower number for a sinusoid makes sense. The path distance from one edge of the road to another is longer when following a sinusoid than when going in a straight line.

Now let’s tackle the problem of a wavy path along a circular road. Polar coordinates seem like our best bet for this. We’ll define the radius of the wavy path as

r=(ri+w2)w2cosnt2

where

ri=50002π

is the radius of the inside edge of the circle, the circumference of which is the 5000 m length of the race. We’ll use w=5 as before.

In polar coordinates, differential arc length has a more complicated definition:

ds=dr2+(rdθ)2=(nw4)2sin2nt2+[(ri+w2)w2cosnt2]2dθ

Numerical integration of this over θ from 0 to 2π with different values of n led to a solution of n=133.4 to get a path length of 5070. Here’s a screenshot of the Mathematica code:

Mathematica solution for a circular road

I used t for θ because it’s easier to type.

That this value of n is smaller than for the straight road makes sense because all of the path is beyond the inner edge of the roadway. The waviness is centered on a path that’s already longer than the course.

I suppose I could have set up iterative solutions in Mathematica to get the values of n that led to path lengths of 5070. But NIntegrate worked so quickly that it was faster to just work my way to n via trial-and-error.

I should also mention that Mathematica has an ArcLength function, which seemed at first like the right way to go. But it was extremely slow, possibly because it was trying to get an analytical solution. By doing a little thinking to get the equations for the differential arc length, I saved myself a lot of time.