Skip to content

Differential calculus in higher dimension ​

WARNING

The information in this section is being updated.

In this part of the course we work on the following skills:

  • Become comfortable working with coordinates in arbitrary dimension.
  • Develop an intuition for working with vector fields.
  • Understand the subtleties of derivatives in dimension greater than 1, evaluate and manipulate partial derivatives, directional derivatives, Jacobian.

See also the exercises associated to this part of the course.

Here we start to consider higher dimensional space. That is, instead of R we consider Rn for n∈N. We will particularly focus on 2D and 3D but everything also holds in any dimension. Going beyond R we have more options for functions and correspondingly more options for derivatives. Various different notation is commonly used. Here we will primarily use (x,y)∈R2, (x,y,z)∈R3 or, more generally, x=(x1,x2,…,xn)∈Rn where x1∈R,…,xn∈R. For example, R2 is the plane, R3 is 3D space.

Definition (inner product)

x⋅y=∑k=1nxkyk∈R

We recall that the inner product being zero has a geometric meaning, it means that the two vectors are orthogonal. We also recall that the "length" of a vector is given by the norm, defined as follows.

Definition (norm)

‖x‖=x⋅x=(∑k=1nxk2)12.

For example, in R2 then ‖(x,y)‖=x2+y2. There are various convenient properties for working with norms and inner products, in particular, the Cauchy-Schwarz inequality |x⋅y|≤‖x‖ ‖y‖ and the triangle inequality ‖x+y‖≤‖x‖+‖y‖.

The primary higher-dimensional functions we consider in this course are:

  • Scalar fields: f:Rn→R
  • Vector fields: F:Rn→Rn
  • Paths: α:R→Rn
  • Change of coordinates: x:Rn→Rn

These possibilities all fit into the general pattern of f:Rn→Rm for n,m∈N but tradition and use of the function gives us different terminology and symbols. Such functions are useful for representing various practical things, for example: gravitational force; temperature in a region; wind velocity; fluid flow; electric field; etc.

Open sets, closed sets, boundary, continuity ​

Let a∈Rn, r>0. The open n-ball of radius r and centre a is written as

B(a,r):={x∈Rn:‖x−a‖<r}.

Definition (interior point)

Let S⊂Rn. A point a∈S is said to be an interior point if there is r>0 such that B(a,r)⊂S. The set of all interior points of S is denoted intS.

Definition (open set)

A set S⊂Rn is said to be open if all of its points are interior points, i.e., if intS=S.

Interior points are the centre of a ball contained within the set

For example, open intervals, open disks, open balls, unions of open intervals, etc., are all open sets.

Lemma

Let r>0, a∈Rn. The set B(a,r)⊂Rn is open.

Proof

Let b∈B(a,r). It suffices to show that b is an interior point. (1) Let r1=∥b−a∥<r. (2) Let r2=(r−r1)/2. (3) We claim that B(b,r2)⊂B(a,r): In order to see this take any c∈B(b,r2) and observe that

∥c−a∥≤∥c−b∥+∥b−a∥≤r2+r1=r+r12<r.

Observe that the radius of the ball will be small for points close to the boundary.

Definition (Cartesian product)

If A1⊂R, A2⊂R then the Cartesian product is defined as

A1×A2:={(x,y):x∈A1,y∈A2}⊂R2.

Analogously the Cartesian product can be defined in higher dimensions: If A1⊂Rm, A2⊂Rn then the Cartesian product A1×A2 is defined as the set of all points (x1,…,xm,y1,…,yn)∈Rm+n such that (x1,…,xm)∈A1 and (y1,…,yn)∈A2.

Lemma

If A1,A2 are open subsets of R then A1×A2 is an open subset of R2.

Proof

Let a=(a1,a2)∈A1×A2⊂R2. Since A1 is open there exists r1>0 such that B(a1,r1)⊂A1. Similarly for A2. Let r=min{r1,r2}. This all means that B(a,r)⊂B(a1,r1)×B(a2,r2)⊂A1×A2.

If A1,A2 are intervals then A1×A2 is a rectangle

Discussing the "interior" of the set naturally suggests the topic of the "boundary" of the set. In the following definitions we develop this idea.

