# Multivariable CalculusIntroduction

Calculus is the study of continuously varying functions. Specifically, we examine

The ideas of multivariable calculus are useful for data science in at least a couple of ways: (i) when we *probability* using functions on , 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 converges to a number if the distance from to on the number line can be made as small as desired by choosing sufficiently large. In that case, we say that as , or .

**Example**

The sequence converges to 0 as , since the distance on the number line from 0 to is , and that distance may be made as small as desired by choosing large enough. For example, if you want to be less than , all the values of larger than will work.

Convergence to zero is apparent visually if make a scatter plot of versus , 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 for all and if , then the sequence converges, and its limiting value is equal to the common limiting value of and .

**Exercise**

Suppose that for all . Show that as .

*Solution.* We have for all , so we may apply the squeeze theorem to the sequences and to conclude that as .

## Series

A **series** converges if the sequence converges, where

is the *partial sum*

**Theorem** (Term test)

If does not converge to zero, then the series does not converge.

**Exercise**

Show that 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 converges to 1 as , 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 converges and if for all , then converges.

Conversely, if does not converge and , then also does not converge.

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

**Theorem**

- The series converges if and only if .
- The series converges if and only if .

**Exercise**

Show that the series converges.

*Solution.* We know that and that converges. Therefore, the comparison test implies that converges.

**Exercise**

Numerically examine the statement that converges to .

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 gets arbitrarily close to for large enough .