Skip to main content
Logo image

Chapter 6 Accumulation from rate data

Section 6.1 Approximating accumulation using step functions

Subsection 6.1.1 Simplifying models

A complex model may more faithfully capture the behaviour of a system, but will be more difficult to use for computations. In such a situation, we can use a simplified model that is based on the complex one to perform our calculations.
Consider again our Camrose-Wetaskiwin trip from Example 5.2.9. A (somewhat) more realistic model appears in Figure 6.1.1, including periods of speeding up and slowing down, stopping at traffic lights, and slowing down to negotiate the traffic circle at the junction of highways 13 and 21.
Graph of a rate-of-travel model.
Figure 6.1.1. Graph of a rate-of-travel model.
This rate function is much more difficult to deal with, because the
\begin{equation*} \text{amount} = \text{rate} \times \text{duration} \end{equation*}
formula does not apply to the periods where the rate is continually varying. However, our previous stepped rate function can still be used as a simplified model of the trip.
Graph of a rate-of-travel model.
Figure 6.1.2. Simplifying a rate model with a step-function.
Using the simplified, stepped rate function model, we can obtain an estimate of the distance travelled during the trip by summing up the (oriented) rectangle area, as before.

Subsection 6.1.2 Obtaining better approximations

Question 6.1.3.
How can we obtain a better estimate without greatly increasing computational complexity?
Continuing our car-trip example, the reason our estimate using the simplified, stepped rate function is inaccurate is because the actual rate of travel has variation that the step function does not capture. To get a better estimate, we should allow our stepped rate function model to vary more. We will still use a step function, but with shorter subdomains, so that the step function’s values can change more often to better keep up with the variations in the more complex model.
Diagram of using more steps to increase accuracy of accumulation estimate.
Figure 6.1.4. Using more steps to increase accuracy of accumulation estimate.
Principle 6.1.5. More frequent steps yields better approximation.
In general, given a rate function \(r(t)\text{,}\) a Riemann sum using a Regular step function that steps more frequently will provide a better estimate of the total accumulation over a specific period compared to a Riemann sum using a regular step function that steps less frequently.

Subsection 6.1.3 General form of approximations

We want the variation of our simplified, stepped rate function to approximately mimic the variation in the original rate function, so we should “anchor” heights of the step function to specific heights on the rate function. And since we are talking about a rate function, heights are outputs that are obtained from specific inputs.
So creating a Riemann sum to approximate the total accumulation of a rate function on a specific domain is essentially a two-step process:
  1. split the domain into non-overlapping subdomains
  2. choose an input point in each subdomain that will be used to determine the height of the step function on that subdomain.
The “input points” in the second step are often called sample points, because they are used to “sample” the value of the rate function on that subdomain.
Here is a more detailed procedure.
Rectangular areas corresponding to a Riemann sum for a rate function..
Figure 6.1.7. Rectangular areas corresponding to a Riemann sum for a rate function.

Subsection 6.1.4 Systematic approximation

