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.

Linearization

In the main text, we discussed linearization of relatively simple dynamical systems, such as a pendulum or a moving car. In this appendix, we provide a more comprehensive and formal treatment of linearization for general nonlinear systems. For the curious and the brave!

General nonlinear dynamical systems

A general dynamical system might consist of multiple coupled differential equations involving input signals u1,,umu_1,\dots,u_m and other signals x1,,xnx_1,\dots,x_n. So it will look something like:

x˙1=f1(x1,,xn,u1,,um)x˙2=f2(x1,,xn,u1,,um)    x˙n=fn(x1,,xn,u1,,um)\begin{aligned} \dot x_1 &= f_1(x_1,\dots,x_n,u_1,\dots,u_m) \\ \dot x_2 &= f_2(x_1,\dots,x_n,u_1,\dots,u_m) \\ &\;\;\vdots\\ \dot x_n &= f_n(x_1,\dots,x_n,u_1,\dots,u_m) \end{aligned}

What about higher derivatives? We can always deal with those by introducing additional variables. For example, consider the equations of motion for a pendulum:

m2θ¨+mgsinθ=Tm\ell^2 \ddot\theta + mg\ell \sin\theta = T

We can let x1=θx_1 = \theta and x2=θ˙x_2 = \dot\theta and u1=Tu_1 = T. Then our equations become:

x˙1=x2x˙2=gsinx1+1m2u1\begin{aligned} \dot x_1 &= x_2 \\ \dot x_2 &= -\tfrac{g}{\ell} \sin x_1 + \tfrac{1}{m\ell^2} u_1 \end{aligned}

We can go a step further, and define x=[x1,,xn]\x = [x_1,\dots,x_n] and u=[u1,,um]\u = [u_1,\dots,u_m], and also let f\f be the vector-valued function [f1,,fn][f_1,\dots,f_n]. Then Eq. (1) collapses neatly to a single vector differential equation that can represent pretty much anything:

x˙=f(x,u)\dot\x = \f(\x,\u)

If we use the constant input u(t)=u0\u(t) = \u_0 and initialize our system at x(0)=x0\x(0) = \x_0, we will have x˙=0\dot x=0, so x\x will not change and the system will remain at x(t)=x0\x(t) = \x_0 for all t0t\geq 0. This is why we call (x0,u0)(\x_0,\u_0) an equilibrium point.

A system will typically have many possible equilibrium points. For example, consider the pendulum of Eq. (2). We can form many possible equilibria:

Linearizing a dynamical system

We can linearize a dynamical system about an equilibrium point in a similar way to how we linearized a multivariable function about a reference point. Start with a general dynamical system (4), pick an equilibrium point (x0,u0)(\x_0,\u_0), and apply the linearization of Eq. (5) to the right-hand side. We have one approximation for each i=1,,ni=1,\dots,n:

x˙ifi(x0,u0)+j=1nfixj0(xjx0j)+k=1mfiuk0(uku0k)\dot x_i \approx f_i(\x_0,\u_0) + \sum_{j=1}^n\left.\frac{\partial f_i}{\partial x_j}\right|_0(x_j-x_{0j}) + \sum_{k=1}^m\left.\frac{\partial f_i}{\partial u_k}\right|_0(u_k-u_{0k})

We can write this as one neat vector equation by defining the Jacobian matrix of partial derivatives with respect to x\x and u\u

Jfx=[f1x1f1xnfnx1fnxn],andJfu=[f1u1f1umfnu1fnum]\J_{\f}^{\x} = \bmat{ \frac{\partial f_1}{\partial x_1} & \cdots & \frac{\partial f_1}{\partial x_n} \\ \vdots & \ddots & \vdots \\ \frac{\partial f_n}{\partial x_1} & \cdots & \frac{\partial f_n}{\partial x_n} },\quad\textsf{and}\quad \J_{\f}^{\u} = \bmat{ \frac{\partial f_1}{\partial u_1} & \cdots & \frac{\partial f_1}{\partial u_m} \\ \vdots & \ddots & \vdots \\ \frac{\partial f_n}{\partial u_1} & \cdots & \frac{\partial f_n}{\partial u_m} }

Then the linearization can be written compactly as

