Glosario

Seleccione una de las palabras clave de la izquierda ...

Multivariable CalculusIntroduction

Tiempo de leer: ~20 min

Calculus is the study of continuously varying functions. Specifically, we examine rates of change (derivatives) and learn how to average (or total) the values of a function over a region (integration). In multivariable calculus, we generalize differentiation and integration ideas developed for functions defined on the number line \mathbb{R}^1 to the setting where our functions are defined on \mathbb{R}^d for some d \ge 1.

The ideas of multivariable calculus are useful for data science in at least a couple of ways: (i) when we model data, the functions we use to gauge the goodness of a model typically depend on many model variables. We optimize these functions by thinking about how they increase or decrease under small perturbations of the variables. And (ii) we will mathematically represent the idea of probability using functions on \mathbb{R}^d, and in that context probabilities will be recovered by integrating these functions.

We will begin by studying sequences and series.

Sequences and series

A sequence of real numbers (x_n)_{n=1}^\infty = x_1, x_2, \ldots converges to a number x \in \mathbb{R} if the distance from x_n to x on the number line can be made as small as desired by choosing n sufficiently large. In that case, we say that x_n \to x as n\to\infty, or \lim_{n\to\infty} x_n = x.

Example
The sequence (-1)^n/n converges to 0 as n\to\infty, since the distance on the number line from 0 to (-1)^n/n is 1/n, and that distance may be made as small as desired by choosing n large enough. For example, if you want 1/n to be less than 0.001, all the values of n larger than 1000 will work.

Convergence to zero is apparent visually if make a scatter plot of a_n versus n, because the points are getting arbitrariy close to the horizontal axis as we move further to the right.

Squeeze theorem

If two sequences both converge to the same limit, then any sequence whose terms are sandwiched between the terms of those sequences also converges:

Theorem (Squeeze theorem)
If a_n \leq b_n \leq c_n for all n\geq 1 and if \lim_{n\to\infty} a_n = \lim_{n\to\infty} c_n, then the sequence (b_n)_{n=1}^{\infty} converges, and its limiting value is equal to the common limiting value of (a_n)_{n=1}^{\infty} and (c_n)_{n=1}^{\infty}.

Exercise
Suppose that |x_n| \leq n^{-1/2} for all n \geq 1. Show that x_n \to 0 as n\to\infty.

Solution. We have -n^{-1/2} \leq x_n \leq n^{-1/2} for all n, so we may apply the squeeze theorem to the sequences -n^{-1/2} and n^{-1/2} to conclude that x_n \to 0 as n\to\infty.

Series

A series \sum_{n=1}^\infty x_n = x_1 + x_2 + x_3 + \cdots converges if the sequence (S_n)_{n=1}^\infty converges, where

\begin{align*}S_n = x_1 + x_2 + \cdots + x_n\end{align*}

is the n\text{th} partial sum. Roughly speaking, a series with positive terms converges if its terms converge to 0 fast enough. In particular, the terms must converge to zero:

Theorem (Term test)
If a_n does not converge to zero, then the series \displaystyle{\sum_{n=1}^\infty a_n} does not converge.

Exercise
Show that \displaystyle{\sum_{n=1}^\infty \frac{n}{n+1}} does not converge. Plot the partial sums using the code below to appreciate this fact visually. (You have to run the cell twice for the plot to show; the second time will be quick.)

import matplotlib.pyplot as plt
import numpy as np
A = [n/(n+1) for n in range(1,1001)]
plt.scatter(range(1, 1001), np.cumsum(A))

Solution. Since n/(n+1) converges to 1 as n\to\infty, the sum of these terms does not converge to zero, by the term test. The graph of the sequence of partial sums shows how the partial sums increase (approximately linearly) without bound, illustrating the series' lack of convergence to a finite value.

Another valid statement suggested by the "terms go to 0 fast enough" intuition is that convergence of one series implies convergence of any other series whose terms go to 0 at least as fast:

Theorem (Comparison test)
If \sum_{n=1}^\infty b_n converges and if |a_n| \leq b_n for all n, then \sum_{n=1}^\infty a_n converges.

Conversely, if \sum_{n=1}^\infty b_n does not converge and 0 \leq b_n \leq a_n, then \Sigma_{n=1}^\infty a_n also does not converge.

The comparison test works well in conjunction with a list of basic series whose convergence is known.

Theorem

  • The series \sum_{n=1}^\infty n^p converges if and only if p < -1.
  • The series \sum_{n=1}^\infty a^n converges if and only if -1 < a < 1.

Exercise
Show that the series \sum_{n=1}^\infty \frac{1}{n^2 + n} converges.

Solution. We know that \frac{1}{n^2 + n} < \frac{1}{n^2} and that \sum_{n=1}^\infty \frac{1}{n^2} converges. Therefore, the comparison test implies that \frac{1}{n^2 + n} converges.

Exercise
Numerically examine the statement that \sum_{n=1}^\infty \frac{1}{n^2} converges to \frac{\pi^2}{6}.

import numpy as np

Solution. The expression

sum(1/n**2 for n in range(1,1001)) - np.pi**2/6

returns -0.0009995001666649461, while

import numpy as np
sum(1/n**2 for n in range(1,10_000_001)) - np.pi**2/6

evaluates to -9.999994563525405e-7. This is consistent with the proposition that \sum_{n=1}^N \frac{1}{n^2} gets arbitrarily close to \pi^2/6 for large enough N.

Bruno
Bruno Bruno