Models are not always graphical — sometimes they are formulas or equations, or just data in a computer that we can’t “see.” So it is desirable to have systematic methods of choosing subdomains and sample points that can be applied to any rate function to estimate total accumulation over some time period.
First, we will prefer to use Regular step function, so we will always begin by splitting our time period into subdomains of equal length. Next, we have to decide how to choose sample points that will determine our step-function heights on those subdomains; this can be done systematically in a number of different ways.
Definition 6.1.8. Left Riemann sum.
Given rate function \(r(t)\text{,}\) a left Riemann sum for \(r(t)\) over time domain \(a \le t \le b\) is a Riemann sum for a Regular step function where the step function values are chosen to be the output value of \(r(t)\) at the beginning of each subdomain. That is, we choose each subdomain’s sample point to be its left endpoint.
Example 6.1.9. A left Riemann sum.
Consider rate function
\begin{equation*} r(t) = -t^2 + 4 t + 11 \end{equation*}
over domain \(1 \le t \le 7\text{.}\)
Suppose we would like to use a \(3\)-step regular step function as a simplified rate model. As described in Pattern 5.4.4, the duration of each value in this step function should be
\begin{equation*} \change{t} = \frac{7 - 1}{3} = 2 \text{.} \end{equation*}
Our subdomain boundaries are
\begin{align*} t_0 \amp = 1 \amp t_1 \amp = 3 \amp t_2 \amp = 5 \amp t_3 \amp = 7 \end{align*}
and we choose our sample points to be the left endpoints
\begin{align*} t_1^\ast \amp = t_0 = 1 \amp t_2^\ast \amp = t_1 = 3 \amp t_3^\ast \amp = t_2 = 5 \text{.} \end{align*}
So for a left Riemann sum, our step function “steps” should be at heights
\begin{align*} h_1 \amp = r(t_1^\ast) = r(1) = 14 \\ h_2 \amp = r(t_2^\ast) = r(3) = 14 \\ h_3 \amp = r(t_3^\ast) = r(5) = 6 \text{.} \end{align*}
A graph of a left Riemann sum for a parabolic rate function.
Figure 6.1.10. A left Riemann sum for a parabolic rate function.
Calculating our left Riemann sum is the same as adding up the (oriented) areas of the rectangles in Figure 6.1.10:
\begin{equation*} \sum_{k = 1}^{3} h_k \change{t} = 14 \cdot 2 + 14 \cdot 2 + 6 \cdot 2 = 68\text{.} \end{equation*}
(Of course, we could have used Pattern 5.4.4 again, factored out the common \(\change{t}\text{.}\))
Definition 6.1.11. Right Riemann sum.
Given rate function \(r(t)\text{,}\) a right Riemann sum for \(r(t)\) over time domain \(a \le t \le b\) is a Riemann sum for a Regular step function where the step function values are chosen to be the output value of \(r(t)\) at the end (that is, the right endpoint) of each subdomain.
Example 6.1.12. A right Riemann sum.
Consider again the rate function
\begin{equation*} r(t) = -t^2 + 4 t + 11 \end{equation*}
over domain \(1 \le t \le 7\text{.}\) Again we will a \(3\)-step regular step function as a simplified rate model, so the duration of each value in this step function will be \(\change{t} = 2 \) as before, and our subdomain boundaries will be the same as from Example 6.1.9. We choose our sample points to be right endpoints of these subdomains:
\begin{align*} t_1^\ast \amp = t_1 = 3 \amp t_2^\ast \amp = t_2 = 5 \amp t_3^\ast \amp = t_3 = 7 \text{.} \end{align*}
So for a right Riemann sum, our step function “steps” should be at heights
\begin{align*} h_1 \amp = r(t_1^\ast) = r(3) = 14 \\ h_2 \amp = r(t_2^\ast) = r(5) = 6 \\ h_3 \amp = r(t_3^\ast) = r(7) = -10 \text{.} \end{align*}
A graph of a right Riemann sum for a parabolic rate function.
Figure 6.1.13. A right Riemann sum for a parabolic rate function.
Note that in this diagram we have drawn our step function with closed points at the ends of subdomains, to highlight the fact that we are creating a right Riemann sum. The inclusion or exclusion of any one single instant of time will not affect the total accumulation for that subdomain.
Calculating our right Riemann sum is the same as adding up the (oriented) areas of the rectangles in Figure 6.1.13:
\begin{equation*} \sum_{k = 1}^{3} h_k \change{t} = 14 \cdot 2 + 6 \cdot 2 + (-10) \cdot 2 = 20\text{.} \end{equation*}
Definition 6.1.14. Midpoint Riemann sum.
Given rate function \(r(t)\text{,}\) a midpoint Riemann sum for \(r(t)\) over time domain \(a \le t \le b\) is a Riemann sum for a Regular step function where the step function values are chosen to be the output value of \(r(t)\) at the midpoint of each subdomain.
Example 6.1.15. A midpoint Riemann sum.
We will again use a \(3\)-step regular step function as a simplified rate model of the rate function
\begin{equation*} r(t) = -t^2 + 4 t + 11 \end{equation*}
over domain \(1 \le t \le 7\text{.}\) Our subdomains are again all of length \(\change{t} = 2 \) with boundaries
\begin{align*} t_0 \amp = 1 \amp t_1 \amp = 3 \amp t_2 \amp = 5 \amp t_3 \amp = 7 \text{.} \end{align*}
We choose our sample points to be the midpoints between these boundaries:
\begin{align*} t_1^\ast \amp = 2 \amp t_2^\ast \amp = 4 \amp t_3^\ast \amp = 6 \text{.} \end{align*}
So for a midpoint Riemann sum, the heights of our step function “steps” should be
\begin{align*} h_1 \amp = r(t_1^\ast) = r(2) = 15 \\ h_2 \amp = r(t_2^\ast) = r(4) = 11 \\ h_3 \amp = r(t_3^\ast) = r(6) = - 1 \text{.} \end{align*}
A graph of a midpoint Riemann sum for a parabolic rate function.
Figure 6.1.16. A midpoint Riemann sum for a parabolic rate function.
Note that in this diagram we have drawn our step function with open points at both ends of each subdomain, instead placing a closed point at each midpoint highlight the fact that we are creating a midpoint Riemann sum. Again, the exclusion of any one single instant of time will not affect the total accumulation for that subdomain.
Calculating our midpoint Riemann sum is the same as adding up the (oriented) areas of the rectangles in Figure 6.1.16:
\begin{equation*} \sum_{k = 1}^{3} h_k \change{t} = 15 \cdot 2 + 11 \cdot 2 + (-1) \cdot 2 = 50\text{.} \end{equation*}
Definition 6.1.17. Upper Riemann sum.
Given rate function \(r(t)\text{,}\) an upper Riemann sum for \(r(t)\) over time domain \(a \le t \le b\) is a Riemann sum where the step function values are chosen to be the maximum output value that \(r(t)\) achieves on each subdomain.
Example 6.1.18. An upper Riemann sum.
We’ll go back to the same setup as all of our previous examples, for rate function
\begin{equation*} r(t) = -t^2 + 4 t + 11 \end{equation*}
over domain \(1 \le t \le 7\text{.}\) Looking at the many graphs of this rate function we’ve already produced, we can see that on the first subdomain \(1 \le t \le 3\text{,}\) the maximum value of \(r(t)\) occurs at the parabola peak at the midpoint. After that, the rate function is falling and the maximum value on each of the next two subdomains will occur at the beginning of that subdomain. So to create an upper Riemann sum we choose sample points
\begin{align*} t_1^\ast \amp = 2 \amp t_2^\ast \amp = 3 \amp t_3^\ast \amp = 5 \text{,} \end{align*}
and the heights of our step function “steps” will be
\begin{align*} h_1 \amp = r(t_1^\ast) = r(2) = 15 \\ h_2 \amp = r(t_2^\ast) = r(3) = 14 \\ h_3 \amp = r(t_3^\ast) = r(5) = 6 \text{.} \end{align*}
A graph of an upper Riemann sum for a parabolic rate function.
Figure 6.1.19. An upper Riemann sum for a parabolic rate function.
Notice how the graph of the original rate function stays below the stepped rate function over the entire domain.
Calculating our upper Riemann sum is the same as adding up the (oriented) areas of the rectangles in Figure 6.1.19:
\begin{equation*} \sum_{k = 1}^{3} h_k \change{t} = 15 \cdot 2 + 14 \cdot 2 + 6 \cdot 2 = 70\text{.} \end{equation*}
Definition 6.1.20. Lower sum.
Given rate function \(r(t)\text{,}\) an lower Riemann sum for \(r(t)\) over time domain \(a \le t \le b\) is a Riemann sum where the step function values are chosen to be the minimum output value that \(r(t)\) achieves on each subdomain.
Example 6.1.21. A lower Riemann sum.
Once again we’ll use the same setup as all of our previous examples, for rate function
\begin{equation*} r(t) = -t^2 + 4 t + 11 \end{equation*}
over domain \(1 \le t \le 7\text{.}\) Looking at the many graphs of this rate function we’ve already produced, we can see that the rate function is symmetric on the first subdomain \(1 \le t \le 3\text{,}\) achieving the same minimum value at both the beginning and end of that subdomain. After that, the rate function is falling, so the minimum value on each of the next two subdomains will occur at the end of that subdomain. So to create a lower Riemann sum we choose sample points
\begin{align*} t_1^\ast \amp = 1 \amp t_2^\ast \amp = 5 \amp t_3^\ast \amp = 7 \text{,} \end{align*}
and the heights of our step function “steps” will be
\begin{align*} h_1 \amp = r(t_1^\ast) = r(1) = 14 \\ h_2 \amp = r(t_2^\ast) = r(5) = 6 \\ h_3 \amp = r(t_3^\ast) = r(7) = -10 \text{.} \end{align*}
By a coincidence for this rate function, the step-function heights for this lower Riemann sum have turned out to be the same as for the right Riemann sum. This certainly won’t always happen, but since it has for this rate function we won’t bother including another diagram of the rectangular areas involved in this Riemann sum — refer to Figure 6.1.13 instead. But in that figure, since it is also a diagram of a lower Riemann sum for this rate function, notice how the graph of the rate function stays above the stepped rate function over the entire domain.
Also because of this coincidence, we don’t need to re-calculate the Riemann sum. Looking back at our right Riemann sum calculation, we have
\begin{equation*} \sum_{k = 1}^{3} h_k \change{t} = 20 \text{.} \end{equation*}
Upper and lower Riemann sums are more difficult to work with for approximations using a step function with many steps, since it will be more difficult to determine the maximum or minimum values on each subdomain for a large number of subdomains. But they have important properties for the development of our theory.
When using an upper Riemann sum, on each subdomain the rate function is completely below the level of the simplified, stepped rate function, as we saw in Figure 6.1.19. So the true accumulation for that time duration is less than the accumulation calculated using the step function. Since this is true on each subdomain of the step function, an upper Riemann sum will always overestimate the true accumulation, hence the name upper Riemann sum.
By the same reasoning, a lower Riemann sum will always underestimate the true accumulation.

