23  Derivatives of assembled functions

In Chapter 19 we used the rules associated with evanescent h, that is, limh0, to confirm our claims about the derivatives of many of the pattern-book functions. We will call these rules h-theory for short. This chapter will use h-theory to find algebraic rules to calculate the derivatives of linear combinations of functions, products of functions, and composition of functions. Remarkably, we can figure out these rules without specifying which functions are being combined. So the rules can be written in terms of abstractions: f(), g(), and h(). Later, we will apply those rules to specific functions, to show how the rules are used in practical work.

23.1 Using the rules

When you encounter a function that you want to differentiate, you first have to examine the function to decide which rule you want to apply. In the following, we will to use the names f() and g(), but in practice the functions will often be basic modeling functions, for instance ekx or sin(2πPt), etc.

Step 1: Identify f() and g()

We will write the rules in terms of two function names, f() and g(), which can stand for any functions whatsoever. It is rare to see the product or the composition written explicitly as f(x)g(x) of f(g(x)). Instead, you are given something like exln(x). The first step in differentiating the product or composition is to identify what are f() and g() individually.

In general, f() and g() might be complicated functions, themselves involving linear combinations, products, and composition. But to get started, we will practice with cases where they are simple, pattern-book functions.

Step 2: Find f’() and g’()

For differentiating either products or compositions, you will need to identify both f() and g() (the first step) and then compute the derivatives xf() and xg(). That is, you will write down four functions.

Step 3: Apply the relevant rule

Recall from Chapter ?sec-fun-assembling that will will be working with three important forms for creating new functions out of existing functions:

  1. Linear combinations, e.g. af(x)+bg(x)
  2. Products of functions, e.g. f(x)g(x)
  3. Compositions of functions, e.g. f(g(x))

23.2 Differentiating linear combinations

Linear combination is one of the ways in which we make new functions from existing functions. As you recall, linear combination involves scaling functions and then adding the scaled functions as in af(x)+bg(x), alinear combination of f(x) and g(x). We can easily use h to show what is the result of differentiating a linear combination of functions. First, let’s figure out what is xaf(x), Going back to writing x in terms of a slope function:

xaf(x)=af(x+h)af(x)h =af(x+h)f(x)h=axf(x) In other words, if we know the derivative xf(x), we can easily find the derivative of af(). Notice that even though h was used in the derivation, it appears nowhere in the result xbf(x)=bxf(x). The h is solvent to get the paint on the wall and evaporates once its job is done.

Now consider the derivative of the sum of two functions, f(x) and g(x): x[f(x)+g(x)]=[f(x+h)+g(x+h)][f(x)+g(x)]h =[f(x+h)f(x)]+[g(x+h)g(x)]h =[f(x+h)f(x)]h+[g(x+h)g(x)]h =xf(x)+xg(x)

Because of how x can be “passed through” a linear combination, mathematicians say that differentiation is a linear operator. Consider this new fact about differentiation as a down payment on what will eventually become a complete theory telling us how to differentiate a product of two functions or the composition of two functions. We will lay out the h-theory based algebra of this in the next two sections.

We can summarize the h-theory result for linear combinations this way:

The derivative of a linear combination is the linear combination of the derivatives.

That is:

x[af(x)+bg(x)]=af(x)+bg(x)

as well as

x[af(x)+bg(x)+ch(x)+]=af(x)+bg(x)+ch(x)+

The derivative of a polynomial is a polynomial of a lower order.

Consider the polynomial h(x)=ax0+bx1+cx2 The derivative is

xh(x)=0a+1b+c2x=b+2c x

23.3 Product rule for multiplied functions

The question at hand is how to compute the derivative xf(x)g(x). Of course, you can always use numerical differentiation. But let’s look at the problem from the point of view of symbolic differentiation. And since f(x) and g(x) are just pronoun functions, we will assume you are starting out already knowing the derivatives xf(x) and xg(x).

This situation arises particularly when f(x) and g(x) are pattern-book functions for which you already have memorized xf(x) and xg(x) or are basic modeling functions whose derivatives you will memorize in Section @ref(basic-derivs).

The purpose of this section is to derive the formula for xf(x)g(x) in terms of f(x), g(x), xf(x) and xg(x). This formula is called the product rule. The point of showing a derivation of the product rule is to let you see how the logic of evanescent h plays a role. In practice, everyone simply memorizes the rule, which has a beautiful, symmetric form:

Product rule:    x[f(x)g(x)]=[xf(x)]g(x)+f(x)[xg(x)] and is even prettier in Lagrange notation (where xf(x) is written f): [fg]=fg+gf

