Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

How the simulator is checked

The question. A simulator will print an elbow angle to twelve decimal places whether or not any of them is right. What reasons are there to believe its numbers?

Nobody can compare a simulated arm with a living one at every instant, so belief has to be built from pieces. This simulator rests on four kinds of evidence, and each answers a different question and is silent on the others. Knowing which is which is what lets a reader decide how far to trust a result, including the results in this book.

By the end you will be able to name the four kinds of evidence, say what each can and cannot show, and run one check yourself.

Two questions

A wrong number can come from two places. The program may fail to solve its equations, or the equations may fail to describe a body. The two failures have names.

Verification is the work of determining that a program represents its equations, and their solution, accurately. Validation is the work of determining how far those equations are an accurate picture of the real world, for the use the model is meant for (Thacker et al. 2004, section 1.1). A review written for models of muscle and bone puts them as two questions: “are we solving the equations correctly?” and “are we solving the correct equations?” (Hicks et al. 2015, section 1.1).

Verification is about mathematics and validation is about physics. Verification comes first, because a mistake in the mathematics can produce the right answer for the wrong reason and so hide a mistake in the physics. And neither can prove a model right in every case: each gathers evidence that the model is accurate enough for a stated use (Thacker et al. 2004, section 1.1).

Three of the four kinds of evidence below are verification. The fourth is validation.

Answers known in closed form

Some cases are simple enough for algebra to give the answer, and the simulator can be run on exactly those cases (Thacker et al. 2004, section 3.1). Every chapter of this book has done it once, in its worked example. A few of the comparisons kept with the simulator:

  • A muscle running straight across a hinge, from 0.25 m above it to 0.04 m below, has the length and the moment arm that the triangle of Stage 1 gives. At four elbow angles the simulator’s path agrees with both to within m.
  • A weight on a 0.35 m rod, swinging 2 rad to each side, is far outside the small swings for which a pendulum has a simple formula, but its period is still known exactly. The simulated period agrees to within a millionth of a second.
  • A block of rubber-like tissue stretched to 1.3 times its length should pull with its shear modulus times on each unit of its cross-section, if it keeps its volume exactly. The simulated block agrees to within 0.3 %. It should not agree better: its bulk modulus is a thousand times its shear modulus and not infinite.
  • Over a whole lift, the energy the arm gains must equal the work done by its active fibres less what joint damping removes. The simulator’s account closes to within a millionth of the work.

What this shows. That one law, in one case, is computed as intended. Because the case is small, a failure points straight at its cause.

What it cannot show. Anything about cases without a formula, and those are all the cases a simulator is built for. The straight path says nothing about a path that wraps round a bone. Closed-form answers check the parts, one at a time.

Another simulator

The second kind of evidence compares the whole against a program written by other people. OpenSim implements the same published muscle model (De Groote et al. 2016) and its own rigid-body mechanics. It was run on a published arm with two joints and six muscles (Arm26), and its results were stored as tables. Given that same small arm and those same muscle curves, this simulator must reproduce them.

This is a test of the program, not of the arm. The arm this book builds has its own anatomy and its own measured parameters, and nothing in it is set to agree with OpenSim. Its results are judged against measurements of real people, in the last section of this chapter. OpenSim serves only as a second, independently written program, run on a shared test case so that the arithmetic of the two can be compared to many decimal places. Measurements cannot do that job. People differ from one another by 30 % or more, so a programming slip that moves a result by 10 % would hide inside the spread of any measurement. Two programs given identical inputs should agree to rounding, so such a slip stands out at once.

Quantity comparedCasesLargest difference allowed
The four muscle curvesover 4000 values
Muscle lengthsover 500, six muscles in many poses m
Moment armsthe same muscles and poses m
Fibre length with fibre and tendon in balanceover 200 cases m
Tendon force in the same cases1 part in
Elbow angle of a forearm swinging under gravityevery millisecond for 0.5 s rad
Joint angles of the arm driven by its muscles, with rigid and with stretching tendons, including a 2 kg liftover 150 instants in each run rad
Tendon forces in those runs1 part in

