EDS 212: Day 2, Lecture 1

Limits and derivatives


Overview of Day 2 topics



  • Limits
  • Derivatives
  • Integrals
  • Differential equations (just a bit)

Limits

Limits


✏️

Limits


Definition

We say a number \(L\) is the limit of a function \(f(x)\) as its variable \(x\) approaches a number \(c\), if the function’s output values \(f(x)\) approach \(L\) when \(x\) get closer to \(c\).


We write this symbolically as:

\[ \large \lim_{x\to c} f(x)=L \]


We read this as: “The limit of \(f(x)\) as \(x\) approaches \(c\) is \(L\).”

Limits example: numerical


What is the limit of \(f(x)=2x^2-4\) as \(x\) approaches 2?

We need to examine the values of \(f(x)\) as \(x\) gets closer to 2 from both sides.

Limits example: numerical


What is the limit of \(f(x)=2x^2-4\) as \(x\) approaches 2?

We need to examine the values of \(f(x)\) as \(x\) gets closer to 2 from both sides.


✏️

Limits example: numerical


What is the limit of \(f(x)=2x^2-4\) as \(x\) approaches 2?

We need to examine the values of \(f(x)\) as \(x\) gets closer to 2 from both sides.


From both directions it looks like \(f(x)\) converges to 4.

So, we say that “The limit of \(2x^2-4\) as \(x\) approaches 2 is 4”. We can write it like this:

\[ \lim_{x\to 2}(2x^2-4)=4 \]

Limits example: graph


What is the limit of \(f(x)=2x^2-4\) as \(x\) approaches 2?

From both directions it looks like \(f(x)\) converges to 4.

So, \(\lim_{x\to 2}(2x^2-4)=4\).

Do limits always exist?


✏️

Do limits always exist?


The function \(|x|\) is the absolute value function. It is such that

\[ |x| = \begin{cases} x, & \text{ if } x\geq 0 \\ -x, & \text{ if } x <0 \end{cases} . \]


✏️ Exercise

  1. Let \(f(x) = \frac{|x-2|}{x-2}\). What happens to \(f(x)\) at \(x=2\)?

  2. Try calculating:

\[ \lim_{x\to 2}\frac{|x-2|}{x-2}. \]

Hint: Try to do numerical approximations or draw the graph of \(f(x)\).

Do limits always exist?


✏️ Let’s see a solution

  1. Let \(f(x) = \frac{|x-2|}{x-2}\). What happens to \(f(x)\) at \(x=2\)?

  2. Try calculating: \(\lim_{x\to 2}\frac{|x-2|}{x-2}\).

Do limits always exist?


✏️ \(f(x) = \frac{|x-2|}{x-2}\). What happens to \(f(x)\) at \(x=2\)?

This function is not defined at \(x=2\) since it would require us to divide by zero, which is undefined.


Try calculating \(\lim_{x\to 2}\frac{|x-2|}{x-2}\).

Let’s investigate:

Do limits always exist?


The function \(\frac{|x-2|}{x-2}\) approaches different values from either side at \(x=2\).

Therefore… the limit does not exist!

Introduction to Derivatives

Recall average and instantaneous rate of change


Big idea: Taking the average rate of change to a set limit will eventually converge to the instantaneous.

Average slope


✏️

Start with:


Nearby point:


Average slope:

Average slope


Start with a point \((x,f(x))\) on the graph.

A nearby point can be \((x+\Delta x, f(x+\Delta x))\), where \(\Delta x\) is a short distance from \(x\).


The average slope between \((x,f(x))\) and \((x+\Delta x, f(x+\Delta x))\) is given by

\[\text{average slope} = \frac{f(x+\Delta x) - f(x)}{(x+\Delta x)-x} = \frac{f(x+\Delta x) - f(x)}{\Delta x}.\]

What happens when \(\Delta x\) becomes smaller and smaller?

What happens when \(\Delta x \to 0\)?


What happens when \(\Delta x \to 0\)?


What happens when \(\Delta x \to 0\)?


What happens when \(\Delta x \to 0\)?


Tangent lines


What if we let \(\Delta x=0\)?