As with all derivatives, the product rule is based on the instantaneous rate of change F(x)limh0F(x+h)F(x)h introduced in ?sec-instantaneous-rate-of-change.

We also need two other statements about h and functions:

  1. The derivative F(x) is the slope of of F() at input x. Taking a step of size h from x will induce a change of output of hF(x), so F(x+h)=f(x)+hF(x) .
  2. Any result of the form hF(x), where F(x) is finite, gives 0. More precisely, limh0hF(x)=0

As before, we will put the standard limh0 disclaimer against dividing by h until there are no such divisions at all, at which point we can safely use the equality h=0.

Suppose the function F(x)f(x)g(x), a product of the two functions f(x) and g(x).

F(x)=x[f(x)g(x)]limh0f(x+h)g(x+h)f(x)g(x)h

We will replace g(xh) with its equivalent g(x)+hg(x) giving

=limh0f(x+h)[g(x)+hg(x)]f(x)g(x)h

g(x) appears in both terms in the numerator, once multiplied by f(x+h) and once by f(x). Collecting those terms give:

=limh0[f(x+h)f(x)]g(x)+[f(x+h)hg(x)]h

This has two bracketed terms added together over a common denominator. Let’s split them into separate terms:

=limh0[f(x+h)f(x)h]f(x)g(x)+limh0[f(x)+hf(x)]hg(x)h

The first term is g(x) multiplied by the familiar form for the derivative of f(x)

=f(x)g(x)+limh0f(x)hg(x)h+limh0hf(x)hg(x)h

In each of the last two terms there is an h/h involved. This is safely set to 1, since the limh0 implies that h will not be exactly zero. There remain no divisions by h so we can drop the limh0 in favor of h=0:

=f(x)g(x)+f(x)g(x)+hf(x)g(x)

=f(x)g(x)+g(x)f(x)

The last step relies on statement (2) above.

Some people find it easier to read the rule in Lagrange shorthand, where f and g stand for f(x) and g(x) respectivly, and f (“f-prime”) and g (“g-prime”) stand for f() and g().

Lagrange shorthand:  [f×g]=[f×g]=fg+gf

The expression xx3 is the same as x[x x2]. Since we already know xx (it is 1) and xx2 (it is 2x) let’s apply the product rule to find xx3:

[x×x2]=[x]×x2 + [x2]×x=1×x2+2x×x=3x2

Occasionally, mathematics gives us a situation where being more general produces simplicity.

In the case of function products, the generalization is from products of two functions f(x)g(x) to products of more than two functions, e.g. u(x)v(x)w(x).

The chain rule here takes a form that makes the overall structure much clearer:

x[u(x)v(x)w(x)]=            xu(x)v(x)w(x) +u(x)xv(x)w(x) +u(x)v(x)xw(x)    \end{eqnarray}

In the Lagrange shorthand, the pattern is even more evident:

[uvw]=uvw + uvw + uvw

23.4 Chain rule for function composition

A function composition, as described in Section 9.2, involves inserting the output of one function (the “interior function”) as the input of the other function (the “exterior function”). As we so often do, we will be using pronouns a lot. A list might help keep things straight:

  • There are two functions involved in a composition. Generically, we call them f(y) and g(x). In the composition f(g(x)), the exterior function is f() and the interior function is g().
  • Each of the two functions f() and g() has an input. In our examples, we use y to stand for the input to the exterior function and x for the input to the interior function.
  • As with all rules for differentiation, we will need to compute the derivatives of the functions involved, each with respect to its own input. So these will be yf(y) and xg(x).

A reason to use different pronouns for the inputs to f() and g() is to remind us that the output g(x) is in general not the same kind of quantity as the input x. In a function composition, the f() function will take the output g(x) as input. But since g(x) is not necessarily the same kind of thing as x, why would we want to use the same name for the input to f() as we use for the input to g().

With this distinction between the names of the inputs, we can be even more explicit about the composition, writing f(y=g(x)) instead of f(g(x)). Had we used the pronound x for the input to f() but our explicit statement, although technically correct, would be confusing: f(x=g(x))!

With all these pronouns in mind, here is the chain rule for the derivative xf(g(x)):

x[f(g(x))]=[yf](g(x))×[xg(x)]

Or, using the Lagrange prime notation, where stands for the derivative of a function with respect to its input, we have

Lagrange shorthand:  [f(g)]=f(g)×g

23.5 Rates per time

