Numerical Methods

All books

The second unknown

What this page answers

The class page says a saddle-point problem carries a second unknown, and that the second unknown pays for a rule that has to hold everywhere. It does not say what that unknown is, why it is the one that goes wrong, or why an answer can have the displacements right and the forces wrong.

This closes the consistency row of the measured gaps, and it explains a symptom the book already lists: a plot that looks correct and a reaction force that does not.

The mathematics

Take the smallest possible case. Two displacements u=(u1,u2)u = (u_1, u_2), an energy

12uTKu−fTu,K=(2003),f=(1,1),\tfrac12 u^{\mathsf T} K u - f^{\mathsf T} u, \qquad K = \begin{pmatrix} 2 & 0 \\ 0 & 3 \end{pmatrix}, \quad f = (1, 1),

and one rule that must hold: u1+u2=gu_1 + u_2 = g. Write the rule as Bu=gB u = g with B=(1    1)B = (1\;\;1). Minimising the energy subject to the rule means minimising

12uTKu−fTu+pT(Bu−g),\tfrac12 u^{\mathsf T} K u - f^{\mathsf T} u + p^{\mathsf T}(B u - g),

where pp is a new unknown — one per rule. Differentiating in uu and in pp gives the pair of equations

Ku+BTp=f,Bu=g,K u + B^{\mathsf T} p = f, \qquad B u = g,

which is the block system

(KBTB0)(up)=(fg).\begin{pmatrix} K & B^{\mathsf T} \\ B & 0 \end{pmatrix} \begin{pmatrix} u \\ p \end{pmatrix} = \begin{pmatrix} f \\ g \end{pmatrix}.

The second unknown is not a slack variable or a device. BTpB^{\mathsf T} p is the force the rule exerts on the structure, so pp is the reaction force, and the last row of the block system is the rule itself.

Why it is the one that goes wrong. Eliminate uu using the first equation, u=K−1(f−BTp)u = K^{-1}(f - B^{\mathsf T}p), and substitute into the second:

BK−1f−BK−1BTp=g.B K^{-1} f - B K^{-1} B^{\mathsf T} p = g.

The matrix S=BK−1BTS = B K^{-1} B^{\mathsf T} is small, one by one here, so

p=S−1(BK−1f−g).p = S^{-1}\left(B K^{-1} f - g\right).

Look at what that computes. The bracket is the difference of two quantities of order one — the displacement the load would produce, and the displacement the rule asks for. When the constraint is nearly satisfied by the load alone, those two are nearly equal and their difference is small. The relative error of pp is therefore the relative error of the inputs multiplied by

size ofBK−1fsize ofBK−1f−g,\frac{\text{size of} B K^{-1} f}{\text{size of} B K^{-1} f - g},

which is large whenever pp is small. Meanwhile uu is recovered from f−BTpf - B^T p, and there pp is a small correction to a quantity of order one, so the same absolute error in pp moves uu far less.

That is the mechanism behind "right displacements, wrong forces": the displacement is insensitive to the multiplier, and the multiplier is a difference of large numbers. It is not an implementation error, and a better linear solver does not fix it — the sensitivity is in the formulation.

The check. Solve the system above with g=0.84g = 0.84. The multiplier is p=−0.008p = -0.008 and the displacements are (0.504,0.336)(0.504, 0.336), whose sum is 0.840.84 to the last digit. Now change the rule to g=0.841g = 0.841: one part in eight hundred. The displacements move to (0.5046,0.3364)(0.5046, 0.3364), a relative change of 0.12%0.12\%. The multiplier moves to −0.0092-0.0092, a relative change of 15%15\%. The force is more than a hundred times more sensitive to the constraint than the displacement is.

Leaving the multiplier out entirely is the other failure, and it is a large one: u=K−1f=(0.5,0.333…)u = K^{-1}f = (0.5, 0.333\ldots) misses the rule by 1/61/6, seventeen per cent.

The code

The program solves that system in exact arithmetic for two values of gg one thousandth apart, prints both answers, and prints the two relative changes side by side. The unconstrained solve is printed first, as the wrong answer the multiplier exists to correct.

One solve, two constraints, both sensitivities
import sympy as sp

K = sp.Matrix([[2, 0], [0, 3]])
B = sp.Matrix([[1, 1]])
f = sp.Matrix([1, 1])


def solve(g):
    """The constrained answer, with the multiplier p recovered last."""
    S = B * K.inv() * B.T
    p = (S.inv() * (B * K.inv() * f - sp.Matrix([g])))[0]
    u = K.inv() * (f - B.T * p)
    return p, u


plain = K.inv() * f
print("no multiplier  u =", list(plain), " gap =", (B * plain)[0] - 1)

for g in (sp.Rational(84, 100), sp.Rational(841, 1000)):
    p, u = solve(g)
    print(f"g = {float(g):.3f}   p = {float(p):+.6f}   "
          f"u = ({float(u[0]):.4f}, {float(u[1]):.4f})")

p1, u1 = solve(sp.Rational(84, 100))
p2, u2 = solve(sp.Rational(841, 1000))
print(f"force moved by  {float(abs(p2 - p1) / abs(p1)):.1%}")
print(f"u moved by      {float(abs(u2[0] - u1[0]) / abs(u1[0])):.2%}")
print("gap after       ", (B * u2)[0] - sp.Rational(841, 1000))
no multiplier  u = [1/2, 1/3]  gap = -1/6
g = 0.840   p = -0.008000   u = (0.5040, 0.3360)
g = 0.841   p = -0.009200   u = (0.5046, 0.3364)
force moved by  15.0%
u moved by      0.12%
gap after        0

The two constrained rows both satisfy the rule — the last line prints a gap of exactly zero — and their multipliers differ by fifteen per cent. A check that only looked at the displacements would call the first solve right and the second solve right, and would miss the change in the force entirely.

The theory

The block system is symmetric and indefinite: it has eigenvalues of both signs, so it is not a minimisation and the methods built for KK alone do not apply. That is the reason the class exists as a class, and the reason the algorithms that work on it are different ones.

Three things follow from the algebra above.

What it will not do: it will not give the displacements and the forces to the same relative accuracy. They are recovered from the same solve, and they are not equally sensitive to it.

What this cost

The block system is larger than KK: uu plus one unknown per rule. Assembling and solving it directly costs O((n+m)3)O((n+m)^3) for a dense solve. The sparse version costs what its factorisation costs, which for an indefinite matrix is more awkward than for a definite one: pivoting for stability conflicts with preserving the sparsity.

Eliminating uu first and solving Sp=BK−1f−gS p = B K^{-1}f - g instead costs one solve with KK per column of BTB^{\mathsf T}, plus a solve with SS. That is cheaper when there are few rules, which is the common case, and it is also the form that shows the sensitivity.

What it will not do: it will not tell you that the rules are nearly dependent. That is a rank deficiency in BB, and it shows up as an ill-conditioned SS, not as a wrong displacement.

Back to the map

Saddle point is the class page this works under. One matrix, two errors is the same sensitivity argument without the constraint. Home is the summary.

Settings

Colour scheme

Light or dark pages. Your colour and layout stay the same.

Colour

The paper, ink and lettering. Your layout stays the same.

Quiet colours
Bold colours
Layout

How pages are arranged. Your colours stay the same.

Reading offline

Keep this book on this device and read it offline.