Scalar Calculus

Computational Mathematics and Statistics Camp University of Chicago September 2018

What is calculus?

  • Study of continuous change within functions
  • Differential calculus
  • Integral calculus
  • Strong connection between the two branches
  • Undergirds many relevant mathematical/statistical methods
    • Maximization/optimization
    • Expectation
    • Cumulative probability

Derivatives

\[ \frac{d}{dx}f(x) =\lim\limits_{h\to 0} \frac{f(x+h)-f(x)}{(x+h)-x} = \lim\limits_{h\to 0} \frac{f(x+h)-f(x)}{h} \]

  • Leibniz Notation: \(\frac{d}{dx}(f(x))\)
  • Prime or Lagrange Notation: \(f'(x)\)

Derivatives

The Derivative as a Slope

The Derivative as a Slope

Properties of derivatives

Constant rule

\[\left[k f(x)\right]' = k f'(x)\]

Sum rule

\[\left[f(x)\pm g(x)\right]' = f'(x)\pm g'(x)\]

Product rule

\[\left[f(x)g(x)\right]' = f'(x)g(x)+f(x)g'(x)\]

Quotient rule

\(\frac{f(x)}{g(x)}' = \frac{f'(x)g(x)-f(x)g'(x)}{[g(x)]^2}, g(x)\neq 0\)$

Power rule

\[\left[x^k\right]' = k x^{k-1}\]

Composite functions

\[f \circ g=f[g(x)]\]

  • \(f(x)=\log x\) for \(0<x<\infty\)
  • \(g(x)=x^2\) for \(-\infty<x<\infty\)

    \[f\circ g=\log x^2, -\infty<x<\infty\]

    \[g\circ f = [\log x]^2, 0<x<\infty\]

Chain Rule

\[y=f\circ g= f[g(x)]\]

\[\frac{d}{dx} \{ f[g(x)] \} = f'[g(x)] g'(x)\]

  • Derivative of the “outside” times the derivative of the “inside”

Derivatives of natural logs and the exponent

\[(e^x)^\prime = e^x\]

\[\log(x)^\prime = \frac{1}{x}\]

  • Composite functions

    \[\left(e^{g(x)}\right)^\prime = e^{g(x)} \cdot g^\prime(x)\]

    \[\left(\log g(x)\right)^\prime = \frac{g^\prime(x)}{g(x)}, ~~\text{if}~~ g(x) > 0\]

Basic proof of \(\frac{d}{dx} e^x\)

\[ \begin{eqnarray} \frac{d}{dx}f(x) & = & \lim\limits_{h\to 0} \frac{f(x+h)-f(x)}{h} \\ & = & \lim\limits_{h\to 0} \frac{e^{x + h} - e^x}{h} \\ & = & \lim\limits_{h\to 0} \frac{e^x e^h - e^x}{h} \\ & = & \lim\limits_{h\to 0} \frac{e^x(e^h - 1)}{h} \\ & = & e^x \lim\limits_{h\to 0} \frac{e^h - 1}{h} \end{eqnarray} \]

Basic proof of \(\frac{d}{dx} e^x\)

Basic proof of \(\frac{d}{dx} e^x\)

\[ \begin{eqnarray} \frac{d}{dx}f(x) & = & e^x \lim\limits_{h\to 0} \frac{e^h - 1}{h} \\ & = & e^x (1) \\ & = & e^x \end{eqnarray} \]

Basic proof of \(\frac{d}{dx} e^x\)

Derivative of the Exponential Function

Derivative of the Exponential Function

Derivative of a logarithm

Derivative of the Natural Log

Derivative of the Natural Log

Indefinite integration

  • Derivative: \(f(x)\)
  • Antiderivative: \(F(x)\)
  • Antiderivative of \(f(x) = \frac{1}{x^2}\)?

    \[ \begin{eqnarray} \int \frac{1}{x^2} dx & = & -\frac{1}{x} + c \\ \frac{d}{dx} \left[ -\frac{1}{x} + c \right] & = & \frac{1}{x^2} \\ F(x) & = & \int f(x) dx \end{eqnarray} \]

Many possible antiderivatives

\[f(x) = (x^2-4)\]

The Many Indefinite Integrals of a Function

The Many Indefinite Integrals of a Function

Common Rules of Integration

  1. Constants are allowed to slip out: \(\int a f(x)dx = a\int f(x)dx\)
  2. Integration of the sum is sum of integrations: \(\int [f(x)+g(x)]dx=\int f(x)dx + \int g(x)dx\)
  3. Reverse Power-rule: \(\int x^n dx = \frac{1}{n+1} x^{n+1} + c\)
  4. Exponents are still exponents: \(\int e^x dx = e^x +c\)
  5. Recall the derivative of \(\log(x)\) is one over \(x\), and so: \(\int \frac{1}{x} dx = \log x + c\)
  6. Reverse chain-rule: \(\int e^{f(x)}f^\prime(x)dx = e^{f(x)}+c\)
  7. More generally: \(\int [f(x)]^n f'(x)dx = \frac{1}{n+1}[f(x)]^{n+1}+c\)
  8. Remember the derivative of a log of a function: \(\int \frac{f^\prime(x)}{f(x)}dx=\log f(x) + c\)

Definite integral

  • Finding the area under a function
  • Determine the area \(A(R)\) of a region \(R\) defined by a curve \(f(x)\) and some interval \(a\le x \le b\)

    \[S(f,\Delta x)=\sum\limits_{i=1}^n f(x_i)\Delta x\]

  • Riemann sum

    \[A(R)=\lim\limits_{\Delta x\to 0}\sum\limits_{i=1}^n f(x_i)\Delta x\]

Definite integral

\[\lim\limits_{\Delta x\to 0} \sum\limits_{i=1}^n f(x_i)\Delta x = \int\limits_a^b f(x) dx\]

\[\int\limits_a^b f(x) dx\]

Fundamental theorem of calculus

\[F(x)=\int\limits_a^x f(t)dt, \quad a\le x\le b\]

\[F^\prime(x)=f(x), \quad a<x<b\]

  • Differentiation is the reverse of integration

Fundamental theorem of calculus

\[\int\limits_a^bf(x)dx = F(b)-F(a)\]

  1. Find the indefinite integral \(F(x)\)
  2. Evaluate \(F(b)-F(a)\)

Example

Solve \(\int\limits_1^3 3x^2 dx\)

\[ \begin{eqnarray} f(x) & = & 3x^2 \\ F(x) & = & x^3 + c \\ \int\limits_1^3 3x^2 dx & = & F(3) - F(1) \\ & = & (3^3 + c) - (1^3 + c) \\ & = & 27 + c - 1 - c \\ & = & 26 \end{eqnarray} \]

Common Rules for Definite Integrals

  1. There is no area below a point: \[\int\limits_a^a f(x)dx=0\]
  2. Reversing the limits changes the sign of the integral: \[\int\limits_a^b f(x)dx=-\int\limits_b^a f(x)dx\]
  3. Sums can be separated into their own integrals: \[\int\limits_a^b [\alpha f(x)+\beta g(x)]dx = \alpha \int\limits_a^b f(x)dx + \beta \int\limits_a^b g(x)dx\]
  4. Areas can be combined as long as limits are linked: \[\int\limits_a^b f(x) dx +\int\limits_b^c f(x)dx = \int\limits_a^c f(x)dx\]

Integration by substitution

  • What if the integrand is not easily calculated?
  • Find shortcuts
  • Related to the chain rule
  • \(\int g(x)dx\)
    • \(g(x)\) is complex
  • Find a new function \(u(x)\) such that \(g(x)=f[u(x)]u'(x)\)

    \[\int g(x) dx= \int f[u(x)]u'(x)dx = \int \frac{d}{dx} F[u(x)]dx = F[u(x)]+c\]

Integration by substitution

  1. Identify some part of \(g(x)\) that might be simplified by substituting in a single variable \(u\) (which will then be a function of \(x\))
  2. Determine if \(g(x)dx\) can be reformulated in terms of \(u\) and \(du\)
  3. Solve the indefinite integral
  4. Substitute back in for \(x\)

Integration by substitution

\[\int \frac{x}{x^2 + 1} dx\]

\[\frac{1}{2} \int \frac{2x}{x^2 + 1} dx\]

\[ \begin{eqnarray} u & = & x^2 + 1 \\ du & = & 2x \,dx \\ \int \frac{x}{x^2 + 1} dx & = & \frac{1}{2} \int \frac{2x}{x^2 + 1} dx \\ & = & \frac{1}{2} \int \frac{1}{u} du \\ & = & \frac{1}{2} \log(u) + c \\ & = & \frac{1}{2} \log(x^2 + 1) + c \\ \end{eqnarray} \]

Integration by parts

  • Product rule

    \[ \begin{eqnarray} \frac{d}{dx} f(x) g(x) & = & f(x) g'(x) + g(x) f'(x) \\ \frac{d}{dx}(uv) & = &u\frac{dv}{dx}+v\frac{du}{dx} \end{eqnarray} \]

  • Integration by parts

    \[\int u dv = u v - \int v du\]

Integration by parts

\[\int x \log(x) dx\]

\[ \begin{eqnarray} u &=& \log(x) \\ du &=& \frac{1}{x} \,dx \\ dv & = & x \, dx \\ v &=& \frac{1}{2}x^2 \end{eqnarray} \]

\[ \begin{eqnarray} \int x \log(x) \, dx &=& u v - \int v du \\ &=& \log(x) \times \frac{1}{2} x^2 - \int (\frac{1}{2} x^2) (\frac{1}{x} \, dx) \\ &=& \frac{1}{2} x^2 \log(x) - \int \frac{1}{2}x \,dx \\ &=& \frac{1}{2} x^2 \log(x) - \frac{1}{2} \int x \,dx \\ &=& \frac{1}{2} x^2 \log(x) - \frac{1}{2} \left( \frac{1}{2}x^2 \right) + c \\ &=& \frac{1}{2} x^2 \log(x) - \frac{1}{4} x^2 + c \\ \end{eqnarray} \]