In news and policy discussions, you will often hear about “inflation rate” or “birth rate” or “interest rate” or “investment rate of return.” In each case, there is a function of time combined with a derivative of that function: with the general form tf(t)f(t) .

  • Inflation rate: The function is cost_of_living(t). The derivative is the rate of change with respect to time in the cost of living: tcost_of_living(t).
  • Birth rate: The function is population(t). The derivative is tpopulation(t), or at least that component of the overall tpopulation(t) that is related to births. (Other components are deaths and the balance of in-migration and out-migration.)
  • Interest rate: The function is account_balance(t) and the derivative is taccount_balance(t).
  • Investment returns: The function is net_worth(t) and the derivative is tnet_worth(t).

In all these cases, The “rate” is not merely “per time” as would be the case for tf(t). Instead the rate is “per unit of the whole per time.” For birth rate, the “whole” is the population. The birth rate is the number of births in a year divided by the population itself. Birth rates are often stated with the phrase is “per capita per year.”

“Per capita” is Latin. It translates to “by head.” Its modern sense is “per unit of population.” Of course, the “unit of population” is a person.

Notice the two uses of “per” in the phrase: “births per capita per year.” A proportional rate is two rates in one. Births per capita is a proportion of the population. Births per year is an average rate with respect to time. But “births per capita per year” is a rate in the proportion with respect to time.

The rate word “per” also appears as part of “percent,” which literally means “per hundred.” A “percentage change” is the amount of change divided by the base amount. Confusingly, perhaps, “percentage change” is often truncated to the shorter “percent.” This is the case with inflation rates, interest rates, and rates of return on investment. The interest rate on a credit-card debt is stated as a proportion of the current debt; all that is packed into the word “percent.” The interest rate itself is the “proportion of the current debt per year”: two rates in one.

Similarly for an inflation rate. “Inflation” is stated as the change in prices divided by the current price: a proportional change. “Inflation rate” is the proportional change per unit of time, where the “whole” is current prices and the rate is change in current prices per year divided by current prices.

Thanks to the chain rule, there is a shortcut way of writing proportional rates per time. Exactly equivalent to the ratio tf(t)f(t) is tln(f(t)) .

Derivatives of logarithms appear often in fields such as economics or finance, where it is common to consider the logarithm of the economic quantity to render changes as percent of the whole.

Math in the World: Linear or logarithmic axes?

It always pays to look carefully at the axes in a graph. For instance, consider Figure 23.1 which shows the cumulative number of COVID during a period in 2020, early in the pandemic.

Figure 23.1: Growth in the number of Coronavirus cases in Italy and the US early in the pandemic. Source

The two panels in Figure 23.1 show the same data about growing numbers of coronavirus cases, the left graph on linear axes, the right on the now-familiar semi-log axes.

Most people are excellent at comparing slopes, even if they find it difficult or tedious to quantify a slope with a number and units. For instance, a glance suffices to show that in the left graph, well through mid-March the red curve (Italy) is steeper on any given date than the blue curve (US). Correspondingly, the number of people with coronavirus was growing faster (per day) in Italy.

The right graph tells a different story: up until about March 1, the Italian cases were increasing faster than the US cases. Afterwards, the US sees a larger growth rate than Italy until, around March 19, the US growth rate is substantially larger than the Italy growth rate.

The previous two paragraphs and their corresponding graphs seem to contradict one another. But they are both accurate, truthful depictions of the same events. What’s different between the two graphs is that the left shows one kind of rate and the right shows another kind of rate. In the left, the slope is new-cases-per-day, the output of the derivative function

left graph:     _tdaily_new_cases(t).

On the right, the slope is the proportional increase in cases per day, that is,

right graph:     tdaily_new_cases(t)daily_new_cases(t).

From the chain rule, we know that

t[ln(f(t))]=tf(t)f(t) .

Since the right graph is on semi-log axes, the slope we perceive visually is t[ln(f(t))]. That is an obscure-looking bunch of notation until the chain rule reveals it to be the rate of change at time t divided by the value at time t.

The derivation of the chain rule relies on two closely related statements which are expressions of the idea that near any value x a function can be expressed as a linear approximation with the slope equal to the derivative of the function :

  1. g(x+h)=g(x)+hg(x)
  2. f(y+ϵ)=f(y)+ϵf(y), which is the same thing as (1) but uses y as the argument name and ϵ to stand for the small quantity we usually write with an h.

We will now look at xf(g(x)) by writing down the fundamental definition of the derivative. This, of course, involves the disclaimer limh0 until we are sure that there is no division by h involved.

x[f(g(x))]limh0f(g(x+h))f(g(x))h

Let’s examine closely the expression f(g(x+h)). Applying rule (1) above turns it into limh0f(g(x)+hg(x)) Now apply rule (2) but substituting in g(x) for y and hg(x) for ϵ, giving

limh0f(g(x+h))=limh0[f(g(x))+hg(x)f(g(x))]