A computer carries about sixteen digits, so the first rows are agreement to within rounding. The runs through time agree less closely, and for a reason that has nothing to do with either program’s equations: both step through time, each with its own rule and its own small error. Recomputed by OpenSim itself with a looser setting and with a different stepping rule, the reference runs moved by about rad. A comparison cannot be finer than its reference.

What this shows. Two programs, written independently from the same published description, turn the same inputs into the same outputs. A slip of programming in either would have to be matched by the same slip in the other.

What it cannot show. That the shared description is right. If both programs took a formula from a paper with a misprint in it, they would agree perfectly and both be wrong, which is why agreement between programs counts as circumstantial evidence and not as proof (Thacker et al. 2004, section 3.2). Nor does it reach beyond the cases in the tables.

Disagreement is evidence too. On the arm as published, OpenSim’s own two ways of getting a moment arm, asking for it directly and measuring how the muscle’s length changes as the joint turns, differ by up to 0.15 mm for one muscle where its path wraps round a bone. The comparisons of moment arms and of muscle-driven motion above are made on a copy of the arm with the wrapping removed, where the two ways agree to rounding. A comparison between programs tests their definitions as well as their arithmetic.

Proofs checked by machine

The third kind of evidence is about the equations themselves. The appendix of proved properties lists facts such as these: a longer tendon always pulls harder; the formula that turns a fibre’s force back into its speed undoes the force–velocity curve exactly; one step of TR-BDF2 never makes a decaying quantity grow. Each has been proved with a proof assistant, which accepts an argument only when no step is missing.

A proof covers every input at once, and no amount of trying examples can do that. But notice what it is about. It is about an equation with exact real numbers. The simulator evaluates the same equation with sixteen-digit numbers and rounds after every operation, and the proof does not read the program at all.

So each proved property is also tried on the program, at many inputs.

  • The proof says the speed formula undoes the force–velocity curve for every speed. The program, at 2001 speeds from five times the fastest shortening to five times the fastest lengthening, returns to the speed it started from to within one part in . That small remainder is the rounding.
  • The proof says one step of TR-BDF2 multiplies a decaying quantity by the factor derived in Stiff equations and implicit steps. The program’s step, at 131 values of from 0.03 to 100 000, gives that factor to within one part in a million.

There is even a place where real numbers and computer numbers part company. One term of the active force–length curve divides by a width that is zero at a single fibre length. In the computer the division gives infinity and the term comes out as 0, which is also the value the term approaches from both sides. In exact mathematics division by zero has no such answer, so the proof has to state the value 0 at that length explicitly.

What this shows. That the mathematics the simulator is built on holds together, for every input and not only the ones tried.

What it cannot show. That the program computes that mathematics, which is what the trials at many inputs are for. And it says nothing about bodies: a proof that the tendon curve always rises does not show that a tendon follows the curve.

Published measurements

The last kind of evidence is the only one that looks at a body. The arm model of the last part of this book is compared with three sets of measurements. The measured moment arms and fibre movements were not used in building it. The strength measurements were, in part, and the difference matters.

Moment arms. In ten arms from cadavers, the greatest elbow moment arm of each muscle was measured (Murray et al. 2002, table 3).

MuscleModelRange across the measured arms
Biceps, two heads46.1 and 46.3 mm42–54 mm
Brachialis28.2 mm21–30 mm
Extensor carpi radialis longus31.0 mm26–45 mm
Triceps, three heads18.5 to 21.8 mm18–28 mm
Brachioradialis76.9 mm70–90 mm
Pronator teres15.9 mm13–20 mm

Every one lies inside the range of real arms. Two did not until their origins were placed by measurement rather than by the atlas: the same study found that a muscle’s greatest moment arm follows the distance from the axis to its nearer attachment, and brachioradialis and pronator teres now arise at the distance that relation gives for the measured moment arms (Stage 3). With the atlas’s own origins they peaked at 52.0 and 10.5 mm, below the range.

