1.6 Calculus: many variables
Open and closed sets
To make precise statements about functions of many variables, we need to generalize the notions of open and closed intervals to many dimensions.We want to say that a set of points in an ndimensional set is “open” if it does not include its boundary. But how exactly can we define the boundary of an arbitrary set of nvectors?
Our definition of boundary point for an interval can easily be extended. We say that a point x is a boundary point of a set of nvectors if there are points in the set that are arbitrarily close to x, and also points outside the set that are arbitrarily close to x. A point x is an interior point of a set if we can find a (small) number ε such that all points within the distance ε of x are in the set.
The green point in the following figure, for example, is a boundary point of the (twodimensional) blue set because every disk centered at the point, however small, contains both points in the set and points outside the set. The red point is an interior point because the gray disk around it (and all smaller disks, as well as some larger ones) contains exclusively points in the set.
Here is a more precise definition of the two notions.
 Definition

 A point x is a boundary point of a set S of vectors if for every number ε > 0 (however small), at least one point within the distance ε of x is in S, and at least one point within the distance ε of x is outside S.
 A point x is an interior point of a set S of vectors if there is a number ε > 0 such that all points within the distance ε of x are members of S.
 Example
 The set of interior points of the set {(x, y): x^{2} + y^{2} ≤ c^{2}}, the disk of radius c centered at the origin, is {(x, y): x^{2} + y^{2} < c^{2}}, and the set of its boundary points is {(x, y): x^{2} + y^{2} = c^{2}}, the circle of radius c centered at the origin.
 Definition

 The set S of nvectors is open if every point in S is an interior point of S.
 The set S of nvectors is closed if every boundary point of S is a member of S.
 Example
 The set of boundary points of the set {(x, y): x^{2} + y^{2} ≤ c^{2}}, the disk of radius c centered at the origin, is {(x, y): x^{2} + y^{2} = c^{2}}, the circle of radius c centered at the origin, which is a subset of the disk. Thus the disk is closed.
 Example
 The set of interior points of the set {(x, y): x + y ≤ c, x ≥ 0, and y ≥ 0} is {(x, y): x + y < c, x > 0, and y > 0}, and the set of boundary points is {(x, y): x + y = c and 0 ≤ x ≤ c and 0 ≤ y ≤ c, or x = 0 and 0 ≤ y ≤ c, or y = 0 and 0 ≤ x ≤ c}. Thus the set is closed.
Differentiability
For a function f of a single variable and any point x in the domain of f, a line through (x, f(x)) with slope equal to the derivative f'(x) of f at the point x is a good approximation of the function around x (see this page). If no good linear approximation exists at some point x (as is the case if the graph of the function has a “kink” at x), then the function is not differentiable at x.The definition of differentiability for a function of many variables captures the same idea: a function of many variables is differentiable at a point if there exists a good linear approximation of the function around the point. Like the graph of a differentiable function of a single variable, the graph of a differentiable function of many variables is “smooth”, with no “kinks”.
To formulate a precise definition, first note that the definition of differentiability for a function of a single variable can be rewritten as follows: a function of a single variable defined on an open interval I is differentiable at the point a ∈ I if there is a number r such that
lim_{h→0} 

Here is the definition for a function of many variables.
 Definition

The function f of n variables defined on an open set S is differentiable at the point a ∈ S if there is a vector r = (r_{1}, ..., r_{n}) such that
lim_{h→0} f(a + h) − f(a) − r · h ∥h∥
i=1h2
i), and r · h is the inner product of r and h. In this case, r is the derivative of the function f at a. If f is differentiable at every point in S then it is differentiable on S.
 Definition
 The function f of many variables defined on an open set S is twicedifferentiable on S if it is differentiable on S and its derivative is also differentiable on S.
Partial derivatives
 Definition

Let f be a function of n variables and let (x_{1}, ..., x_{n}) be a point in its domain. If
lim_{h→0} f(x_{1}, ..., x_{i} + h, ..., x_{n}) − f(x_{1}, ..., x_{n}) h
 Example
 Let f(x_{1}, x_{2}) = (x_{1})^{3}ln x_{2}. The partial derivative of f with respect to its first argument is the function f'_{1} defined by f'_{1}(x_{1}, x_{2}) = 3(x_{1})^{2}ln x_{2} and the partial derivative of f with respect to its second argument is the function f'_{2} defined by f'_{2}(x_{1}, x_{2}) = (x_{1})^{3}/x_{2}.