Definition (exterior points)

Let S⊂Rn. A point a∉S is said to be an exterior point if there exists r>0 such that B(a,r)∩S=∅. The set of all exterior points of S is denoted extS.

Observe that extS is an open set. We use the notation Sc=Rn∖S and we say that Cc is the complement of the set S.

Definition (boundary)

The set Rn∖(intS∪extS) is called the boundary of S⊂Rn and is denoted ∂S.

Definition (closed)

A set S⊂Rn is said to be closed if ∂S⊂S.

Lemma

S is open ⟺ Sc is closed.

Proof

Observe that Rn=intS∪∂S∪extS (disjointly). If x∈∂S then, for every r>0, B(x,r)∩S≠∅ and so x∈∂(Sc). Similarly with S and Sc swapped and so ∂S=∂(Sc). If S is open then intS=S and Sc=extS∪∂S=extS∪∂(Sc) and so Sc is closed. If S is not open then there exists a∈∂S∩S. Additionally a∈∂(Sc)∩S hence Sc is not closed.

Limits and continuity ​

Let S⊂Rn and f:S→Rm. If a∈Rn, b∈Rm we write limx→af(x)=b to mean that ‖f(x)−b‖→0 as ‖x−a‖→0. Observe how, if n=m=1, this is the familiar notion of continuity for functions on R.

Definition (Continuous)

A function f is said to be continuous at a if f is defined at a and limx→af(x)=f(a). We say f is continuous on S if f is continuous at each point of S.

Even functions which look "nice" can fail to be continuous as we can see in the following example.

Example (continuity in higher dimensions)

Let f be defined, for (x,y)≠(0,0), as

f(x,y)=xyx2+y2

and f(0,0)=0. What is the behaviour of f when approaching (0,0) along the following lines?

linevalue
{x=0}f(0,t)=0
{y=0}f(t,0)=0
{x=y}f(t,t)=12
{x=−y}f(t,t)=−12

Theorem

Suppose that limx→af(x)=b and limx→ag(x)=c. Then

  1. limx→a(f(x)+g(x))=b+c,
  2. limx→aλf(x)=λb for every λ∈R,
  3. limx→af(x)⋅g(x)=b⋅c,
  4. limx→a‖f(x)‖=‖b‖.

We prove a couple of the parts of the above theorem here, the other parts are left as exercises.

Proof of part 3.

Observe that f(x)⋅g(x)−b⋅c=(f(x)−b)⋅(g(x)−c)+b⋅(g(x)−c)+c⋅(f(x)−b). By the triangle inequality and Cauchy-Schwarz,

‖f(x)⋅g(x)−b⋅c‖≤‖f(x)−b‖‖g(x)−c‖+‖b‖‖g(x)−c‖+‖c‖‖f(x)−b‖.

Since we already know that ‖f(x)−b‖→0 and ‖g(x)−c‖→0 as x→a, this implies that ‖f(x)⋅g(x)−b⋅c‖→0.

Proof of part 4.

Take f=g in part (c) implies that limx→a‖f(x)‖2=‖b‖2.

When writing a vector field (or similar functions) it is often convenient to divide the higher-dimensional function into smaller parts. We call these parts the components of a vector field. For example F(x)=(F1(x),F2(x)) in 2D, F(x)=(F1(x),F2(x),F3(x)) in 3D, etc.

Theorem

Let F(x)=(F1(x),F2(x)). Then F is continuous if and only if F1 and F2 are continuous.

Proof

We will independently prove the two implications.

  • (⇒) Let e1=(1,0), e2=(0,1) and observe that Fk(x)=F(x)⋅ek. We have already shown that the continuity of two vector fields implies the continuity of the inner product.
  • (⇐) By definition of the norm‖F(x)−F(a)‖2=∑k=12(Fk(x)−Fk(a))2and we know ‖Fk(x)−Fk(a)‖→0 as ‖x−a‖→0.

In higher dimensions the analogous statement is true for the vector field F(x)=(F1(x),…,Fm(x)) with exactly the same proof. I.e., F is continuous if and only if each fk is continuous.

Example (polynomials)

A polynomial in n variables is a scalar field on Rn of the form