We will substitute the blue and brown expression for the magenta expression in xf(g(x))limh0f(g(x+h))f(g(x))h giving

xf(g(x))limh0f(g(x))+hg(x)f(g(x))f(g(x))h

In the denominator, f(g(x)) appears twice and cancels itself out. That leaves a single term with an h in the numerator and an h in the denominator. Those h’s cancel out, at the same time obviating the need for limh0 and leaving us with the chain rule:

xf(g(x))limh0hg(x)f(g(x))h=f(g(x)) g(x)

Use the chain rule to find the derivative xe2x.

Recognize that g(x)2x is the interior function in e2x and f(x)exp(x) is the exterior function. Thus xe2x=f(g(x))g(x)=exp(g(x))2=2e2x . Happily, this is the same result as we got from using the product rule to find xe2x.

Recognizing e2x as ex×ex, we can apply the product rule.

The chain rule can be used in a clever way to find a formula for xln(x).

We’ve already seen that the logarithm is the inverse function to the exponential, and vice versa. That is:

eln(y)=y   and   ln(ey)=x

Since ln(ey) is the same function as y, the derivative yln(ey)=yy=1.

Let’s differentiate the second form using the chain rule:

yln(ey)=[yln](ey)ex=1 giving [yln](ey)=1ey=recip(ey)

Whatever the function xln() might be, it takes its input and produces as output the reciprocal of that input. In other words:

xln(x)=1x .

Knowing that xln(x)=1/x and the chain rule, we are in a position to demonstrate the power-law rule xxp=pxp1. The key is to use the identity eln(x)=x.

xxp=x[eln(x)]p

The rules of exponents allow us to recognize [eln(x)]p=epln(x) Thus, xp can be seen as a composition of the exponential function onto the logarithm function.

Applying the chain rule to this composition gives

xepln(x)=epln(x)x[pln(x)]=epln(x)px . Of course, we already know that epln(x)=xp, so we have

xxp=xppx=pxp1 .

  • x[sin(ax+b)]=[xsin](ax+b)×x[ax+b]=cos(ax+b)×a.

23.6 Derivatives of the basic modeling functions

The basic modeling functions are the same as the pattern-book functions, but with bare x replaced by line(x). In other words, each of the basic modeling functions is a composition of the corresponding pattern-book function with line(x). Consequently, the derivatives of the basic modeling functions can be found using the chain rule.

Suppose f() is one of our pattern-book functions. Then xf(ax+b)=af(ax+b) where a is the derivative with respect to x of ax+b.

Here are the steps for differentiating a basic modeling function f(ax+b) where f() is one of the pattern-book functions:

  • Step 1: Identify the particular pattern-book function f() and write down its derivative f. For example, if f() is sin(), then f() is cos().
  • Step 2: Find the derivative of the linear interior function. If the function is ax+b, then the derivative is a. If the interior function is 2πP(tt0), the derivative is 2πP.
  • Step 3: Write down the original function f(ax+b) but replace f with f and pre-multiply by the derivative of the interior function. For instance, xf(ax+b)=af(ax+b) Another example: tsin(2πP(tt0))=2πPcos(2πP(tt0))

By convention, there are different ways of writing line(x) for the different pattern-book functions, for instance:

Pattern-book function Basic modeling
sin(x)    sin(2π[xx0]/P)
exp(x)    exp(kx)
x2    [mx+b]2
1/x    1/[mx+b]
ln(x)    ln(ax+b)

The rule for the derivative of any basic modeling function f(line(x)) is xf(line(x))=xline(x)×xf(line(x))

To illustrate:

  • xekx=kekx where line(x)=kx.
  • xsin(2π(xx0)/P)=2πPsin(2π(xx0)/P) where line(x)=2π(xx0)/P).
  • x(mx+b)2=m2(mx+b)=2m2x+m2b where line(x)=mx+b.
  • xreciprocal(mx+b)=x1mx+b=m(mx+b)2 where line(x)=mx+b and we use the fact that xreciprocal(x)=1/x2
  • xln(ax+b)=a/(ax+b)
  • xpnorm(x,mean,sd)=dnorm(x,mean,sd).
  • xdnorm(x,mean,sd)=xmsd2dnorm(x,mean,sd)

You will be using the derivatives of the basic modeling functions so often, that you should practice and practice until you can write the derivative at a glance.

There are many possible implementations of the general concept of hump functions and sigmoid functions. This book uses dnorm() for the hump and pnorm() for the sigmoid.

The names dnorm and pnorm are worth remarking on. As we’ve said before, dnorm() is called the gaussian function in many fields of science and engineering. It is also a centrally important function in statistics, where it is called the normal function. (that is how important it is: it is just “normal.”) You may also have heard the normal function described as a “bell-shaped curve.”

