894 Appendix A Numerical Methods
var = Variation(t0, X0, t1, X1);
if (var > minvariation) {
tm=(t0+t1)/2;
xmid = X(tm);
Subdivide(level - 1, t0, X0, tm, Xm, sub);
Subdivide(level - 1, tm, Xm, t1, X1, sub);
return;
}
}
sub.Append(X1);
}
Initial call:
List sub = { X(tmin) };
Subdivide(maxlevel, tmin, X(tmin), tmax, X(tmax), sub);
The maxlevel parameter avoids deep recursive calls when a small minvariation is
specified. However, if
level reaches zero, the variation for the current interval is not
necessarily within the specified tolerance. Since the variation does not provide error
bounds for the distance calculation, this is not a problem.
A.9 Topics from Calculus
This section reviews several topics from calculus that can be useful in solving a
number of problems discussed in this book, particularly distance and intersection.
A.9.1 Level Sets
Political maps show boundaries of states and countries, and some amount of geo-
graphical features (rivers, oceans, etc.), but these are often shown indicatively. Topo-
graphic maps, on the other hand, are useful because they explicitly show the elevation
of the land. This is done by the use of contours—curves representing the cross section
of the land at a particular altitude. By observing the altitude markings associated with
particular contours, as well as their topology, the map user can easily distinguish in-
clines, peaks, and valleys. Further, the steepness of a slope can easily be discerned,
by the relative distance between adjacent contours—the closer together they are, the
steeper the slope.
A contour map can be considered to be a way of visualizing a function of two
variables f(x, y) =z,wherex and y are the latitude and longitude and z is the height
(altitude). If we intersect the function f with a horizontal plane