x˙f(x0,u0)+Jfx(x0,u0)(xx0)+Jfu(x0,u0)(uu0)\dot\x \approx \f(\x_0,\u_0) + \J_{\f}^{\x}(\x_0,\u_0) \cdot (\x-\x_0) + \J_{\f}^{\u}(\x_0,\u_0) \cdot (\u-\u_0)

Now define the deviations from the reference as we did before, but now these are going to be small signals rather than being small numbers:

δx(t):=x(t)x0andδu(t):=u(t)u0\bdelta\x(t) := \x(t)-\x_0 \qquad\textsf{and}\qquad \bdelta\u(t) := \u(t)-\u_0

Since x0\x_0 is a constant, we have δx˙=x˙\bdelta\dot\x = \dot\x. Also, we chose (x0,u0)(\x_0,\u_0) to be an equilibrium point, so f(x0,u0)=0\f(\x_0,\u_0)=\bm{0}. Therefore, we can write (7) even more compactly as:

δx˙    Jfx(x0,u0)δx  +  Jfu(x0,u0)δu\boxed{\bdelta\dot\x \;\approx\; \J_{\f}^{\x}(\x_0,\u_0) \cdot \bdelta\x \;+\; \J_{\f}^{\u}(\x_0,\u_0) \cdot \bdelta\u}

Since the Jacobians Jfx(x0,u0)\J_{\f}^{\x}(\x_0,\u_0) and Jfu(x0,u0)\J_{\f}^{\u}(\x_0,\u_0) are evaluated at the (constant) equilibrium point (x0,u0)(\x_0,\u_0), they are just matrices of numbers. In other words, The approximation of Eq. (9) is an LTI system!

Example: pendulum on a cart

Consider an inverted pendulum on a cart. We will not derive the equations of motion here since our focus is on linearization; if you’re interested, there are several nice derivations available online (here and here, for example).

The equations of motion are:

(m1+m2)x¨m2θ¨cosθ+m2θ˙2sinθ=fθ¨x¨cosθgsinθ=0\begin{aligned} (m_1+m_2)\,\ddot x - m_2\ell \,\ddot\theta \cos\theta + m_2\ell \,\dot\theta^2 \sin\theta &= f \\ \ell \,\ddot\theta - \ddot x \cos\theta - g \sin\theta &= 0 \end{aligned}

We would like to linearize these equations about the equilibrium point where the pendulum is perfectly upright (θ0=0\theta_0=0) and the cart is stationary (x˙0=0\dot x_0=0, θ˙0=0\dot\theta_0=0), with no external force applied (f0=0f_0=0).

We begin by putting our equations into the standard form x˙=f(x,u)\dot\x = \f(\x,\u). We choose our state variables as

x=[x1x2x3x4]=[xx˙θθ˙],u=[u1]=[f].\x = \bmat{ x_1 \\ x_2 \\ x_3 \\ x_4 } = \bmat{ x \\ \dot x \\ \theta \\ \dot\theta },\quad \u = \bmat{ u_1 } = \bmat{ f }.

Substituting these definitions into the equations of motion and rearranging, we obtain:

x˙1=x2(m1+m2)x˙2m2x˙4cosx3+m2x42sinx3=u1x˙3=x4x˙4x˙2cosx3gsinx3=0\begin{aligned} \dot x_1 &= x_2 \\ (m_1+m_2)\,\dot x_2 - m_2\ell \,\dot x_4 \cos x_3 + m_2\ell \,x_4^2 \sin x_3 &= u_1 \\ \dot x_3 &= x_4 \\ \ell \,\dot x_4 - \dot x_2 \cos x_3 - g \sin x_3 &= 0 \end{aligned}

Written in matrix form to expose the state derivatives, we obtain:

[10000m1+m20m2cosx300100cosx30][x˙1x˙2x˙3x˙4]=[x2m2x42sinx3+u1x4gsinx3]\bmat{1 & 0 & 0 & 0 \\ 0 & m_1+m_2 & 0 & -m_2\ell \cos x_3 \\ 0 & 0 & 1 & 0 \\ 0 & -\cos x_3 & 0 & \ell } \bmat{\dot x_1 \\ \dot x_2 \\ \dot x_3 \\ \dot x_4} = \bmat{ x_2 \\ m_2\ell x_4^2 \sin x_3 + u_1 \\ x_4 \\ g \sin x_3 }