How far the fibres move. The same group reported the change in fibre length over 100° of elbow movement, 90° for the triceps, as a fraction of optimal fibre length (Murray et al. 2000). The model gives 55 % for the long head of the biceps against 56 % measured, 49 % against 48 % for the short head, and 26 % against 28 % for the long head of the triceps. For brachioradialis it gives 59 % against 55 %: with its origin placed by measurement its fibres now travel a little further than measured, where with the atlas’s origin they travelled 42 %.

Strength. Thirty men pushed and pulled as hard as they could with the elbow held at five angles (Frey-Law et al. 2012, tables 4 and 5). The men were larger than the man whose anatomy the model is built from, so the model is first made their size, and its muscles are driven as the men drove theirs (Stage 3). Its elbow then straightens more weakly than the average man at four of the five angles, by 0.5 to 0.9 standard deviations, and as strongly at 110°: at 40° it gives 36.8 N·m where the men averaged 50.5 N·m with a standard deviation of 14.7. Nothing in the extensors was adjusted to these measurements, so this is a fair comparison, and it says the model’s triceps is on the weak side of ordinary.

The flexors are a different case. Driven the same way the model gives 48.1 N·m at 40° against 62.9 ± 14.8, 66.3 N·m at 65° against 63.0 ± 12.9, and 32.2 N·m at 15° against 56.4 ± 13.5, 1.79 standard deviations below the average there and within one of it at the other four angles. But one number in the model was chosen with these very measurements in view. How long the flexors’ fibres are when the elbow is nearly straight was not known for this arm. The value adopted, 1.23 times their optimal length, is among those that bring the flexion torque at 15° within two standard deviations of the men: every value from 1.05 to 1.30 does, the best only just, 1.67 below for 1.08 to 1.13, and 1.23 leaves it 1.79 below, so the adjustment makes the model pass with little to spare. Calibration is the adjusting of a model’s numbers to improve its agreement with measurements. It is a proper part of building a model, and it is not validation: measurements used to set a number cannot also be used to test it (Thacker et al. 2004, glossary and sections 4 and 5). The flexion figures show how well one adjustable number could be made to fit, and that here it only just fits.

Since then (passive rounds M1 and M2, 28 and 29 November 2026). The figures above are from the round in which the calibration was made. Passive round M1 gave the biceps its measured operating length in place of the calibrated value, and the flexion test at 15° began to fail. Passive round M2 then made the comparison like for like: Frey-Law subtracted each angle’s relaxed torque from the men’s peaks, and the model’s relaxed moment is now subtracted too. The model bends with 27.9 N·m at 15°, 2.11 standard deviations below, and straightens within 0.61 of the men at every angle (Stage 3). The failure is kept: a calibration that is replaced by a measurement does not come back to rescue a test.

What this shows. That for these quantities, in these poses, the model behaves like a person within the spread of people, and where it does not, by how much and in which direction.

What it cannot show. Anything outside what was measured: other joints, moving contractions, another person. A model is valid for the range in which it was compared (Thacker et al. 2004, section 4). The measurements carry errors of their own, and were made for their authors’ purposes and not to test a model (Thacker et al. 2004, section 4.3). A torque is a force times a moment arm, so a right torque can hide two errors that cancel, which is why the moment arms are compared separately (Thacker et al. 2004, section 4.1). In the same way a right total can hide a wrong split: since lane LS1 the share each elbow flexor takes of a held load is compared with living flexors’ EMG and elastography, and the model fails all four of those tests while its bending strength at 90° passes against thirty men (Many muscles, one joint). And a comparison counts only while the model has not been adjusted to pass it, as the flexors show.

The four side by side

EvidenceThe question it answersWhat it leaves open
Closed-form answerIs this law computed as intended?Every case without a formula
Another simulatorDo two independent programs agree?Whether the description they share is right
Machine-checked proofDo the equations have this property for every input?Whether the program computes those equations
Published measurementDoes the model behave like a body, here?Everything that was not measured

No row can stand in for another. A model can pass the first three and still describe no arm that ever lived, and a model that matches a measurement may be doing so by a mistake that happens to help.

