Mehmet Emre Tiryaki
Back to Notes

Multivariable Calculus

Gradient and Hessian

For f:Rn→Rf : \mathbb{R}^n \to \mathbb{R},

∇xf=[∂f∂x1⋮∂f∂xn]∈Rn,∇x2f=[∂2f∂x12⋯∂2f∂x1∂xn⋮⋱⋮∂2f∂xn∂x1⋯∂2f∂xn2]∈Rn×n\nabla_x f = \begin{bmatrix} \frac{\partial f}{\partial x_1} \\ \vdots \\ \frac{\partial f}{\partial x_n} \end{bmatrix} \in \mathbb{R}^n, \qquad \nabla_x^2 f = \begin{bmatrix} \frac{\partial^2 f}{\partial x_1^2} & \cdots & \frac{\partial^2 f}{\partial x_1 \partial x_n} \\ \vdots & \ddots & \vdots \\ \frac{\partial^2 f}{\partial x_n \partial x_1} & \cdots & \frac{\partial^2 f}{\partial x_n^2} \end{bmatrix} \in \mathbb{R}^{n \times n}

Jacobian

For g:Rn→Rmg : \mathbb{R}^n \to \mathbb{R}^m,

g(x1,…,xn)=[g1(x1,…,xn)⋮gm(x1,…,xn)]g(x_1, \ldots, x_n) = \begin{bmatrix} g_1(x_1, \ldots, x_n) \\ \vdots \\ g_m(x_1, \ldots, x_n) \end{bmatrix}

for each gi:Rn→Rg_i : \mathbb{R}^n \to \mathbb{R}. Then the analogue of a derivative is the Jacobian matrix

Jg(x)=∇xg(x)=[∇g1(x)T⋮∇gm(x)T]=[∂g1∂x1⋯∂g1∂xn⋮⋱⋮∂gm∂x1⋯∂gm∂xn]∈Rm×nJ_g(x) = \nabla_x g(x) = \begin{bmatrix} \nabla g_1(x)^T \\ \vdots \\ \nabla g_m(x)^T \end{bmatrix} = \begin{bmatrix} \frac{\partial g_1}{\partial x_1} & \cdots & \frac{\partial g_1}{\partial x_n} \\ \vdots & \ddots & \vdots \\ \frac{\partial g_m}{\partial x_1} & \cdots & \frac{\partial g_m}{\partial x_n} \end{bmatrix} \in \mathbb{R}^{m \times n}

Integrals

The standard notation for an integral over x⃗∈Rn\vec{x} \in \mathbb{R}^n is

∫f(…) dx⃗=∫∫⋯∫f(…) dx1 dx2…dxn\int f(\ldots) \, d\vec{x} = \int \int \cdots \int f(\ldots) \, dx_1 \, dx_2 \ldots dx_n

Supremum and Infimum

For f:V→Ff : V \to \mathbb{F} with an ordering on F\mathbb{F}, sup⁡f(x)=xsup⁡\sup f(x) = x_{\sup} such that

  • xsup⁡≥f(x)x_{\sup} \ge f(x) for all x∈Vx \in V, i.e. xsup⁡x_{\sup} is an upper bound,
  • xsup⁡≤ux_{\sup} \le u for every upper bound uu.

Note xsup⁡∈Fx_{\sup} \in \mathbb{F} but it is not necessarily in the range of ff. If ff has a max, it is the supremum. In R\mathbb{R}, this is the concept of least upper bound.

And inf⁡f(x)=xinf⁡\inf f(x) = x_{\inf} such that xinf⁡≤f(x)x_{\inf} \le f(x) for all xx, and xinf⁡≥ℓx_{\inf} \ge \ell for every lower bound ℓ\ell. In R\mathbb{R} this is the greatest lower bound. If a min exists, it is the infimum.

Taylor Expansions

For f:Rn→Rf : \mathbb{R}^n \to \mathbb{R}, we can approximate around a point x0x_0 using its Taylor series.

First-order approximation:

f(x)≈f(x0)+∇xf(x0)T(x−x0)f(x) \approx f(x_0) + \nabla_x f(x_0)^T (x - x_0)

Second-order approximation:

f(x)≈f(x0)+∇xf(x0)T(x−x0)+12(x−x0)T∇2f(x0)(x−x0)f(x) \approx f(x_0) + \nabla_x f(x_0)^T (x - x_0) + \frac{1}{2}(x - x_0)^T \nabla^2 f(x_0)(x - x_0)

The notation O(hn)O(h^n) is used to account for the dropped terms in the infinite Taylor series. E.g. let h=x−x0h = x - x_0,

f(x0+h)=f(x0)+∇f(x0)Th+O(∥h∥2)f(x_0 + h) = f(x_0) + \nabla f(x_0)^T h + O(\|h\|^2)

the error term (dropped terms) shrinks as fast as ∥h∥2\|h\|^2.

Calculus with Matrices

Linear form For a,x∈Rna, x \in \mathbb{R}^n, f(x)=aTxf(x) = a^T x,

∇xf=a,∇x2f=0,∇x(x)=In\nabla_x f = a, \qquad \nabla_x^2 f = 0, \qquad \nabla_x(x) = I_n

Quadratic form For x∈Rnx \in \mathbb{R}^n, A∈Rn×nA \in \mathbb{R}^{n \times n}, f(x)=xTAxf(x) = x^T A x,

∇xf=(A+AT)x,∇x2f=A+AT\nabla_x f = (A + A^T)x, \qquad \nabla_x^2 f = A + A^T

Euclidean norm f(x)=∥x∥22=xTxf(x) = \|x\|_2^2 = x^T x,

∇xf=2x,∇x2f=2In\nabla_x f = 2x, \qquad \nabla_x^2 f = 2I_n

Least squares For A∈Rm×nA \in \mathbb{R}^{m \times n}, x∈Rnx \in \mathbb{R}^n, b∈Rmb \in \mathbb{R}^m,

f(x)=∥Ax−b∥22=(Ax−b)T(Ax−b)=xTATAx−2bTAx+bTbf(x) = \|Ax - b\|_2^2 = (Ax - b)^T(Ax - b) = x^T A^T A x - 2b^T A x + b^T b ∇xf=2AT(Ax−b),∇x2f=2ATA\nabla_x f = 2A^T(Ax - b), \qquad \nabla_x^2 f = 2A^T A

Convexity

A function f:Rn→Rf : \mathbb{R}^n \to \mathbb{R} is convex if

f(λx+(1−λ)y)≤λf(x)+(1−λ)f(y),∀x,y∈Rn, ∀λ∈[0,1]f(\lambda x + (1 - \lambda)y) \le \lambda f(x) + (1 - \lambda) f(y), \quad \forall x, y \in \mathbb{R}^n,\ \forall \lambda \in [0,1]

Intuitively, the line segment between any 2 points on the graph of ff lies above or on the graph. Concavity is the reverse, where the segment lies below.

For twice differentiable ff, an equivalent statement is

  • ff is convex iff ∇2f\nabla^2 f is positive semidefinite everywhere,
  • ff is concave iff ∇2f\nabla^2 f is negative semidefinite everywhere.