Subsection 6.1.5 Using Sage to calculate Riemann sums

The approximate accumulation values in the various examples of Subsection 6.1.4 are all quite different from each other, even though each calculation involves the same rate function and same number of steps. This is because using only \(3\) steps will not give a very good approximation no matter which scheme of sample points is used, so none of these approximations is close to the true accumulation total.
We need to use many, many more steps to obtain a reasonable approximation, but doing such calculations by hand is not a good idea — that’s what we have computers for, to compute things.
Example 6.1.23. Using Sage to compute a right Riemann sum.
Let’s go back to our rate function
\begin{equation*} r(t) = -t^2 + 4 t + 11 \end{equation*}
over domain \(1 \le t \le 7\text{,}\) but now let’s compute a right Riemann sum with \(1000\) steps. We know that each subdomain will have length
\begin{equation*} \change{t} = \frac{7 - 1}{1000} = 0.006 \text{,} \end{equation*}
but we need to know the pattern of step-function heights to be able to enter that pattern into Sage’s sum function. Since such heights are obtained by substituting subdomain sample points into the rate function, we really just need to know the pattern of right endpoints to be able to enter a right Riemann sum into Sage.
The subdomain boundaries are all separated by the subdomain length, so to get from subdomain boundary to the next, we add the subdomain length.
\begin{align*} t_0 \amp = 1 \\ t_1 \amp = 1 + 0.006 \\ t_2 \amp = 1.006 + 0.006 \\ t_3 \amp = 1.012 + 0.006 \\ \amp \vdots \end{align*}
At the first right endpoint, \(t_1\text{,}\) we are one subdomain length away from the starting point \(1\text{.}\) At the second right endpoint, \(t_2\text{,}\) we are two subdomain lengths from the starting point \(1\text{.}\) Continuing the pattern, at the \(\nth[k]\) right endpoint, we are \(k\) subdomain lengths from the starting point. So a formula in the index \(k\) for the right endpoints is
\begin{equation*} t_k^\ast = 1 + k \change{t} \text{,} \end{equation*}
and so the height of the \(\nth[k]\) “step” in our simplifying, stepped rate function is
\begin{equation*} r(t_k^\ast) = r(1 + k \change{t}) \text{.} \end{equation*}
We are now ready to enter our right Riemann sum
\begin{equation*} \sum_{k = 1}^{1000} r(1 + k \change{t}) \change{t} = \left(\sum_{k = 1}^{1000} r(1 + k \change{t})\right) \change{t} \text{.} \end{equation*}
Checkpoint 6.1.24.
(a)
What happens if you edit the above Sage code to use even more steps, like \(n = 10000\) or \(n = 100000\text{?}\) (Be sure to also change the \(\change{t} = 0.006\) value accordingly.)
(b)
Edit the above Sage code to compute a left Riemann sum instead. To do this, you will need to come up with a formula in \(k\) to describe the \(\nth[k]\) left endpoint.
(c)
Edit the above Sage code to compute a midpoint Riemann sum instead. To do this, you will need to come up with a formula in \(k\) to describe the \(\nth[k]\) midpoint.

