TactivergeLite

Lite / Textbooks / Applied Engineering Mathematics / Chapter 3

3. Linearisation, Jacobians and Newton's method

Version 1 · Technically checked (automated checks only) · 4 source lessons · Full interactive version

Introduction

Most real systems are nonlinear, but near any operating point they behave almost linearly. This chapter turns that idea into tools: a matrix as a linear map, the Jacobian as the best linear map at a point, linearised models whose eigenvalues reveal local behaviour, and Newton's method, which solves nonlinear equations by repeatedly solving the linear approximation.

Figure 3.1. Riding the tangent to √2 (described in words)

The curve f(x) = x² − 2 with tangent lines. Starting at x0 = 2, the first tangent meets the axis at x1 = 1.5, the next at x2 = 1.41667 and then x3 = 1.41422, already within 0.00002 of √2 = 1.41421. The number of correct digits roughly doubles each step.

Explanation

Built from 4 School lessons. Each part is the lesson's own explanation.

3.1 Rotation, shear, stretch and projection

Every 2×2 matrix is a picture. Can you guess what [[1, 1], [0, 1]] does to a square before you calculate anything?

Columns are images of the basis

A·(x, y) = x·A(î) + y·A(ĵ). So column 1 is A(î) and column 2 is A(ĵ). Linear maps keep the origin fixed, keep lines straight and keep evenly spaced grid lines evenly spaced.

A catalogue

Rotation by θ: [[cos θ, −sin θ], [sin θ, cos θ]], det 1. Shear: [[1, k], [0, 1]], det 1. Stretch: [[s₁, 0], [0, s₂]], det s₁s₂. Reflection in the x-axis: [[1, 0], [0, −1]], det −1. Projection onto the x-axis: [[1, 0], [0, 0]], det 0.

Projections

A projection P drops each vector onto a subspace. Doing it twice changes nothing more, so P² = P. It squashes a direction to zero, so det P = 0 and there is no inverse: from the shadow you cannot recover the object. Projection onto a unit vector u is P = uuᵀ, which reappears in least squares.

Common mix-ups

Open the Lite lesson: Rotation, shear, stretch and projection

3.2 Module check: the Jacobian as a linear map

Near any pose, a robot arm behaves like a matrix. What can that matrix tell you about where the arm can and cannot move?

Question → method → evidence

Question: at a given pose, which hand motions are possible and how much joint motion do they need? Method: linearise to J, then treat Δp = J·Δθ as a linear system. Evidence: solve for Δθ, compare the predicted hand motion with the exact forward kinematics, and examine det J and the columns of J.

Columns tell the story

Column 1 of J is the hand velocity from turning joint 1 alone; column 2 from joint 2 alone. Their span is the set of achievable hand velocities. If the columns become parallel, the span collapses to a line, exactly as in week 1's column picture.

Near-singular is already bad

Close to a singularity, det J is small and J⁻¹ has huge entries: a modest hand step demands enormous joint speeds, and sensor noise in θ is amplified. Controllers use damped least squares or avoid such poses. This links straight to conditioning in week 5.

Derivation: The two-link Jacobian
  1. Hand position: x = L₁cos θ₁ + L₂cos(θ₁ + θ₂), y = L₁sin θ₁ + L₂sin(θ₁ + θ₂).

  2. Small changes: Δx ≈ (∂x/∂θ₁)Δθ₁ + (∂x/∂θ₂)Δθ₂, and the same for y. In matrix form Δp ≈ J·Δθ.

  3. J = [[−L₁sin θ₁ − L₂sin(θ₁ + θ₂), −L₂sin(θ₁ + θ₂)], [L₁cos θ₁ + L₂cos(θ₁ + θ₂), L₂cos(θ₁ + θ₂)]].

  4. det J = L₁L₂[sin(θ₁ + θ₂)cos θ₁ − cos(θ₁ + θ₂)sin θ₁] = L₁L₂ sin θ₂.

  5. Where det J ≠ 0, Δθ = J⁻¹Δp gives the joint step for a desired hand step. Where det J = 0, J has rank 1 and some Δp cannot be produced.

Common mix-ups

Open the Lite lesson: Module check: the Jacobian as a linear map

3.3 Linearising nonlinear models

A pendulum hanging down is stable; balanced upright it falls. One Jacobian matrix explains both. How?

The method

  1. Find equilibria by solving f(x*) = 0. 2. Compute the Jacobian J = ∂f/∂x. 3. Evaluate it at each equilibrium. 4. Classify with the eigenvalues (week 6). If no eigenvalue has zero real part, the nonlinear system behaves like its linearisation close to that point (the Hartman–Grobman theorem).

Validity