Then we would have a slope line that only touches the graph at exactly \(x\).

These very special types of lines are called tangent lines.

Derivative definition


Remember the slope of the line that passes between two points \((x_1, y_1)\) and \((x_2, y_2)\) is:

\[\text{slope}=\frac{y_2-y_1}{x_2-x_1}.\]

If we have a function \(f(x)\), then \((x,f(x))\) represents a point on its graph.

Choose a different point on the graph that is \(\Delta x\) away: \((x+\Delta x,f(x+\Delta x))\).

Plug these pointson the graph of \(f(x)\) into the slope equation:

\[ \text{slope}=\frac{f(x+\Delta x)-f(x)}{\Delta x}. \]

When we let \(\Delta x \to 0\) we get the slope of the tangent line at \(x\)

\[ \large f'(x)=\lim_{\Delta x \to 0} \frac{f(x+\Delta x)-f(x)}{\Delta x} \]

This is the derivative of \(f\) at \(x\). Also denoted \(\frac{df}{dx}\).

Not all functions are differentiable


  • The absolute value function \(|x|\) is one example, this is defined by \[|x| = \begin{cases} x &, x \geq 0\\ -x &, x<0 \end{cases}.\]

It’s graph is:

Why derivatives in an EDS program?







Describing rates of change is common in environmental science (rate of pollutant concentration change, rate of population growth, rate of energy consumption)

Calculus and derivatives are used to study change


Environmental Science studies change


Environmental Science studies change


Environmental Science studies change



🤔 Talk with a partner, what are 2 fields of environmental science where studying the rate of change and derivatives would be important?

Let’s take a 5 minute break


image: Flaticon.com

Rules for differentiation (1)


Constant Rule ✏️







Power Rule ✏️

Rules for differentiation (1)


Constant Rule

Let \(c\) be a constant (so, a number). If \(f(x) = c\), then \(f'(x)=0\). Equivalently

\[\frac{d}{dx}c = 0\]

Power Rule

Let \(n\) be a (real) number, if \(f(x)= x^n\), then \(f'(x) = nx^{n-1}\). Equivalently \[ \frac{d}{dx}[x^n] =nx^{n-1}. \]

Examples ✏️

\[ \begin{align} &y=100 & &f(x)=x^5 & &f(x)=\frac{1}{x^2} \end{align} \]

Rules for differentiation (2)


Sum and Difference Rules

✏️

Rules for differentiation (2)


Sum and Difference Rules

Let \(f(x)\) and \(g(x)\) be differentiable functions. Then

\[ \begin{align} \frac{d}{dx}[f(x)+g(x)]=\frac{d}{dx}f(x)+\frac{d}{dx}g(x) \\ \frac{d}{dx}[f(x)-g(x)]=\frac{d}{dx}f(x)-\frac{d}{dx}g(x) \end{align} \]

😵All this says is: if the function has pieces that are added or subtracted you can take the derivative of each individual piece and add those derivatives.

The \(\frac{d}{dx}\) notation can be a lot here, the prime notation is a bit better:

\[ \begin{align} [f(x)+g(x)]'=f'(x)+g'(x) \\ [f(x)-g(x)]'=f'(x)-g'(x) \end{align} \]

✏️ Example

\[ f(x)=x^3-x^2-15 \]

Rules for differentiation (3)


Constant Multiplier Rule

✏️

Rules for differentiation (3)


Constant Multiplier Rule

The derivative of a constant \(c\) multiplied by a function \(f(x)\) is the same as the constant multiplied by the derivative:

\[\frac{d}{dx}[kf(x)] = k\frac{d}{dx}f(x)\]

✏️ Example

Rules for differentiation (3)


Constant Multiplier Rule

The derivative of a constant \(c\) multiplied by a function \(f(x)\) is the same as the constant multiplied by the derivative:

\[\frac{d}{dx}[kf(x)] = k\frac{d}{dx}f(x)\]

✏️ Example

\[ y=x^2+\sqrt{2}x-\frac{8}{x}+4 \]

Derivative of logs & exponents



Two special derivatives:


  • \(\frac{d}{dx}(e^x) = e^x\)


  • \(\frac{d}{dx}ln(x)=\frac{1}{x}\)

Summary of differentiation rules



Differentiation Rule \(f'(x)\) notation \(\frac{d}{dx}\) notation
Constant Rule \(f(x)=c \Rightarrow f'(x)=0\) \(\frac{d}{dx}[c]=0\)
Power Rule \(f(x)=x^n \Rightarrow f'(x)=n x^{n-1}\) \(\frac{d}{dx}[x^n]=n x^{n-1}\)
Sum Rule \((g(x)+h(x))'=g'(x)+h'(x)\) \(\frac{d}{dx}[g(x)+h(x)]=\frac{d}{dx}g(x)+\frac{d}{dx}h(x)\)
Difference Rule \((g(x)-h(x))' = g'(x)-h'(x)\) \(\frac{d}{dx}[g(x)-h(x)]=\frac{d}{dx}g(x)-\frac{d}{dx}h(x)\)
Constant Multiplier Rule \((c\cdot g(x))'=c\,g'(x)\) \(\frac{d}{dx}[c\,g(x)]=c\,\frac{d}{dx}g(x)\)


And two special derivatives: \(\frac{d}{dx}(e^x) = e^x\) and \(\frac{d}{dx}ln(x)=\frac{1}{x}\).

There’s more differentiation rules (product, quotient, chain rule).

They’re fun, but we won’t be reviewing them.

Higher order derivatives


  • We can continue to take derivatives of derivatives.

  • The second derivative becomes the rate of change of the rate of change.

  • If we interpret the first derivative as velocity, then the second derivative is acceleration.

  • Notation:

    • Function: \(f(x) = y\)
    • 1st derivative: \(f'(x)\) or \(\frac{dy}{dx}\)
    • 2nd derivative: \(f''(x)\) or \(\frac{d^2y}{dx^2}\)
    • nth derivative: \(f^{(n)}(x)\) or \(\frac{d^ny}{dx^n}\)

Derivatives practice


Solve individually and then check with a partner.

  1. Which rules should you use to take these derivatives?

\[ \begin{align} \text{A) }& f(x)=3x^4 &\text{B) } y=4x^2+3x-16 \end{align} \]

  1. Find the derivatives of these functions

\[ \begin{align} &\text{A) } y=3x^2 & &\text{B) }h(x)=2x(x^2 + 3x) & &\text{C) }g(y)=2\sqrt{y} - e^y + 20\ln(y) \end{align} \]

  1. Find the 3rd derivative of:

\[G(z)=3z^4-8z^3+2z-19\]

Derivatives practice


✏️ Let’s see a solution!

2.B) Find the derivative \[h(x)=2x(x^2 + 3x)\]

Derivatives practice


✏️ Let’s see a solution!

2.C) Find the derivative \[g(y)=2\sqrt{y} - e^y + 20\ln(y)\]

Derivatives practice


✏️ Let’s see a solution!

  1. Find the 3rd derivative of \(G(z)=3z^4-8z^3+2z-19\).

Derivatives solution


  1. Which rules should you use to take these derivatives?

\[ \begin{align} \text{A) }& f(x)=3x^4 &\text{B) } y=4x^2+3x-16 \end{align} \]

  1. Power Rule (with the Constant Multiplier Rule)

  2. Sum/Difference Rule, Power Rule, Constant Multiplier Rule, and Constant Rule (for \(-16\))


  1. Find the derivatives of these functions