In statistical nomenclature, dnorm() is called the “normal probability density function (PDF)” and pnorm() is called the “normal cumulative density function (CDF).” that is way too wordy for our purposes. For brevity, we have adopted the R name for those functions: dnorm() and pnorm().

Owing to the origin of the names dnorm and pnorm, we are writing the parameters of the functions—mean and sd—using the computer language notation. The pattern-book functions are just dnorm(x) and pnorm(x), without listing the parameters. But the basic modeling functions, with parameters, are written dnorm(x,mean,sd) and dnorm(x,mean,sd). This violates the convention that the basic modeling functions are the composition of the pattern-book functions with line(x). But dnorm() does not work this way because, by convention, the amplitude of the peak of dnorm() changes with the input parameter sd. That is not true for any other basic modeling function.

Composition or product?

There is one family of functions for which function composition accomplishes same thing as multiplying functions: the power-law family.

Consider, for instance, the function h(x)[3x]4. Let’s let g(x)3x and f(y)y4. With these definitions, h(x)=f(g(x)).

Recognizing that yf(y)=4y3 and xg(x)=3, the chain rule gives xh(x)=4g(x)3f(g(x))×3g(x)=4(3x)3f(g(x))×3=434×x3=324 x3 Another way to look at the same function is g(x) multiplied by itself 3 times: h(x)=g(x)g(x)g(x)g(x) This is a product of 4 terms. Applying the product rule gives xh(x)=g(x)g(x)g(x)g(x)+ g(x)g(x)g(x)g(x)+ g(x)g(x)g(x)g(x)+ g(x)g(x)g(x)g(x) Since multiplication is commutative, all four terms are the same, each being 34x3. The sum of all four is therefore 4×34x3=324x3.

These are two long-winded ways of getting to the result. For most people, differentiating power-law functions algebraically is simplified by using the rules of exponentiation rather than the product or chain rule. Here, h(x)[3x]4=34x4so xh(x) is easily handled as a scalar (34) times a function x4. Consequently, applying the rule for differentiating power laws,

xh(x)=34×xx4=34×4x3=324x3

As another example, take h(x)x34. This is, of course, the composition f(g(x)) where f(y)y1/4 and g(x)x3. Applying the chain rule to find xh(x) will work (of course!), but is more work than applying the rules of exponentiation followed by a simple power-law differentiation.

h(x)=x34=x3/4  so  xh(x)=34x(3/41)=34x1/4

23.7 Exponentials and logarithms (optional)

The natural logarithm function, ln(x), is one of our basic modeling functions. As you know, there are other logarithmic functions. The one most often used is the logarithm-base-10, written log10(x) or log10(x). Ten is an integer, and a nice number to use in arithmetic. So in practice, it is sensible to use log10(). (Indeed, log10() is the digit() function, introduced in Chapter ?sec-magnitudes).

The “natural” in the “natural logarithm” means something different.

The base of the natural logarithm is the number called Euler’s constant and written e. As a celebrity number, e is right up there with π and i. Just as π has a decimal expansion that is infinitely long—the familiar π=3.14159265358979...—Euler’s constant has an infinitely long decimal representation: e=2.71828182845905...

It is not obvious why e=2.71828182845905... should be called “natural” by mathematicians. The reasons are:

  1. ln(x) is the inverse of ex, which is special for being invariant under differentiation: xex=ex.
  2. The derivative xln(x) which has a particularly simple form, namely, 1/x.

Let’s look at the log-base-10 and its computer-savvy cousin log-base-2. The very definition of logarithms means that both 10 and 2 can be written 10=eln(10)   and   2=eln(2) This implies that the base-10 and base-2 exponential functions can be written in terms of Euler’s constant e:

10x=[eln(10)]x=eln(10)x   and   2x=[eln(2)]x=eln(2)x

Calculating x10x or x2x is a matter of applying the chain rule:

x[10x]=x[eln(10)x]=eln(10)x×ln(10) = 10x×2.3026

and

x[2x]=x[eln(2)x]=eln(2)x×ln(2) = 2x×0.6931

Like ex, the derivatives of 10x and 2x are proportional to themselves. For ex the constant of proportionality is 1, a very natural number indeed.

23.8 Drill

Part 1 Which of the derivative rules should you use to find tet2 ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 2 Which of the derivative rules should you use to find tex2 ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 3 Which of the derivative rules should you use to find tetsin(t) ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 4 Which of the derivative rules should you use to find tetsin(x) ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 5 Which of the derivative rules should you use to find tln(t) ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 6 Which of the derivative rules should you use to find ttet ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 7 Which of the derivative rules should you use to find x 37x5 ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 8 Which of the derivative rules should you use to find x 19 ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 9 Which of the derivative rules should you use to find x 15x23x+7ln(x) ?

  1. The constant multiplier rule
  2. The linear combination rule
  3. The product rule
  4. The chain rule
  5. No rule needed, it is so basic.