f(x1,…,xn)=∑k1=0j⋯∑kn=0jck1,…,knx1k1⋯xnkn.

E.g., f(x,y):=x+2xy−x2 is a polynomial in 2 variables. Polynomials are continuous everywhere in Rn. This is because they are the finite sum of products of continuous scalar fields.

Example (rational functions)

A rational function is a scalar field

f(x)=p(x)q(x)

where p(x) and q(x) are polynomials. A rational function is continuous at every point x such that q(x)≠0.

As described in the following result, the continuity of functions continues to hold, in an intuitive way, under composition of functions.

Theorem

Suppose S⊂Rl, T⊂Rm, f:S→Rm, g:T→Rn and that f(S)⊂T so that

(g∘f)(x)=g(f(x))

makes sense. If f is continuous at a∈S and g is continuous at f(a) then g∘f is continuous at a.

Proof

limx→a‖f(g(x))−f(g(a))‖=limy→g(a)‖f(y)−f(g(a))‖=0

Example

We can consider the scalar field f(x,y)=sin⁡(x2+y)+xy as the composition of functions.

Derivatives of scalar fields ​

Plot where colour represents the value of f(x,y)=x2+y2. The change in f depends on direction

We can imagine, for example in the figure, that in higher dimensions, the derivative of a scalar field depends on the direction. This motivates the following.

Definition (directional derivative)

Let S⊂Rn and f:S→R. For any a∈intS and v∈Rn, ‖v‖=1 the directional derivative of f with respect to v is defined as

Dvf(a)=limh→01h(f(a+hv)−f(a)).

When h is small we can guarantee that a+hv∈S because a∈intS so this definition makes sense.

Theorem

Suppose S⊂Rn, f:S→R, a∈intS. Let g(t):=f(a+tv). If one of the derivatives g′(t) or Dvf(a) exists then the other also exists and

g′(t)=Dvf(a+tv).

In particular g′(0)=Dvf(a).

Proof

By definition 1h(g(t+h)−g(h))=1h(f(a+hv)−f(a)).

The following result is useful for proving later results.

Theorem (mean value)

Assume that Dv(a+tv) exists for each t∈[0,1]. Then for some θ∈(0,1),

f(a+v)−f(a)=Dvf(z),where z=a+θv.

Proof

Apply mean value theorem to g(t)=f(a+tv).

The following notation is convenient. For any k∈{1,2,…,n}, let ek be the n-dimensional unit vector where all entries are zero except the kth position which is equal to 1. I.e., e1=(1,0,…,0), e2=(0,1,0,…,0), en=(0,…,0,1).

Definition (partial derivatives)

We define the partial derivative in xk of f(x1,…,xn) at a as

∂f∂xk(a)=Dekf(a).

Remark

Various symbols used for partial derivatives: ∂f∂xk(a)=Dkf(a)=∂kf(a). If a function is written f(x,y) we write ∂f∂x,∂f∂y for the partial derivatives. Similarly for higher dimension.

In practice, to compute the partial derivative ∂f∂xk, one should consider all other xj for j≠k as constants and take the derivative with respect to xk. In a moment we see this rigorously.

If f:R→R is differentiable, then we know that, when x is close to a,

f(x)≈f(a)+(x−a)f′(a).

More precisely, we know that f(x)=f(a)+(x−a)f′(a)+ϵ(x−a) where |ϵ(x−a)|=o(|x−a|). (This is little-o notation and here means that |f(x)−f(a)−(x−a)f′(a)|/|x−a|→0 as |x−a|→0.) This way of seeing differentiability is convenient for the higher dimensional definition of differentiability.

Definition (differentiable)

Let S⊂Rn be open, f:S→R. We say that f is differentiable at a∈S if there exists a linear transformation dfa:Rn→R such that, for x∈B(a,r),

f(x)=f(a)+dfa(x−a)+ϵ(x−a)

where |ϵ(x−a)|=o(‖x−a‖).

For future convenience we introduce the following notation.

Definition (gradient)

The gradient of the scalar field f(x,y,z) at the point a is

∇f(a)=(∂f∂x(a)∂f∂y(a)∂f∂z(a)).

In general, when working in Rn for some n∈N, the gradient of the scalar field f(x1,…,xn) at the point a is