\[ \begin{align} &\text{A) } y=3x^2 & &\text{B) }h(x)=2x(x^2 + 3x) \end{align} \]

  1. \(y' = 3\cdot 2x^{(2-1)} = 6x\)

  2. First expand: \(h(x) = 2x\cdot x^2 + 2x \cdot 3x = 2x^3+6x^2\)

Then differentiate term by term: \(h'(x) = 2\cdot 3x^{(3-1)} + 6\cdot 2x^{(2-1)} = 6x^2+12x\)

Derivatives solution


  1. Find the derivative of this function

\[ g(y)=2\sqrt{y} - e^y + 20\ln(y) \]

Rewrite \(\sqrt{y}\) as \(y^{1/2}\):

\[ \begin{align} g(y) &= 2y^{1/2}-e^y+20\ln(y)\\ g'(y) &= 2\cdot\frac{1}{2}y^{(1/2-1)} - e^y + 20\cdot\frac{1}{y}\\ &= \frac{1}{\sqrt{y}} - e^y + \frac{20}{y} \end{align} \]

Derivatives solution


  1. Find the 3rd derivative of:

\[G(z)=3z^4-8z^3+2z-19\]

\[ \begin{align} G'(z) &= 3\cdot 4z^{(4-1)} - 8\cdot 3z^{(3-1)} + 2\cdot 1z^{(1-1)} - 0 = 12z^3-24z^2+2\\ G''(z) &= 12\cdot 3z^{(3-1)} - 24\cdot 2z^{(2-1)} + 0 = 36z^2-48z\\ G'''(z) &= 36\cdot 2z^{(2-1)} - 48\cdot 1z^{(1-1)} = 72z-48 \end{align} \]

Partial derivatives

Partial derivatives



When we find a partial derivative, we find an expression for the slope with respect to one variable in a multivariate function.


Notation: the partials of \(f(x,y,z)\) are \(\frac{\partial f}{\partial x}\), \(\frac{\partial f}{\partial y}\), and \(\frac{\partial f}{\partial z}\)

We read \(\frac{\partial f}{\partial x}\) as “the partial derivative of \(f\) with respect to \(x\)


How to take partial derivatives? Find the derivative with respect to a single variable, treating all others as constants.

OK, but what do partials actually mean?


The slope with respect to one variable if other variables are held constant.

\(\frac{\partial f}{\partial x}\) evaluated at \((x_0,y_0)\) can be written as \(\left.\frac{\partial f}{\partial x}\right|_{(x_0,y_0)}\) and tells us the slope of \(f\) in the \(x\)-direction, while \(y\) is held fixed at \(y_0\).

Partial derivatives example


Find all partial derivatives of

\[B(x,y, z)=0.4x^3y-3.6y^2+4zx + 8\]

✏️

Partial derivatives example


Find all partial derivatives of

\[B(x,y, z)=0.4x^3y-3.6y^2+4zx + 8\] \[\frac{\partial B}{\partial x}=1.2x^2y+4z\] \[\frac{\partial B}{\partial y}=0.4x^3-7.2y\] \[\frac{\partial B}{\partial z}=4x\]

✏️What is the value of the partial derivative of \(B\) with respect to \(z\) at the point \((1,2,3)\)?

Solution


Find all partial derivatives of

\[B(x,y, z)=0.4x^3y-3.6y^2+4zx + 8\] \[\frac{\partial B}{\partial x}=1.2x^2y+4z\] \[\frac{\partial B}{\partial y}=0.4x^3-7.2y\] \[\frac{\partial B}{\partial z}=4x\]

✏️What is the value of the partial derivative of \(B\) with respect to \(z\) at the point \((1,2,3)\)?

\[\frac{\partial B}{\partial z}\Bigr\rvert_{(1,2,3)} = \frac{\partial B}{\partial z}\Bigr\rvert_{(1,2,3)}4x = 4*1 = 4. \]

Partial derivatives practice


  1. The temperature (in Celsius) across a surface (where \(x\) and \(y\) are in meters) is described by:

\[T(x,y)=x^2y-2x+y-1\]

At what “rate” is temperature changing (with respect to distance):

  • In the \(x\) direction, at the point (1,3) on the surface?
  • In the \(y\) direction, at the point (0,2) on the surface?
  • Write your answer as a complete sentence involving rate of change.
  1. A dragon’s breath temperature (\(T\), in degrees Celsius) is modeled as a function of its wingspan (\(W\), in meters) and length (\(L\), also in meters):


\[T(W,L)=0.41WL+2.6W^2\]

  • At what rate is breath temperature changing with respect to length for a dragon that is 4.1m long, with a wingspan of 4.5m?

  • At what rate is breath temperature changing with respect to wingspan, for the same dragon?

  • Write your answer as a complete sentence involving rate of change.

Partial derivatives practice


✏️ Let’s see a solution.

  1. The temperature (in Celsius) across a surface (where \(x\) and \(y\) are in meters) is described by:

\[T(x,y)=x^2y-2x+y-1\]

At what “rate” is temperature changing (with respect to distance):

  • In the \(x\) direction, at the point (1,3) on the surface?
  • In the \(y\) direction, at the point (0,2) on the surface?

Partial derivatives practice


✏️ Let’s see a solution.

  1. The temperature (in Celsius) across a surface (where \(x\) and \(y\) are in meters) is described by:

\[T(x,y)=x^2y-2x+y-1\]

At what “rate” is temperature changing (with respect to distance):

  • In the \(x\) direction, at the point (1,3) on the surface?
  • In the \(y\) direction, at the point (0,2) on the surface?

\[\frac{\partial T}{\partial x} = 2xy - 2, \qquad \frac{\partial T}{\partial y} = x^2 + 1\]

\[\left.\frac{\partial T}{\partial x}\right|_{(1,3)} = 2(1)(3)-2 = 4 \;{}^\circ\text{C/m}\]

\[\left.\frac{\partial T}{\partial y}\right|_{(0,2)} = (0)^2+1 = 1 \;{}^\circ\text{C/m}\]

Partial derivatives practice


✏️ Let’s see a solution.

  1. A dragon’s breath temperature (\(T\), in degrees Celsius) is modeled as a function of its wingspan (\(W\), in meters) and length (\(L\), also in meters):


\[T(W,L)=0.41WL+2.6W^2\]

  • At what rate is breath temperature changing with respect to length for a dragon that is 4.1m long, with a wingspan of 4.5m?

  • At what rate is breath temperature changing with respect to wingspan, for the same dragon?

Partial derivatives practice


✏️ Let’s see a solution.

  1. A dragon’s breath temperature (\(T\), in degrees Celsius) is modeled as a function of its wingspan (\(W\), in meters) and length (\(L\), also in meters):


\[T(W,L)=0.41WL+2.6W^2\]

  • At what rate is breath temperature changing with respect to length for a dragon that is 4.1m long, with a wingspan of 4.5m?

  • At what rate is breath temperature changing with respect to wingspan, for the same dragon?

\[\frac{\partial T}{\partial L} = 0.41W, \qquad \frac{\partial T}{\partial W} = 0.41L + 5.2W\]

\[\left.\frac{\partial T}{\partial L}\right|_{(W=4.5,\,L=4.1)} = 0.41(4.5) = 1.845 \;{}^\circ\text{C/m}\]

\[\left.\frac{\partial T}{\partial W}\right|_{(W=4.5,\,L=4.1)} = 0.41(4.1)+5.2(4.5) \]

\[= 1.681+23.4 = 25.081 \;{}^\circ\text{C/m}\]

Example: higher order & partial derivatives in environmental data science



The Advection-Dispersion-Reaction Equation for solute transport models the change in a solute concentration \(C\) over time \(t\) and \(x,y,z\) space, where groundwater is flowing in direction \(x\):


\[\frac{\partial C}{\partial t}=D_x \frac{\partial^2C}{\partial x^2} + D_y\frac{\partial^2C}{\partial y^2}+D_z\frac{\partial^2C}{\partial z^2}-v\frac{\partial C}{\partial x}-\lambda RC\]

\(D_x, D_y, D_z\) are hydrodynamic diffusion coefficients in the \(x\), \(y\), and \(z\) direction.

Let’s break it down.



\[\frac{\partial C}{\partial t}=D_x \frac{\partial^2C}{\partial x^2} + D_y\frac{\partial^2C}{\partial y^2}+D_z\frac{\partial^2C}{\partial z^2}-v\frac{\partial C}{\partial x}-\lambda RC\]


  • Left-hand-side: Rate of concentration change (over time)
  • Right-hand-side first 3 terms: Concentration change due to dispersion in \(x\), \(y\), and \(z\) directions
  • Right-hand-side fourth term: Concentration change due to groundwater transport (in groundwater flow direction, x)
  • Right-hand-side final term: Reaction term (e.g. biodegradation / abiotic degradation)

Lunch break!


image: Flaticon.com