Best Practices for Numerical Computations
Numerical problems are often subtle.
When a Clean Run Is Not Enough
Numerical problems are often subtle. A calculation can finish without any visible trouble, print a tidy number, and still rest on a mathematical idea that you have never fully checked. The guidance for this chapter is direct: before you rely on the result of a numerical computation, you should be certain about the mathematical aspects of the problem. If you are not certain, you should not simply carry on as though the answer is settled.
What do you think happens?
A computation runs with no errors and produces a number. Does that prove the mathematics behind it is sound?
Reveal answer
No. Running a computation without error does not by itself establish that its mathematics is sound.
Error-free execution only tells you the steps could be carried out. It says nothing about whether the rule applied at each step actually fits the problem. That fit is the thing you must be certain about.
Tracing a Multi-Stage Computation
Consider a result produced in several stages, where each stage feeds its output into the next. The stages are linked, so the final number depends on every one of them. If any stage relies on a mathematical rule that does not truly fit the situation, the error does not announce itself. The later stages simply carry the number forward, and the final output looks just as confident as a correct one would.
A Three-Stage Result With One Doubtful Stage
You compute a result in three stages. At Stage 2 you are unsure whether the mathematical rule you are applying really fits the situation. Stage 2 runs without errors and produces a number. What should you do before treating the final result as settled?
- 1Stage 1 completes
The first stage runs, and you are satisfied that its mathematical basis fits the problem. Its output passes to Stage 2.
- 2Stage 2 runs without errors
The computation finishes and produces a number. No error is raised, so the run looks successful.
- 3Check the mathematics, not the run
The clean run does not establish that the mathematics is sound. You are not certain whether the rule fits, so the number from Stage 2 cannot yet be treated as settled.
- 4Stage 3 uses the doubtful number
If you continued, Stage 3 would build on the unconfirmed output. The final result would inherit the uncertainty without showing it.
- 5Apply the guidance
Because you are not certain, you do not carry on as if the answer is settled. You move to one of the recommended responses: expert advice, experimentation, or both.
The final number is not yet trustworthy. The doubtful stage must be resolved before the result is relied upon.
The Certainty Check Comes First
The source describes a cautious decision process. The first question is always whether you are certain about the mathematics of the problem. The certainty check comes before anything else. If you are certain, you move straight to the solution and use the result.
If you are not certain, the process does not end there. One of the remaining paths applies. You can take expert advice, you can experiment, or you can do both. The source does not require you to pick only one of these, and combining them is allowed. Whichever path you take, the uncertainty must be resolved through it before you treat the final number as settled.
Expert Advice, Experimentation, or Both
When you are not certain, the source gives you three options. The wording is deliberate: the choice is yours. Taking expert advice means getting an outside view on the mathematics of the problem. Experimenting means testing the computation yourself to learn how it behaves. Doing both means using the two together, which the source explicitly permits.
Applying the Process to an Unclear Step
Now apply the full cautious process to the three-stage result from earlier. You have reached Stage 2 and you are unsure whether its mathematical rule fits. Walk through the decision in order, checking the certainty question first and then choosing a branch.
- 1Ask the certainty question first: are you certain about the mathematics of Stage 2? You are not, so you cannot move straight to the solution.
- 2Recognise that the clean run from Stage 2 does not settle the question, because error-free execution does not establish that the mathematics is sound.
- 3Choose one of the remaining paths: take expert advice, experiment, or do both. Any of these is acceptable under the source's guidance.
- 4Resolve the doubt through the path you chose. Only after the uncertainty about Stage 2 is resolved should you let Stage 3 build on its output.
- 5Once you are certain about the mathematics, proceed to the final result and treat it as settled.
Mistakes to Avoid
Common mistake Treating a clean run as proof that the mathematics is correct
What it looks likeA stage finishes with no error messages, so the number is assumed to be right.
Why it failsThe source states that running a computation without error does not by itself establish that its mathematics is sound.
Do this insteadCheck whether the mathematical rule fits the problem, separately from whether the code ran.
Common mistake Carrying on when you are unsure
What it looks likeYou doubt a rule in Stage 2 but continue straight into Stage 3 because the output looks reasonable.
Why it failsThe guidance says that if you are not certain, you should not simply carry on as if the answer is settled.
Do this insteadStop at the uncertain step and move to one of the recommended responses.
Common mistake Assuming you must choose only one response
What it looks likeYou decide that either expert advice or experimentation must be picked, and never both.
Why it failsThe source says the options are not exclusive and that combining the two is allowed.
Do this insteadUse expert advice, experimentation, or both, depending on what the situation needs.
Common mistake Skipping the certainty check and going directly to experiments
Practice: Deciding on an Unclear Step
A colleague shows you a numerical result. The program ran without errors, but you are not sure the mathematical rule used in the middle step truly fits the problem. Walk through the cautious decision process: what is the first question you ask, what do you do if the answer is no, and what must happen before you treat the final number as settled?
Hints
- Start with the certainty check, which comes before any other step in the process.
- Remember that the three responses are not exclusive.
- Think about whether the clean run itself answers the question about the mathematics.
Key Takeaways for Numerical Work
The core habit is to separate two questions that are easy to blur together: whether the computation ran, and whether its mathematics is sound. Only the second one tells you whether the result can be relied upon.
At a glance
- Numerical problems are often subtle, so be certain about their mathematical aspects before you rely on a result.
- A computation that runs without error does not by itself establish that its mathematics is sound.
- When you are not certain, the certainty check comes first, and then you take expert advice, experiment, or do both.
- The three responses are not exclusive, but whichever you use must resolve the doubt before the final number is treated as settled.