The Mathematics of my commute plot

In order to explain how I generated the graph of my bicycle commute, first I should explain how I got the data. Late in the Fall of 1998, I walked up the route, carrying a 4-foot level and a measuring tape. I held one end of the level on the road, holding it level of course, and measured the distance down to the road at the other end. I then walked along the route, counting my paces, until I found another likely spot. I tried to measure anywhere near any changes of gradient. I recorded the paces and the inches of elevation.

I rode the bus back down. The bus driver was real curious about what I was doing with this 4-foot long level on the side of the road for almost an hour. I tried to explain, but I don't think he believed me.

What I got from that, once I converted my paces to feet along the route and the inches to a ratio of incline (this is exactly the slope of the curve at each point, was a set of data points of the slope dy/dx of the curve at various points along the curve.

So, how do you convert this data to a plot? The first hassle was to convert these data points to a continuous function, reasonably approximating the slope of the road. I did this using Maple's spline function, but it caused some trouble. The problem is that the spline could not be manipulated as an ordinary function. A spline is a way to connect the dots from a data set to get a smooth approximating function. Usually, you want to use a cubic spline, which uses the best-approximating cubic through each adjacent set of three data points, making sure the slopes match up at the ends. This was too hard for Maple, with all the data points I had (54). So I used a ``linear spline'', which is really just a piecewise-linear approximation. This means I really just connected the dots with straight lines. The slope then is continuous, but it is not itself differentiable.

When I say that Maple couldn't handle it, I mean that Maple could not integrate the formulas I needed. As mentioned earlier, with help from Helmut Kahovec, Robert Israel, and others on sci.math.symbolic I was able to modify the spline definition enough to get it to work.

But, there is another problem. What I computed was the slope at points along the curve, measuring with respect to length along the path, not horizontal ( x ) displacement. So, the arclength parameter needed to be converted to the height and the length. It is a straightforward calculus problem to do this, though. If we have data for dy/dx as a function of s then we can find y as a function of s by

y(s)
=
ó
õ
s

0 
dy
dx
dx
=
ó
õ
s

0 
dy
dx
dx
ds
ds
=
ó
õ
s

0 
dy
dx
1
ds/dx
ds
=
ó
õ
s

0 
dy
dx
1
  æ
Ö

1+( [dy/ dx]) 2
 
ds,
which uses the data we have, the slope at points along the curve, as a function of arclength. Similarly,
x(s)
=
ó
õ
s

0 
dx
=
ó
õ
s

0 
1
  æ
Ö

1+( [dy/ dx]) 2
 
ds,
so we just have to find these integrals. Unfortunately, with dy/dx given as a spline, Maple bogs down (even with the improved code). The solution is to use the data set directly to compute these integrands, then use Maple's spline routine to extrapolate these expressions, and integrate those using the improved ways of dealing with splines. The plot I drew is then obtained by plotting (x(s),y(s)) over the domain. If you want, the code I used (thanks again to Helmut Kahovec) is available here. It is a text file suitable for running Maple in batch mode.


File translated from TEX by TTH, version 1.58.