Advanced Octave A64 — Numerical tests and tolerances

by Giux GX-TXT, octave-en, scripts-en 2 min read

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

  1. Which property controls the sum of the three fractions?
  2. Why do you need an absolute tolerance near zero?
  3. Is the perturbed case saved in the Source Dataset?

Worked solution

  1. The preservation of the total foreseen by the model.
  2. Only a relative criterion becomes too restrictive when the reference is null or very small.
  3. No: It is a temporary carrier used to verify that the assertion detects the violation.

Download the Module 11 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *