\(\newcommand{\line}{\text{line}} \newcommand{\hump}{\text{hump}} \newcommand{\sigmoid}{\text{sigmoid}} \newcommand{\recip}{\text{recip}} \newcommand{\diff}[1]{{\cal D}_#1} \newcommand{\pnorm}{\text{pnorm}} \newcommand{\dnorm}{\text{dnorm}} \newcommand{\CC}[1]{\color{#648fff}{#1}} \newcommand{\CE}[1]{\color{#785ef0}{#1}} \newcommand{\CA}[1]{\color{#dc267f}{#1}} \newcommand{\CB}[1]{\color{#fe6100}{#1}} \newcommand{\CD}[1]{\color{#ffb000}{#1}}\)

27 Change and accumulation

Every 10 years, starting in 1790, the US Census Bureau carries out a constitutionally mandated census: a count of the current population. The overall count as a function of year is shown in Figure 27.1. [Source]

In the 230 years spanned by the census data, the US population has grown 100-fold, from about 4 million in 1790 to about 330,000,000 in 2020.

US population since 1790.

Figure 27.1: US population since 1790.

It’s always tempting to look for simple patterns in such data. Perhaps the US population has been growing exponentially. A semi-log plot of the same data suggests that the growth is only very roughly exponential. (See Figure ??.) A truly exponential process would present as a curve with a constant derivative, but the derivative of the function in the graphed is decreasing over the centuries.

Insofar as the slope over the semi-log graph is informative, it amounts to this quantity: \[\partial_t \ln(\text{pop}(t)) = \frac{\partial_t\, \text{pop}(t)}{\text{pop}}\] This is the per-capita rate of growth, that is, the rate of change in the population divided by the population. Conventionally, this fraction is presented as a percentage: percentage growth in the population per year, as in Figure 27.2.

Annual per capita growth rate of the US population (percent)

Figure 27.2: Annual per capita growth rate of the US population (percent)

The dots in the graph are a direct calculation from the census data. There’s a lot of fluctuation, but an overall trend stands out: the population growth rate has been declining since the mid-to late 1800s. The deviations from the trend are telling and correspond to historical events. There’s a relatively low growth rate seen from 1860 to 1870: that’s the effect of the US Civil War. The Great depression is seen in the very low growth from 1930 to 1940. Baby Boom: look at the growth from 1950-1960. The bump from 1990 to 2000? Not coincidentally, the 1990 Immigration Act substantially increased the yearly rate of immigration.

If the trend in the growth rate continues, the US will reach zero net growth about 2070, then continue with negative growth. Of course, negative growth is just decline. A simple prediction from Figure 27.2 is that the argmax of the US population will be around 2070.

How large will the population be when it reaches its maximum?

In Block 2, we dealt with situations where we know the function \(f(t)\) and want to find the rate of change \(\partial_t f(t)\). Here, we know the rate of change of the population and we need to figure out the population itself, in other words to figure out from a known \(\partial_t f(t)\) what is the (as yet) unknown function \(f(t)\).

The process of figuring out \(f(t) \longrightarrow \partial_t f(t)\) is, of course, called differentiation. The opposite process, \(\partial_t f(t) \longrightarrow f(t)\) is called anti-differentiation.

If the trend in the growth rate continues, the US will reach zero net growth about 2070, then continue with negative growth. Of course, negative growth is just decline. A simple prediction from Figure 27.2 is that the argmax of the US population will be around 2070.

How large will the population be when it reaches its maximum?

In Block 2, we dealt with situations where we know the function \(f(t)\) and want to find the rate of change \(\partial_t f(t)\). Here, we know the rate of change of the population and we need to figure out the population itself, in other words to figure out from a known \(\partial_t f(t)\) what is the (as yet) unknown function \(f(t)\).

The process of figuring out \(f(t) \longrightarrow \partial_t f(t)\) is, of course, called differentiation. The opposite process, \(\partial_t f(t) \longrightarrow f(t)\) is called anti-differentiation.

In this block we’ll explore the methods for calculating anti-derivatives and some of the settings in which anti-derivative problems arrive.

The predictions from the accumulate-population-growth model are shown as a \(\color{magenta}{\text{magenta}}\) line in Figure 27.3.

Predicted US population based on the historical linear decline in per-capita growth.

Figure 27.3: Predicted US population based on the historical linear decline in per-capita growth.

According to the accumulation model, the population peaks in 2075 at 390 million. We’ll be back down to the present population level in about 100 years.

Professional demographers make much more sophisticated models using detailed data from many sources. The demographers at the US Census Bureau predict that the population will reach a maximum of 404 million in 2060, shown by the little blue dot in Figure 27.3. That’s not too different from what we got by analyzing just the raw census numbers. 3135

27.1 Accumulation

Imagine a simple setting: water flowing out of a tap into a basin or tank. Measurement of the amount of water into the basin will be in a unit of volume, say liters. Measurement of the flow \(f(t)\) of water from the tap into the tank has different units, say liters per second. If volume \(V(t)\) is the volume of water in the tank as a function of time, \(f(t)\) at any instant is \(f(t) = \partial_t V(t)\).

Clearly there is a relationship between the two functions \(f(t)\) and \(V(t)\). With derivatives, we can give a good description of that relationship: \[f(t) = \partial_t V(t)\] This description will be informative if we have measured the volume of water in the basin as a function of time and want to deduce the rate of flow from the tap. Now suppose we have measured \(f(t)\) and want to figure out the volume. The volume at any instant is the past flow accumulated to that instant. As a matter of notation, we write this view of the relationship as \[V(t) = \int f(t) dt,\] which you can read as “volume is the accumulated flow.”

Other examples of accumulation and change:

  • velocity is the rate of change of position with respect to time. Likewise, position is the accumulation of velocity over time.
  • force is the rate of energy with respect to position. Likewise energy is the accumulation of force as position changes.
  • deficit is the rate of change of debt with respect to time. Likewise, debt is the accumulation of deficit over time.

27.2 Notation for anti-differentiation

For differentiation we are using the notation \(\partial_x\) as in \(\partial_x f(x - a)\). Remember that the subscript on \(\partial\) names the with-respect-to input. There are three pieces of information this notation:

  1. The \(\color{magenta}{\partial}\) symbol which identifies the operation as partial differentiation.
  2. The name of the with-respect-to input \(\partial_{\color{magenta}{x}}\) written as a subscript to \(\partial\).
  3. The function to be differentiated, \(\partial_x \color{magenta}{f(x - a)}\).

For anti-differentiation, our notation must also specify the three pieces of information. It might be tempting to use the same notation as differentiation but replace the \(\partial\) symbol with something else, perhaps \(\eth\) or \(\spadesuit\) or \(\forall\), giving us something like \(\spadesuit_x f(x-a)\).

Convention has something different in store. The notation for anti-differentiation is \[\large \int f(x-a) dx\] 1. The \(\color{magenta}{\int}\) is the marker for anti-differentiation. 2. The name of the with-respect to variable is contained in the “dx” at the end of the notation: \(\int f(x-a) d\color{magenta}{x}\) 3. The function being anti-differentiated is in the middle \(\int \color{magenta}{f(x-a)} dx\).

For those starting out with anti-differentiation, the conventional notation can be confusing, especially the \(dx\) part. It’s easy confuse \(d\) for a constant and \(x\) for part of the function being anti-differentiated.

Think of the \(\int\) and the \(dx\) as brackets around the function. You need both brackets for correct notation, the \(\int\) and the \(dx\) together telling you what operation to perform.

Remember that just as \(\partial_x f(x-a)\) is a function, so is \(\int f(x-a) dx\).

27.3 R/mosaic notation

Recall that the notation for differentiation in R/mosaic is D(f(x-a) ~ x).

This has the same three pieces of information as \(\partial_x f(x-a)\)

  1. D() signifies differentiation.
  2. ~ x identifies the with-respect-to variable.
  3. f(x-a) ~ is the function on which the operation is to be performed.

This style of notation extends beautifully to anti-differentiation: antiD(f(x-a) ~ x)

Remember that just as D(f(x-a) ~ x) creates a new function out of f(x-a) ~ x, so does antiD(f(x-a) ~ x).

27.4 Dimension and anti-differentiation

This entire block will be about anti-differentiation, its properties, and its uses. You already know that anti-differentiation (as the name suggests) is the inverse of differentiation. There is one consequence of this that it’s helpful to keep in mind as we move on to other chapters.

This being calculus, the functions that we construct and operator upon have inputs that are quantities and outputs that are also quantities. Every quantity has a dimension, as discussed in Chapter 16. When you are working with any quantity, you should be sure that you know its dimension and its units.

The dimension of the input to a function does not by any means have to be the same as the dimension of the output. For instance, we have been using many functions where the input has dimension time and the output is position (dimension L) or velocity (dimension L/T) or acceleration (dimension L/T\(^2\)).

Imagine working with some function \(f(y)\) that’s relevant to some modeling project of interest to you. Returning to the bracket notation that we used in Chapter 16, the dimension of the input quantity will be [\(y\)]. The dimension of the output quantity is [\(f(y)\)].

The function \(\partial_y f(y)\) has the same input dimension [\(y\)] but the output will be [\(f(y)\)] / [\(y\)]. For example, suppose \(f(y)\) is the mass of fuel in a rocket as a function of time \(y\). The input dimension [\(y\)] is T. The output dimension is M. The output of the function \(\partial_y f(y)\) will be different; it has dimension [\(f(y)\)] / [\(y\)], which in this case will be M / T. (Less abstractly, if the fuel mass is given in kg, and time is measured in seconds, then \(\partial_y f(y)\) will have units of kg-per-second.)

How about the dimension of the anti-derivative \(F(y) = \int f(y) dy\)? The input still has input dimension T. The output … well, whatever [\(F(y)\)] is, we know the dimension of \([f(y)] = [\partial_y F(y)]\) will have dimension \([F(y)]\, /\, [y] =\) M. Since the dimension [\(y\)] = T, it must be that [\(F(y)\)] = M T.

To summarize:

  • The dimension of derivative \(\partial_y f(y)\) will be [\(f(y)\)] / [\(y\)].
  • The dimension of the anti-derivative \(\int f(y) dy\) will be [\(f(y)\)] \(\times\) [\(y\)].

Paying attention to the dimensions (and units!) of input and output can be a boon to the calculus student. Often students have some function \(f(y)\) and they are wondering which of the several calculus operations—differentiation, anti-differentiation, finding a maximum, finding an argmax or a zero—they are supposed to do. The thing to do is figure out what will be the dimension of the quantity you want. From that, you can often figure out which operation is appropriate.

To illustrate, imagine that you have constructed \(f(y)\) for you task and you know, say, [\(f(y)\)] = M and [\(y\)] = T$. Look things up in the following table:

Dimension of result Calculus operation
M / T differentiate
M T anti-differentiate
M find max or min
T find argmax/argmin or a function zero
M T\(^2\) anti-differentiate twice in succession
M / T\(^2\) differentiate twice in succession

For example, suppose the output of the accelerometer on your rocket has dimension L / T\(^2\). You are trying to figure out from the accelerometer reading what is your altitude. Altitude has dimension L. Look up in the table to see that you want to anti-differentiate acceleration twice in succession.

27.5 From Calculus Made Easy

Calculus Made Easy, by Silvanus P. Thompson, is a classic, concise, and elegant textbook from 1910. It takes a common-sense approach, sometimes lampooning the traditional approach to teaching calculus.

Some calculus-tricks are quite easy. Some are enormously difficult. The fools who write the textbooks of advanced mathematics—and they are mostly clever fools—seldom take the trouble to show you how easy the easy calculations are. On the contrary, they seem to desire to impress you with their tremendous cleverness by going about it in the most difficult way. — from the preface

Thompson’s first chapter starts with the notation of accumulation, which he calls “the preliminary terror.”

The preliminary terror … can be abolished once for all by simply stating what is the meaning—in common-sense terms—of the two principal symbols that are used in calculating.

These dreadful symbols are:

  1. \(\Large\ d\) which merely means “a little bit of.”

Thus \(dx\) means a little bit of \(x\); or \(du\) means a little bit of \(u\). Ordinary mathematicians think it more polite to say “an element of,” instead of “a little bit of.” Just as you please. But you will find that these little bits (or elements) may be considered to be indefinitely small.

  1. \(\ \ \Large\int\) which is merely a long \(S\), and may be called (if you like) “the sum of.”

Thus \(\ \int dx\) means the sum of all the little bits of \(x\); or \(\ \int dt\) means the sum of all the little bits of \(t\). Ordinary mathematicians call this symbol “the integral of.” Now any fool can see that if \(x\) is considered as made up of a lot of little bits, each of which is called \(dx\), if you add them all up together you get the sum of all the \(dx\)’s, (which is the same thing as the whole of \(x\)). The word “integral” simply means “the whole.” If you think of the duration of time for one hour, you may (if you like) think of it as cut up into \(3600\) little bits called seconds. The whole of the \(3600\) little bits added up together make one hour.

When you see an expression that begins with this terrifying symbol, you will henceforth know that it is put there merely to give you instructions that you are now to perform the operation (if you can) of totaling up all the little bits that are indicated by the symbols that follow.

The next chapter shows what it means to “total up all the little bits” of a function.

27.6 Exercises

Exercise 27.02: bcJnUq
What is the name of the with-respect-to input in $$\int g(y) dy$$? 



(x )  y
( )  dy
( )  x
( )  t

[[Nice!]]

What is the name of the with-respect-to input in $$\int g(t) dy$$ 



(x )  y
( )  dy
( )  x
( )  t

[[Excellent!]]

What is the name of the with-respect-to input in $$\int g(x, t) dt$$ 



( )  y
( )  dt
( )  x
(x )  t

[[Nice!]]

Exercise 27.04: Ya2cVq
Which of the following functions is $$\int a + bx dx$$? (Hint: Differentiate each of them until you find the one that matches $$a + bx$$.) 



(x )  $$ax + rac{1}{2}b x^2 + C$$
( )  $$ax + 2b x^2 + C$$
( )  $$a + b x^2 + C$$

[[Correct.]]

Which of the following functions is $$\int e^{-kx} dt$$? 



(x )  $$ - \frac{1}{k} e^{-kx}$$
( )  $$- k e^{-k x}$$
( )  $$\frac{1}{k} e^{-kx}$$

[[Correct.]]

Exercise 27.06: wmyERp

Every function has an anti-derivative. But there are many functions, for example \(\dnorm()\) where there is no formula for the anti-derivative. Even so, the R/mosaic antiD() operator will figure out what is the anti-derivative.

For each of the following functions, use makeFun() to implement the function as f(). Then use antiD() to construct the anti-derivative of f() and give this the name F(). Finally, use D() to compute the derivative of F(). For instance:

f <- makeFun(x*dnorm(x) ~ x)
F <- antiD(f(x) ~ x)
dF <- D(F(x) ~ x)
slice_plot(f(x) ~ x, domain(x=c(0, 10))) %>%
  slice_plot(dF(x) ~ x, color="blue", size=3, alpha = 0.2)
For the function $$f(x) \equiv \pnorm(x^2)$$, what is $$F(5)$$? (Pick the closest answer.) 



( )  4
(x )  4.5
( )  5
( )  5.5
( )  6
( )  6.5

[[Excellent!]]

For the function $$f(x) \equiv \sin(x) \ln(x^2)$$, what is $$F(5)$$? (Pick the closest answer.) 



( )  -4
( )  -3.5
( )  -3
(x )  -2.5
( )  -2

[[Excellent!]]

For the function $$f(x) \equiv x^2 \pnorm(x)$$, what is $$F(5)$$? (Pick the closest answer.) 



( )  35
( )  37
( )  39
(x )  41
( )  43

[[Right!]]

Make up a function of your own choosing, ensuring that it is defined on the domain used in the slice_plot() command in the Sandbox. See if you can construct one for which antiD() does not give a right answer. When you find one, send it to your instructor.

By the way, did we mention that you’re welcome to include piecewise functions in your search for a function that will defeat antiD()?
Exercise 27.08: kEAW8g

In the population prediction model at the start of the chapter want to find a function \(P(y)\) that gives the population as a function of year \(y\). From the data, we plotted out \(\ln\left[P(y)\right]\) and found a fairly smooth curve that was upward sloping and concave down. Next, we made a plot of the derivative with respect to year of that upward-sloping, concave-down curve and found the derivative to be well approximated by a straight-line function with a negative slope \(a - b y\). In other words, we found \[\partial_y \ln(P(y)) = a - b\,y\] We want to figure out \(P(y)\) from this relationship.

Step 1: Anti-differentiate the functions on both sides of the equation. This has the effect of removing the \(\partial_y\) from the left side of the equation and replacing the right side by $ dy $.

Task 1: Confirm that \(\int \left[a - b\,y\right]dy = a y - \frac{1}{2} b y^2 + C\).

Step 2: From Step 1 we have translated the relationship between population and year into this form:

\[\ln(P(y)) = a y - \frac{1}{2} b y^2 + C\]

Task 2: Exponentiate both sides of the newly framed relationship to get $ P(y) = (a y - b y^2 + C)$ and use the algebra of exponentials to write this as \(P(y) = A e^{ay -b y^2}\).

Step 3: Let’s declare that \(y=0\) means “the present year.”

Task 3: Find the population in the present year and use that information to estimate one of the parameters in \(P(y) = A e^{ay-b y^2}\).

Step 4: The per-capita growth rate is \(G(y) \approx \partial_y e^{a y - b y^2}\). The data suggest that \(G(0) = a = \approx 0.01\) and that \(G(75) \approx 0\). Similarly, \(b \approx 0.01/75\). You can use the chain rule to calculate \(G(y) \approx \partial_y e^{a y - b y^2} = (a - 2 b y) e^{a y - b y^2}\)

Task 4: You know \(a\) and you have a rough value for \(b\). Let’s refine that value for \(b\). To do this, set \(y=75\) and plot \((a - 2 b y) e^{a y - b y^2}\) as a function of \(b\). Find the \(b\) that corresponds to 0 growth.

f <- makeFun((a - 2*b*y)*exp(a*y - b * y^2) ~ b, a = 0.01, y=75 )
slice_plot(f(b) ~ b, domain(b=c(0.000,0.01/75)))

Read off the value of \(b\) from the graph.

Now that you have numerical estimates for \(a\) and \(b\), plot out \(P(y)\) for the next 200 years. According to the prediction, what will be the population in year 2200?

Exercise 27.10: NYPDR

The graph shows a function \(f(x)\). Like all functions, it has an anti-derivative. Here are several functions, \(F_1(x)\) through \(F_4(x)\). One and only one is the anti-derivative of the function shown in the graph. Your job is to figure out which one.

F1 <- rfun(~ x, seed = 782)
F2 <- rfun(~ x, seed = 934)
F3 <- rfun(~ x, seed = 297)
F4 <- rfun(~ x, seed = 892)

Don’t worry about how rfun() makes a function. Once you run those four lines, you can use slice_plot() in the usual way to plot out any of the four functions over the domain \(-5 \leq x \leq 5\).

Which one of the functions is an anti-derivative of the function graphed above? (Hint: See the next problem.) 



(x )  `F1()`
( )  `F2()`
( )  `F3()`
( )  `F4()`

[[Excellent!]]

Confirming graphically that a candidate $$F(x)$$ is indeed the anti-derivative of $$f(x)$$ is hard because the two functions can have very different shapes. But there is a very simple operation you can apply to $$F(x)$$ to make the comparison trivial. What is this operation? 



( )  anti-differentiate $$F(x)
(x )  differentiate $$F(x)$$
( )  compose $$f(x)$$ with itself
( )  multiply $$F(x)$$ times $$f(x)

[[If the result matches the shape of $$f(x)$$, you've confirmed that $$F(x)$$ is the anti-derivative of $$f(x)$$.]]