The linear model is accurate only for small deviations. For the pendulum, sin θ ≈ θ is within 1% for |θ| below about 14°. A centre in the linearisation (zero real parts) is inconclusive: the nonlinear terms decide. Always state the range over which you trust the linear model.

Why controllers love it

Linearise a balancing robot about upright, design a controller that moves the saddle's unstable eigenvalue into the left half-plane, then test the controller on the full nonlinear model to see how big a push it survives.

Derivation: Linearising the pendulum
  1. States θ and ω = θ′: θ′ = ω, ω′ = −(g/L) sin θ − bω. This is x′ = f(x), nonlinear because of sin θ.

  2. Equilibria: f = 0 needs ω = 0 and sin θ = 0, so θ = 0 (hanging) or θ = π (upright).

  3. Near an equilibrium x, write x = x + δ. Taylor: δ′ ≈ J(x*)·δ with J the Jacobian, Jᵢⱼ = ∂fᵢ/∂xⱼ.

  4. Here J = [[0, 1], [−(g/L) cos θ, −b]].

  5. θ = 0: J = [[0, 1], [−g/L, −b]], tr = −b < 0, det = g/L > 0: a stable spiral (for small b). θ = π: J = [[0, 1], [g/L, −b]], det = −g/L < 0: a saddle, unstable.

Common mix-ups

Open the Lite lesson: Linearising nonlinear models

3.4 Newton's method: ride the tangent

Bisection needs about 20 steps for six decimal places. Newton's method often needs four. What's the catch?

Fast when close

From a good starting guess, Newton's method converges quadratically: the number of correct digits roughly doubles each step. For x² − 2 from 1, four steps give about 12 correct digits, where bisection on [0, 2] would need about 40.

It needs the derivative

You must supply f′(x), worked out by hand or estimated numerically. If f′(x_k) = 0 the tangent is flat and never crosses zero: the method can't continue. Guard against it and cap the number of steps.

It can run away

If the start is far from the root, or the function flattens out, the tangent can throw the next guess further away. arctan x from x₀ = 1.5 diverges. Engineers often bracket first with bisection, then switch to Newton once close, or reject any Newton step that leaves the bracket.

Derivation: Where the Newton update comes from
  1. Near a guess x_k, replace the curve by its tangent line: y ≈ f(x_k) + f′(x_k)·(x − x_k).

  2. Find where that line crosses zero: 0 = f(x_k) + f′(x_k)·(x − x_k).

  3. Solve for x: x_{k+1} = x_k − f(x_k)/f′(x_k). This needs f′(x_k) ≠ 0.

  4. For f(x) = x² − c, f′(x) = 2x, so x_{k+1} = x_k − (x_k² − c)/(2x_k) = (x_k + c/x_k)/2: average the guess with c divided by the guess.

  5. Near a simple root the error obeys e_{k+1} ≈ C·e_k², so an error of 10⁻³ becomes about 10⁻⁶, then 10⁻¹². That's quadratic convergence.

Common mix-ups

Open the Lite lesson: Newton's method: ride the tangent

Worked examples

Rotation, shear, stretch and projection: example 1

Write the matrix that rotates by 90° anticlockwise and check it sends (1, 0) to (0, 1).

Solution

θ = 90°: [[0, −1], [1, 0]]. First column (0, 1) is where î lands. ✓ Second column (−1, 0): ĵ goes to −î, also correct.

Rotation, shear, stretch and projection: example 2

Find the matrix projecting onto the line through u = (1, 1)/√2.

Solution

P = uuᵀ = ½[[1, 1], [1, 1]]. Check P² = ¼[[2, 2], [2, 2]] = P. ✓ P(1, 0) = (0.5, 0.5), the foot of the perpendicular.

Module check: the Jacobian as a linear map: example 1

L₁ = L₂ = 1, θ₁ = 0, θ₂ = 90°. Find J and the joint step for Δp = (0, 0.01).

Solution

sin(θ₁ + θ₂) = 1, cos(θ₁ + θ₂) = 0, sin θ₁ = 0, cos θ₁ = 1. J = [[−1, −1], [1, 0]], det J = 1. J⁻¹ = [[0, 1], [−1, −1]]. Δθ = J⁻¹(0, 0.01) = (0.01, −0.01) rad.

Linearising nonlinear models: example 1

Find and classify the equilibria of x′ = y, y′ = x − x³.

Solution

Equilibria: y = 0 and x(1 − x²) = 0, so x = 0, ±1. J = [[0, 1], [1 − 3x², 0]]. At x = 0: det = −1, a saddle. At x = ±1: J = [[0, 1], [−2, 0]], tr = 0, det = 2: a linear centre, inconclusive in general; here energy conservation shows they are genuine centres.