A worked example: halving the step

One check asks for no formula, no second program and no measurement, and anyone can run it. A stepping rule of order has an error in proportion to the step raised to the power . Halve the step, and the error must fall by a factor of : 2 for a first-order rule, 4 for a second-order one, 16 for a fourth-order one. If a rule is programmed with a wrong weight or a slope taken at the wrong moment, it usually still gives plausible answers, and this factor is where the fault shows. Refining the step until the answer settles is the most common check on any computed solution (Thacker et al. 2004, sections 1.1 and 2). The same check made in space, with bricks in place of steps, is How fine is fine enough?.

Take the weight of Stepping through time, let go from 60°, and ask where it is 0.48 s later. A reference computed to thirteen digits says −43.43°. The table gives the size of each rule’s error.

StepExplicit EulerBackward EulerTR-BDF2Runge–Kutta 4
20 ms4.624°4.849°0.042 11°0.000 084 4°
10 ms2.363°2.418°0.010 48°0.000 005 01°
5 ms1.191°1.205°0.002 62°0.000 000 305°
20 ms ÷ 10 ms1.962.014.0216.85
10 ms ÷ 5 ms1.982.014.0116.45

To check one cell: . The two first-order rules halve their error, TR-BDF2 quarters it, and Runge–Kutta 4 divides it by a number that closes on 16 as the step shrinks. The semi-implicit rule of Stepping through time is first order too, and its error halves in the same way in that chapter’s laboratory.

Try it

The lab opens with steps of 20 ms. Each press of Step halves the step and computes the swing again with all four rules.

  1. Check the worked example. The readouts give the first row of the table: 4.624° for explicit Euler and 0.0421° for TR-BDF2. Press Step: the errors are 2.363° and 0.0105°, divided by 1.96 and 4.02.
  2. Predict, then check. After three more presses the step is 1.25 ms, a sixteenth of where it started. What will TR-BDF2’s error be? About ; the lab says 0.000 163°.
  3. Read the first plot. Each rule’s points settle on one of the dashed lines at 2, 4 and 16.
  4. Read the second plot. It counts the decimal places of the angle that each rule has right. Each halving is worth 0.3 of a place to a first-order rule, 0.6 to TR-BDF2 and 1.2 to Runge–Kutta 4.
  5. A different swing. Set the starting angle to 170°, nearly upside down, and halve five times. The errors are different and the factors are the same: 1.99 and 2.01 for the two Euler rules, 4.00 for TR-BDF2 and 15.9 for Runge–Kutta 4.

What this model leaves out

  • How uncertain the inputs are. The checks above take the model’s inputs as given. A muscle’s strength and a tendon’s slack length are themselves measurements with a spread, and that spread passes through the model into its results. Following it through is a study of its own (Thacker et al. 2004, section 4.4); What the model leaves out lists what is known to matter for the arm.
  • Experiments made for the purpose. The measurements used here were found in the literature. An experiment designed to test a model records everything the model needs as input, on the same person (Thacker et al. 2004, section 4.3).
  • Other people. One model of one arm is compared with groups of other people. Fitting the arm to a person is about closing that gap.
  • How far two runs may differ. Halving the step checks a stepping rule; it does not say how much a whole run moves when a solver setting changes by a negligible amount. When two runs disagree measures that spread on the arm’s curl.

Summary

  • Verification asks whether the equations are solved correctly; validation asks whether they are the correct equations. Neither can do the other’s work.
  • A closed-form answer checks one law in one case, to rounding. Another simulator checks the whole program, as far as the description both share is right.
  • A proof covers every input of an equation and says nothing about the program, so each proved property is also tried on the program at many inputs.
  • Published measurements are the only check against a body. The arm model matches most of them within the spread of people and misses some, and a measurement used to set one of the model’s numbers no longer counts as a check.
  • Halving the step should divide a rule’s error by two to the power of its order. It is a check anyone can run.

Next: a solver can be verified and still give two runs that disagree. How large a difference is the model’s own spread? When two runs disagree.