Inverting the matrix on the left and multiplying both sides by the inverse, we can isolate the derivative terms x˙i\dot x_i.

[x˙1x˙2x˙3x˙4]=[100001m1+m2sin2x30m2cosx3m1+m2sin2x300100cosx3(m1+m2sin2x3)01][x2m2x42sinx3+u1x4gsinx3]\bmat{\dot x_1 \\ \dot x_2 \\ \dot x_3 \\ \dot x_4} = \bmat{1 & 0 & 0 & 0 \\ 0 & \frac{1}{m_1+m_2 \sin^2 x_3} & 0 & \frac{m_2\cos x_3}{m_1+m_2 \sin^2 x_3} \\ 0 & 0 & 1 & 0 \\ 0 & \frac{\cos x_3}{\ell (m_1+m_2 \sin^2 x_3)} & 0 & \frac{1}{\ell} } \bmat{ x_2 \\ m_2\ell x_4^2 \sin x_3 + u_1 \\ x_4 \\ g \sin x_3 }

Multliplying out the right-hand side, we obtain the nonlinear equations of motion in the standard form of (4):

x˙1=x2x˙2=m2sin(x3)x42+12m2gsin(2x3)+u1m1+m2sin2(x3)x˙3=x4x˙4=12m2sin(2x3)x42+(m1+m2)gsin(x3)cos(x3)u1(m1+m2sin2(x3))\begin{aligned} \dot x_1 &= x_2 \\ \dot x_2 &= \frac{m_2 \ell \sin (x_3) \, x_4^2 + \tfrac{1}{2}m_2 g \sin (2x_3) + u_1}{m_1 + m_2 \sin^2 (x_3)} \\ \dot x_3 &= x_4 \\ \dot x_4 &= \frac{-\tfrac{1}{2}m_2 \ell \sin (2x_3) \, x_4^2 + (m_1 + m_2) g \sin (x_3) - \cos (x_3)u_1 }{\ell (m_1 + m_2 \sin^2 (x_3))} \end{aligned}

Let’s compute the Jacobian matrices Jfx\J_{\f}^{\x} and Jfu\J_{\f}^{\u} evaluated at the equilibrium point (x0,u0)=0(\x_0,\u_0) = 0. We will show one sample calculation. To compute the (2,3)(2,3) entry of Jfx\J_{\f}^{\x}, we need to compute f2x3\frac{\partial f_2}{\partial x_3} and evaluate it at the equilibrium:

f2x30=x3(m2sin(x3)x42+12m2gsin(2x3)+u1m1+m2sin2(x3))0=m2x42cos(x3)+m2gcos(2x3)m1+m2sin2(x3)(m2sin(x3)x42+12m2gsin(2x3)+u1)2m2sin(x3)cos(x3)(m1+m2sin2(x3))20=m2gm1\begin{aligned} \left.\frac{\partial f_2}{\partial x_3}\right|_0 &= \left.\frac{\partial}{\partial x_3} \left( \frac{m_2 \ell \sin (x_3) \, x_4^2 + \tfrac{1}{2}m_2 g \sin (2x_3) + u_1}{m_1 + m_2 \sin^2 (x_3)} \right)\right|_0 \\ &= \left.\frac{m_2 \ell x_4^2 \cos (x_3) + m_2 g \cos (2x_3)}{m_1 + m_2 \sin^2 (x_3)} - \frac{(m_2 \ell \sin (x_3) \, x_4^2 + \tfrac{1}{2}m_2 g \sin (2x_3) + u_1) \cdot 2 m_2 \sin (x_3) \cos (x_3)}{(m_1 + m_2 \sin^2 (x_3))^2}\right|_0 \\ &= \frac{m_2 g}{m_1} \end{aligned}

Proceeding in a similar manner for all entries, we obtain the following Jacobian matrices at the equilibrium point:

Jfx(x0,u0)=[010000m2gm10000100(m1+m2)gm10],Jfu(x0,u0)=[01m101m1]\J_{\f}^{\x}(\x_0,\u_0) = \bmat{0 & 1 & 0 & 0 \\ 0 & 0 & \frac{m_2 g}{m_1} & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & \frac{(m_1 + m_2) g}{\ell m_1} & 0 },\quad \J_{\f}^{\u}(\x_0,\u_0) = \bmat{0 \\ \frac{1}{m_1} \\ 0 \\ -\frac{1}{\ell m_1} }

Finally, substituting these Jacobians into Eq. (9), we obtain the linearized equations of motion for the inverted pendulum on a cart about the upright equilibrium:

δx˙=[010000m2gm10000100(m1+m2)gm10]δx+[01m101m1]δu\boxed{\bdelta\dot\x = \bmat{0 & 1 & 0 & 0 \\ 0 & 0 & \frac{m_2 g}{m_1} & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & \frac{(m_1 + m_2) g}{\ell m_1} & 0 } \bdelta\x + \bmat{0 \\ \frac{1}{m_1} \\ 0 \\ -\frac{1}{\ell m_1} } \bdelta \u}

If we want, we can return this to our non-vector coordinates:

δx¨=m2gm1δθ+1m1δfδθ¨=(m1+m2)gm1δθ1m1δf\boxed{\begin{aligned} \delta\ddot x &= \tfrac{m_2 g}{m_1} \delta \theta + \tfrac{1}{m_1} \delta f \\ \delta\ddot\theta &= \tfrac{(m_1 + m_2) g}{\ell m_1} \delta \theta - \tfrac{1}{\ell m_1} \delta f \end{aligned}}

Linearizing about a trajectory

So far, we only discussed linearization about an equilibrium point, which leads to an LTI approximation. It is also possible to linearize about a time-varying trajectory (x0(t),u0(t))(\x_0(t),\u_0(t)). This is useful for control systems where we want to follow a desired trajectory rather than stay at a fixed point.

In this case, we must ensure that the trajectory is feasible, meaning that it satisfies the system dynamics:

x˙0(t)=f(x0(t),u0(t))\dot\x_0(t) = \f(\x_0(t),\u_0(t))

With this in place, we can linearize the right-hand side of (4) about the time-varying trajectory (x0(t),u0(t))(\x_0(t),\u_0(t)) using the same approach as before. We obtain:

x˙f(x0,u0)+Jfx(x0,u0)δx+Jfu(x0,u0)δu\dot\x \approx \f(\x_0,\u_0) + \J_{\f}^{\x}(\x_0,\u_0) \cdot \bdelta\x + \J_{\f}^{\u}(\x_0,\u_0) \cdot \bdelta\u

Before we had δx(t)=x(t)x0\bdelta\x(t) = \x(t)-\x_0 (constant reference), and therefore δx˙(t)=x˙(t)\bdelta\dot{\x}(t) = \dot\x(t), but now x0\x_0 is time-varying, so we have to be careful when taking derivatives. We now have: δx(t)=x(t)x0(t)\bdelta\x(t) = \x(t)-\x_0(t) (time-varying reference), so δx˙(t)=x˙(t)x˙0(t)\bdelta\dot{\x}(t) = \dot\x(t) - \dot\x_0(t). Substituting this into (22) and using (21), we obtain:

δx˙    Jfx(x0(t),u0(t))δx  +  Jfu(x0(t),u0(t))δu\boxed{\bdelta\dot\x \;\approx\; \J_{\f}^{\x}(\x_0(t),\u_0(t)) \cdot \bdelta\x \;+\; \J_{\f}^{\u}(\x_0(t),\u_0(t)) \cdot \bdelta\u}

Although this looks very similar to (9), there is a key difference: we are now evaluating the Jacobians at the time-varying trajectory (x0(t),u0(t))(\x_0(t),\u_0(t)) rather than at the fixed equilibrium point (x0,u0)(\x_0,\u_0). So the Jacobians Jfx(x0(t),u0(t))\J_{\f}^{\x}(\x_0(t),\u_0(t)) and Jfu(x0(t),u0(t))\J_{\f}^{\u}(\x_0(t),\u_0(t)) will be time-varying matrices, and the resulting linearized system will be a linear time-varying (LTV) system rather than an LTI system.