Archi-Civilarchi-civil.com
Calculations You Can Defend · HES-02  |  Confidence: A

Home / Articles / Calculations You Can Defend HES-02

The Difference Between Reading a Calculation and Verifying It

The code of the truss and Cross engines looked reasonable when read; both were wrong. The code of the three-moment page looked correct; the first measurement said it was wrong — but what was wrong was the measurement. This article explains why reading is not enough and how verification is done.

Confidence: A Engine: engine/statics.js Test: tests/v572-inline-calc-pages.test.js Reading: ~10 min Last verified: 2026-10-21 Türkçe: Türkçe oku
Open the calculator → All articles →

1. Why reading is not enough

The truss engine's error lay in two lines: the stiffness matrix lacked the 1/L factor, the force recovery had it. Each line was reasonable on its own; the problem was that they were written with different assumptions. In the Cross engine, carry-over used the correct factor (0.5) — just on the wrong member. Someone reading the code line by line could have approved every line.

Reading is good for understanding what the code intends. The only reliable way to know what it does is to run it and compare the result with something independent of the code.

2. Verifying the verifier

The most instructive moment of the audit was a mistake. The slope-deflection, three-moment and stiffness-matrix pages looked correct when read. Even so, each was run with 20 random inputs and compared with a separately written reference solver. Two pages matched; the three-moment page showed a 107% deviation.

Before drawing a conclusion, two hand-solvable cases were checked directly: two equal spans (known answer MB = −qL²/8 = −45 kNm) and 6 m + 4 m (−35 kNm). The page was exactly right in both. The error was in the reference solver: a sign in its reaction formula had been reversed. Once fixed, the agreement was complete.

Lesson: when two independent implementations disagree, you do not know which one is wrong. A hand-solvable case decides. The verifier is code too, and it needs verifying.

3. You cannot find what is missing by reading

The response spectrum page did not include the long-period range of TBDY at all (T > TL = 6 s) and gave 33% too much acceleration there. Every existing line was correct. What was wrong was a line that had never been written. Finding an omission by reading requires knowing in advance what is missing.

What found this error was sweeping the full input range: some of the random inputs were deliberately chosen above 6 s and the result was compared with the site's TBDY engine.

Lesson: tests must cover not only typical input values but also the limits and the points where formulas change regime.

4. Honesty of the screen

Two errors concerned the screen, not the calculation. The spectrum page asked the user for a damping ratio but used it nowhere: 2% or 20%, the result was the same. The code-pack selector, in some cases, showed the US code on its button while calculating to TBDY.

In both cases the calculation engine was correct. But the user was getting wrong information from the screen about what the calculation rested on. For an engineer this is as dangerous as a wrong number.

Lesson: verification must cover what the interface says, not only the numbers: is every input actually used? Is the selection shown on screen the one used in the calculation?

5. Rounding is a source of error too

The first version of the test for in-page calculations found "mismatches" on two pages. Both were errors in the test. The page showed a = 21.1 mm, the engine 21.05 mm — the difference was only the one-decimal rounding on screen. In a footing example qmin was almost zero (1.69 kPa), where a relative tolerance becomes meaningless.

Lesson: a value read from the screen is only as precise as the decimals it shows. The test tolerance must include that rounding as an absolute allowance; otherwise correct code raises false alarms, and over time trust in the tests erodes.

6. Five rules

  1. At least one hand-solvable case for every calculation. It is the referee when two implementations disagree.
  2. An independent second implementation. A different method (slope-deflection against Cross) or a different author.
  3. Random and boundary inputs. Including the points where formulas change regime and the ends of the range.
  4. Check what the user sees. Not only the engine, but every value and every label on the screen.
  5. Verify the verifier. The reference solver, the test and the tolerance can all be wrong.

These rules have been added to archi-civil.com's tests; each comes from a situation that actually happened in the audit.

References

  1. archi-civil.com release notes (README), v569–v574: errors found, the sign error in the reference solver, and the test tolerance fix.
  2. tests/v571-continuous-beam-pages.test.js and tests/v572-inline-calc-pages.test.js: tests that run the pages' own scripts in a mock page environment with random inputs.
  3. Roache, P. J. (1998). Verification and Validation in Computational Science and Engineering. Hermosa Publishers.

The numbers in this article were produced by the site's engines; code values are given with their clause numbers.

archi-civil.com — The Difference Between Reading a Calculation and Verifying It · HES-02 ·