Advanced Octave A20 — Ill-conditioned systems
Advanced GNU Octave with GX-TXT · Module 04
A linear system can have a very small residual and an extremely sensitive solution to small data variations. The number of conditioning helps to recognize this sensitivity before attributing excessive precision to the result.
Objectives and prerequisites
In the introductory course we have already solved linear systems. Here we compare two known terms almost identical with the same mal-conditioning matrix using NUMERIC_API_v1/linear_matrix via the Bridge. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. The numbers are a synthetic mathematical example.
An almost singular matrix
Import sistemi_condizionati.m, record it in the Session and run it in the Runner.
We use the A = [1, 1; 1, 1.000001] matrix: the two rows are almost proportional. The program solves A x = b once and then adds 10⁻⁷ to the second b component. For the call to Bridge it builds structures with components real and imaginary; in this example the imaginary part is nothing.
The inspect action returns information about the matrix, including the air conditioning number. The solve action provides the solution in the components provided for in the contract. The program also calculates norm(A*x-b) for each solution compared to its known term.
In the test without disturbance the solution is about [1, 1]; with the perturbation it becomes about [0,9, 1,1]. The air conditioning number is about 4 × 10⁶. The residual displayed is zero to print accuracy for both problems: each solution suits your system well, but the two systems have significantly different solutions.
How to interpret the result
The conditioning describes how much a problem can amplify relative disturbances in inputs; it is not directly equivalent to the actual error of each solution. The residual measures, however, how much the calculated solution satisfies the equations provided. If the problem is poorly conditioned, a small residual does not guarantee that the solution accurately represents the magnitude of interest when the data is uncertain.
In a spectrophotometric measure, for example, almost dependent lines could make it difficult to distinguish contributions from different species. One must examine uncertainties and models, possibly improve the experimental design or consider an appropriate method: it is not enough to increase the printed figures.
Exercise
- What was disturbed in the second calculation?
- Why does a small residue not exclude a strong sensitivity?
- Is the condition number equal to the actual error of the solution?
Worked solution
- The second component of the known term, of
10⁻⁷. - The residual controls the adaptation to the equations provided; almost identical inputs can still have very different solutions.
- No. It is an indicator of the potential sensitivity of the problem, not a direct measure of the error obtained in any case.
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