Section 6.2 Computing an exact accumulation value using step functions

We can combine Principle 6.1.5 and Pattern 6.1.22 to “home in” on the exact answer. And for a rate function with a continuous graph, it turns out we can work exclusively with regular step functions.

Example 6.2.2. Numerically computing an exact accumulation value.

Consider rate function \(r(t) = t^2 + 1\) on the domain \(0 \le t \le 1\text{.}\) Since the graph of this rate function always goes up as you move to the right, a left Riemann sum will compute the lower sum and a right Riemann sum will compute the upper sum.
This time, instead of working with a specific value of \(n\text{,}\) let’s work out the patterns while leaving \(n\) unspecified, so that it will be easy to change the value of \(n\) in our Sage code.
To create a regular step function, whether for an upper or lower sum, the subdomain lengths should be
\begin{equation*} \change{t} = \frac{1 - 0}{n} = \frac{1}{n} \text{.} \end{equation*}
Beginning at the left-most subdomain boundary, \(t_0 = 0\text{,}\) each subsequent subdomain boundary should be \(\change{t}\) past the previous one:
\begin{align*} t_0 \amp = 0 \\ t_1 \amp = 0 + \frac{1}{n} \\ t_2 \amp = \frac{1}{n} + \frac{1}{n} = \frac{2}{n} \\ t_3 \amp = \frac{2}{n} + \frac{1}{n} = \frac{3}{n} \\ \amp \vdots \end{align*}
And so the pattern of left- and right-endpoints is as follows.
\begin{align*} \text{Left } \amp \text{endpoints} \amp \text{Right } \amp \text{endpoints} \\ t_1^\ast \amp = t_0 = 0 \amp t_1^\ast \amp = t_1 = \frac{1}{n} \\ t_2^\ast \amp = t_1 = \frac{1}{n} \amp t_2^\ast \amp = t_2 = \frac{2}{n} \\ t_3^\ast \amp = t_2 = \frac{2}{n} \amp t_3^\ast \amp = t_3 = \frac{3}{n} \\ \amp \vdots \amp \amp \vdots \\ t_k^\ast \amp = t_{k-1} = \frac{k - 1}{n} \amp t_k^\ast \amp = t_k = \frac{k}{n} \\ \amp \vdots \amp \amp \vdots \\ t_n^\ast \amp = t_{n-1} = \frac{n - 1}{n} \amp t_n^\ast \amp = t_n = \frac{n}{n} \end{align*}
Focussing on the pattern in the expressions for \(t_k^\ast\) in each scheme to use in Sigma notation (and ultimately in a Sage sum command), the upper and lower Riemann sums are
\begin{gather*} \text{Lower: } \sum_{k=1}^{n} r(t_k^\ast) \change{t} = \left( \sum_{k=1}^{n} r(t_k^\ast) \right) \change{t} = \left (\sum_{k=1}^{n} r\left(\frac{k - 1}{n}\right) \right) \cdot \frac{1}{n}\\ \text{Upper: } \sum_{k=1}^{n} r(t_k^\ast) \change{t} = \left( \sum_{k=1}^{n} r(t_k^\ast) \right) \change{t} = \left (\sum_{k=1}^{n} r\left(\frac{k}{n}\right) \right) \cdot \frac{1}{n}\text{.} \end{gather*}
The sage cell below is set up to compute both the lower and upper sums, with the number of steps \(n\) left as a parameter you can change. Try increasing \(n\) a few times, an order of magnitude at a time, to observe these two sums “squeezing” in closer to the true total accumulation value. (You may need to look closely to see the difference in the two values!) Can you guess the true total accumulation value from the pattern in the results as you increase \(n\text{?}\)

Warning 6.2.3.

