Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

0.2 Calculus and Linear Algebra

Calculus describes rates, sensitivities, and accumulated quantities. Linear algebra provides the language for systems with many states, inputs, outputs, and design variables. Together, they support nearly every CCD formulation and numerical method in this course.

Derivatives and partial derivatives

Single-variable derivatives

The derivative of a scalar function f(x)f(x) is written

dfdx.\frac{df}{dx}.

It measures the rate at which ff changes when xx changes. In optimization, a derivative indicates how an objective or constraint responds to a small adjustment in a decision variable.

If

f(x)=x2,f(x)=x^2,

then

dfdx=2x.\frac{df}{dx}=2x.

The second derivative,

d2fdx2,\frac{d^2f}{dx^2},

measures how the slope changes and provides information about curvature.

Partial derivatives

When a function depends on several variables, a partial derivative describes its sensitivity to one variable while the others are held fixed:

fxi.\frac{\partial f}{\partial x_i}.

For

J(k,c)=k2+2c2kc,J(k,c)=k^2+2c^2-kc,

the partial derivatives are

Jk=2kc,Jc=4ck.\frac{\partial J}{\partial k}=2k-c, \qquad \frac{\partial J}{\partial c}=4c-k.

Gradient

The gradient collects the first partial derivatives of a scalar function into a vector:

J(x)=[Jx1Jx2Jxn].\nabla J(\mathbf{x})= \begin{bmatrix} \dfrac{\partial J}{\partial x_1}\\ \dfrac{\partial J}{\partial x_2}\\ \vdots\\ \dfrac{\partial J}{\partial x_n} \end{bmatrix}.

For the function J(k,c)J(k,c),

J(k,c)=[2kc4ck].\nabla J(k,c)= \begin{bmatrix} 2k-c\\ 4c-k \end{bmatrix}.
A derivative gives a single-variable slope, while a gradient collects partial derivatives and points toward steepest increase.

Derivatives and gradients provide the change information used by many optimization algorithms.

Chain rule

If one variable depends on another,

z=f(y),y=g(x),z=f(y),\qquad y=g(x),

the chain rule propagates derivatives through the nested relationship:

dzdx=dzdydydx.\frac{dz}{dx}=\frac{dz}{dy}\frac{dy}{dx}.

This idea is fundamental to sensitivity analysis and automatic differentiation.

Jacobian and Hessian

For a vector-valued function

r(x)=[r1(x)r2(x)rm(x)],\mathbf{r}(\mathbf{x})= \begin{bmatrix} r_1(\mathbf{x})\\ r_2(\mathbf{x})\\ \vdots\\ r_m(\mathbf{x}) \end{bmatrix},

the Jacobian is the matrix of first derivatives:

rx=[r1x1r1xnrmx1rmxn].\frac{\partial\mathbf{r}}{\partial\mathbf{x}}= \begin{bmatrix} \dfrac{\partial r_1}{\partial x_1} & \cdots & \dfrac{\partial r_1}{\partial x_n}\\ \vdots & \ddots & \vdots\\ \dfrac{\partial r_m}{\partial x_1} & \cdots & \dfrac{\partial r_m}{\partial x_n} \end{bmatrix}.

The Hessian of a scalar function is the matrix of its second partial derivatives. Jacobians describe the local sensitivity of vector equations; Hessians describe the local curvature of scalar objectives or constraints.

Example: gradient of a design objective

Let

J(m,k)=m2+0.5k2mk.J(m,k)=m^2+0.5k^2-mk.

Then

Jm=2mk,Jk=km,\frac{\partial J}{\partial m}=2m-k, \qquad \frac{\partial J}{\partial k}=k-m,

so

J(m,k)=[2mkkm].\nabla J(m,k)= \begin{bmatrix} 2m-k\\ k-m \end{bmatrix}.

This calculation is the basic language of gradient-based optimization.

Integration and numerical integration

Definite integrals as accumulated quantities

A definite integral accumulates a quantity over an interval:

t0tfq(t)dt.\int_{t_0}^{t_f}q(t)\,dt.

In engineering, integrals can represent accumulated energy, work, fuel, tracking error, or control effort. For example,

J=0Tu(t)2dtJ=\int_0^T u(t)^2\,dt

is a common measure of control effort.

A continuous curve and sampled values illustrate an integral and its numerical approximation.

A definite integral measures accumulated area; numerical methods approximate it using sampled values.

Numerical integration

When time is discretized at t0,t1,,tNt_0,t_1,\ldots,t_N, a left-rectangle approximation is

t0tfq(t)dti=0N1qiΔti,\int_{t_0}^{t_f}q(t)\,dt \approx \sum_{i=0}^{N-1}q_i\Delta t_i,

where qiq(ti)q_i\approx q(t_i) and Δti=ti+1ti\Delta t_i=t_{i+1}-t_i.

The trapezoidal rule uses both endpoints of each interval:

t0tfq(t)dti=0N1Δti2(qi+qi+1).\int_{t_0}^{t_f}q(t)\,dt \approx \sum_{i=0}^{N-1}\frac{\Delta t_i}{2}(q_i+q_{i+1}).

For the control-effort objective,

J=0Tu(t)2dt,J=\int_0^T u(t)^2\,dt,

the trapezoidal approximation is

Ji=0N1Δti2(ui2+ui+12).J\approx \sum_{i=0}^{N-1}\frac{\Delta t_i}{2} \left(u_i^2+u_{i+1}^2\right).

This form appears later in direct-transcription methods.

Linear algebra

Vectors, matrices, and dimensions

A vector is an ordered list of numbers; a matrix is a rectangular array:

x=[x1x2x3],A=[1023].\mathbf{x}= \begin{bmatrix} x_1\\x_2\\x_3 \end{bmatrix}, \qquad A= \begin{bmatrix} 1&0\\2&3 \end{bmatrix}.

If ARm×nA\in\mathbb{R}^{m\times n}, then AA has mm rows and nn columns. The product AxA\mathbf{x} is defined only when the number of columns in AA equals the number of components in x\mathbf{x}.

Important operations include vector and matrix addition, scalar multiplication, matrix multiplication, transpose ATA^T, and—when it exists—the inverse A1A^{-1}.

Identity matrices and linear systems

The identity matrix satisfies

Ix=x.I\mathbf{x}=\mathbf{x}.

A linear system has the form

Ax=b.A\mathbf{x}=\mathbf{b}.

If AA is square and nonsingular, the mathematical solution can be written x=A1b\mathbf{x}=A^{-1}\mathbf{b}. In computation, however, one normally uses a linear-system solver rather than forming the inverse explicitly.

Norms

A norm measures vector size. The Euclidean norm is

x2=x12+x22++xn2.\|\mathbf{x}\|_2=\sqrt{x_1^2+x_2^2+\cdots+x_n^2}.

Norms appear in convergence tests, regularization terms, error measures, and engineering-performance metrics.

Eigenvalues and eigenvectors

An eigenvalue–eigenvector pair satisfies

Av=λv.A\mathbf{v}=\lambda\mathbf{v}.

In state-space models, eigenvalues help characterize dynamic behavior and stability.

Positive definiteness

A symmetric matrix QQ is positive definite if

zTQz>0for every nonzero z.\mathbf{z}^{T}Q\mathbf{z}>0 \qquad\text{for every nonzero }\mathbf{z}.

Positive-definite matrices occur frequently in quadratic objectives and Lyapunov analysis.

Activity 0.1: Composite Engineering Functions, Gradients, and Hessians

Activity 0.2: Numerical Integration and Observed Convergence Order

Activity 0.3: Linear Algebra, Modal Coordinates, and Positive Definiteness