question id: lamb-rise-sofa-1
Chap 23 Exercises
\[ \newcommand{\dnorm}{\text{dnorm}} \newcommand{\pnorm}{\text{pnorm}} \newcommand{\recip}{\text{recip}} \]
Exercise 1 For each of the following, say whether the function is a composition \(f(g(x))\) or a product \(f(x) g(x)\), or neither.
- What sort of combination is \(h_1(x)\equiv \ln(x) e^x\)?
- What sort of combination is \(h_2(x)\equiv \sin(x) \cos(x)\)?
question id: lamb-rise-sofa-2
- What sort of combination is \(h_3(x) \equiv \sin(\ln(x))\)?
question id: lamb-rise-sofa-3
- What sort of combination is \(h_4(x) \equiv e^{\ln(x)}\)?
question id: lamb-rise-sofa-4
- What sort of combination is \(h_5(x) \equiv \sin(x) - \dnorm(x)\)?
question id: lamb-rise-sofa-5
- What sort of combination is \(h_6(x) \equiv e^{x^2}\)?
question id: lamb-rise-sofa-6
- What sort of combination is \(h_7(x) \equiv \pnorm(x^2)\)?
question id: lamb-rise-sofa-7
- What sort of combination is \(h_8(x) \equiv \pnorm(x) \dnorm(x)\)?
question id: lamb-rise-sofa-8
- What sort of combination is \(h_9(x) \equiv 1/\sin(x)\)?
question id: lamb-rise-sofa-9
Exercise 2 In function compositions of the form \(f\left(\strut g(x)\right)\), the function \(f()\) is called the exterior function and \(g()\) is called the interior function.
- In \(\cos(\ln(x))\) which is the interior function?
question id: bdb932-1
- In \(1/\sin(x)\) which is the exterior function?
question id: bdb932-2
- In \(\sin\left(\frac{2 \pi}{P} (t-t_0)\right)\) which is the exterior function?
question id: bdb932-3
- In \(\sin\left(2 \pi (t-t_0)/P\right)\) which is the interior function?
question id: bdb932-4
Exercise 3 Recall the differentiation rules for three of the pattern-book functions as presented in XREF not implemented yet:
Function name | Formula | Formula for derivative | power-law exponent \(p\) |
---|---|---|---|
Identity | \(x\) | \(1\) | 1 |
Square | \(x^2\) | \(2\, x\) | 2 |
Reciprocal | \(1/x\) | \(-1/x^2\) | -1 |
All three of these pattern-book functions are members of the power-law family: \(x^p\). They differ only in the value of \(p\).
There is a differentiation rule for the power-law family generally. The next question offers several formulas for this rule, only one of which is correct. You can figure out which one by trying the pattern-book functions in the table above and seeing which formula gives the correct answer for the derivative.
Which of these formulas gives the correct differentiation rule for the power-law family \(x^p\)?
\(p x^{p-1}\)
\((p-1) x^{p+1}\)
\(x^{p-1}\)
\((p-1) x^{p-1}\)
question id: doe-pay-kitchen
Exercise 4 Although we created an R function named slopeFun()
for the purposes of demonstration, it is better to use the R/mosaic operator D()
which calculates the derivative, sometimes using symbolic methods and sometimes using a finite-difference method.
As an example of the use of D()
, here is some more R code that defines a function f()
and finds \(\partial_x f()\), calling it d_f()
. Then each function is plotted on the same domain.
For each of the following functions, write a brief comparison of the function to it is differenced version. You can combine phrases such as “same shape”, “different shape. larger in amplitude”, “smaller in amplitude”, “same period”, “shorter period”, “longer period”, or whatever seems appropriate. For instance, for the original example in the sandbox, a reasonable comparison might be, “f() is concave down but Diff(f) is concave up.”
A. For the function \(f(x) \equiv 3 x\), compare \(f()\) to \(\partial_x f\).
B. For the function \(f(x) \equiv x^2\), compare \(f()\) to \(\partial_x f\).
C. For the function \(f(x) \equiv e^x\), compare \(f()\) to \(\partial_x f\).
D. For the function \(f(x) \equiv e^{-0.3 x}\), compare \(f()\) to \(\partial_x f\).
E. For the function \(f(x) \equiv \sin(x)\), compare \(f()\) to \(\partial_x f\).
F. For the function \(f(x) \equiv \sin(2 \pi x)\), compare \(f()\) to \(\partial_x f\)).
G. For the function \(f(x) \equiv \sin(\frac{2 \pi}{20} x)\), compare \(f()\) to \(\partial_x f\)).
Exercise 5 In Exercise exr-goat-walk-window 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:
<- makeFun(ifelse(t < 0, 0, exp(-k * t)) ~ t, k = log(2)/3) pill
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.
<- makeFun(A*pill(t) + A*pill(t-8) + A*pill(t-16) + A*pill(t-24) + A*pill(t-32) ~ t, A=1) regimen8
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
.
A primary objective in choosing a drug regime is to ensure that the availability stays above the therapeutic level. A secondary objective is to keep the elimination rate small so that the drug can be handled by patients with poorly functioning livers.
The derivative \(\partial_t \text{regimen8}(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—6-hour, 8-hour, 8-hour-double-first-dose—construct \(\partial_t \text{regimen}(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 6 The function \(F(t)\) shown in Figure fig-pig-see-pantry-sigmoids is a linear combination of three time-shifted sigmoids.
As you know, the derivative of a sigmoid \(\text{pnorm}(t)\) is a gaussian with the same center and standard deviation.
- How many gaussians will be in \(\partial_t F(t)\).
question id: psp4-1
Figure fig-pig-see-pantry-many shows several functions. One of them is \(\partial_t F(t)\).
- Which function is the actual derivative of \(F(t)\)? (Hint: The vertical axis is important as is the value of \(\text{dnorm}(0)\).)
question id: psp4-2
- 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 \(\text{dnorm}(0)\).)
question id: pig-see-pantry-3
Exercise 7 Recall from Section@sec-monotonicity that a function is monotonically increasing on a given domain when the function’s slope is positive everywhere in that domain. A monotonically decreasing function, similarly, has a negative slope everywhere in the domain. When the slope is zero, or positive in some places and negative in others, the function is neither monotonically increasing or decreasing.
Each of the following graphs shows the derivative of some function \(f(x)\). (Note: the graph does not show \(f(x)\) but rather the function \(\partial_x f(x)\)) For each graph, say whether the function \(f()\) is monotonically increasing, monotonically decreasing, or neither. (Note that the horizontal scale is the same in every graph, but the vertical scale can be different from one scale to another.)
- Function A is …
monotonically increasing
monotonically decreasing
constant
non-monotonic
Can’t tell from the info provided
question id: pine-lead-car-1
- Function B is …
monotonically increasing
monotonically decreasing
constant
non-monotonic
Can’t tell from the info provided
question id: pine-lead-car-2
- Function C is …
monotonically increasing
monotonically decreasing
constant
non-monotonic
Can’t tell from the info provided
question id: pine-lead-car-3
- Function D is …
monotonically increasing
monotonically decreasing
constant
non-monotonic
Can’t tell from the info provided
question id: pine-lead-car-4
Function E is …
monotonically increasing
monotonically decreasing
constant
non-monotonic
Can’t tell from the info provided
question id: pine-lead-car-5
- Function F is …
monotonically increasing
monotonically decreasing
constant
non-monotonic
Can’t tell from the info provided
question id: pine-lead-car-6
Activities
Exercise 8 Confirm using algebraic manipulation the differentiation rule for a product of three functions:
\[\left[ u\cdot v\cdot w\right]' = \color{blue}{u'}\cdot v\cdot w\ +\ u\cdot \color{blue}{v'}\cdot w\ +\ u\cdot v\cdot \color{blue}{w}'\] Here, \(u\) is shorthand for \(u(x)\), and \(u'\) is shorthand for \(\partial_x u(x)\), and similarly for \(v\) and \(w\).
Hint: \(\left[ u\cdot v\cdot w\right] = u \cdot \left[ v \cdot w\right]\). So a product of three functions can be seen as a product \(u\cdot h\) where \(h \equiv v \cdot w\).
Exercise 9 Consider this function, defined piecewise:
\[h(x) \equiv \left\{ \begin{array}{ll}0 & \text{for}\ x < 0\\x^2 & \text{otherwise}\end{array}\right.\ .\]
Write the R command to create this function. (Hint: Remember
ifelse
from XREF not implemented yet.)Using Active R chunk lst-camel-begin-piano, plot \(h(x)\) over the domain \(-1 \leq x \leq 1\), then sketch a copy of the graph on your paper.
Create the function \(\partial_x h(x)\) by differentiating separately each piece of the piecewise function \(h()\). Write down \(\partial_x h(x)\) using mathematical notation similar to the definition of \(h(x)\) given above.
Sketch a graph of \(\partial_x h(x)\) over the domain \(-1 \leq x \leq 1\). You’re welcome to use a Active R chunk lst-camel-begin-piano, but you may be able to figure out the shape of the graph yourself.
The shape of the function you sketched in (4) has a name, given in the text in Section @ref(continuity). What is that name?
Now you will do much the same as in items (3), (4), and (5), but instead of the first derivative \(\partial_x h(x)\), create, sketch, and name the second derivative \(\partial_{xx} h(x)\).
Create and write down \(\partial_{xx} h(x)\) in mathematical notation.
Sketch \(\partial_{xx} h(x)\)
Classify the smoothness of \(h(x)\) using the following table:
Smoothness | Criterion |
---|---|
\(C^0\) | \(\partial_x h(x)\) is discontinuous |
\(C^1\) | \(\partial_x h(x)\) is continuous |
\(C^2\) | \(\partial_{xx} h(x)\) is continuous |
\(C^3\) | \(\partial_{xxx} h(x)\) is continuous |
\(\vdots\) | and so on. |
\(C^\infty\) | All orders of derivative of \(h(x)\) are continous. |
Exercise 10 Recall from Exercise exr-duck-see-socks the Lorenz curve used to describe income inequality. The Lorenz curve shows the fraction of total income versus population fraction.
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:
- \(L(0) = 0\)
- \(L(1) = 1\) that is, the aggregate fraction of income earned by the entire population is 100%.
- \(\partial_P L(P) \ > \ 0\) that is, monotonically increasing
- \(\partial_{PP} L(P) \ > \ 0\) that is, concave up.
Consider a function \(H(P) \equiv L_1(L_2(P))\) which is the composition of two Lorenz curves.
- A. Use the composition rule to show that \(H(P)\) is monotonically increasing. (Hint, calculate \(\partial_P H(P)\) and show that it must be positive.)
- B. Using both the composition and product rules, calculate \(\partial_{PP} H(P)\) and show that \(H(P)\) must be concave up.
Exercise 11 The formula for the function \(\dnorm(x)\) is \[\dnorm(x) \equiv \frac{1}{\sqrt{2 \pi}} \exp\left(\frac{x^2}{2}\right)\ .\]
A. Use the chain rule to find \(\partial_x \dnorm(x)\).
B. Confirm from your answer to (1) that there is another formula for \(\partial_x \dnorm(x)\), namely \[\partial_x \dnorm(x) = - x \dnorm(x)\ .\]
C. Use the product rule to find \(\partial_{xx} \dnorm(x)\).
D. From your answer to (3), compute the 3rd derivative \(\partial_{xxx} \dnorm(x)\):
E. Let’s generalize the pattern. Each of the previous derivatives has been a polynomial—let’s call it \(p_n(x)\) for the \(n\)th derivative—times \(\dnorm(x)\). Knowing \(p_n(x)\), we can easily find \(p_{n+1}(x)\): \[p_{n+1}(x) = -x p_n(x) + \partial_x p_n(x)\] We know \(p_1(x) = -x\) so \(p_2(x) = x^2 - 1\). In turn, this tells us \(p_3(x) = 3x - x^3\). Find:
- \(p_4(x)\)
- \(p_5(x)\)
- \(p_6(x)\)