5 Pattern-book functions
In this Chapter, we introduce the pattern-book functions—a brief list of basic mathematical functions that provide a large majority of the tools for representing the real world as a mathematical object. Think of the items in the pattern-book list as different actors, each of whom is skilled in portraying an archetypal character: hero, outlaw, lover, fool, comic. A play brings together different characters, costumes them, and relates them to one another through dialog or other means.
A mathematical model is a kind of story; a mathematical modeler is a kind of playwright. She combines mathematical character types to tell a story about relationships. We need only a handful of mathematical functions, the analog of the character actors in drama and comedy to sketch a model. In creating a mathematical model, you clothe the actors to suit the era and location and assemble them in harmony or discord.
Costume designers use their imagination, often enhanced by referencing published collections of patterns and customizing them to the needs at hand. These references are sometimes called “pattern books.” (See Figure 5.1.)
Similarly, we will start with a pattern set of functions that have been collected from generations of experience. To remind us of their role in modeling, we will call these pattern-book functions. These pattern-book functions are useful in describing diverse aspects of the real world and have simple calculus-related properties that make them relatively easy to deal with. There are just a handful of pattern-book functions from which untold numbers of useful modeling functions can be constructed. Mastering calculus is in part a matter of becoming familiar with the mathematical connections among the pattern-book functions. (You will see these in due time.)
Here is a list of our pattern-book functions written traditionally and in R:
Pattern name | Traditional notation | R notation |
---|---|---|
exponential | exp(x) |
|
logarithm (“natural log”) | log(x) |
|
sinusoid | sin(x) |
|
square | x^2 |
|
proportional | x |
|
one | 1 |
|
reciprocal | 1/x |
|
gaussian | dnorm(x) |
|
sigmoid | pnorm(x) |
The input name used in the table,
In addition to the names of the pattern-book functions, you should be able to draw their shapes easily. Table 11.1 provides a handy guide.
These pattern-book functions are widely applicable. But nobody would confuse the pictures in a pattern book with costumes that are ready for wear. Each pattern must be tailored to fit the actor and customized to fit the theme, setting, and action of the story. We will study how this is done starting in Chapter Chapter 8.
5.1 Pattern and shape
The pattern-book functions are closely related to one another but each has a distinctive shape. The variety of shapes makes the small set of pattern-book functions suited to a wide range of modeling tasks.
The constant function is so simple that you may be inclined to deny that it is a function at all. The output of the constant function is always numerical 1, regardless of the input. Its graph is therefore a horizontal line.
You may wonder why to take the trouble to make a function whose output is always the same. After all, in a formula it shows up simply as the number 1, not looking like a function at all. But formulas are not the only way of representing functions. For instance, in Block III we will use a mathematical structure called a “vector” to represent functions where the constant function won’t be just the number 1.
The proportional function is also simple. Whatever is the input will become the output. (Another appropriate name for the proportional function is the “identity function” because the output is identical to the input.) The graph of the proportional function is a straight line going through
Despite the simplicity of the proportional function, it is heavily used in modeling. In a formula, the proportional function appears as
The remaining pattern-book functions all have curved shapes.
The *Gaussian function is shaped like a mountain or, in many descriptions, like the outline of a bell. As the input becomes larger—in either the positive or negative directions—the output gets closer and closer to zero but never touches zero exactly.
The Gaussian function shows up so often in modeling that it has another widely used name: the normal function. But “normal” has additional meanings in mathematics, so we will not use that name in this book.
The sigmoid function models smooth transitions. For large negative inputs, the output is (very nearly) zero. For large positive inputs, the output is (very nearly) one. The sigmoid is closely related to the Gaussian. As you progress in calculus, the relationship will become evident.
The exponential function has important applications throughout science, technology, and the economy. For large negative inputs, the value is very close to zero in much the same way as for the Gaussian or sigmoid functions. But the output increases faster and faster as the input gets bigger. Note that the output of the exponential function is never negative for any input.
The logarithmic function is defined only for positive inputs. As the input increase from just above zero, the output t constantly grows but at a slower and slower rate. It never levels out.
The exponential and logarithmic functions are intimate companions. You can see the relationship by taking the graph of the logarithm, and rotating it 90 degrees, then flipping left for right as in Figure 5.8. (Note in Figure 5.8 that the graph is shown as if it were printed on a transparency which we are looking at from the back.)
The output of the sinusoid function oscillates as the input changes. It is a periodic function, meaning that the pattern repeats itself identically from left to right in the graph.
If you studied trigonometry, you may be used to the sine of an angle in the context of a right triangle. That is the historical origin of the idea. For our purposes, think of the sinusoid just as a function that takes an input and returns an output. Starting in the early 1800s, oscillatory functions found a huge area of application in representing phenomena such as the diffusion of heat through solid materials and, eventually, radio communications.
In trigonometry, the sine has the cosine as a partner. But the two functions
5.2 Exponentials & doubling time
The exponential function has a characteristic property that makes it extremely important in models of many phenomena: The value doubles in constant time. That phrase, “doubles in constant time” can be obscure, so let’s look at it carefully with reference to a graph of the exponential function.
Figure 5.10 is a graph of the exponential function, annotated with a set of evenly spaced vertical lines. The intersection of each vertical line with the function has been marked with a dot to make it easier to read off the output of the exponential when the input has any of the values marked by the vertical lines. For example, one of the vertical lines is at
In other words, the output of the exponential function doubles whenever the input is increased by 0.693. Likewise, decreasing the input by 0.693 cuts the output by half. No other function than the exponential has this property that a constant change in the input (namely, 0.693) leads to a doubling of the output. So, 0.693 is “constant time” that leads to doubling.
5.3 The power-law family
Four of the pattern-book functions—
Within the power-law family, it is helpful to know and be able to distinguish between several groups:
- The monomials. These are power-law functions such as
, , , , , , where is a whole number (i.e., a non-negative integer). Of course, is the same as the constant function, since . Likewise, is the same as the identity function since . As for the rest, they have just two general shapes: both arms up for even powers of (like in , a parabola); one arm up and the other down for odd powers of (like in , a cubic). Indeed, you can see in Figure 5.17 that has a similar shape to and that is similar in shape to . For this reason, high-order monomials are rarely needed in practice.
- The negative powers. These are power-law functions where
, such as , , . For negative powers, the size of the output is inversely proportional to the size of the input. In other words, when the input is large (not close to zero) the output is small, and when the input is small (close to zero), the output is very large. This behavior happens because a negative exponent like can be rewritten as ; the input is inverted and becomes the denominator, hence the term “inversely proportional”.
- The non-integer powers, e.g.
, , and so on. When is either a fraction or an irrational number (like ), the real-valued power-law function can only take non-negative numbers as input. In other words, the domain of is to when is not an integer. You have likely already encountered this domain restriction when using the power law with since , and the square root of a negative number is not a real number. You may have heard about the imaginary numbers that allow you to take the square root of a negative number, but for the moment, you only need to understand that when working with real-valued power-law functions with non-integer exponents, the input must be non-negative. (The story is a bit more complicated since, algebraically, rational exponents like or with an odd-valued denominator can be applied to negative numbers. Computer arithmetic, however, does not recognize these exceptions.)
5.3.1 Computing note
When a function like x^(1/3)
. Similarly, later in the book you will encounter power-law functions where the exponent is written as a formula. Particularly common will be power-law functions written x^(n-1)
or x^(n+1)
.
5.3.2 Some power-law relationships
You have been using power-law functions from early in your math and science education. Some examples:1
Examples of power-law relationships
Setting | Function formula | exponent |
---|---|---|
Circumference of a circle | 1 | |
Area of a circle | 2 | |
Volume of a sphere | 3 | |
Distance traveled by a falling object | 2 | |
Gas pressure versus volume | ||
… perhaps less familiar … | ||
Distance traveled by a diffusing gas | ||
Animal lifespan (in the wild) versus body mass | 0.25 | |
Blood flow versus body mass | 0.75 |
One reason why power-law functions are so important in science has to do with the logic of physical quantities such as length, mass, time, area, volume, force, power, and so on. We will discuss this at length later in the course and the principles will appear throughout calculus.
5.4 Domains of pattern-book functions
Each of our basic modeling functions, with two exceptions, has a domain that is the entire number line
The two exceptions are:
- the logarithm function, which is defined only for
. - some of the power-law functions:
.- When
is negative, the output of the function is undefined when . You can see why with a simple example: . Most students had it drilled into them that “division by zero is illegal,” and , a double law breaker. - When
is not an integer, that is the domain of the power-law function does not include negative inputs. To see why, consider the function .
- When
5.5 Symbolic manipulations
Several of the pattern book functions appear so often in MOSAIC Calculus that it is worth reviewing how to manipulate them symbolically. As an example, consider the function
We will be working with exponential and power-law functions in this chapter. It is essential that you recognize that these are utterly different functions.
An exponential function, for instance,
A power-law function works the reverse way: the input is raised to a constant quantity, as in
A mnemonic phrase for exponentials functions is
Exponential functions have
in the exponent.
Of course, the exponential function can have inputs with names other than
5.5.1 Exponential and logarithm
Basic symbolic patterns for exponentials are (i) and (ii)
.
Exponentials with a base other than
.
For mental arithmetic, easier use base 2 or 10. The base
The logarithms, which we will return to in Chapter 15 are the inverse function of the exponential: Rule (v).
One place that we will encounter rules (ii) and (v) is in Chapter 8 when we look a “doubling times” and “half lives.” There we will deal with expressions such as
Important symbolic patterns for logarithms are Rules (vi) through (vii).
Notice that the symbolic patterns for logarithms involve multiplication, division, and exponentiation, but not addition:
5.5.2 Power-law functions
In power-law functions, the quantity in the exponent is constant: we will call it
5.5.3 Sinusoids
As we mentioned earlier, we will be calling both the
5.5.4 The straight-line function
You are probably used to a function that we call the “straight-line function”
There are two simple symbolic manipulations that you will be using often in MOSAIC Calculus:
- Find the input
for which the output . This input has many names in mathematics: the “root,” the “ -intercept,” the “zero crossing,” etc. We will call any input value that corresponds to an output of zero to be “a zero of the function.”
For the straight-line function, the zero is readily found symbolically:
- Re-write the straight-line function in the form
Here, the slope is designated with
The name “logarithm” is anything but descriptive. The name was coined by the inventor, John Napier (1550-1617), to emphasize the original purpose of his invention: to simplify the work of multiplication and exponentiation. The name comes from the Greek words logos, meaning “reasoning” or “reckoning,” and arithmos, meaning “number.” A catchy marketing term for the new invention, at least for those who speak Greek!
Although invented for the practical work of numerical calculation, the logarithm function has become central to mathematical theory as well as modern disciplines such as thermodynamics and information theory. The logarithm is key to the measurement of information and magnitude. As you know, there are units of information used particularly to describe the information storage capacity of computers: bits, bytes, megabytes, gigabytes, and so on. Very much in the way that there are different units for length (cm, meter, kilometer, inch, mile, …), there are different units for information and magnitude. For almost everything that is measured, we speak of the “units” of measurement. For logarithms, instead of “units,” by tradition another word is used: the base of the logarithm. The most common units outside of theoretical mathematics are base-2 (“bit”) and base-10 (“decade”). But the unit that is most convenient in mathematical notation is “base e,” where
5.6 Drill
Drill 1 Which of the pattern book bofunctions has an output value very near zero over almost all of its domain?
Drill 2 Which of these basic modeling functions has value very near zero over almost half of its domain?
Drill 3 Which of these basic modeling functions has value very near zero over almost half of its domain?
Drill 4 Which of these pattern-book functions is not a monomial?
Drill 5 Which value(s) is missing from the domain of
- Zero
- All non-positive numbers
- Negative numbers
- No numbers are missing.
Drill 6 Which value(s) is missing from the domain of
- Zero
- All non-positive numbers
- Negative numbers
- No numbers are missing.
Drill 7 Which value(s) is missing from the domain of
- Zero
- All non-positive numbers
- Negative numbers
- No numbers are missing.
Drill 8 Which value(s) is missing from the domain of
- Zero
- All non-positive numbers
- Negative numbers
- No numbers are missing.
Drill 9 Which value(s) is missing from the domain of
- Zero
- All non-positive numbers
- Negative numbers
- No numbers are missing.
Drill 10 Which of the following values is in the domain of the function
-2 -1 0 All of them
Drill 11 Is zero in the domain of the function
Yes No
Drill 12 Which of the following values is in the domain of the function
-2 -1 0 All of them
Drill 13 What is the output from the command log(-1)
?
0 An error message. -Inf NaN
Drill 14 What is the output from the command log(0)
?
0 -Inf NaN
Drill 15 Which of the following values is in the domain of the function
-1 0 1 All of them
Drill 16 Which of the following values is in the domain of the function
-1 0 1 All of them
Drill 17 By how much should you increase the input to the exponential function to produce a doubling of the output?
0.5 0.693 1 1.386 2 none of these
Drill 18 By how much should you increase the input to the exponential function to produce a quadrupling of the output?
0.5 0.693 1 1.386 2 none of these
Drill 19 By how much should you decrease the input to the exponential function to cut the output value by a factor of one-half?
0.5 0.693 1 1.386 2 none of these
5.7 Exercises
Exercise 5.01
Run this graph-making command in your console:
slice_plot(exp(x) ~ x, bounds(x=-3:3))
In this exercise, you will be modifying the sandbox code to draw different functions, so you can examine their shapes.
Your task is to read and interpret the graphs of the basic modeling functions. Here, you will be looking for zero-crossings: the neighborhood of a point in the function’s domain where the output of the function is negative for inputs on one side and positive for inputs on the other side. If zero is touched but not crossed, we will call that “touched zero.”
The table below lists the pattern-book functions. For each function in the list, fill in the table. That is, say whether the function crosses zero, touches zero but does not cross, or does not touch at all in the part of the domain shown in the graphic:
function name | R formula | zero in domain shown in graph | asymptotic zero |
---|---|---|---|
exponential | exp(x) |
no zeros | for very negative |
logarithm | |||
sinusoid | |||
square | |||
proportional | |||
constant | |||
reciprocal | |||
gaussian | |||
sigmoid |
Exercise 5.02
There are nine pattern-book functions: constant, identity, square, reciprocal, sinusoid, exponential, logarithm, gaussian, sigmoid.
On a piece of paper, sketch from memory a graph of each of the pattern-book functions.
Exercise 5.03
These questions ask you, for each of the pattern-book functions, to find a specific input/output pair.
Using your R console, answer these questions.
Part A What is the exact output of the pattern-book exponential function when the input is
0 0.3989423 1/2 1
Part B What is the exact output of the pattern-book sine function when the input is
0 0.3989423 1/2 1
Part C What is the exact output of the pattern-book sigmoid function when the input is
0 0.3989423 1/2 1
Part D What is the output (to several digits) of the pattern-book Gaussian function when the input is
0 0.3989423 1/2 1
Part E What is the exact output of the pattern-book constant function?
0 0.3989423 1/2 1
Exercise 5.04
Part A True or false:
TRUE FALSE
Part B True or false:
TRUE FALSE
Part C True or false:
TRUE FALSE
Part D The gravitational force, F, between two bodies is inversely proportional to the square of the distance
Exercise 5.06
All but two of the pattern-book functions have a domain that runs over the whole number line:
A. Which pattern-book function has a domain that excludes zero and negative numbers as inputs?
B. Which pattern-book function has just a single value missing from its domain?
Exercise 5.07
Consider this graph of a function
Part A What is the domain of
Part B What is the range of
Exercise 5.08
A function’s domain is the set of possible inputs to the function. A function’s range is the set of possible outputs.
In each of the following questions, choose the correct answer from these possibilities:
- All: All
- Pos: The positive numbers (excluding zero)
- Neg: The negative numbers (excluding zero)
- NonNeg: The non-negative numbers
- Closed: Closed.
Part A What is the range of the pattern-book exponential function?
Pos NonNeg Neg All Closed
Part B What is the range of the pattern-book sine function?
Pos Neg All Closed
Part C What is the range of the pattern-book logarithm function?
Pos NonNeg Neg All Closed
Part D What is the range of the pattern-book square function?
Pos NonNeg Neg All Closed
Part E What is the range of the pattern-book proportional function?
Pos Neg All Closed
Part F What is the range of the pattern-book sigmoid function?
Pos NonNeg Neg All Closed
Exercise 5.09
Use an R console to make this plot.
slice_plot(log(x) ~ x, bounds(x=-5:5))
Explain why the function graph doesn’t cover the whole domain indicated in the command.
Calculate
log(-5)
. What is the result?
The answer to (2) demonstrates an important feature of modern computer numerics. When an input is outside of the domain of the function, the function value is undefined. This “undefined” value is represented by a special “number,” which has no value. In fact, the value stands for “not a number.”
- Do some arithmetic with
NaN
, for instance, adding 5 or multiplying by 3. Explain the results.
5.8 New Concepts
Exercise 5.15
Some of our pattern-book functions have a distinctive property called scale invariance. This means the graph of the function looks the same even when plotted on very different horizontal and vertical axes. The function
?fig-square-invariance shows a power-law function,
Other pattern-book functions are not scale invariant, for example
In contrast to scale-invariant functions, some of our pattern-book functions have a characteristic scale. This is a domain length over which the whole of a characteristic feature of the function is evident. Graphing on larger domains simply squashes down the characteristic feature to a small part of the graphic domain. For instance, in the
The output of the sigmoid function runs from 0 to 1 but reaches these values only asymptotically, as
Part A The gaussian (hump) function dnorm()
has a characteristic scale. Which of these is a domain length that can encompass the characteristic shape of the gaussian?
0.1 1 6 16 256
Part B The sigmoid function pnorm()
also has a characteristic scale. Which of these is a domain length that can encompass the characteristic shape of the sigmoid?
0.1 1 6 16 256
Throughout science, it is common to set a standard approach to defining a characteristic scale. For instance, the characteristic scale of an aircraft could be taken as the length of body. Gaussian and sigmoids are so common throughout science that there is a convention for defining the characteristic scale called the standard deviation. For the pattern book gaussian and sigmoid, the standard deviation is 1. That is much shorter than the domain that captures the bulk of action of the gaussian or sigmoid. For this reason, statisticians in practice use a characteristic scale of
The animal lifespan relationship is true when comparing species. Individual-to-individual variation within a species does not follow this pattern.↩︎