M08 — Choosing the class: one suspension corner, five ways
The class of a problem is not printed on the mechanism. It is a property of how the
model was written down, and the method follows from the class. This notebook takes one
suspension corner from solvers/otkd and poses it five ways: a square nonlinear system,
an over-determined one, a rank-deficient one, a compliant one and a moving one. Then it
reads the symptoms of a wrong solve, and the evidence that an answer is right.
Book pages: The class is a choice you make, The same corner, five ways, Saddle
point, When it goes wrong and Knowing the answer is right in
books/numerical-methods. The solver numbers are otkd's own, run live and cached.
The question. The same corner, the same parts. What decides whether you solve it with Newton, least squares, a KKT system or a time stepper, and how do you know the answer is right?
By the end you can:
- classify a model from its rows, unknowns and rank, and name the solve that follows
- find a redundant row with the SVD, and say why it is not a zero singular value
- write a compliant joint as a KKT saddle point, and trade it against a penalty
- say why a stiff tyre spring sets an explicit time step, and what replacing it with a constraint buys
- read a residual history as a diagnosis: linear, oscillating, stalled, singular
- check an answer with a bound, a second method, a limit case and a conserved quantity
Assumes: M01–M07: order, Newton, linear systems and the SVD, optimisation and KKT, eigenvalues and modes, equation classes and implicit steps, Monte Carlo.
How to use it: predict before you reveal, commit before you check, and move the controls until the equation's behaviour stops surprising you.
Warm-up: remember
1. Where is the wheel: a square system, and Newton
Setting: the problem, its sets and its symbols
Problem. Given the corner's rows at a driver angle , find the pose with . In the plane, given two circles, find the upper ball joint with , and say which of its roots Newton returns from .
| Symbol | In | Meaning |
|---|---|---|
| the unknowns: seven pose coordinates per moving body, a position (m) and a unit quaternion | ||
the numbers of unknowns and rows, as otkd's check reports them |
||
| the driver: the lower arm's angle (rad), 0.1 here | ||
| the rows: joint constraints, one driver row and one norm per quaternion | ||
| the Jacobian | ||
| minus the rank of the constraint rows; rows minus rank | ||
| Newton's iterates and step, | ||
| the error at a root | ||
| the upper ball joint in front view (m) | ||
| the circles' centres: the upper arm's hinge axis and the lower ball joint (m) | ||
| their radii (m): the upper arm, and the upright between the ball joints | ||
| the two rules (m²) | ||
| the starting guess , with on the slider |
How these symbols connect
Fixing the driver angle defines the 3-D residual map , whose Jacobian determines and . When and has full rank, Newton linearises into to reduce the error . In the 2-D front-view slice, the same iteration maps the upper ball joint through the two circle equations set by centres and radii , starting from .
Symbol-by-symbol notes
$q$ and the quaternion norms
Each moving body carries coordinates: for position (m) and for a unit quaternion describing orientation. Because a quaternion has one extra component, includes one unit-norm row per moving body alongside the joint rows and the driver row.
$\text{mobility}$ versus $\text{redundancy}$
is minus the rank of the constraint rows alone (the free motions before the driver acts). is total rows minus the rank of all rows (spare equations); zero redundancy with makes the system square.
$r$ (3-D) versus $F$ (2-D)
is otkd's full 3-D corner system at angle , whereas isolates the upper ball joint as the intersection of two circles in front view. Writing avoids square roots and gives residual units of .
$p_0$ and multiple roots
Two intersecting circles generically meet at two distinct points, both solving to round-off. Which assembly Newton reaches depends on the starting guess , not on the size of the residual.
Fix the lower arm's angle. The upper ball joint must then sit on a circle about the
upper arm's hinge, and at a fixed distance from the lower ball joint. Two rules, two
unknowns: a root problem. otkd writes the same corner in three dimensions: seven pose
coordinates per moving body (a position and a unit quaternion), so
unknowns, and 21 rows (the joints, one driver row that sets the arm angle, and
three quaternion norms). Its check reports:
| unknowns | rows | rank of the constraint rows | mobility | actuators | redundancy |
|---|---|---|---|---|---|
| 21 | 21 | 20 | 1 | 1 | 0 |
The constraint rows leave one free motion, the actuator's driver row closes it, and no row is spare. Rows equal rank equal : square, so otkd calls Newton. That choice is made from the rank of the symbolic Jacobian, never from a flag.
Newton replaces by its linearisation and solves . Near a simple root the error obeys , so the number of correct digits roughly doubles each step.
Two circles meet twice. In the plane, the upper ball joint is the intersection of those two circles, with centres and radii taken from otkd's design geometry. Both intersections are real assemblies of the same parts. Move the starting guess and watch which one Newton returns.
Hinge centre , radius 0.3034 m; lower ball joint , radius 0.3722 m. From Newton reaches in 5 steps: the design assembly. The residual at either answer is at round-off, so the residual cannot tell you which one you have; only the pose, compared with the last frame, can.
The corner itself. otkd's Newton, driven from the design pose to a lower-arm angle of 0.1 rad. Correct digits are of the residual; their ratio step to step tends to the order. The last step is capped by round-off.
| step | residual | correct digits | ratio to previous |
|---|---|---|---|
| 0 | 1.00e-01 | 1.0 | |
| 1 | 4.71e-03 | 2.3 | 2.33 |
| 2 | 1.21e-05 | 4.9 | 2.11 |
| 3 | 1.82e-09 | 8.7 | 1.78 |
| 4 | 3.18e-16 | 15.5 | 1.77 |
Condition number of at the answer: 46.8.
source: `open_textbook.otkd.solvers.newton.newton` — `solvers/otkd/src/open_textbook/otkd/solvers/newton.py:11`
def newton(
system: System,
q0: np.ndarray,
*,
rows: list[int] | None = None,
tol: float = 1e-12,
max_steps: int = 60,
) -> tuple[np.ndarray, int, list[tuple[np.ndarray, np.ndarray]]]:
"""Solve `rows(q) = 0` from `q0`. Returns the solution, step count and residual history."""
q = np.array(q0, dtype=float)
history: list[tuple[np.ndarray, np.ndarray]] = []
for step in range(max_steps):
r = system.residual(q, rows)
history.append((q.copy(), r.copy()))
error = float(np.max(np.abs(r))) if r.size else 0.0
if error < tol:
return q, step, history
jac = system.jacobian(q, rows)
try:
delta = np.linalg.solve(jac, -r)
except np.linalg.LinAlgError:
delta, *_ = np.linalg.lstsq(jac, -r, rcond=None)
if not np.all(np.isfinite(delta)):
raise SolverError("Newton step is not finite", residual=error)
base = float(np.max(np.abs(r)))
alpha = 1.0
for _ in range(40):
trial = q + alpha * delta
if float(np.max(np.abs(system.residual(trial, rows)))) < base or alpha < 1e-8:
break
alpha *= 0.5
q = q + alpha * delta
r = system.residual(q, rows)
index = (rows or system.constrained)[int(np.argmax(np.abs(r)))]
raise SolverError(
f"Newton did not converge in {max_steps} steps: |r|inf = {np.max(np.abs(r)):.3e}, "
f"worst row {system.problem.rows[index].name}",
residual=float(np.max(np.abs(r))),
)
When Newton on the square corner breaks
- Assumes: the Jacobian is nonsingular near the root, and the start lies in the basin of the assembly you want
- When it fails: at a toggle the Jacobian is singular and convergence drops to linear or stops; from the other basin Newton returns the other assembly, with a residual just as small
- Check: the rank and condition of at the answer, and the pose against the previous frame (otkd flags a jump of 0.25 rad or 0.05 m as a branch change)
2. A spare row: least squares, and the SVD that names it
Setting: the problem, its sets and its symbols
Problem. Given the two-leg corner's rows with , find minimising , and find which rows are dependent: the vectors with .
| Symbol | In | Meaning |
|---|---|---|
| the unknowns, as in §1: a position (m) and a unit quaternion per moving body | ||
| the numbers of unknowns and rows | ||
| §1's rows, with the upper hinge replaced by a front and a rear ball joint | ||
| the least-squares cost | ||
| the Jacobian at the answer | ||
| the Gauss–Newton step, | ||
| the SVD : , orthogonal, diagonal with the singular values | ||
| the right null space: motions the rows allow | ||
| the left null space: weights under which a sum of rows vanishes identically | ||
| rows minus the rank of all rows | ||
| with row dropped (the dropdown) |
How these symbols connect
Replacing the upper hinge with two ball joints adds rows so ; instead of solving directly, least squares minimises the scalar cost with Gauss–Newton steps built from . At the solution, the SVD separates (allowed motions in ) from (row dependencies in , counted by ). Deleting row forms so you can test which single row can be dropped without losing rank.
Symbol-by-symbol notes
$\phi$ and the Gauss–Newton step $\Delta q$
Minimising turns an over-determined system into an unconstrained optimisation problem. Linearising yields the normal equations , which remain even though is .
$U$, $\Sigma$ and $V$
In the full SVD , and are orthogonal, while is rectangular with the non-negative singular values on its main diagonal. Columns of span the pose space , and columns of span the row space .
$\ker J$ versus $\ker J^{\mathsf T}$
A vector satisfies and represents an infinitesimal motion permitted by all rows (the right null space). A vector satisfies and gives weights for a linear combination of rows that vanishes identically (the left null space).
$J_{-i}$
is with row removed. Checking the rank of across candidate rows distinguishes a redundant row from an independent constraint.
Replace the upper arm's hinge by two ball joints, a front leg and a rear leg. A body held at two points can still turn about the line through them, so the second leg adds rows but no new restriction: 22 rows, unknowns. All rows together have rank 21, so redundancy is 22 − 21 = 1; the constraint rows have rank 20, so the mobility is still 1. Rows exceed rank, and rank equals : redundant, so otkd calls least squares and then diagnoses.
Least squares minimises . Its Gauss–Newton step solves in the least-squares sense, . Because the spare row agrees with the others, the minimum is an exact solution: the residual history is 1.0e-01, 4.7e-03, 1.2e-05, 1.8e-09, 3.7e-16, the same digits as Newton in §1. The final cost is 1.1e-31. That says the rows are consistent, not that the answer is right.
The SVD writes . Columns of with are motions the rows allow (the right null space). Columns of beyond the rank satisfy : a weighted sum of rows that vanishes identically, which is what a dependence among rows is (the left null space). Your prediction at the top is answered here.
Reveal result (lock in your prediction above first)
21 singular values, the smallest 0.088: none is zero, and the condition number is 46.8. The redundancy is the one left null vector, supported on uca-front.ty, uca-front.tz, uca-rear.ty, uca-rear.tz, uca.unit. Between them, the two legs' and rows and the upper arm's quaternion norm say one thing twice: the arm is held at two points on its own axis.
Which row is the spare one? Drop one row and look at what is left.
Without uca-front.ty: rank 21 of , condition 46.8. square again: Newton, and the same answer. otkd's study-square.yaml drops uca-front.ty, and Newton on that square system matches least squares to 9.1e-16 in every pose coordinate.
source: `open_textbook.otkd.solvers.svd.diagnose` — `solvers/otkd/src/open_textbook/otkd/solvers/svd.py:23`
otkd's diagnosis: one SVD, one tolerance for the rank and for naming rows.
def diagnose(system: System, q: np.ndarray, *, rows: list[int] | None = None, rtol: float = 1e-10) -> Diagnosis:
"""Rank, left null space and participating row names at `q`.
`rtol` governs both decisions: singular values at or below `rtol * s[0]` are
treated as zero when computing `rank`, and rows whose largest left-null
coefficient exceeds `rtol` are named in `dependent_rows`.
"""
rows = system.constrained if rows is None else rows
jac = system.jacobian(q, rows)
rank, null, s = left_null(jac, rtol=rtol)
names = [system.problem.rows[i].name for i in rows]
if null.shape[1]:
weight = np.max(np.abs(null), axis=1)
dependent = tuple(name for name, w in zip(names, weight) if w > rtol)
else:
dependent = ()
condition = float(s[0] / s[rank - 1]) if rank else float("inf")
return Diagnosis(
singular_values=s,
rank=rank,
redundancy=len(rows) - rank,
dependent_rows=dependent,
null_space=null,
condition=condition,
)
When least squares with an SVD diagnosis breaks
- Assumes: the redundant rows agree with each other, and the rank tolerance sits in a clear gap between the singular values
- When it fails: with an inconsistency, least squares returns a compromise that satisfies no row and stalls at a residual floor; a tolerance inside a cluster of small singular values names the wrong rank
- Check: the final residual should reach round-off (the cost is not proof); drop one named row and compare the square Newton answer
3. A compliant joint: constrained minimisation and the KKT saddle point
Setting: the problem, its sets and its symbols
Problem. Given the tie rod's compliance and the loads , find the pose minimising the energy subject to the rigid rows ; equivalently, find with and .
| Symbol | In | Meaning |
|---|---|---|
| the unknowns: a position (m) and a unit quaternion per moving body | ||
| the rigid rows: joints, quaternion norms and the driver | ||
| the tie rod's extension (m) | ||
| its compliance (m/N); the stiffness is | ||
| the loads (N) and the positions of the points they act at (m); is their work (J) | ||
| the energy (J) | ||
| the multipliers: the reaction in each rigid row | ||
| the Lagrangian | ||
| the Hessian | ||
| the rigid rows' Jacobian | ||
| the tie-rod row | ||
| a unit vector along the free motion | ||
| the KKT matrix, the Newton matrix of the stationarity equations | ||
| the penalty stiffness that replaces the multipliers (the slider) | ||
the stiffness of each bush component at the upper ball joint, swept in otkd's double-wishbone-ubj payload (MN/m) |
||
| a condition number | ||
| in the book's smallest case only: minimise subject to |
How these symbols connect
Turning the tie rod into a spring of compliance combines its extension and the external work into the potential energy (J), minimised subject to the rigid rows . Pairing with multipliers in the Lagrangian gives stationarity equations whose Newton matrix is the KKT matrix , assembled from and (with tie-rod gradient and free-motion vector ). Replacing by a penalty stiffness (or physical bush stiffness ) gives an unconstrained formulation whose condition number can be compared against .
Symbol-by-symbol notes
$c$ versus $k$ and $k_{\text{bush}}$
Compliance has units , the reciprocal of stiffness (), and belongs to the physical tie-rod spring. By contrast, is a numerical penalty stiffness placed on the rigid rows , while () is the physical bush stiffness swept in otkd's double-wishbone-ubj payload.
$\lambda$ and its sign
Each entry of is the Lagrange multiplier enforcing one row of , carrying units of generalised reaction force (energy per unit of that constraint row). Note that otkd's solver uses the opposite sign convention for from .
$H$, $B$, $a$ and $z$
linearises the rigid rows, while is the tie-rod gradient (giving as the Gauss–Newton part of ). A unit vector satisfies , pointing along the single free motion left by the rigid rows.
$K$ and $\kappa$
packs , , and an zero block into the Newton matrix for . The condition number tracks linear-solve sensitivity, allowing a direct comparison between and the penalised Hessian .
$(x, \lambda)$ in the scalar example
In the book's smallest case only, is a single scalar unknown (not a 3-D load application point ) and is the single multiplier enforcing .
Make the tie rod's length a spring of compliance m/N and load the wheel centre with -3500 N in and 1800 N in (the study file's loads). Now nothing prescribes the free motion; the energy does. The equilibrium minimises
where is the tie rod's extension and the 20 rigid rows (16 joint rows, 3 norms, the driver). With , stationarity is and ; its Newton matrix is the KKT matrix
is the reaction in every rigid row: the force comes out as part of the answer (otkd uses the opposite sign for ). The book's smallest case: minimise subject to gives , solved by , .
Reveal result (lock in your prediction above first)
The book's smallest case first: its has eigenvalues -0.618 and 1.618, one of each sign. The solution is a minimum in and a maximum in , a saddle point.
Built from otkd's Jacobian at the design pose, with (the Gauss–Newton part of the spring's Hessian; is the tie-rod row): 21 positive, 20 negative, 0 zero. alone has rank 1, yet is nonsingular, because is positive on the one free motion: is 1.64e+04 for the unit null vector of . Cholesky and conjugate gradients need positive definiteness, so the solve is a symmetric indefinite factorisation, MINRES, or (in otkd) least squares on the KKT residual.
The other way to write it. Drop the multipliers and replace every rigid row by a stiff spring: minimise with no constraint at all. The Hessian becomes : symmetric, positive definite, Cholesky-ready. The price is in two places. The rows are now met only to about force , and, once is above the spring's own , the stiff directions grow with while the free motion does not, so the condition number grows like . Move .
At the penalised Hessian's condition number is 8.98e+04. The KKT matrix's is 2.99e+07 at every , because it has no . That number is not small: it mixes the spring's with rows of order 1, and scaling the blocks would bring it down. What matters is that it does not grow, while the penalty's passes it near and keeps climbing. Below the penalty is not yet the rigid model at all: the curve's left arm is the rigid rows being softer than the spring.
The bushed corner in the book is this penalty, made physical. The upper ball joint becomes a bush (three compliant components), and otkd's committed double-wishbone-ubj payload sweeps its stiffness. At rest the bushed camber differs from the rigid one by:
| bush stiffness (MN/m) | |camber difference from rigid| at rest (deg) | | --- | --- | | 0.2 | 0.9086 | | 1 | 0.1796 | | 10 | 0.0179 | | 100 | 0.0018 |
Each tenfold stiffness divides the difference by 5.06, 10.03, 9.94: first order in the compliance, the of the penalty. The book's 1.8 MN/m is the stiffness at which that difference is a tenth of a degree.
source: `open_textbook.otkd.solvers.equilibrium.equilibrium` — `solvers/otkd/src/open_textbook/otkd/solvers/equilibrium.py:34`
otkd solves the KKT residual in , scaled by the load.
def equilibrium(
system: System,
q0: np.ndarray,
loads: LoadCase,
*,
tol: float = 1e-12,
) -> tuple[np.ndarray, int, list[tuple[np.ndarray, np.ndarray]]]:
problem = system.problem
rows = system.constrained
springs = system.springs
n = problem.n
free = n - len(rows)
if free < 1:
raise SolverError("equilibrium needs at least one compliant degree of freedom")
force_scale = max(1.0, float(sum(np.linalg.norm(force) for _, _, force in loads)))
history: list[tuple[np.ndarray, np.ndarray]] = []
def residual(x: np.ndarray) -> np.ndarray:
q, lam = x[:n], x[n:]
grad = problem.gradient(q, system.g, system.theta, springs)
for body, point, force in loads:
point_jac, _ = problem.point_derivatives(body, point)
jacobian = np.asarray(point_jac(*q, *system.g), dtype=float).reshape(3, n)
grad = grad - jacobian.T @ force
stationarity = (grad - system.jacobian(q, rows).T @ lam) / force_scale
return np.concatenate([stationarity, system.residual(q, rows)])
def record(x: np.ndarray, *args) -> None:
"""Accepted iterates only, so `iterations[]` means what it means elsewhere."""
history.append((np.asarray(x[:n]).copy(), residual(x)))
start = np.concatenate([np.asarray(q0, dtype=float), np.zeros(len(rows))])
# `max_nfev` is generous because a joint at 100 MN/m needs a few hundred evaluations on the
# frame where the load first swings it; a well-behaved frame uses five.
result = scipy_least_squares(
residual,
start,
method="trf",
x_scale="jac",
callback=record,
xtol=tol,
ftol=tol,
gtol=tol,
max_nfev=1000,
)
# The two blocks are measured separately, because they are not the same unit: a constraint
# left at 1e-8 is a metre of violation, which is a different claim from a force balance left
# at 1e-8 of the load.
constraints = float(np.max(np.abs(result.fun[n:]))) if len(rows) else 0.0
stationarity = float(np.max(np.abs(result.fun[:n])))
if constraints > 1e-12 or stationarity > 1e-9:
raise SolverError(
f"equilibrium did not converge: {result.message}",
residual=max(constraints, stationarity),
)
return result.x[:n], int(result.nfev), history
When the KKT saddle point, and the penalty that replaces it breaks
- Assumes: has full row rank and is positive on the null space of
- When it fails: a redundant constraint makes the KKT matrix singular and the multipliers non-unique; a penalty leaves a constraint error near and a condition number near ; with no load the compliance is invisible and the stiffness ladder passes vacuously
- Check: count the inertia ( positive, negative), and sweep the stiffness: the difference from the rigid model should fall tenfold per decade
4. A moving corner: time stepping, stiffness and modes
Setting: the problem, its sets and its symbols
Problem. Given the mass matrix , the applied forces , the rows and a start , find and with and for all . For the two-mass sketch, given , find the largest step at which RK4 on stays bounded.
| Symbol | In | Meaning |
|---|---|---|
| time and the run's duration (s) | ||
| the pose coordinates: a position (m) and a unit quaternion per moving body | ||
| otkd's mass matrix (kg, and kg m² for rotations) | ||
| the applied forces (N, and N m for moments) | ||
| the rows, including the tyre's contact plane, and their Jacobian | ||
| the multipliers: the constraint forces | ||
| the right side of , from differentiating twice | ||
| the time step (s; the slider is in ms) | ||
| the sketch's chassis and unsprung masses (kg), from otkd | ||
| the wheel rate, 25 kN/m, and the tyre rate on the slider (N/m) | ||
| in the sketch only: (kg) and the stiffness matrix of and (N/m) | ||
| the sketch's state: chassis and wheel displacements (m) and velocities (m/s) | ||
| the first-order system matrix, | ||
| the modes: (rad/s); is the largest | ||
| an eigenvalue of | ||
| RK4's stability function: one step multiplies a mode by | ||
| a real argument, on the imaginary axis |
How these symbols connect
In otkd's moving corner, mass , applied forces and constraints couple into over ; differentiating twice gives so each RK4 stage solves a linear system for . In the two-mass sketch, chassis and unsprung masses and spring rates build matrices (with modes ) and the first-order system (with eigenvalues ). Stepping with RK4 at step scales each eigenmode by , evaluated along the imaginary axis as to test boundedness.
Symbol-by-symbol notes
$M$ and $K$: full corner versus sketch
In the full DAE, is otkd's mass matrix (kg for translations, for rotations). In the two-mass sketch only, and are the 2-DOF mass and stiffness matrices (not §3's KKT matrix).
$\gamma$ in $\Phi_q \ddot q = \gamma$
Differentiating once gives , and differentiating again gives . The vector collects those velocity-dependent terms on the right-hand side.
$y$ and $A$
Stacking the chassis and wheel displacements (m) above their velocities (m/s) forms the state vector . Writing the second-order sketch in first-order form builds the matrix with in its lower-left block and in its upper-right block.
$\omega_j$ versus $\mu$ and $\nu$
Each generalised eigenpair gives a real angular frequency (rad/s) and mode shape . For an undamped sketch the eigenvalues of are purely imaginary, and is the dimensionless argument when evaluating .
$h$ (s versus ms) and $R$
The time step enters in seconds so is dimensionless, while the interactive slider displays in milliseconds. is RK4's degree-4 polynomial stability function approximating .
Give the corner mass and release it. The equations become with : a differential-algebraic system, because the constraints have no time derivative of their own. otkd differentiates twice, , and solves the saddle-point system for at every stage of a classical RK4 step, then projects back onto the constraint. The class of each step is §3's; the class of the run is an initial-value problem.
The committed quarter-car run (books/maths-applied, 601 output steps over
3.0 s): the wheel travels from 0 to 212.8 mm and back, and
first returns at s, about 1.6 Hz. With no damper
it repeats. Energy drift over the run: 6.3e-08 of the start; largest
constraint violation: 1.1e-15.
In that model the tyre is a hard row, a plane the wheel cannot leave. Write it instead as a spring and the class changes again: a second mode appears, the wheel hopping on the tyre. A two-mass sketch shows what it costs. The masses are otkd's: 300 kg of chassis, and 17.0 kg of arms and upright lumped at the wheel. The wheel rate kN/m and the tyre rate are chosen for the sketch, not taken from otkd. The modes solve (M05), and RK4 applied to multiplies each mode by with . For an undamped mode and , which stays at or below 1 only while : stable for , for every mode at once.
Reveal result (lock in your prediction above first)
| bounce | hop | ratio | |
|---|---|---|---|
| frequency (Hz) | 1.37 | 18.3 | 13.4 |
Largest stable RK4 step: 24.60 ms; with the tyre ten times stiffer, 8.20 ms, smaller by 3.00. Accuracy for the bounce alone would allow far more. At your ms, against the limit 2.83: stable.
The wheel starts 20 mm displaced. Below the limit RK4 loses energy slowly; above it the hop mode grows by a fixed factor every step. As the hop frequency goes with it and the explicit step goes to zero. otkd's rigid tyre is that limit taken exactly: the stiff mode is replaced by a constraint and a multiplier, and a 5 ms RK4 step only has the bounce to resolve. The other cure keeps the spring and goes implicit (M06).
When explicit time stepping breaks
- Assumes: lies inside the method's stability region for every mode
- When it fails: a fast mode you do not care about grows without bound, and the run blows up at a step that is far finer than accuracy needs
- Check: compute from the eigenvalues before choosing ; with no damping, watch the energy
5. Symptoms, and the diagnosis they point to
Setting: the problem, its sets and its symbols
Problem. Given rules and the start , find with , or the least-squares compromise when , by . Then, from the residual history alone, find which fault was introduced.
| Symbol | In | Meaning |
|---|---|---|
| the upper ball joint in front view (m), as in §1 | ||
§1's centres and radii (m); a third rule , comes from otkd's point tri |
||
| the number of rules | ||
| (m²) | ||
| the true Jacobian, with rows | ||
| the matrix the iteration uses at step : when healthy, otherwise the fault's | ||
| the pseudo-inverse of : the least-squares solve | ||
| the iterates, from | ||
| the residual (m²); the readout is the ratio | ||
| ; ; 1 mm too long; moved to put the two arms in line |
How these symbols connect
The circle rules ( for the baseline corner, when adding the third centre tri) have true Jacobian . Starting at , each step advances using the possibly faulted matrix and its pseudo-inverse . Recording the max-norm residual and its step-to-step ratios produces a trace from which the active fault can be diagnosed.
Symbol-by-symbol notes
$J\lt em>F$ versus $\tilde J\lt /em>k$
is the exact Jacobian of at , with rows . is the matrix actually used at step : it equals in the healthy run and carries a single deliberate defect otherwise.
$A^{+}$ (the pseudo-inverse)
When and is nonsingular, gives the ordinary Newton step. When (over-determined) or loses rank, computes the minimum-norm least-squares step (np.linalg.lstsq).
$\eta\lt em>k$ and the ratio $\eta\lt /em>{k+1}/\eta_k$
has units of because each compares squared distances. The dimensionless ratio measures how the residual changes from one iteration to the next.
The four faults
Each fault alters one ingredient at a time: freezing , dropping the factor of so , adding an inconsistent third rule ( with lengthened by mm), or moving so the two circles are tangent (arms in line, a toggle).
A wrong solve has a shape, and the residual history is where it shows. The two-circle corner from §1, started from , with one fault at a time. Pick a fault, and predict first.
Reveal result (lock in your prediction above first)
Jacobian frozen at the start: successive residual ratios 0.042, 0.013, 0.011, 0.011, 0.011. A constant ratio well below 1 is linear convergence (the frozen Jacobian; the toggle, where the double root makes the ratio 1/4 in the residual). A ratio of 1 with alternating values is an overshoot. A ratio of 1 at a fixed level is a floor: least squares has found the best compromise between rules that disagree.
Symptoms, and the first suspect for each. The same reading extends past the residual to the rank, the time step and the energy.
| what you see | first suspect | first check |
|---|---|---|
| the residual falls by a fixed factor per step | an approximate or stale Jacobian; a singular one at the root | the Jacobian against finite differences; rank at the answer |
| the residual alternates and never settles | a step too large: a Jacobian wrong by a factor, or a fold | the Jacobian by differences; damping or a line search |
| the residual stalls at a floor | inconsistent rows, or the wrong model | the residual row by row; the SVD's dependent rows |
| the rank drops | a redundant row (left null space) or a lost constraint or toggle (right null space) | which side of the SVD the zero is on |
| the time step collapses, or the run blows up | a stiff mode and an explicit method | the eigenvalues; an implicit method or a constraint |
| energy grows with no source | a non-conservative scheme or a missing term | halve : the drift must fall at the method's order |
When reading a symptom breaks
- Assumes: one fault at a time, so the residual history has one signature
- When it fails: two faults together (a stale Jacobian near a toggle, say) give a mixed signature that looks like neither
- Check: change one thing at a time: the Jacobian against finite differences first, then the rank at the answer, then the consistency of the rows
6. Is the answer right?
Setting: the problem, its sets and its symbols
Problem. Given , and a computed , bound the relative error by quantities known without . Then, for the corner's own solves, find evidence that a computed answer is right when no exact solution is available.
| Symbol | In | Meaning |
|---|---|---|
| the off-diagonal entry ( on the slider) | ||
| the matrix with rows and | ||
| the right side ; its second entry is perturbed by before the solve | ||
| the exact solution and the computed one | ||
| the residual , against the unperturbed | ||
| a vector norm and the matrix norm it induces | ||
| the condition number ; the table uses the -norm | ||
| §1's Jacobian at the answer and its condition number | ||
| §3's tie-rod compliance (m/N), extension (m) and force (N) | ||
| the RK4 step on §4's sketch (s) | ||
| the sketch's energy (J), conserved by the exact motion | ||
| of the ratio of successive errors as halves |
How these symbols connect
For the linear system parameterised by , perturbing by gives a computed vector whose residual and condition number bound the unknown relative error without needing . The same verification discipline extends to the corner's own solves: pairing §1's residual with , checking §3's tie-rod force as compliance , and tracking §4's conserved energy and empirical as RK4's step halves.
Symbol-by-symbol notes
$r$ versus $\hat x - x$
The residual measures how well satisfies the equation (always computable), whereas measures how close is to the exact solution (unknown in practice). They are linked by , which is where enters.
$\lVert \cdot \rVert$ and $\kappa(A)$
The error bound holds for any vector norm paired with its induced matrix norm . The interactive table uses the -norm (maximum absolute entry for vectors, maximum absolute row sum for matrices), giving .
$c$, $g$ and $g/c$
In §3's compliant corner, as tie-rod compliance (), the extension (m) shrinks towards zero while their ratio (N) is the elastic tie-rod force approaching the rigid reaction.
$E$ and $\text{order}$
Along the exact undamped motion of §4's sketch, mechanical energy (J) is constant, so checks accuracy without a reference solution. Halving computes the empirical separately for position and for energy.
A residual measures the equation; an error measures the answer. For with computed and residual , , so
The book's check: , , exact , and perturbed by . Move .
| relative residual | relative error | bound residual | |
|---|---|---|---|
| 1.0e+06 | 1.0e-13 | 1.0e-07 | 1.0e-07 |
The residual shrinks as grows while the error does not: at large a tiny residual certifies nothing until the conditioning is multiplied in.
Four checks on the corner, none of which needs the exact answer.
1. The residual, with the conditioning. §1's Newton ends at 3.2e-16 with : an error estimate near 1e-14 in coordinates of order 1.
2. A second, independent method. otkd's closed-form two-circle camber against the Newton sweep: largest difference 2e-13 degrees over 81 frames. Least squares on the two-leg model against Newton with the spare row dropped: 9.1e-16. Two runs of the same code would not count: they share their mistakes.
3. A limit case that returns a trusted model. Stiffen the compliant tie rod towards rigid (otkd's equilibrium solver, at rest, under the study's loads). The extension goes to zero and the force converges, each decade changing it about ten times less than the last: first order in , the §3 penalty again.
| compliance (m/N) | tie-rod extension (m) | tie-rod force g/c (N) | change from previous (N) |
|---|---|---|---|
| 1e-05 | -1.778e-04 | -17.7801 | |
| 1e-06 | -1.880e-05 | -18.7956 | -1.0155 |
| 1e-07 | -1.890e-06 | -18.9035 | -0.1079 |
| 1e-08 | -1.891e-07 | -18.9144 | -0.0109 |
| 1e-09 | -1.892e-08 | -18.9155 | -0.0011 |
4. A conserved quantity, and a convergence table. With no damper the energy is conserved, so its drift is a check with no reference solution: the committed quarter-car run drifts by 6.3e-08. On the §4 sketch (tyre N/m, one second, against the exact solution from the matrix exponential), halving :
| h (ms) | position error | order | energy error | energy order |
|---|---|---|---|---|
| 8 | 9.05e-03 | 6.13e-01 | ||
| 4 | 8.52e-04 | 3.41 | 3.17e-02 | 4.27 |
| 2 | 5.24e-05 | 4.02 | 1.03e-03 | 4.95 |
| 1 | 3.19e-06 | 4.04 | 3.22e-05 | 4.99 |
The position settles at order 4, RK4's order. The energy error settles near 5, one higher: per step , and steps give . A convergence table checks the order of the quantity you measure.
When a small residual as evidence breaks
- Assumes: the problem is well conditioned and the equations are the ones you meant
- When it fails: the conditioning multiplies the residual into the error, and a converged answer to the wrong model looks exactly like a right one
- Check: times the relative residual, an independent second method, a limit case that returns a trusted model, and a conserved quantity
Practice
Hint 1
Treat the body as fixed: the wheel sits between two springs in parallel, so .
Hint 2
RK4 on an undamped mode is stable for .
Mixed practice: which class, which method, and why?
Name the class before you pick an option.
Check yourself (closed book)
Keep these:
- The class is a property of how the model is written: rows, unknowns and rank decide it, and the solve follows.
- Square and full rank: Newton. Rows above rank, rank : least squares, then the left null space names the spare rows.
- A constraint with a price is a KKT saddle point, indefinite with one negative eigenvalue per row; a penalty is definite, approximate to and conditioned like .
- An explicit step is set by the fastest mode; a stiff spring can be replaced by a constraint, or kept and stepped implicitly.
- Read the residual history: linear, alternating, a floor, a rank drop. Then check the answer with residual, a second method, a limit case and a conserved quantity.
Your connection
Pick a model you work with. Write down its class as you posed it, one other way you could have posed it, and which check would tell you the two agree.
Answers
Practice A. .
Practice B. about 24.6 ms, from rad/s.
Practice C. .
Mixed practice. Newton; least squares; implicit time stepping; a generalised eigenproblem; a convergence table from three runs; Monte Carlo with an error bar.
Where the maths is derived
Optional. These notes give the intuition and application; the sources below give the full derivations and proofs.
§1 A square system: Newton
- Nocedal and Wright (2006), Numerical Optimization: Newton's method for nonlinear equations, its quadratic convergence and line-search globalisation (ch. 11).
- otkd, the model, its exports and a generated solver: the rows, the rank test that chooses the solver, and each example's row table (
docs/problem-mapping.md§4 and §8).
§2 A spare row: least squares and the SVD
- Trefethen and Bau (1997), Numerical Linear Algebra: the SVD and the subspaces it reveals (lectures 4–5) and least-squares problems (lecture 11).
§3 A compliant joint: the KKT saddle point
- Benzi, Golub and Liesen (2005), Numerical solution of saddle point problems: when a saddle-point matrix is nonsingular, its inertia, and the penalty, Schur-complement and Krylov solvers.
- Nocedal and Wright (2006), Numerical Optimization: the KKT conditions (ch. 12) and why the quadratic penalty's Hessian grows ill-conditioned (ch. 17).
§4 A moving corner: stiffness and modes
- Hairer and Wanner (1996), Solving Ordinary Differential Equations II: stiffness and the stability regions of explicit and implicit methods, and constrained mechanical systems as differential-algebraic equations.
- Hairer, Lubich and Wanner (2006), Geometric Numerical Integration: why some integrators keep the energy over long runs and general-purpose ones drift.
§6 Is the answer right?
- Trefethen and Bau (1997), Numerical Linear Algebra: conditioning and the bound from relative residual to relative error (lecture 12).
- LeVeque (2007), Finite Difference Methods for Ordinary and Partial Differential Equations: measuring errors and observed orders from refined runs (appendix A).
Compiled from notebooks/methods/m08_choosing_the_class.py — run locally with cd notebooks && uv run marimo edit methods/m08_choosing_the_class.py for live Python scratch cells.
Back to the book: The same corner, five ways · The class is a choice