Part 10 What is x 15x23x+7ln(x)?

30x37/x30x3+7/x15x3+7/x30x3x+7/x

Part 11 What is tek+ln(e2)t?

  1. kek+2/et
  2. 0
  3. -1
  4. ek+1/e

Part 12 What is xln(x)/x2? (Hint: You can write the function in a simpler way.)

  1. 2x3(1/x1)
  2. 2x3ln(x)
  3. 2x1ln(x)
  4. x3(12ln(x))

Part 13 Which of these is t(ln(6)+t4et)?

  1. 16+4t3et
  2. 16+4t3et
  3. 4t3et
  4. 4t3et

Part 14 Which of these is u(1u6π3+4u3+e)?

  1. 6u73π2+4u3
  2. 6u53π2+12u2+1e
  3. 6u7+12u2
  4. 6u5+12u2+1e

Part 15 Which of these is v(v74+e743v6v2)=

  1. 741v4+7e618v52v
  2. 74v3412v3
  3. 47v3718v52v
  4. 74v34+e712v3

Part 16 What is t(4sin(2πt)5)?

  1. 8cos(2πt)
  2. 4πcos(2πt)
  3. 4cos(2πt)5
  4. 8πcos(2πt)

Part 17 What is t(7+8t2+3t4)?

4t+12t28t+4t316t+12t316t2+9t3

Part 18 The derivative xdnorm(x)=xdnorm(x). What is xdnorm(x24) ?

  1. x22dnorm(x24)
  2. x2dnorm(x24)
  3. x38dnorm(x24)
  4. x8dnorm(x24)

Part 19 What is t(6t3t2+2t4)?

63t+8t263t+6t366t+8t33t+6t3

Part 20 What is tln(t2+1)?

2tln(t2+1)1/t2+12tt2+11/2t

Part 21 For the function g(t)sin(2πP(tt0)) is the interior function linear?

Yes No

Part 22 For the function g(P)sin(2πP(tt0)) is the interior function linear?

Yes No

Part 23 For the function h(u)ln(a2ub) is the interior function linear?

Yes No

Part 24 For the function f(w)ekw, is the interior function linear?

Yes No

Part 25 Saying “the interior function is linear” is not an entirely complete statement. A full statement is “the interior function is linear in terms of the input x” or “in terms of the input u” or whatever name we choose to use for the input.
Is the expression Vx+U linear in terms of U?

Yes No

Part 26 Saying “the interior function is linear” is not an entirely complete statement. A full statement is “the interior function is linear in terms of the input x” or “in terms of the input u” or whatever name we choose to use for the input.
Is the expression Vx2+U linear in terms of U?

Yes No

Part 27 Saying “the interior function is linear” is not an entirely complete statement. A full statement is “the interior function is linear in terms of the input x” or “in terms of the input u” or whatever name we choose to use for the input.
Is the expression Vx2+U linear in terms of X?

Yes No

23.9 Exercises

Exercise 23.01

Section 23.1 explains that in differentiating a linear combination of two functions, or a product of two functions, or one function composed with another, your first task is to identify the two functions f() and g() involved. Second, compute the derivative of each of those functions on its own: xf(x) and xg(x).

Carry out these two tasks for each of the combined functions shown in the table. (The first row has been done for you as an example.)

Combination f() g() xf() xg()
exln(x) ln(x) ex recip (that is 1/x) ex
sin(ex)
x+x2
1/sin(x)
pnorm(x)2
pnorm(x)
pnorm(x2)
pnorm(sin(x))

Exercise 23.02

For each of the following, say whether the function is a composition f(g(x)) or a product f(x)g(x), or neither.

Part A What sort of combination is h1(x)ln(x)ex?

product composition neither

Part B What sort of combination is h2(x)sin(x)cos(x)?

product composition neither

Part C What sort of combination is h3(x)sin(ln(x))?

product composition neither

Part D What sort of combination is h4(x)eln(x)?

product composition neither

Part E What sort of combination is h5(x)sin(x)dnorm(x)?

product composition neither

Part F What sort of combination is h6(x)ex2?

product composition neither

Part G What sort of combination is h7(x)pnorm(x2)?

product composition neither

Part H What sort of combination is h8(x)pnorm(x)dnorm(x)?

product composition neither

Part I What sort of combination is h9(x)1/sin(x)?