The notation ∂f/∂x is also sometimes used. This notation has two major disadvantages. First, it is clumsy in using five symbols where three (D_{i}f) suffice. Second, its reference to the variable with respect to which the function is being differentiated is imprecise. If f is a function of two variables, for example, and we want to denote its partial derivative with respect to its first argument at the point (a, b), what letter do we use to denote the first argument? Despite these limitations, the notation is often used by economists, and I sometimes follow suit.
Occasionally the argument of a function may be more conveniently referred to by its name than its index. If I have called the arguments of f by the names w and p, for example (writing f(w, p)), I may write f_{p}(w, p) for the value of the partial derivative of f with respect to its second argument at the point (w, p).
If a function of many variables is differentiable at some point, then all of its partial derivatives exist at that point.
 Proposition proof
 Let f be a function of many variables that is differentiable at x. Then all the partial derivatives of f exist at x and f is continuous at x.
 Proof hide

Let f be a function of n variables and choose i with 1 ≤ i ≤ n. In the definition of the derivative of f at x, take h to be a vector with h_{i} = t and h_{j} = 0 for all
j ≠ i. Then for any nvector r, r · h = tr_{i}, so from the definition,
lim_{t→0} f(x + h) − f(x) t = r_{i}. To show that f is continuous at x, note that it follows from the definition of the derivative that there is a function K of n variables with lim_{h→0} K(h)/h = 0 such that f(x + h) = f(x) + f'(x)h + K(h). Taking the limit as h → 0 on both sides, lim_{h→0} f(x + h) = f(x), so that f is continuous.
However, the fact that all of the n partial derivatives of f exist at some point does not imply that f is differentiable, or even continuous, at that point. A simple example is the function f of two variables defined by f(x_{1}, x_{2}) = x_{1} + x_{2} if x_{1} = 0 or x_{2} = 0 and f(x_{1}, x_{2}) = 0 otherwise. Both partial derivatives of f exist at (0, 0) (they are equal to 1), but f is not continuous at (0, 0). Less obviously, a function that has partial derivatives at every point may not be differentiable, or even continuous. (See the example if you are curious.)
 Example
 Here is a function that has partial derivatives for all points in its domain but is not continuous at every point in its domain, and thus is not differentiable at every point in its domain. Define the function f of two variables by
f(x, y) = 0 if (x, y) = (0, 0) xy/(x^{2} + y^{2}) if (x, y) ≠ (0, 0).
 Definition
 A function of many variables is continuously differentiable if it is differentiable and its derivative is a continuous function.
 Proposition source
 Let f be a function of n variables defined on an open set S. Then f is continuously differentiable on S if and only if all its partial derivatives exist and are continuous on S.
Cross partial derivatives
Just as we can differentiate the derivative of a function (if the derivative is differentiable) to get the second derivative, we can partially differentiate the partial derivatives of a function (if the partial derivatives are differentiable). The functions produced by such operations are called “cross partial derivatives”. Definition
 Let f be a function of n variables. Suppose that the partial derivative f'_{j} of f with respect to its jth argument exists. Then if the derivative of f'_{j} with respect to its ith argument exists, it is called the ijth cross partial derivative of f and is denoted f"_{ij}.
 Proposition (Young's theorem) source

Let f be a function of n variables and let 1 ≤ i ≤ n and 1 ≤ j ≤ n. If the partial derivatives f'_{i} and
f'_{j} of f exist in an open set S containing (x_{1}, ..., x_{n}) and both of these partial derivatives are differentiable at (x_{1}, ..., x_{n})
then
f"_{ij}(x_{1}, ..., x_{n}) = f"_{ji}(x_{1}, ..., x_{n}).
 Example

Define the function f by f(x_{1}, x_{2}) = x_{1}x2
2 for all (x_{1}, x_{2}). We have f'_{1}(x_{1}, x_{2}) = x2
2, so that f'_{21}(x_{1}, x_{2}) = 2x_{2}, and f'_{2}(x_{1}, x_{2}) = 2x_{1}x_{2}, so that f'_{12}(x_{1}, x_{2}) = 2x_{2}.
If you are wondering how the conclusion of the proposition can fail for a function that does not satisfy the assumptions, take a look at this example.
 Example
 Here is a function for which the crosspartials exist at (0, 0) but are not continuous at this point and the conclusion of the proposition fails: the crosspartials are not equal at (0, 0). Define the function f of two variables by
f(x, y) = 0 if (x, y) = (0, 0) xy(x^{2} − y^{2})/(x^{2} + y^{2}) if (x, y) ≠ (0, 0).