The “coincidence” of the lower sum corresponding to the left Riemann sum and the upper sum corresponding to the right Riemann sum was a feature of the particular rate function used in Example 6.2.2, and will not hold true for other rate functions.

Section 6.3 The definite integral

Subsection 6.3.1 Definition

Even when the graph of the rate function is not continuous, we can look to see if a number \(A\) that satisfies the conclusion of Fact 6.2.1 exists.
Definition 6.3.1. Definite integral.
Given a function \(r(t)\) on domain \(a \le t \le b\text{,}\) suppose there exists one unique number \(A\) so that
\begin{equation*} L(P) \le A \le U(P) \end{equation*}
for all possible \(P\) (where \(P\text{,}\) \(L(P)\text{,}\) and \(U(P)\) are as in Pattern 6.1.22). In this case, we say that \(r(t)\) is integrable on domain \(a \le t \le b\text{,}\) call the value \(A\) the definite integral of \(r(t)\) over domain \(a \le t \le b\), and write
\begin{equation*} \ccmint{a}{b}{r(t)}{t} \end{equation*}
to represent the value of \(A\text{.}\) The domain endpoints \(a\) and \(b\) are called the lower and upper bounds of integration, respectively, and the function \(r(t)\) is called the integrand, meaning “that which is being integrated.”
Remark 6.3.2.
We have made the definition of definite integral about a general function \(r(t)\text{,}\) not specifically about a rate function \(r(t)\text{.}\) It is possible for a function whose graph is not continuous to fail to be integrable. However, if \(r(t)\) is indeed a rate function (whether with continuous graph or not), then it is the rate of variation function for some accumulation function, and so must be integrable because in this case the \(A\) value in Definition 6.3.1 will just be the total accumulation amount over that time domain of the quantity whose rate of variation \(r(t)\) models.
Compare the notation for a Riemann sum on the left with the notation for a definite integral on the right:
\begin{align*} \amp \sum_{k = 1}^{n} r(t_k^\ast) \change{t_k} \amp \amp \ccmint{a}{b}{r(t)}{t}\text{.} \end{align*}
We have replaced the Greek letter \(\Sigma\text{,}\) which corresponds to the letter S in the English alphabet, with the integral symbol \(\int\text{,}\) an elongated letter S. The lower and upper bounds of the Riemann sum, \(k = 1\) and \(k = n\text{,}\) have been replaced with the bounds of the domain, \(t = a\) and \(t = b\text{.}\) The subdomain duration \(\change{t_k}\) has been replaced with \(dt\text{,}\) which we think of as an “infinitesimal” subdomain duration. (The Greek letter \(\Delta\) corresponds to the letter D in the English alphabet.) Finally, we have replaced both the \(t_k^\ast\) and the \(t_k\) in \(\change{t_k}\) with just a simple \(t\text{.}\)
All of these replacements are tied to the same idea — that the value of the definite integral comes from computing Riemann sums for the function \(r(t)\) over the domain \(a \le t \le b\) using step functions that step more and more frequently, involving subdomains of shorter and shorter durations. Eventually, we end up essentially “sampling” the rate function at every single \(t\)-value between \(t = a\) and \(t = b\text{,}\) essentially creating a stepped rate function with an infinite number of steps on subdomains of infinitesimal length \(dt\text{.}\) And on such subdomains, there is really no difference between sample points that are left endpoints or right endpoints or midpoints or arbitrarily chosen sample points.
A representative rectangular area in a Riemann sum.
(a) A representative rectangular area in a Riemann sum.
A representative "slice" of area in a definite integral.
(b) A representative “slice” of area in a definite integral.
Figure 6.3.3. A rectangular area in a Riemann sum shrinks to become a “slice” of area in a definite integral.

Subsection 6.3.2 The definite integral as net oriented area

Riemann sums using step functions that step more and more frequently correspond to more and more rectangles, eventually closely mimicking the area under the function’s graph.
A Riemann sum of rectangular areas approximating net oriented area bounded between a graph and the horizontal axis.
Figure 6.3.4. A Riemann sum approximating net oriented area bounded between a graph and the horizontal axis.
Principle 6.3.5. Graphical interpretation of the definite integral.
For an integrable function \(r(t)\text{,}\) the definite integral
\begin{equation*} \ccmint{a}{b}{r(t)}{t} \end{equation*}
represents the net oriented area bounded between the graph of the function and the horizontal axis over the domain \(a \le t \le b\text{.}\)
Interpreting a definite integral as net oriented area.
Figure 6.3.6. Interpreting \(A_1,A_2,A_3\) as (positive) geometric areas, the definite integral \(\ccmint{a}{b}{r(t)}{t}\) will compute to the net area \(A_1 - A_2 + A_3\text{.}\)
Example 6.3.7. Using area to compute accumulation.
Consider the rate function whose graph is shown in Figure 6.3.8.
Graph of an example rate function.
Figure 6.3.8. A rate function.
Even though the rate function is not constant or a step function, we can still easily compute the total accumulation of the quantity whose rate of variation is modelled by simply calculating the total oriented area bounded between the graph and the horizontal axis.
Graph of an example rate function with bounded oriented area.
Figure 6.3.9. Accumulation as net oriented area.
We have two positively oriented trapezoidal areas and a negatively oriented triangular area. Calculating the area of these shapes, we have
\begin{align*} \text{total accumulation} \amp = \left(\frac{1 + 7/3}{2}\right) \cdot 2 - \frac{2/3 \cdot 1}{2} + \left(\frac{1 + 2}{2}\right) \cdot \frac{3}{2}\\ \amp = \frac{21}{4}\text{.} \end{align*}

