22 Continuity and smoothness
As introduced in Chapter 1, a space is a set of possibilities. For instance, for the function domain(x = -3:3)
in R/mosaic notation. Of course, when we write domain(x = -3:3)
we mean the space of
You’ve been learning about sets since early in school. A child learning about numbers starts with the “counting numbers”:
The next step in a child’s mathematical education is the “rational numbers,” that is, numbers that are written as a ratio:
Between any two rational numbers, there is another rational number, indeed there is an infinite number of rational numbers. For instance, between
If you didn’t stumble on the word “spaces” in the previous sentence, you are well on your way to understanding what is meant by “continuous.” For instance, between any two rational numbers there is another rational number. Think of rational numbers as stepping stones that provide a path from any number to any other number.
It is a deep question whether the rational numbers are a walkway instead of isolated stepping stones? A walkway is a structure on which you can move any amount, no matter how small, without risk of going off the structure. In contrast, a too-small move along a path of stepping stones will put you in the water.
A continuous set is like a walkway; however little you move from an element of the set you will still be on the set. The continuous set of numbers is often called the number line, although a more formal name is the real numbers. (“Real” is an unfortunate choice of words, but we are stuck with it.)
The underlying metaphor here is space. Between any two points in space, there is another point in space. We will be working with several different kinds of spaces, for instance:
- the number line: all the real numbers
- the positive numbers: the real numbers greater than zero
- the non-negative numbers: this is the tiniest little extension of the positive numbers adding zero to the set.
- a closed interval, such as the numbers between 5 and 10, which we will write like this:
where is a name we are giving to the set. (Another way to write the space is the declarative statement .) - the Cartesian plane: all pairs of real numbers such as
. Other metaphors for this: the points on a piece of paper or a computer screen. - three-dimensional coordinate spaces like our everyday three-dimensional world, generally written as a set of three real numbers such as
. - higher-dimensional spaces, but we won’t go there until the last parts of the book.
The specialty of calculus is describing relationships between continuous sets. Functions such as
In this chapter, we will elaborate on continuity, one of the ideas introduced in Chapter 6, and use the concept of continuity to characterize functions in a new way: their smoothness.
22.1 Continuity
The intuition behind continuity is simple: If you can draw the graph of a function without lifting the pencil from the paper, the function is continuous.
Continuity can be an important attribute of a modeling function. Often, we expect that a small change in input produces a small change in output. For instance, if your income changes by one penny, you would expect your lifestyle not to change by much. If the temperature of an oven changes by 1 degree, you don’t expect the quality of the cake you are baking to change in any noticeable way.
All of our basic modeling functions are continuous over their entire input domain. (Exception: the domain of the function
Drawing the graph of the Heaviside function
In contrast, the piecewise ramp function (Figure 22.3) is continuous; you don’t need to lift the pencil from the paper to draw the ramp function.
Imagine that you were constructing a model of plant growth as a function of the amount of water (in cc) provided each day. The plant needs about 20 cc of water to thrive. You use the Heaviside function for the model, say
Common sense suggests that a change of 0.002 cc in the amount of water—a small fraction of a drop, 2 cubic millimeters of volume—is not going to lead to a qualitative change in output. So you might prefer to use a sigmoid function as your model rather than a Heaviside function.
On the other hand, sometimes a very small change in input does lead to a large change in output. For instance, a sensible model of the hardness of water as a function of temperature would include a discontinuity at
One of author Charles Dickens’s famous characters described the relationship between income, expenditure, and happiness this way:
“Annual income 20 pounds, annual expenditure 19 [pounds] 19 [shillings] and six [pence], result happiness. Annual income 20 pounds, annual expenditure 20 pounds ought and six, result misery.” — the character Wilkins Micawber in David Copperfield
Macawber referred to the common situation in pre-20th century England of putting debtors in prison, regardless of the size of their debt. Macawber’s statement suggests he would model happiness as a Heaviside function
Whenever the output of a function is a binary (yes-or-no) value, you can anticipate that a model will involve a discontinuous function.
22.2 Discontinuity
Recall the logical path that led us to the idea of the derivative of a function. We started with the differencing operator, which takes as input a function and a “small” value of
No appears. No appears No appears.- and so on.
With discontinuous functions, we have no such luck. Figure 22.4 shows what happens if we compute
Code
<- makeFun(ifelse(x >=0, 1, 0) ~ x)
H <- makeFun((H(x + 0.1) - H(x))/0.1 ~ x)
DH01 <- makeFun((H(x + 0.01) - H(x))/0.01 ~ x)
DH001 <- makeFun((H(x + 0.001) - H(x))/0.001 ~ x)
DH0001 slice_plot(DH01(x) ~ x, bounds(x=-0.02:0.02),
npts=500, color="red", size=2) %>%
slice_plot(DH001(x) ~ x,
color="darkgreen", npts=500, size=3, alpha=0.5) %>%
slice_plot(DH0001(x) ~ x,
color="blue", npts=500, alpha=0.5, size=2)
Differencing the Heaviside function produces very different functions depending on the value of
Since there is no convergence in the shape of
22.3 Smoothness
Smoothness is a different concept than continuity, although the two are related. Most simply, any discontinuous function is not smooth at any input where a discontinuity occurs. But even the continuous ramp function is not smooth at the start of the ramp. Intuitively, imagine you were sliding your hand along the ramp function. You would feel the crease at
A function is not smooth if the derivative of that function is discontinuous. For instance, the derivative of the ramp function is the Heaviside function, so the ramp is not smooth at
All of our basic modeling functions are smooth everywhere in their domain. In particular, the derivatives of the basic modeling functions are continuous, as are the second derivative, third derivative, and so on down the line. Such functions are called C-infinity, written
You cannot tell from Figure 22.5 that the second derivative is discontinuous. But if you were in a plane flying along that trajectory, you would feel a jerk as you crossed
Mathematicians quantify the “smoothness” of a function by looking at the function’s continuity and the continuity of its derivatives. Smoothness is assessed on a scale
: the function is continuous. Intuitively, this means that the function’s graph can be drawn without lifting the pencil from the paper. : the function has a derivative over its entire domain and that derivative is continuous. (See Figure 22.5 for an example.) : the function has a derivative over its entire domain and that derivative is continuous. In other words, exists and is continuous. : Like , but we are talking about the th-derivative of existing and being continuous. : Usually when we denote a sequence with an infinite number of terms, we write down something like . It would be entirely valid to do this in talking about the sequence. But many of the mathematical functions we work with are infinitely differentiable, that is .
Examples of
: the derivatives are , , , , … You can keep going infinitely. : the derivatives are , , and so on. : the derivatives are , , , … Higher order derivatives are all simply 0. Boring, but still existing.
Example of non-
, the absolute value function. is a pasting together of two functions: The domain is split at .
22.4 Practical smoothness is different.
For engineering and design problems, smoothness means something substantially different than described by the mathematical concepts above. Chapter 48 introduces cubic splines which are continuous functions defined by a finite set of coordinate pairs: two variables of a data frame. Each line of the data frame specifies a “knot point.” The spline consists of ordinary cubic polynomials drawn piecewise between consecutive knot points. At a knot point, the cubics on either side have been arranged to have their first and second derivatives match. Thus, the first two derivatives are continuous. The function is at least