Newton's method: ride the tangent: example 1

Newton's method with a step limit and a flat-slope guard, compared with the true root.

Solution

import math


def newton(f, df, x, tol=1e-12, max_steps=20):
    """Return (estimate, steps). Raises ValueError on a flat tangent or no convergence."""
    for step in range(1, max_steps + 1):
        slope = df(x)
        if slope == 0:
            raise ValueError(f"flat tangent at x = {x}")
        x_new = x - f(x) / slope
        if abs(x_new - x) < tol:
            return x_new, step
        x = x_new
    raise ValueError("did not converge")


root, steps = newton(lambda x: x * x - 2, lambda x: 2 * x, 1.0)
print(root, steps, abs(root - math.sqrt(2)) < 1e-15)   # 1.414213562373095 6 True

try:
    newton(math.atan, lambda x: 1 / (1 + x * x), 1.5)
except (ValueError, OverflowError) as err:
    print("arctan from 1.5:", type(err).__name__)

Interactive figures, in words

Figure 3.2 from Linearising nonlinear models

In 'Any 2×2 matrix' mode, enter the hanging-down linearisation [[0, 1], [−4, −0.5]], then the upright one [[0, 1], [4, −0.5]] (g/L = 4, b = 0.5). Compare the portraits and the classification.

In general mode the phase portrait is set to the pendulum's linearised matrices. Text reports trace, determinant, eigenvalues and the equilibrium type: stable spiral for hanging, saddle for upright.

Figure 3.3 from Newton's method: ride the tangent

Choose x² − 2 and Newton. Step four times and compare the error column with bisection's. Then choose arctan x (Newton trap): start at 1.0, then at 1.5. What does the tangent do from 1.5?

The stepper shows Newton's method on x² − 2 from 1: the orange tangent at each guess meets the axis at the next guess, 1.5, 1.41667, 1.4142157, with the error column shrinking from 10⁻¹ to 10⁻³ to 10⁻⁶ to 10⁻¹². For arctan x from 1.5, each tangent lands further away and the readout reports divergence.

The interactive versions are in the full chapter.

Laboratory

These run in a browser on the full site (they need a faster connection). Simulations are simplified educational models.

Practice

Each question links to its Lite lesson, where your answer is checked on our server and a wrong answer gets a hint. Answers are never sent to your device.

  1. A sends î to (2, 0) and ĵ to (0, 3). What is A?
    Answer it in “Rotation, shear, stretch and projection”
  2. P projects onto a line. What is P³?
    Answer it in “Rotation, shear, stretch and projection”
  3. At θ₂ = 180° (folded back), the rank of J is…
    Answer it in “Module check: the Jacobian as a linear map”
  4. Why do controllers avoid poses where det J is small but not zero?
    Answer it in “Module check: the Jacobian as a linear map”
  5. Hanging pendulum, linearised: J = [[0, 1], [−9, −0.6]]. Classify.
    Answer it in “Linearising nonlinear models”
  6. For which angle is sin θ ≈ θ least trustworthy?
    Answer it in “Linearising nonlinear models”
  7. Newton's method on f(x) = x² − 4 starts at x₀ = 0. What happens?
    Answer it in “Newton's method: ride the tangent”
  8. Which statement compares bisection and Newton fairly?
    Answer it in “Newton's method: ride the tangent”

Engineering applications

Robot arm control

The Jacobian maps small joint movements to small tip movements. Controllers invert it to steer the tip, and avoid poses where its determinant is near zero because joint speeds would blow up.

Circuit operating points

Simulators find the operating point of circuits with diodes and transistors by Newton's method: linearise each device, solve the linear network, repeat until the voltages stop changing.

Watch (optional)

Streaming video uses a lot of data. Everything you need is in the text.

Summary

Glossary

Derivative (rate of change)
The derivative of a quantity is its instantaneous rate of change: the gradient of its graph at a point. Field Guide
2D rotation matrix
A 2D rotation by angle θ anticlockwise maps (x, y) to (x cos θ − y sin θ, x sin θ + y cos θ), written as a 2×2 matrix. Field Guide
Forward kinematics (two-link arm)
Forward kinematics computes where the end-effector is from the joint angles and link lengths. Field Guide
Inverse kinematics
Inverse kinematics finds joint angles that place the end-effector at a desired position. There may be several solutions, one, or none. Field Guide

Project: A Newton solver with guard rails

Write a Newton solver for one nonlinear engineering equation (a diode in series with a resistor works well). Add a fall-back to bisection when the step leaves a safe bracket. Show the convergence table and one start where plain Newton fails.

Deliverables

Write it up on paper or in your own notes. Lite never stores what you write.

References

← 2. Least squares and model fitting4. Differential equations and stability →