Subsection 6.3.3 Using Sage to compute definite integrals

Computing definite integrals with pencil-and-paper (whether using Riemann sums or other methods) is not a common skill requirement outside of mathematics classes. However, understanding how Riemann sums approximate definite integrals is very useful — if you have a quantity you would like to measure, and can figure out a way to estimate that quantity using something that looks like a Riemann sum, then the desired exact quantity will just be the related definite integral value.
Once you can see how a definite integral will solve your problem, it is time to ask a computer to compute that integral for you. The syntax for computing a definite integral in Sage is (unsurprisingly) essentially the same as for computing a sum.
	integrate(function, variable, start, end)

(Compare with the Sage summation syntax discussed in Subsection 5.3.3.) Alternatively, you can define a function and then apply the integrate method to it.
 r(t) = some_formula 
 r.integrate(variable, start, end) 
Example 6.3.10. Computing a definite integral with Sage.
In Example 6.2.2, we attempted to approximate the total accumulation over the domain \(0 \le t \le 1\) of some quantity whose rate of variation was modelled by the rate function \(r(t) = t^2 + 1\text{.}\)
Let’s ask Sage to compute the exact accumulation value. The command format is integrate(integrand, variable, start, end).
And here it is using a function definition.
Does this result correspond with what you guessed might be the true accumulation value at the end of Example 6.2.2, based on the pattern of upper and lower Riemann sum results when increasing the number of steps?

Subsection 6.3.4 Properties of the definite integral

Given the definite integral’s origin in terms of Riemann sums, the definite integral satisfies similar properties to summation/Sigma notation.
And here are a couple of other conventions, meaning they have no formal justification in terms of Riemann sums but instead are intuitively the “right” thing to do, mathematically.
Convention 6.3.12. More properties of the definite integral.
  1. Integrating over a zero-length domain.
    For every function \(r(t)\) we set
    \begin{equation*} \ccmint{a}{a}{r(t)}{t} = 0 \text{.} \end{equation*}
  2. Integrating in reverse.
    If \(r(t)\) is integrable on the domain \(a \le t \le b\text{,}\) then we set
    \begin{equation*} \ccmint{b}{a}{r(t)}{t} = - \ccmint{a}{b}{r(t)}{t} \text{.} \end{equation*}
Remark 6.3.13.
Property 1 of Convention 6.3.12 should make intuitive sense, since if no time is allowed to pass then the quantity whose rate of variance is described by \(r(t)\) cannot accumulate or decrease.
Hopefully Property 2 also makes intuitive sense — an accumulation of some quantity over time would appear to be a dissipation or loss of quantity if we allowed time to run in reverse, and vice versa.
In light of the two conventions of Convention 6.3.12, Property 5 of Pattern 6.3.11 is also valid even if \(c\) is not between \(a\) and \(b\text{,}\) as long the integrand is integrable over all of the domains involved. For example, when \(c \gt b\) then
\begin{align*} \ccmint{a}{b}{r(t)}{t} \amp = \ccmint{a}{c}{r(t)}{t} - \ccmint{b}{c}{r(t)}{t} \\ \amp = \ccmint{a}{c}{r(t)}{t} - \left( - \ccmint{c}{b}{r(t)}{t} \right) \\ \amp = \ccmint{a}{c}{r(t)}{t} + \ccmint{c}{b}{r(t)}{t} \text{,} \end{align*}
and similarly when \(c \lt a\text{.}\)

Subsection 6.3.5 Re-basing an integral

Many of the integration formulas we present in this book will be “based” at \(t = 0\text{:}\)
\begin{equation*} \ccmint{0}{c}{ r(t) }{t} \text{.} \end{equation*}
The reason for this is that \(t = 0\) is the most “natural” initial time for an observation period. (Occasionally we will base integration formulas at \(t = 1\) in the case that the rate function \(r(t)\) is undefined at \(t = 0\text{.}\))
We can still use such \(0\)-based integration formulas to compute any other integral
\begin{equation*} \ccmint{a}{b}{ r(t) }{t} \end{equation*}
with the help of Property 5 of Pattern 6.3.11, since
\begin{equation*} \ccmint{0}{b}{ r(t) }{t} = \ccmint{0}{a}{ r(t) }{t} + \ccmint{a}{b}{ r(t) }{t} \text{.} \end{equation*}

Section 6.4 Recovering a quantity function from a rate function

Subsection 6.4.1 The definite integral as an accumulation function