∇f(a)=(∂f∂x1(a)∂f∂x2(a)⋮∂f∂xn(a)).

Theorem

If f is differentiable at a then dfa(v)=∇f(a)⋅v. This means that, for x∈B(a,r),

f(x)=f(a)+∇f(a)⋅(x−a)+ϵ(x−a)

where |ϵ(x−a)|=o(‖x−a‖). Moreover, for any vector v, ‖v‖=1,

Dvf(a)=∇f(a)⋅v.

Proof

Since f is differentiable there exists a linear transformation dfa:Rn→R such that f(a+hv)=f(a)+hdfa(v)+ϵ(hv) and hence

Dvf(a)=limh→01h(f(a+hv)−f(a))=limh→01h(h dfa(v)+ϵ(hv))=dfa(v).

In particular dfa(ek)=Dekf(a).

Theorem

If f is differentiable at a, then it is continuous at a.

Proof

Observe that |f(a+v)−f(a)|=|dfa(v)+ϵ(v)|. This means that

|f(a+v)−f(a)|≤‖dfa‖‖v‖+|ϵ(v)|

and so this tends to 0 as ‖v‖→0.

Theorem

Suppose that f(x1,…,xn) is a scalar field. If the partial derivatives ∂1f(x),…,∂nf(x) exist for all x∈B(a,r) and are continuous at a then f is differentiable at a.

Proof

For convenience define the vectors

v=(v1,v2,…,vn),uk=(v1,v2,…,vk,0,…,0).

Observe that

uk−uk−1=vkek,u0=(0,0,…,0),un=v.

Using the mean value theorem we know that there exists zk=uk−1+θkek such that f(a+uk)−f(a+uk−1)=vkDe_kf(a+z_k). Consequently

f(a+v)−f(a)=∑k=1nf(a+uk)−f(a+uk−1)=∑k=1nvkDekf(a+z_k)=∑k=1nvkDekf(a+uk−1)+∑k=1nvk(Dekf(a+z_k)−Dekf(a+uk−1))

To conclude, observe that the second sum vanishes as ‖v‖→0 and that the first sum, ∑k=1nvkDekf(a+uk−1), converges to v⋅∇f(a).

Chain rule ​

When we are working in R we know that, if g and h are differentiable, then f(t)=g∘h(t) is also differentiable and also f′(t)=g′(h(t)) h′(t). This is called the chain rule and is frequently very useful in calculating derivatives. We now investigate how this extends to higher dimension?

Example

Suppose that α:R→R3 describes the position α(t) at time t and that f:R3→R describes the temperature f(α) at a point α The temperature at time t is equal to g(t)=f(α(t)). We want to calculate g′(t) because this is the change in temperature with respect to time.

In situations like the above example it is convenient to consider the derivative of a path α:R→Rn. Let α:R→Rn and suppose it has the form α(t)=(α1(t),…,αn(t)). We define the derivative as

α′(t):=(x1′(t)⋮xn′(t)).

Here α′ is a vector-valued function which represents the "direction of movement".

α(t)=(cos⁡t,sin⁡t,t), t∈R

Theorem

Let S⊂Rn be open and I⊂R an interval. Let x:I→S and f:S→R and define, for t∈I,

g(t)=f(x(t)).

Suppose that t∈I is such that x′(t) exists and f is differentiable at x(t). Then g′(t) exists and

g′(t)=∇f(x(t))⋅x′(t).

Proof

Since f is differentiable, f(y)−f(x)=∇f(x)⋅(y−x)+ϵ(x,y−x) where |ϵ(x,y−x)|=o(y−x). Let h>0 be small.

1h[g(t+h)−g(t)]=1h[f(x(t+h))−f(x(t))]=1h∇f(x(t))⋅(x(t+h)−x(t))  +1hϵ(x(t),x(t+h)−x(t)).

Observe that 1h(x(t+h)−x(t))→x′(t) as h→0.

Example ​

A particle moves in a circle and its position at time t∈[0,2π] is given by

x(t)=(cos⁡t,sin⁡t).

The temperature at a point y=(y1,y2) is given by the function f(y):=y1+y2, The temperature the particle experiences at time t is given by g(t)=f(x(t)). Temperature change:

g′(t)=∇f(x(t))⋅x′(t)=(11)⋅(−sin⁡tcos⁡t)=cos⁡t−sin⁡t.
x(t) is the position of a particle.

Level sets & tangent planes ​

Let S⊂R2, f:S→R. Suppose c∈R and let

L(c)={x∈S:f(x)=c}.

The set L(c) is called the level set. In general this set can be empty or it can be all of S. However the set L(c) is often a curve and this is the case of interest. This is the same notion as that of contour lines on a map. I.e., x(ta)=a for some ta∈I and

f(x(t))=c

for all t∈I. Then

  • ∇f(a) is normal to the curve at a
  • Tangent line at a is {x∈R2:∇f(a)⋅(x−a)=0}

This is because the chain rule implies that ∇f(x(t))⋅x′(t)=0.

Example

Let f(x1,x2,x3):=x12+x22+x32.

  • If c>0 then L(c) is a sphere,
  • L(0) is a single point (0,0,0),
  • If c<0 then L(c) is empty.

Example

Let f(x1,x2,x3):=x12+x22−x32. See figure.

  • If c>0 then L(c) is a one-sheeted hyperboloid,
  • L(0) is an infinite cone,
  • If c<0 then L(c) is a two-sheeted hyperboloid.
Sphere
2-sheet hyperboloid
Infinite cone
1-sheet hyperboloid

Let f be a differentiable scalar field on S⊂R3 and suppose that the level set L(c)={x∈S:f(x)=c} defines a surface.

  • The gradient ∇f(a) is normal to every curve α(t) in the surface which passes through a,
  • The tangent plane at a is {x∈R3:∇f(a)⋅(x−a)=0}.

Same argument as in R2 works in Rn.

Tangent plane and normal vector

Derivatives of vector fields ​

Essentially everything discussed above for scalar fields extends to vector fields in a predictable way. This is because of the linearity and that we can consider each component of the vector field independently.

Definition (directional derivative)

Let S⊂Rn and F:S→Rm. For any a∈intS and v∈Rn the derivative of the vector field F with respect to v is defined as

DvF(a):=limh→01h(F(a+hv)−F(a)).

Remark

If we use the notation F=(F1,…,Fm), i.e., we write the function using the ``components'' where each Fk is a scalar field, then DvF=(DvF1,…,DvFm).

Definition (differentiable)

We say that F:Rn→Rm is differentiable at a if there exists a linear transformation dfa:Rn→Rm such that, for x∈B(a,r),

F(x)=F(a)+dfa(x−a)+ϵ(x−a),

‖ϵ(x−a)‖=o(‖x−a‖).

Theorem

If F is differentiable at a then F is continuous at a and dfa(v)=DvF(a).

Proof

Same as for the case of scalar fields when f:Rn→R.

Jacobian matrix & the chain rule ​

The relevant differential for higher-dimensional functions is the Jacobian matrix.

Definition (Jacobian matrix)

Suppose that F:R2→R2 and use the notation F(x,y)=(F1(x,y),F2(x,y)). The Jacobian matrix of F at a is defined as

DF(a)=(∂F1∂x(a)∂F1∂y(a)∂F2∂x(a)∂F2∂y(a)).

The Jacobian matrix is defined analogously in any dimension. I.e., if F:Rn→Rm the the Jacobian at a is

DF(a)=(∂1F1(a)∂2F1(a)⋯∂nF1(a)∂1F2(a)∂2F2(a)⋯∂nF2(a)⋮⋮⋮∂1Fm(a)∂2Fm(a)⋯∂nFm(a))

If we choose a basis then any linear transformation Rn→Rm can be written as a m×n matrix. We find that dfa(v)=DF(a)v.

Let S⊂Rn and F:S→Rm. If f is differentiable at a∈S then, for all x∈B(a,r)⊂S,

F(x)=F(a)+DF(a)(x−a)+ϵ(x−a)

where |ϵ(x−a)|=o(‖x−a‖). This is like a Taylor expansion in higher dimensions.

Here we see that in higher dimensions we have a matrix form of the chain rule.

Theorem

