During Class
Brain Gains
1. Compute $ D_xQ $ for $ Q(x) = \sum_{k=1}^{21} kx^k $.
Solution
The derivative of a sum is the sum of the derivatives. Using the sum rule and the power rule we see. $$\begin{align*} \frac{d}{dx}\left(\sum_{k=1}^{21} kx^k\right) &=\sum_{k=1}^{21}\frac{d}{dx}\left(kx^k\right) \\ &=\sum_{k=1}^{21}k(kx^{k-1}) \\ &=\sum_{k=1}^{21}k^2x^{k-1}. \end{align*}$$
2. Compute the derivative of $f(x) = \sqrt{4e^x+7x^2}$.
Solution
We use the chain rule.
We can write $f(x) = g(h(x))$ where $g(x) = \sqrt{x} = x^{1/2}$ and $h(x) = 4e^x+7x^2$. We then have $g'(x) = \frac{1}{2}x^{-1/2}$ and $h'(x) = 4e^x+14x$. The chain rule then gives $$f'(x) = g'(h(x))h'(x) = \frac{1}{2}(h(x))^{-1/2}(4e^x+14x) = \frac{1}{2}(4e^x+7x^2)^{-1/2}(4e^x+14x)$$.
Group Meeting
Start by giving each person a moment to share what they chose to prepare for class. Help each other address any questions. When each person has had a chance to share, move on the other activities.
Activity - Chain Rule
Compute the derivative of each function below, by first identifying $y(u)$ and $u(x)$. Take turns writing your solutions on the chalk board and discussing any questions.
- $f(x) = (x^2+3)^4$
- $g(x) = (3e^x+x^2)^5$
- $h(x) = (2+\ln x)^3$
- $k(x) = \ln(x^2+3)$
- $m(x) = e^{x^2+3}$
Activity - Higher Order Derivatives
Since the derivative of a function is a function, we can find the derivative of a derivative. In fact, we can continue to take derivatives to find the third derivative, fourth derivative, etc. When we take a derivative of a derivative we find a higher order derivative. The second derivative $f$ we can denote with $$f''(x) = \frac{d}{dx}\left(\frac{d}{dx}(f)\right) = \frac{d^2f}{dx^2}.$$ We use similar notation for higher order derivatives, such at $f'''(x)$ for the third derivative and $\frac{d^4f}{dx^4}$ for a 4th derivative. We avoid prime notation and use notation such as $f^{ (7) }(x)$ when the number of derivatives is quite large.
Open this Higher Order Derivatives worksheet and take turns computing derivatives, passing the chalk after each problem.
Activity - Derivative Practice with Parameters
Find the derivatives described below.
- Let $f(x; b, m) = b + mx$.
- Find the derivative of $f$ with respect to $x$ assuming $b$ and $m$ are constant.
- Find the derivative of $f$ with respect to $m$ assuming $x$ and $b$ are constant.
- Find the derivative of $f$ with respect to $b$ assuming $x$ and $m$ are constant.
Answers
- We have $\frac{df}{dx} = m$ given $b$ and $m$ are constant. Soon we will write this using partial derivative notation as $\frac{\partial f}{\partial x}= m$. The stylied $d$ written as $\partial$ means that you assume all other variables are constant.
- We have $\frac{df}{dm} = x$ given $x$ and $b$ are constant. Partial derivative notation gives $\frac{\partial f}{\partial m}= x$.
- We have $\frac{df}{db} = 1$ given $x$ and $m$ are constant. Partial derivative notation gives $\frac{\partial f}{\partial b} = 1$.
- Let $g(x,y) = x^2+5xy-y^3$.
- Find the derivative of $g$ with respect to $x$ assuming $y$ is constant.
- Find the derivative of $g$ with respect to $y$ assuming $x$ is constant.
Answers
- We have $\frac{dg}{dx} = 2x+5(1)y-0$ given $y$ is constant. We can write this as $\frac{\partial g}{\partial x}=2x+5y$.
- We have $\frac{dg}{dy} = 0+5x(1)-3y^2$ given $x$ is constant. We can write this as $\frac{\partial g}{\partial y}=5x-3y^2$.
- Let $g(x,y) = x^3y^3 - 5y + 1$.
- Find the derivative of $g$ with respect to $x$ assuming $y$ is constant.
- Find the derivative of $g$ with respect to $y$ assuming $x$ is constant.
Answers
- We have $\frac{dg}{dx} = 3x^2y^3$ given $y$ is constant. We can write this as $\frac{\partial g}{\partial x}=3x^2y^3$.
- We have $\frac{dg}{dy} = 3x^3y^2 - 5$ given $x$ is constant. We can write this as $\frac{\partial g}{\partial y}=3x^3y^2 - 5$.
- Given $h(x,y;a) = (x^2 e^y - a\ln(x) - 10)^5$.
- Find the derivative of $h$ with respect to $x$ assuming $y$ and $a$ are constant.
- Find the derivative of $h$ with respect to $y$ assuming $x$ and $a$ are constant.
- Find the derivative of $h$ with respect to $a$ assuming $x$ and $y$ are constant.
Answers
- We have $\frac{dh}{dx} = 5(x^2e^y - a\ln(x) - 10)^4(2x e^y - \frac{a}{x})$ given $y$ and $a$ are constant, or simply $\frac{\partial h}{\partial x} = 5(x^2e^y - a\ln(x) - 10)^4(2x e^y - \frac{a}{x})$.
- We have $\frac{dh}{dy} = 5(x^2e^y - a\ln(x) - 10)^4(x^2 e^y)$ given $x$ and $a$ are constant, or simply $\frac{\partial h}{\partial y} = 5(x^2e^y - a\ln(x) - 10)^4(x^2 e^y)$.
- We have $\frac{dh}{da} = 5(x^2e^y - a\ln(x) - 10)^4(-\ln(x))$ given $x$ and $y$ are constant, or simply $\frac{\partial h}{\partial a} = 5(x^2e^y - a\ln(x) - 10)^4(-\ln(x))$.
Activity - Additional Derivative Rule Practice
Find the derivative of each of the functions below with respect to the independent variable.
- $f(x) = (x^2 - 1)(-x^3 - 5x +2)$
- $h(x) = \frac{-2x^2 + x + 4}{x^2 + 4x -1}$
- $g(x) = \frac{ (1-2x)(x+4) }{ (x^2 + 3x - 1) }$
- $y = 5\pi$
- $s(x) = 4ax^{3a} - bx^{2c}$ where $a$, $b$, and $c$ are constants.
- $r(x) = \sqrt{1-3x}$
- $l(x) = 100 - 3x + 7x^2$
- $q(t) = -3e^{t}$
- $z = 1-2\ln(x)$
- $w = \frac{ x^2 - 2x + 1 }{ (3-x)(5x+2) }$
Answers
- $\frac{df}{dx}(x) = (\frac{d}{dx}(x^2 - 1))(-x^3 - 5x +2) + (x^2 - 1)\frac{d}{dx}(-x^3 - 5x +2) = (2x)(-x^3 - 5x +2) + (x^2 - 1)(-3x^2-5) = -5x^4 - 12x^2 + 4x + 5$
- $\frac{dh}{dx}(x) = \frac{ (\frac{d}{dx}(-2x^2 + x + 4))(x^2 + 4x -1) - (-2x^2 + x + 4)\frac{d}{dx}(x^2 + 4x -1)}{ (x^2 + 4x -1)^2} = \frac{ (-4x + 1)(x^2 + 4x -1) - (-2x^2 + x + 4)(2x + 4) }{ (x^2 + 4x -1)^2} = \frac{-9x^2 -4x-17}{ (x^2 + 4x -1)^2}$
- $\frac{dg}{dx}(x) = \frac{ (\frac{d}{dx}(1-2x)(x+4))(x^2 + 3x - 1) - (1-2x)(x+4)\frac{d}{dx}(x^2 + 3x - 1) }{ (x^2 + 3x - 1)^2 } = \frac{ ((\diff{}{x}(1-2x))(x+4) + (1-2x)\diff{}{x}(x+4))(x^2 + 3x - 1) - (1-2x)(x+4)(2x + 3) }{ (x^2 + 3x - 1)^2 } = \frac{ x^2 -4x -5 }{ (x^2 + 3x - 1)^2 }$
- $\frac{dy}{dx}(x) = 0$
- $\frac{ds}{dx}(x) = 12a^2x^{3a-1} - 2bcx^{2c-1}$
- $\frac{dr}{dx}(x) = -\frac{3}{2}(1-3x)^{-\frac{1}{2}} = -\frac{3}{2\sqrt{1-3x}}$
- $\frac{dl}{dx} = -3 + 14x$
- $\frac{dq}{dt} = -3e^t$
- $\frac{dz}{dx} = -\frac{2}{x}$
- $\frac{dw}{dx} = \frac{ 3x^2 + 22x - 25 }{ (3-x)^2(5x+2)^2 }$
Activity - Linearization
Linearization Review
Recall that when we find the derivative of a function $f(x)$ at a point $x=a$, we are find the slope of the linear approximation to the function at $x=a$. The graph of the linear approximation is a line that is tangent to the graph of the function. This activity focuses on finding the linear approximation to a function at a point, and writing an equation for it in various ways.
As an example, let's find the linear approximation to $f(x) = x^2$ at $x = 3$. The linear approximation must pass through the point $x=3$ and $y = f(3) = 3^2 = 9$. The derivative of $f$ is $f'(x) = 2x$. The slope of the linear approximation is $m=f'(3) = 2(3) = 6$. So the graph of the linear approximation is a line through the point $(x,y) =(3,9)$ with slope $f'(3)=6$.
- Using point-slope form, an equation for the tangent line is $y - 9 = 6(x-3)$.
- Solving for $y$ above gives $y = L(x) = 9+6(x-3)$. It's common to use the form $L(x) = f(a) + f'(a)(x-a)$ when stating a linear approximation.
- We can write the above in slope-intercept form to obtain $y = 6x-9$.
The point-slope form is useful for quickly writing an equation of a line when we know the point and slope. The form $L(x) = f(a) + f'(a)(x-a)$ preserves the fact that we wanted the linear approximation at $x=3$. The slope-intercept form is unique, and allows quick comparison. All three forms are useful.
For each function below, give an equation of the linear approximation at the specified point using (a) point-slope form, (b) the form $L(x;a) = f(a)+f'(a)(x-a)$, and (c) slope intercept form.
- $f(x) = -3e^{x}$ at $x = 0$
- $l(x) = 100 - 3x + 7x^2$ at $x = -3$
- $g(x) = 1-2\ln(x)$ at $x = 1$
Answers
-
- $y + 3 = -3x$
- $y = -3 - 3(x-0)$
- $y = -3 - 3x$
-
- $y - 172 = -45(x+3)$
- $y = L(x) = 172 -45(x+3)$
- $y = L(x) = 37 - 45x$
-
- $y - 1 = -2(x-1)$
- $y = L(x) = 1 -2(x-1)$
- $y = L(x) = 3 -2x$
Discussion
Loglikelihood
You have been given a list of data for 50 ElvesRUs employees, $(t_i, c_i)$, were $t_i$ is the number of years working at ElvesRUs and $c_i$ is the salary for the $i^{\text{th}}$ employee. (Here's a short GPT conversation to generate some sample data.) The salary (platinum coins per year) for an employee at ElvesRUs can be modeled by $f(t;A,b,k)=Ae^{bt}+k,$ where $t$ is the number of years an elf has been working at ElvesRUs.
- Write the formula for the residuals.
Assume the residuals (errors) are independent and normally distributed (with mean of 0 and standard deviation of 1). Note: This tells us the probability model we will be using and it tells us we can multiply the probabilities to get the likelihood function.
- The probability model we are using is $ p(r) = \frac{1}{\sqrt{2\pi}}e^{-\frac{r^2}{2}} $.
- Write the likelihood function for the residuals in this situation.
- Write the loglikelihood function for the residuals in this situation.
Answers
First we write a formula for the residuals (or errors) to obtain $$r_i(A, b, k; t_i, c_i) = c_i - f(t_i; A, b, k) = c_i - (Ae^{bt_i} + k) = c_i - Ae^{bt_i} - k.$$
Because we are told the errors (or residuals) are normally distributed (with mean of 0 and standard deviation of 1), the probability model we will use is $$p(r) = \frac{1}{\sqrt{2\pi}}e^{-\frac{r^2}{2}}.$$ Or we could write this $p(A, b, k; t_i, c_i) = \frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}(c_i - Ae^{bt_i} - k)^2}.$
Because the errors are independent we can multiply the probability models to find the joint probability model as $$J(t_i, c_i;A, b, k) = \prod_{i=1}^{50} \frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}(c_i - Ae^{bt_i} - k)^2}.$$
The likelihood function (interchange the role of variables and parameters) is then $$L(A, b, k; t_i, c_i) = \prod_{i=1}^{50} \frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}(c_i - Ae^{bt_i} - k)^2}.$$
We take the natural log of the likelihood function to find the loglikelihood function as $$\ell(A, b, k; t_i, c_i) = \ln\left(\prod_{i=1}^{50} \frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}(c_i - Ae^{bt_i} - k)^2}\right).$$
We rewrite $\ell$, using the properties of logarithms and sums, to obtain $$\ell(A, b, k; t_i, c_i) = 50\ln\left(\frac{1}{\sqrt{2\pi}}\right) -\frac{1}{2}\sum_{i=1}^{50} (c_i - Ae^{bt_i} - k)^2.$$
Activity - Loglikelihood
You have been given a list of 44 data points, $(t_i, y_i)$, were $t_i$ is the time in hours since the light was turned on and $y_i$ is the percent intensity of the bulb after $t_i$ hours. A model for the percent intensity of the bulb is $f(x;m,b) = mx+b$, where $t$ is the time in hours since the light was turned on.
- Write the formula for the residuals.
Assume the residuals (errors) are independent and normally distributed (with mean of 0 and standard deviation of 1).
- Write down the probability model we are using for one of the residuals.
- What does knowing the residuals are independent allow us to do?
- Use the assumption of independent residuals to write the joint probability function.
- Write the likelihood function for the residuals in this situation.
- Write the loglikelihood function for the errors in this situation.
- Rewrite the loglikelihood function using the properties of logs and sums.