product composition neither

Exercise 23.03

Consider this function, F(t), which is a linear combination of three time-shifted sigmoids.

As you know, the derivative of a sigmoid pnorm(t) is a gaussian with the same center and standard deviation.

Part A How many gaussians will be in tF(t).

2 3 6 none

The following figure shows several functions. One of them is tF(t).

Part B Which function is the actual derivative of F(t)? (Hints: The vertical axis is important as is the value of dnorm(0).)

A B C D

Part C Of the functions (1), (2), (3), and (4) below, which function is the second derivative of F(t)? (Hints: The vertical axis is important as is the value of dnorm(0).)

(1) (2) (3) (4)

Exercise 23.04

In function compositions of the form f(g(x)), the function f() is called the exterior function and g() is called the interior function.

Part A In cos(ln(x)) which is the interior function?

  1. ln()
  2. cos()
  3. sin()
  4. None of the above
  5. It is not a function composition

Part B In 1/sin(x) which is the exterior function?

  1. recip()
  2. cos()
  3. sin()
  4. None of the above
  5. It is not a function composition

Part C In sin(2πP(tt0)) which is the exterior function?

  1. tt0
  2. 2πP
  3. 2πPt
  4. 2πP(tt0)
  5. sin()
  6. None of the above
  7. It is not a function composition

Part D In sin(2π(tt0)/P) which is the interior function?

  1. tt0
  2. 2π/P
  3. 2πt/Pt
  4. 2π(tt0)/P
  5. sin()
  6. None of the above
  7. It is not a function composition.

Part E In sin(x)dnorm(x2), which is the interior function?

  1. x2
  2. x
  3. dnorm(x2)
  4. None of the above
  5. It is not a function composition.

Exercise 23.06

Compare the functions f1dnorm(x,mn,sd) and f2dnorm([xmn]/sd) by plotting them out in a SANDBOX.

to construct the plot, you will have to pick specific values for mn and sd. Make sure that you use the same sd and mn when constructing f1() and f2(). For instance:

f1 <- makeFun(dnorm(x, mn, sd) ~ x, mn=2, sd=3)
f2 <- makeFun(dnorm( (x-mn) / sd) ~ x, mn=2, sd=3)

Part A When sd=1, are the two functions the same?

  1. Yes
  2. Yes, but only if mn=1
  3. Yes, but only if mn=0
  4. No

Part B When sd1, for any given mean, the two functions are not the same. What’s the relationship between f1(x) and f2(x)?

  1. f2(x)=sdf1(x)
  2. f1(x)=sdf2(x)
  3. f1(x)=sd2f2(x)
  4. f2(x)=sd2f1(x)

Exercise 23.08

Pilots of commercial passenger aircraft consider the comfort of their passengers into account when flying. In transitioning from level flight onto the descent path for landing, for example, pilots take care that the vertical component of acceleration isn’t so great that passengers feel the plane “falling out from under them.”

A simple model of the descent path is a sigmoid function. Suppose that the descent starts from an altitude of A=20,000 feet at a distance of 30,000 feet from the end of the runway. A reasonable model for the vertical component of the flight path is altitude(x)Apnorm(x,  mn=30000/2,  sd=30000/6) Notice that the parameter “mean” is set to be half the distance to the runway, and the parameter “sd” is set to be a third of that. This ensures that the start and end of the descent will involve flight that is close to level.

The vertical acceleration is the second derivative of alt() with respect to time: ttaltitude(t). But notice that alt() is a function of distance from the runway, not time.

to treat alt() as a function of time, we need to write “distance from the runway” as a function of time. Let’s set t=0 to be the time when the plane begins its descent, when it is 30,000 feet from the end of the runway. Distance from the runway will be x(t)=30000vt where v is the plane’s velocity. Composing altitude() onto x(t) gives a new function

alt(t)altitude(x(t))=altitude(30000vt)

Suppose that the aircraft is flying at v=200 miles-per-hour, which is 200mileshour1hour3600s5280ft1mile=293.3fts. At that speed, it will take a little more than 100 seconds for the aircraft to reach the runway.

Using a sandbox, plot out the function alt(t) function, choosing a domain for t that lets you see the whole descent path.

alt <- makeFun(20000 * pnorm(30000 - v * t, 30000/2, 30000/6) ~ t, v = 293.3)
slice_plot(alt(t) ~ t, bounds(t=0:110))

Compute the second derivative ttalt(t) to find the vertical component of acceleration of the aircraft. (Important note: Due to a bug in R, use numD() rather than D() to compute the second derivative.)

Graph the second derivative over the appropriate domain and look for the most extreme values of acceleration.