Given an integrable rate function for some quantity, the definite integral allows us to create a function that could describe the accumulation of that quantity at any point in time in the domain over which the rate function is integrable.
Example 6.4.1. Accumulation of pumped air as a function.
Consider once again the pump-leak-pump pattern in Example 5.2.13. Let \(r(t)\) represent the rate of variation of the air in the raft (graphed in Figure 5.2.14). Let \(A_0(t)\) represent the volume of air accumulated in the raft from fixed starting time \(t = 0\) to variable ending time \(t\text{,}\) with \(t\) measured in minutes and \(A_0(t)\) measured in cubic metres. In Example 5.2.1, we calculated
\begin{equation*} A_0(4) = \ccmint{0}{4}{r(t)}{t} = 2.25 \text{.} \end{equation*}
From that calculation, we can easily also extract the quantities
\begin{gather*} A_0(1) = \ccmint{0}{1}{r(t)}{t} = 0.5 \\ A_0(3) = \ccmint{0}{3}{r(t)}{t} = 2 \text{.} \end{gather*}
Since no air is leaking or being pumped in the fifth minute, we also have
\begin{equation*} A_0(5) = \ccmint{0}{5}{r(t)}{t} = 2.25 \text{.} \end{equation*}
Finally, in Example 5.2.13 we also calculated
\begin{equation*} A_0(10) = \ccmint{0}{10}{r(t)}{t} = 2.65 \text{.} \end{equation*}
The definite integral notation gives us a way to write a “formula” for the accumulation function \(A_0(t)\text{.}\) In each of the values of \(A_0(t)\) examined in Example 6.4.1, the lower bound of integration was our fixed starting time \(0\text{,}\) and the upper bound of integration was the new ending time for the time interval over which we wished to measure the accumulation. This ending time is our independent variable for the function \(A_0(t)\text{.}\) However, we have a notational problem — we are also using \(t\) as the input variable of our rate function. The \(t\) in \(r(t)\) in the definite integral
\begin{equation*} A_0(10) = \ccmint{0}{10}{r(t)}{t} \end{equation*}
represents a variable time between \(t = 0\) and \(t = 10\text{,}\) and the \(dt\) represents a miniscule time period duration, so the \(t\) in \(r(t)\) and \(dt\) in the integral notation are serving much different purposes than the \(t\) in \(A_0(t)\text{.}\) To separate these roles, we’ll choose a different letter for the independent variable in the rate function when we choose to have a variable upper bound of integration.
Also, we used the subscript \(0\) on the function \(A_0(t)\) in Example 6.4.1 to we indicate that all of the accumulations that we calculated were over a time period beginning at \(t = 0\text{.}\) However, there will be instances where we want to measure accumulation from a different starting time other than \(t = 0\text{,}\) in which case we can just change that subscript.
As a “formula” for an accumulation function, a definite integral is not very convenient — computing a definite integral requires examining patterns of upper and lower sums, which is not so easy if the upper bound of integration is a variable. Luckily Sage can also handle this for us.
Example 6.4.3. Using Sage to compute an accumulation function formula.
Let’s return once again to the example of some quantity whose variation is modelled by the rate function \(r(t) = t^2 + 1\text{,}\) as in Example 6.2.2 and Example 6.3.10. Swapping \(u\) for \(t\) in our rate function so that \(t\) can act as the variable upper bound of integration, our accumulation function (with fixed starting time \(t_0 = 0\)) becomes
\begin{equation*} A_0(t) = \ccmint{0}{t}{u^2 + 1}{u} \text{.} \end{equation*}
Recall that the Sage integration command format is integrate(integrand, variable, start, end). In this format, variable means the letter being used as the integrand function’s independent variable, so here we use u in that spot. But our end value is also variable, so we’ll have the letter \(t\) there instead of a number like before.
Our lower and upper sum calculations in Example 6.2.2 hinted that \(A_0(1)\) was likely to be \(1.\overline{3}\text{.}\) Our Sage calculation in Example 6.3.10 confirmed the value of \(A_0(1)\) to be \(4/3\text{,}\) and substituting \(t = 1\) into the formula returned by Sage above gives the same result.
Warning 6.4.4. Accumulation ignores initial value.
If someone on a cross-country road trip averages 90 kmh over 10 h on one of the days of the trip, then we can easily calculate that they travelled approximately 900 km that day. But that doesn’t tell us where in the country they were at the end of the day. For that information, we need to know where they started (and, in this example, what direction and on which highway they travelled).
Example 6.4.5. Taking initial quantity into account.
Suppose we observe an initial quantity of \(5/3\) units of material, but the quantity of material grows according to rate function \(r(t) = t^2 + 1\text{.}\) How much total material is present one unit of time later? Using our previous calculation from Example 6.3.10, we have
\begin{align*} \text{final amount} \amp = \text{initial amount} + \text{accumulated amount} \\ \amp = \frac{5}{3} + \frac{4}{3} \\ \amp = 3 \text{.} \end{align*}
Finally, we will do one example of using Riemann sums to calculate an actual formula for an accumulation function, though in practice we will not often return to “first principles” to carry out calculations.
Example 6.4.6. Using Riemann sums to compute an accumulation function formula.
Let’s return to the rate function \(r(t) = t^2 + 1\) from Example 6.2.2 over a time domain beginning at \(t = 0\text{,}\) but this time we will leave the upper bound on this time domain as a variable, in order to obtain an accumulation function in terms of this domain end point instead of just a single accumulation value. Because we want to be able to mimic the calculations from Example 6.2.2, instead of changing the letter for the independent variable in the rate function \(r(t)\text{,}\) instead we will use the letter \(z\) for the variable endpoint of the domain.
Again, the graph of this rate function always goes up as you move to the right, so a left Riemann sum will compute the lower sum and a right Riemann sum will compute the upper sum. Our analysis here is almost identical to that from Example 6.2.2, except that our subdomain widths are dependent on \(z\text{:}\)
\begin{equation*} \change{t} = \frac{z - 0}{n} = \frac{z}{n} \end{equation*}
(where we are still using \(0\) as the start of the time domain). Just as before, beginning at the left-most subdomain boundary, \(t_0 = 0\text{,}\) each subsequent subdomain boundary should be \(\change{t}\) past the previous one, so that the pattern of boundaries is
\begin{equation*} t_k = k \cdot \frac{z}{n} \text{.} \end{equation*}
Recall that \(t_0\) is the first left-endpoint and \(t_1\) is the first right-endpoint. So similar to Example 6.2.2, the pattern of left- and right-endpoints is as follows.
\begin{align*} \text{Left } \amp \text{endpoints} \amp \text{Right } \amp \text{endpoints} \\ t_k^\ast \amp = t_{k-1} = (k - 1) \cdot \frac{z}{n} \amp t_k^\ast \amp = t_k = k \cdot \frac{z}{n} \end{align*}
We can now set up our upper and lower Riemann sums:
\begin{gather*} \text{Lower: } \sum_{k=1}^{n} r(t_k^\ast) \change{t} = \left( \sum_{k=1}^{n} r(t_k^\ast) \right) \change{t} = \left (\sum_{k=1}^{n} r\left((k - 1) \cdot \frac{z}{n}\right) \right) \cdot \frac{z}{n}\\ \text{Upper: } \sum_{k=1}^{n} r(t_k^\ast) \change{t} = \left( \sum_{k=1}^{n} r(t_k^\ast) \right) \change{t} = \left (\sum_{k=1}^{n} r\left(k \cdot \frac{z}{n}\right) \right) \cdot \frac{z}{n}\text{.} \end{gather*}
The sage cell below is set up to compute both the lower and upper sums, with the number of steps \(n\) left as a parameter you can change. (The polynomial(RR) part tells Sage to interpret the result as a polynomial with Real coefficients.) Increase \(n\) a few times, an order of magnitude at a time, until you can see a pattern emerging, with subsequent lower and upper sum results “squeezing” to a formula for the accumulation function (with independent variable \(z\) instead of \(t\)).

