S03 — Two legs, one contradiction
Replace the upper wishbone's hinge by two ball-jointed legs and otkd's corner has 22
rows for 21 unknowns. If the rows agree, least squares returns the same pose as the
square model. If one hardpoint is out, no pose satisfies every row, and least squares
still returns a pose. This notebook measures the difference between those two cases
on otkd's double-wishbone-two-leg model, and asks what the compromise pose is worth.
Book pages: 1.3 Two legs, one contradiction and its deeper page What least squares is
minimising in books/maths-applied. Design: solvers/otkd/docs/problem-mapping.md §6
(the solvers) and §8 (the row tables). Every solver number here is otkd's, run live and
cached.
The question. When least squares returns a pose for a model with more rows than unknowns, is that pose right, or only the smallest misfit the rows allow? And how would you tell?
By the end you can:
- count rows, rank and redundancy, and read which rows depend on each other off the left null vector
- say what least squares minimises, how Gauss–Newton and otkd's trust-region solve minimise it, and what their stopping test certifies
- tell a consistent redundancy from a contradiction by the residual floor, and predict the floor per millimetre of error as
- explain why weights and units decide a contradicted answer and change nothing in a consistent one
- decide when a least-squares pose is right and when it is merely small
Assumes: M03 §5–6 (normal equations, QR, the SVD), M04 §5 (Gauss–Newton) and M08 §2 (the two-leg corner's counts).
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. Two legs, twenty-two rows
Setting: the problem, its sets and its symbols
Problem. Given the two-leg corner's geometry and drive , the constraint map and its Jacobian at a solved pose, find , the redundancy , and a unit vector with ; read which rows links and why.
| Symbol | In | Meaning |
|---|---|---|
| the moving bodies; the ground is fixed | ||
| the unknowns: per body a position (m) and a quaternion (dimensionless) | ||
| the data: hardpoint coordinates (m), site frames (dimensionless), the tie-rod length (m) | ||
| the drive: the lower arm's angle (rad) | ||
| the row index set, : joint rows (m or dimensionless), one driver row (rad), one norm row per body (dimensionless) | ||
| the constraint map; is the residual, in each row's own unit | ||
| the Jacobian , exact (otkd differentiates symbolically) | ||
| the SVD of ; , orthogonal, the singular values | ||
| a left null vector, : a combination of rows that vanishes (dimensionless weights) | ||
the upper arm's axis, from ucaf to ucar (dimensionless) |
||
| otkd's rotation matrix, quadratic in the quaternion | ||
| the book's planar sketch: upper ball joint, the two leg pivots, the lower ball joint (m) |
How these symbols connect
Fixing the geometry and drive angle defines the constraint map across the three moving bodies , mapping a pose to a residual vector in mixed row units. Differentiating symbolically at a solved pose gives the Jacobian , whose SVD determines and any unit left null vector satisfying . The non-zero entries of index the linearly dependent rows in , which we interpret geometrically through the upper arm's axis and otkd's rotation matrix .
Symbol-by-symbol notes
$q \in \mathbb{R}^{21}$ and moving bodies $B$
Each body in contributes seven unknowns: three world-frame position coordinates in metres and a dimensionless quaternion . The ground is fixed and carries no unknowns.
$\Phi$ and row units on $I$
The rows in carry mixed units: joint translations and the tie-rod length are in metres, the single driver row is in radians, and joint orientation rows plus the three quaternion-norm rows are dimensionless. Entry of therefore has row 's unit divided by unknown 's unit.
$U \Sigma V^{\mathsf T}$ and $u$
For the tall Jacobian , is , is , and holds singular values. A left null vector () is a unit vector of dimensionless row weights, distinct from a right null vector (), which describes a free pose motion.
$R(q)$ and quaternion scaling
Here refers to one body's rotation matrix built from its four quaternion components, not the full 21-coordinate vector. Because otkd writes as a quadratic polynomial in the quaternion without dividing by , any departure from unit norm scales lengths on that body by .
$D, B\lt em>1, B\lt /em>2, C$ vs the 3D corner
These four points belong only to the book's two-dimensional front-view sketch (metres in ), used to introduce the two-leg geometry before switching to otkd's three-dimensional bodies and 21-coordinate pose .
The book starts in the plane. The upper ball joint is two unknowns, and three facts pin it: the front leg keeps its length, the rear leg keeps its length, the upright keeps its length. Three equations, two unknowns. Seen from the front, the two legs lie almost along the line of sight, so their two circles are the same circle: one fact written twice.
otkd keeps all three dimensions. Its double-wishbone-two-leg model replaces the upper
arm's hinge by two spherical joints, uca-front at ucaf and uca-rear at ucar, which
are 200.2 mm apart. Seven pose coordinates per moving body give
unknowns; the rows are the joints, one driver row (the lower arm's angle,
in radians) and one quaternion norm per body. check reports:
| unknowns | rows | rank of the constraint rows | rank of all rows | redundancy | mobility |
|---|---|---|---|---|---|
| 21 | 22 | 20 | 21 | 1 | 1 |
A body held at two points can still turn about the line through them, so the second leg adds three rows but only two restrictions. Rows exceed rank by one: one row is a combination of the others. The SVD names the combination (M03 §6, M08 §2). With , the last column of satisfies , and its non-zero weights at the solved pose are:
| row | unit | weight in u |
|---|---|---|
| uca-front.ty | m | -0.6992 |
| uca-front.tz | m | -0.0350 |
| uca-rear.ty | m | +0.6992 |
| uca-rear.tz | m | +0.0350 |
| uca.unit | — | +0.1402 |
Read it as an identity. The arm's two pivots are a fixed distance apart, so moving the
rear pivot along the arm's axis must be matched by the front pivot, unless the arm
itself changes size. 's weights on the front and rear and rows are the
axis direction, ,
scaled; the rows carry nothing because the axis has no component. The arm's size
enters through its quaternion: otkd's rotation matrix is quadratic in , so it
scales lengths by , and the norm row uca.unit is the fifth member. The driver row
and every other row have weight zero: only these five rows can disagree with each other.
The smallest singular value is 0.088, far from zero: the redundancy is
not in the singular values at all.
source: solvers/otkd/examples/double-wishbone-two-leg/topology.yaml:20-30
The two legs, as otkd reads them.
tri: {origin: tri}
tro: {origin: tro}
joints:
- {name: lca-ground, kind: revolute, a: ground, b: lca, site: lca-hinge}
# two sphericals pin two points of one rigid body: six rows, five independent
- {name: uca-front, kind: spherical, a: ground, b: uca, site: ucaf}
- {name: uca-rear, kind: spherical, a: ground, b: uca, site: ucar}
- {name: lca-up, kind: spherical, a: lca, b: up, site: lbj}
- {name: uca-up, kind: spherical, a: uca, b: up, site: ubj}
- {name: tie-rod, kind: distance, a: ground, b: up, from: tri, to: tro}
2. What least squares minimises, and how otkd minimises it
Setting: the problem, its sets and its symbols
Problem. Given with and a start , find by iterates , with the Gauss–Newton step or the trust-region step; say what each stopping test certifies.
| Symbol | In | Meaning |
|---|---|---|
| the unknowns, the -th iterate, a minimiser: positions (m) and quaternions | ||
| the rows and the residual , in mixed units (m, rad, dimensionless) | ||
| the Jacobian | ||
| the objective | ||
| its gradient and Hessian | ||
| the step at iterate | ||
| the trust-region radius, in the scaled variables | ||
| SciPy's diagonal scaling of the variables | ||
| the drive the slider sets (rad); is the design pose | ||
| the 2-norm condition number of a matrix | ||
| machine epsilon for doubles, |
How these symbols connect
At a drive angle chosen on the slider, the constraint map turns each iterate (starting from the design pose ) into a 22-row residual and the scalar objective . Linearising with produces the update : Gauss–Newton solves an unconstrained linear least-squares step from and , whereas otkd's trust-region method restricts that step to the scaled ball . Convergence and accuracy depend on , , machine epsilon , and whether stopping checks or .
Symbol-by-symbol notes
$S(q)$ and mixed row units
Because combines metres, radians, and dimensionless entries without weighting, sums squares numerically in those raw units. The factor keeps the gradient tidy as .
$\nabla S$ and $\nabla^2 S$
The gradient vanishes at any stationary point of , whether or not . The full Hessian includes a second-derivative sum weighted by that Gauss–Newton omits.
$\Delta\lt em>k$, $D$, and $\rho\lt /em>k$
The step shares the mixed units of (metres for positions, dimensionless for quaternions). SciPy's diagonal matrix rescales those variables before enforcing , so the radius is measured in the scaled coordinates rather than raw metres.
$\kappa(\cdot)$ for $J$ vs $J^{\mathsf T} J$
For a full-column-rank matrix , the 2-norm condition number is . Forming the normal-equations matrix squares it, , magnifying rounding errors of size in the linear step.
$\theta$ and start pose $q_0$
Each slider value rad defines a fresh drive target, while every curve starts from the same design pose (where ).
Given rows , least squares minimises
Gauss–Newton (M04 §5) drops the second term of the Hessian, which needs second derivatives of every row. The Newton step on becomes : exactly the normal equations of the linear problem . So each step is a linear least-squares solve, and M03 §5 says how to do it: by QR, because . The dropped term is weighted by , so when the rows can all be met it vanishes at the answer and Gauss–Newton converges like Newton.
otkd's solver hands to SciPy's least_squares(method="trf"), a trust-region
method. Each step minimises only within , with
a scaling of the variables. If the actual fall in matches the model's prediction,
grows and the step becomes the Gauss–Newton step; if not, shrinks and the
step turns towards steepest descent. "Reflective" refers to how it handles bounds; otkd
sets none. SciPy stops when the gradient, the step or the fall in is below tolerance.
None of those tests asks for . otkd adds that check afterwards: it raises unless
.
Move the drive angle. Each curve starts at the design pose, where only the driver row is wrong.
| θ (rad) | otkd evaluations (SciPy's count) | otkd residual calls (all) | final cost | ||
|---|---|---|---|---|---|
| 0.10 | 5 | 116 | 46.8 | 2187 | 1.1e-31 |
All three reach round-off, and the correct digits roughly double each step: a zero-residual problem, so Gauss–Newton is quadratic. The normal equations lose about 1.7 more digits in each step's direction than QR, and the next step corrects them; with near 47 that costs nothing visible.
otkd passes no Jacobian, so SciPy differences the residual: one call per unknown for every Jacobian, which is why the calls outnumber SciPy's own count. A forward difference with SciPy's default step differs from otkd's exact symbolic by 3.5e-08 relative to its largest entry at θ = 0.1, and the iteration still reaches round-off: an approximate Jacobian slows convergence, the exact residual decides where it ends.
source: `open_textbook.otkd.solvers.least_squares.least_squares` — `solvers/otkd/src/open_textbook/otkd/solvers/least_squares.py:12`
otkd's least squares: SciPy's trust region, no Jacobian passed, and its own refusal of any floor.
def least_squares(
system: System,
q0: np.ndarray,
*,
rows: list[int] | None = None,
tol: float = 1e-12,
max_steps: int = 200,
) -> tuple[np.ndarray, int, list[tuple[np.ndarray, np.ndarray]], float]:
"""Solve the over-determined system. Returns the solution, evaluations, history, cost."""
history: list[tuple[np.ndarray, np.ndarray]] = []
def residual(x: np.ndarray) -> np.ndarray:
return system.residual(x, rows)
def record(x: np.ndarray) -> None:
history.append((np.asarray(x).copy(), residual(x).copy()))
x0 = np.asarray(q0, dtype=float)
record(x0)
result = scipy_least_squares(
residual,
x0,
method="trf",
ftol=tol,
xtol=tol,
gtol=tol,
max_nfev=max_steps * (system.problem.n + 1),
callback=record,
)
record(result.x)
if float(np.max(np.abs(result.fun))) > 1e-8:
raise SolverError(
f"least squares did not converge: {result.message}",
residual=float(np.max(np.abs(result.fun))),
)
return result.x, int(result.nfev), history, float(result.cost)
When Gauss–Newton and the trust region breaks
- Assumes: the residual at the answer is small, so the neglected is too
- When it fails: with a large floor the step is wrong in the curvature and convergence is linear, or the trust region shrinks step after step; a rank-deficient makes the step itself undefined
- Check: watch and separately: the first must fall to round-off, the second tells you whether the rows agree
3. A consistent redundancy, and a contradiction
Setting: the problem, its sets and its symbols
Problem. Given the consistent rows at rad, their solution , and an error in the frame's rear pivot only, find , the floor as a function of , and the change of pose and camber from . First, as a control, the same question for a moved shared point.
| Symbol | In | Meaning |
|---|---|---|
| the unknowns and the consistent least-squares pose | ||
| the rows (m, rad, dimensionless), with Jacobian | ||
| the unit left null vector of at (§1) | ||
| the two bodies a joint connects | ||
| body 's position (m) and rotation; the ground has , | ||
| a joint's site origin, from the geometry (m) | ||
| the site's frame (dimensionless) | ||
| a spherical joint's three rows: the relative displacement of the bodies' attachment points, in the site frame (m) | ||
the error of the frame's pivot of uca-rear; the arm's attachment is unchanged |
||
the three uca-rear rows |
||
| the shift of the residual: on , zero elsewhere (m) | ||
| the contradicted residual | ||
| its least-squares pose | ||
camber (deg), from the axle wc to wco |
How these symbols connect
Starting from the consistent rows and their solved pose at rad, each spherical joint links two bodies and via their poses , and site data to form three displacement rows in metres. Displacing only the frame's pivot of uca-rear by adds a constant offset supported on the three rows , turning into the perturbed residual . Minimising yields , whose residual floor , point shifts, and camber we compare against alongside the left null vector from §1.
Symbol-by-symbol notes
$A, B$, $(p\lt em>A, R\lt /em>A)$, and site $(o, C)$
Each joint connects an ordered pair of bodies and , with the fixed ground given and . The site origin (metres) locates the joint in the geometry, and the orthogonal frame sets the axes in which the displacement is measured.
$\delta$, $I_r$, and $e$
The error mm shifts the frame's pivot of uca-rear along one chosen axis while leaving the arm's attachment unchanged. In metres, places on the matching row of (uca-rear.tx, .ty, .tz) and zero on all other 19 rows.
$r\lt em>\delta$ vs $\Phi$, and $q^*\lt /em>\delta$ vs $q^*$
Adding the constant vector shifts the residual map to while leaving the Jacobian unchanged. Keep (the consistent solution of ) distinct from (the least-squares minimiser of ).
Units of $\lVert r\lt em>\delta(q^*\lt /em>\delta) \rVert$
Because mixes metres, radians, and dimensionless rows, the unweighted Euclidean norm combines those units into one scalar; the charts display entries scaled by (millimetres for translation rows, for dimensionless rows).
Camber $\gamma$
Computed in degrees on from the solved world-frame axle vector joining wheel centre wc to outboard point wco, giving a physical angle by which to compare with .
A redundant model is consistent when some pose satisfies every row; then least squares finds it, the residual falls to round-off, and the answer is the square model's. It is a contradiction when no pose does; then least squares finds the pose of smallest misfit, and the residual stops on a floor above round-off. The prediction below tests the first way you might try to make one.
Reveal result (lock in your prediction above first)
At the design pose with the drive at zero, the largest row with ucar moved is
6.1e-18. At θ = 0.1 the least-squares cost is
6.4e-32, and camber is -1.1297° against
-1.1287° before: a different, consistent mechanism. The reason is in
the row (problem-mapping §3): a joint at site origin between bodies and is
one for both bodies. At the design pose (, ), whatever is.
A real contradiction needs the frame and the arm to disagree: the frame's pivot at
, the arm's still at . With the frame as (, ) and
this site's , the three uca-rear rows become . The Jacobian is
unchanged; the residual is shifted by , with in those three rows and
zero elsewhere. Below, that is exactly what is solved.
Move the frame's rear pivot. Negative fore-aft is aft, positive lateral is outboard. Each pose is the least-squares solution at θ = 0.1 rad, from SciPy's trf with otkd's exact Jacobian, seeded with the consistent pose.
Reveal result (lock in your prediction above first)
| δ | floor | predicted | largest row | uca.unit |
largest point shift | camber shift |
|---|---|---|---|---|---|---|
| -1.00 mm, fore-aft (y) | 6.99e-04 | 6.99e-04 | 4.89e-04 | +9.8e-05 | 0.479 mm | +0.0053° |
Why the floor is . Near the consistent pose , . Minimising over is a linear least squares problem; its residual is minus its projection onto the range of , that is the projection of onto the left null space. With one redundancy that space is the line through , so
The residual's pattern is always 's: front and rear fore-aft rows with
opposite signs, a small share in the vertical rows and in uca.unit. Its size is
the component of the error along . For the rear pivot that is times
's rear weights dotted with the direction of the error: about
0.70 per unit fore-aft,
0.035 vertically, and zero laterally.
The lateral curve is not zero but quadratic: across the axis the arm swings to meet
the pivot, the distance between the pivots changes only by about
, and the pose moves instead. A 2 mm lateral error leaves a floor
of 7.0e-06
and moves a point by
3.05 mm.
otkd's verdict. Run through otkd's own least_squares, the 1 mm aft case raises:
least squares did not converge: Both
ftolandxtoltermination conditions are satisfied.
Read the message with care. The quoted SciPy reason is a convergence message: its own tests on the step and on the fall in were met, at a minimum. What failed is otkd's extra demand that vanish too. A Gauss–Newton run on the same case shows both quantities: goes 1.0e-01, 8.4e-03, 7.0e-04, 7.0e-04, 7.0e-04 and stops, while goes 2.0e-01, 1.9e-02, 3.7e-05, 8.3e-09, 4.3e-14, 1.9e-15. The minimum was found; the rows disagree.
When reading the residual floor breaks
- Assumes: the floor is measured against round-off for the size of the rows
- When it fails: an error across the dependent direction raises the floor only quadratically, so a millimetre of misplacement can hide below a tolerance of while the pose moves
- Check: compare the floor with for the errors you can imagine, and look at the pose, not just the residual
4. Weights and units
Setting: the problem, its sets and its symbols
Problem. Given the contradicted residual with = 1 mm aft, and a diagonal weight , find , and how , its camber and its per-row residual depend on ; repeat with .
| Symbol | In | Meaning |
|---|---|---|
| the unknowns | ||
| the residual of §3, , with the 1 mm aft error | ||
| the weights; carries the inverse of row 's unit, so every is in one currency | ||
the slider's weight on the three uca-rear rows |
||
| the rows in metres (joint translations, the tie rod) | ||
| millimetres multiplies by 1000 for | ||
| the weighted pose, and the consistent pose of §1 | ||
| camber (deg) |
How these symbols connect
Premultiplying the 22-row residual by a positive diagonal matrix forms the weighted objective , whose minimiser is . The two controls assemble together: scales every metre-valued row in by when switched to millimetres, while the slider multiplies the three uca-rear rows by . Solving for at both mm aft and , and comparing camber and unweighted residuals against , measures how row scaling influences the pose.
Symbol-by-symbol notes
$W$ and its units
Here with every , so each row contributes to . Assigning the inverse of row 's unit puts every product into one dimensionless currency before squaring.
$w$ vs $W$
Lowercase is the slider factor applied only to the three uca-rear rows (tx, ty, tz), whereas uppercase is the full diagonal matrix combining with any unit rescaling on .
$M$ and $\text{units}$
The subset contains only the rows in metres (joint translations and the tie-rod length), excluding the driver row (rad) and dimensionless rotation and quaternion-norm rows. Selecting millimetres multiplies by for while leaving all other rows unchanged.
$q^*_W$ vs $q^*$
Both live in , and camber and point shifts compare against the unweighted consistent pose from §1; after solving with , individual row residuals are still displayed unweighted in their original units.
One residual holds metres (joint rows), radians (the driver row) and pure numbers (the rotation and quaternion-norm rows; problem-mapping §3.6 lists each row's unit). An unweighted prices a metre, a radian and a unit of norm the same: an exchange rate no one chose. Weighting makes the choice explicit: minimise with diagonal. Writing rows in millimetres is on those rows. The prediction below asks what that choice does.
The control is the weight on the rear leg's rows, with the 1 mm aft error of §3.
Reveal result (lock in your prediction above first)
| joint rows in | rear-leg weight | camber | camber shift from consistent | largest point shift | uca.unit |
|---|---|---|---|---|---|
| metres | 1 | -1.1234° | +0.0053° | 0.479 mm | +9.80e-05 |
Residuals are shown unweighted, in metres (×10⁻³, so millimetres) or as pure numbers.
In metres with equal weights the camber moves +0.0053°;
in millimetres it moves +0.2238°, about
42 times as far,
because uca.unit takes +4.99e-03: the arm is scaled by , about
0.50 %, which is 1 mm over the 200 mm
between the pivots. A heavy rear weight puts the misfit in the front leg, a light one
in the rear leg: the pose follows the weights.
The consistent model does not care. With no error, across every weight and both units on this slider, the solved pose differs from the unweighted one by at most 1.7e-15. Weights change a consistent model's conditioning and iteration path, never its answer.
When a weighted residual breaks
- Assumes: the weights say how much a unit of misfit in each row costs, in one common currency
- When it fails: rows in different units are weighted by accident; a weak row (here the quaternion norm) absorbs the contradiction and the model stops being the mechanism
- Check: solve with two different, defensible weightings: a consistent model gives the same pose, a contradicted one does not
5. Right, or merely small
Setting: the problem, its sets and its symbols
Problem. Given the contradicted residual and the dependent set , (i) compare for the error on the rear pivot with the residual for the same error on the front pivot; (ii) for each find solving the square system , , and compare the with each other and with .
| Symbol | In | Meaning |
|---|---|---|
| the row index set | ||
| the dependent set: the rows the left null vector links (§1) | ||
| the residual with the 1 mm aft error (§3), mixed units | ||
| the shift for the error on the front pivot, and on the rear (m) | ||
| the unweighted least-squares pose | ||
| the solution with row dropped | ||
| the Jacobian without row , and its condition number | ||
| camber (deg) | ||
| a joint row's stiffness (N/m), for the closing argument |
How these symbols connect
This section runs two tests on the contradicted model using the dependent row set named by in §1. First, applying the 1 mm aft pivot offset as (front pivot) versus (rear pivot) lets us compare the resulting least-squares residuals and poses . Second, deleting each row in turn leaves a square system with Jacobian and exact solution , whose camber and conditioning we compare across and against , before using physical joint stiffnesses to judge when a weighted compromise has physical meaning.
Symbol-by-symbol notes
$K \subset I$
The dependent set collects only the rows carrying non-zero weight in the left null vector of §1 (numerically above ). Rows in do not participate in the redundancy.
$e\lt em>{\mathrm{f}}$ vs $e\lt /em>{\mathrm{r}}$
Both vectors lie in (entries in metres) and encode the same 1 mm aft frame-pivot offset: places on uca-front.ty, whereas places it on uca-rear.ty (the shift used in §3–4).
$q^{(k)}$ and $J_{-k}$
Omitting one row removes one equation from the 22-row model, leaving the square Jacobian and the pose where the remaining 21 rows vanish exactly. The superscript labels the omitted row, not an iteration counter.
$q^*_\delta$ vs $q^{(k)}$
While minimises across all 22 rows in , each satisfies for all and leaves any residual solely in the omitted row .
Stiffness $k_i$ vs omitted row $k$
Do not confuse the omitted row index with the physical joint stiffness (in N/m), used in the closing discussion to connect weighted least squares with elastic strain energy.
Two tests decide what a least-squares pose is worth. The first is the prediction below: can the residual say which row is wrong? The second drops rows.
Reveal result (lock in your prediction above first)
Residual with the error on the front pivot plus residual with it on the rear: at most 2.4e-07 in any row, against a floor of 7.0e-04. The patterns are equal and opposite to second order. The poses are not: camber -1.1321° with the front pivot out, -1.1234° with the rear, -1.1287° as drawn. The residual is the projection of the error onto the left null space, a single line, so it cannot carry which member of the dependent set is wrong. This is the deeper page's warning, measured: least squares does not tell you which equation is wrong.
Drop a dependent row. M08 §2 dropped uca-front.ty and showed that Newton on the
square system matches least squares. That is a test of consistency only if it is repeated:
in a consistent model every member of the dependent set says the same thing, so every drop
gives the same pose. Keep the 1 mm aft error and drop each of the five in turn.
Dropping uca-front.ty: the square system has condition number 47; its
exact solution leaves 1.00e-03 in the dropped row, moves a point by
1.00 mm and gives camber -1.1268° (the dashed line is the
pose as drawn, -1.1287°). With no error, all five drops agree with least
squares to 1.7e-15 in every pose coordinate.
Each drop declares one member of the dependent set to be the wrong one and believes
the rest. Dropping uca-rear.ty discards exactly the row that carries this error and
recovers the drawn pose. The vertical rows have small weight in , so believing them
over a fore-aft row moves points several millimetres for a 1 mm error, through a square system with condition number near 10⁴. Dropping
uca.unit lets the arm change size freely, and lands on the millimetre-weighted pose of §4.
Least squares sits between them, at a point set by the weights.
So a least-squares pose is right when the floor is at round-off: the model is consistent, every drop agrees, and the weights do not matter. With a floor above round-off it is merely small, unless the weights mean something physical. One choice does: if each row is a joint of stiffness , then with is the strain energy, and its minimum is the pose the real corner takes when its bushes share the misfit. That needs the rigid rows, such as the quaternion norms, held as hard constraints, which is the KKT problem of M04 §6. Unit weights in mixed units are not that.
When dropping a dependent row breaks
- Assumes: the model is consistent, so every member of the dependent set says the same thing
- When it fails: with a contradiction each drop gives a different pose, and a row with a small weight in the left null vector gives an ill-conditioned square system that moves the pose far
- Check: drop each member of the dependent set in turn; agreement to round-off is consistency
Practice
Hint 1
Minimise : set the derivative to zero.
Hint 2
: the weights enter squared.
Mixed practice: which method, and why?
Name the class of problem before you pick.
Check yourself (closed book)
Keep these:
- Redundancy is rows minus rank; the left null vector names the rows that restate each other, here both legs' fore-aft and vertical rows and the arm's quaternion norm.
- Least squares minimises and stops when ; Gauss–Newton solves a linear least-squares problem per step (by QR), and otkd's trust region limits that step until the model is trusted.
- Floor at round-off: consistent, and the answer is the square model's. Floor above it: a contradiction, of size about , and only errors along the dependent direction raise it in proportion.
- A contradicted answer belongs to the weights; units are weights. A consistent answer does not depend on them.
- The residual names the dependent set, never the faulty row. A compromise is right only when the weights are physical (square roots of stiffnesses) and the rigid rows are hard.
Your connection
Think of a fit or a model you rely on that has more equations than unknowns. Is its floor round-off, noise or a contradiction, and what weights is its answer using?
Answers
Practice A. mm.
Practice B. mm.
Practice C. , since .
Mixed practice. QR least squares; Newton; the left null space then a drop; an energy minimisation with hard rows (KKT); Monte Carlo.
Where the maths is derived
Optional. These notes give the intuition and application; the sources below give the full derivations and proofs.
§2 What least squares minimises, and how otkd does it
- Nocedal and Wright (2006), Numerical Optimization: trust-region methods (ch. 4), and Gauss–Newton, Levenberg–Marquardt and the large-residual case (ch. 10).
§3 A consistent redundancy against a contradiction
- Trefethen and Bau (1997), Numerical Linear Algebra: least squares as an orthogonal projection, and the SVD's four fundamental subspaces.
§4 Weights and units
- Nocedal and Wright (2006), Numerical Optimization: scaling of variables and of the trust region (ch. 4), and the least-squares problem with its weights (ch. 10).
Compiled from notebooks/suspension/s03_two_legs_least_squares.py — run locally with cd notebooks && uv run marimo edit suspension/s03_two_legs_least_squares.py for live Python scratch cells.
Back to the book: 1.3 Two legs, one contradiction · Chapter 1 Review