dd_alt <- numD(alt(t) ~ t + t)
slice_plot(dd_alt(t) ~ t, bounds(t=0:110))

From the graph, read off the maximum vertical acceleration during the descent.

Part A What are the units of vertical acceleration shown in the graph?

  1. feet-per-second
  2. feet-per-second-squared
  3. miles-per-hour-squared

A rule of thumb is that a vertical acceleration up to 5fts2 is acceptable in terms of passenger comfort. Regrettably, the descent path we described does not meet the standard! So we have to re-design the descent path. Since both the altitude and velocity are set, the only parameter you can change is the distance from the foot of the runway where descent commences. Of course, for the parameters “mean” and “sd” need to be set accordingly.

Part B How far from the foot of the runway should descent begin to stay within the 5fts2 acceleration constraint? Pick the shortest distance that satisfies the constraint.

40,000 ft 50,000 ft 60,000 ft 70,000 ft 80,000 ft

For reflection: A new hire at the airline’s operations center proposes to model the descent as a straight-line function rather than a sigmoid. He points out that the second derivative of a straight-line function is always 0, so the passengers would feel no acceleration at all! Explain to this newbie what’s wrong with his idea.

Exercise 23.09

In Exercise none yet, E9e7c6 you constructed models D(t) of the availability of a drug in the bloodstream for three different pill-taking regimens: every six hours, every eight hours, and a double dose to start followed by a single dose every eight hours. The model for from a single, isolated pill is a zero before the pill is taken, then exponential decay from the level of the pill dose after the pill is taken. Like this:

pill <- makeFun(ifelse(t < 0, 0, exp(-k * t)) ~ t, k = log(2)/3)

The parameter k has been set to represent a drug with a half-life of three hours.

The model for the entire regiment is a linear combination of time-shifted single pills, e.g.

regimen8 <- makeFun(A*pill(t) + A*pill(t-8) + A*pill(t-16) + A*pill(t-24) + A*pill(t-32) ~ t, A=1)

From graphs of the functions themselves it is easy to check whether the availability ever falls below the therapeutic threshold (which we stipulated is 0.25). For instance, the eight-hour regiment with a dose of A=1 does fall below the threshold during the first day. So a larger dose is needed than A=1.

The derivative tregimen8(t) tells the instantaneous rate at which the drug is being administered to and eliminated from the patient’s body.

For each of the three regimens, construct tregimen(t). Ignoring the glitches due to discontinuity at the times the pills are consumed, which of the three regimens has the lowest average rate of drug elimination?

Exercise 23.10

Recall from Section 9.2 the Lorenz curve used to describe income inequality. The Lorenz curve shows the fraction of total income versus population fraction.

Figure 23.2: A Lorenz curve (blue) fitted to income data from the US in 2009. (See Figure 11.15.)

Since the population is arranged from poorest to richest along the horizontal axis, Lorenz curves must be both monotonically increasing and concave up. That is, any Lorenz function L(P), where P is the population fraction, must satisfy these criteria:

  1. L(0)=0
  2. L(1)=1 that is, the aggregate fraction of income earned by the entire population is 100%.
  3. PL(P) > 0 that is, monotonically increasing
  4. PPL(P) > 0 that is, concave up.

Consider a function H(P)L1(L2(P)) which is the composition of two Lorenz curves.

  • A. Use the composition rule to show that H(P) is monotonically increasing. (Hint, calculate PH(P) and show that it must be positive.)
  • B. Using both the composition and product rules, calculate PPH(P) and show that H(P) must be concave up.

Exercise 23.12

The formula for the function dnorm(x) is

dnorm(x)12πexp(x22) .

A. Use the chain rule to find xdnorm(x).

B. Confirm from your answer to (1) that there is another formula for xdnorm(x), namely xdnorm(x)=xdnorm(x) .

C. Use the product rule to find xxdnorm(x).

D. From your answer to (3), compute the 3rd derivative xxxdnorm(x):

E. Let’s generalize the pattern. Each of the previous derivatives has been a polynomial—let’s call it pn(x) for the nth derivative—times dnorm(x). Knowing pn(x), we can easily find pn+1(x):

pn+1(x)=xpn(x)+xpn(x)

We know p1(x)=x so p2(x)=x21. In turn, this tells us p3(x)=3xx3. Find:

  1. p4(x)
  2. p5(x)
  3. p6(x)

Exercise 23.14

Confirm using algebraic manipulation the differentiation rule for a product of three functions:

[uvw]=uvw + uvw + uvw

Here, u is shorthand for u(x), and u is shorthand for xu(x), and similarly for v and w.

Hint: [uvw]=u[vw]. So a product of three functions can be seen as a product uh where hvw.