Subsection 6.4.2 Accumulation versus quantity

However, accumulation is not the whole story. To know the total quantity at a given time, we need to know the “initial amount” as well:
\begin{equation*} \text{final amount} = \text{initial amount} + \text{accumulated amount} \text{.} \end{equation*}
Remark 6.4.8.
In fact, it is not necessary that the “initial” quantity is taken to mean the left endpoint of the domain. That is, Pattern 6.4.7 can be broadened in the following way. If \(r(t)\) is integrable over the domain \(a \le t \le b\) and \(t_0\) is any choice of point in that domain at which the “initial” value \(q(t_0)\) is known, then the formula for \(q(t)\) in Pattern 6.4.7 is still valid over the whole domain \(a \le t \le b\text{,}\) not just on \(t_0 \le t \le b\text{.}\) For those \(t\) in \(a \le t \lt t_0\text{,}\) we just use Property 2 from Convention 6.3.12 when interpreting
\begin{equation*} \ccmint{t_0}{t}{r(u)}{u} \end{equation*}
so that in this case
\begin{equation*} q(t) = q(t_0) + \ccmint{t_0}{t}{r(u)}{u} = q(t_0) - \ccmint{t}{t_0}{r(u)}{u} \end{equation*}
means the “initial” quantity minus some of the amount that accumulated before that “initial” time.
Example 6.4.9. Combining initial amount with an accumulation function.
In Example 6.4.3, we had Sage calculate an accumulation function for the rate function \(r(t) = t^2 + 1\text{:}\)
\begin{equation*} A_0(t) = \ccmint{0}{t}{u^2 + 1}{u} = \frac{t^3}{3} + t \text{.} \end{equation*}
This formula how much extra quantity will have accumulated between initial time \(0\) and an end time \(t\text{.}\) Suppose we have a varying quantity \(q(t)\) and we know both that the associated rate function is \(r(t) = t^2 + 1\) and that the initial quantity is \(q(0) = 4\text{,}\) then we can combine these to determine the final quantity:
\begin{equation*} q(t) = q(0) + A_0(t) = 4 + \frac{t^3}{3} + t \text{.} \end{equation*}
Example 6.4.10. Constant rate implies linear quantity model.
We can combine Pattern 6.4.7 with Property 1 of Pattern 6.3.11 in the case of a constant rate function to recover Pattern 1.4.3.
Suppose \(q(t)\) is a quantity that is varying at a constant rate \(r(t) = c\text{.}\) Using Property 1 of Pattern 6.3.11, we can calculate the accumulation function \(A_0(t)\) as
\begin{align*} A_0(t) \amp = \ccmint{0}{t}{r(u)}{u} \\ \amp = \ccmint{0}{t}{c}{u} \\ \amp = c \cdot (t - 0) \\ \amp = c t \text{.} \end{align*}
Combining this accumulation function with an initial value \(q_0 = q(0)\text{,}\) Pattern 6.4.7 gives us
\begin{equation*} q(t) = q(0) + A_0(t) = q_0 + c t \text{,} \end{equation*}
exactly as in Pattern 1.4.3.