Advanced Octave A64 — Numerical tests and tolerances
Advanced GNU Octave with GX-TXT · Module 11
A scientific result can be controlled through properties that must remain true, such as the preservation of a quantity. We build audits on the results of the A49 reaction network.
Objectives and prerequisites
Run first A49, which creates the three Datasets of fractions A, B and C. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import test_bilancio.m, register it and run it in the Runner.
Significant controls
The script reads 121 samples for each fraction, verify that they are finished and that time coordinates coincide. Then check initial conditions, non-negative fractions within a small tolerance and preservation of A+B+C = 1.
For the total use the abs(calcolato-atteso) <= atol + rtol*abs(atteso) criterion, with atol = 1e-10 and rtol = 1e-8. The absolute part is useful near zero; the relative part takes into account the scale of the expected value. Tolerances must be chosen by problem, unity and precision: these values are demonstrative, not universal.
In the test the maximum deviation of the total is about 3.55 × 10⁻¹⁵. The script then intentionally adds 0.01 to the total and verifys that the assignment refuses; the catch serves to show the expected failure without interrupting the demonstration. The original Datasets are not modified.
Limit of testing
The controls examine the properties declared on the available samples. They do not prove that equations represent a real system, nor replace a comparison with independent data. A robust test includes normal cases and cases that must fail; it also records tolerances and motivations.
Exercise
- Which property controls the sum of the three fractions?
- Why do you need an absolute tolerance near zero?
- Is the perturbed case saved in the Source Dataset?
Worked solution
- The preservation of the total foreseen by the model.
- Only a relative criterion becomes too restrictive when the reference is null or very small.
- No: It is a temporary carrier used to verify that the assertion detects the violation.
Other steps of this project
- Advanced Octave A75 — Dynamical systems in phase space
- Advanced Octave A81 — Geography of the waves and a 3D surface
- Advanced Octave A82 — Age, sex and demographic inequalities
- Advanced Octave A83 — All-cause mortality, certified COVID deaths and surveillance
- Advanced Octave A84 — A reproducible public account
- Advanced Octave A73 — Optimization landscapes and 3D trajectories