Let S⊂Rl, T⊂Rm be open. Let f:S→T and g:T→Rn and define

h=g∘f:S→Rn.

Let a∈S. Suppose that f is differentiable at a and g is differentiable at f(a). Then h is differentiable at a and

Dh(a)=Dg(f(a)) Df(a).

Proof

Let u=f(a+v)−f(a). Since f and g are differentiable,

h(a+v)−h(a)=g(f(a+v))−g(f(a))=Dg(f(a))(f(a+v)−f(a))+ϵg(u)=Dg(f(a))Df(a)v+Dg(f(a))ϵf(v)+ϵg(u).

Example (polar coordinates)

Here we consider polar coordinates and calculate the Jacobian of this transformation. We can write the change of coordinates

(r,θ)↦(rcos⁡θ,rsin⁡θ)

as the function f(r,θ)=(x(r,θ),y(r,θ)) where f:(0,∞)×[0,2π)→R2. We calculate the Jacobian matrix of this transformation

Df(r,θ)=(∂x∂r(r,θ)∂x∂θ(r,θ)∂y∂r(r,θ)∂y∂θ(r,θ))=(cos⁡θ−rsin⁡θsin⁡θrcos⁡θ).

In particular we see that detDf(r,θ)=r, the familiar value used in change of variables with polar coordinated.

Suppose now that we wish to calculate derivatives of h:=g∘f for some g:R2→R. Here we take advantage of the theorem concerning multiplication of Jacobians.

Dh(r,θ)=Dg(f(r,θ)) Df(r,θ)(∂h∂r(r,θ)∂h∂θ(r,θ))=(∂g∂x(f(r,θ))∂g∂y(f(r,θ)))(cos⁡θ−rsin⁡θsin⁡θrcos⁡θ)

In other words, we have shown that

∂h∂r(r,θ)=∂g∂x(rcos⁡θ,rsin⁡θ)cos⁡θ+∂g∂y(rcos⁡θ,rsin⁡θ)sin⁡θ∂h∂θ(r,θ)=−r∂g∂x(rcos⁡θ,rsin⁡θ)sin⁡θ+r∂g∂y(rcos⁡θ,rsin⁡θ)cos⁡θ.

Implicit functions & partial derivatives ​

Just like with derivatives, we can take higher order partial derivatives. For convenience when we want to write ∂∂y∂∂xf(x,y), i.e., differentiate first with respect to x and then with respect to y, we write instead ∂2f∂y∂x(x,y). The analogous notation is used for higher derivatives and any other choice of coordinates.

We first consider the question of when

∂2f∂y∂x(x,y)=?∂2f∂x∂y(x,y).

Example (partial derivative problem)

Let f:R2→R be defined as f(0,0)=0 and, for (x,y)≠(0,0),

f(x,y):=xy(x2−y2)x2+y2.

We calculate that ∂2f∂y∂x(0,0)=−1 but ∂2f∂x∂y(0,0)=1.

Theorem

Let f:S→R be a scalar field such that the partial derivatives ∂f∂x, ∂f∂y and ∂2f∂y∂x exist on an open set S⊂R2 containing x. Further assume that ∂2f∂y∂x is continuous on S. Then the derivative ∂2f∂x∂y(x) exists and

∂2f∂x∂y(x)=∂2f∂y∂x(x).

In many cases we can choose to write a given curve/function either in implicit or explicit form.

ImplicitExplicit
x2−y=0y(x)=x2
x2+y2=1y(x)=±1−x2, |x|≤1
x2−y2−1=0y(x)=±x2−1, |x|≥1
x2+y2−ey−4=0A mess?
x2y4−3=sin⁡(xy)A huge mess?

Given the above observation, the following method of calculating derivatives is sometimes useful. Suppose that some f:R2→R is given and we suppose there exists some y:R→R such that

f(x,y(x))=0 for all x.

Let h(x):=f(x,y(x)) and note that h′(x)=0. Here we are using the idea that h=f∘g where g(x)=(x,y(x)). By the chain rule h′(x) is equal to

(∂f∂x(x,y(x))∂f∂y(x,y(x)))(1y′(x))=0.

Consequently

y′(x)=−∂f∂x(x,y(x))∂f∂y(x,y(x)).