### MA44 Over-determined linear system: least-squares solution

To solve an equality-constrained linear least squares problem. Given an over-determined system
of $m$ linear
equations in $n$
unknowns,

$$\sum _{j=1}^{n}{a}_{ij}{x}_{j}={b}_{i},i=1,2,...m,m\ge n\ge 1,$$

it calculates the solution vector $x$
which satisﬁes the ﬁrst ${m}_{1}$
equations ($0\le {m}_{1}\le n$)
and minimizes the sum of squares of residuals

$$S\left(x\right)=\sum _{i=1}^{m}{r}_{i}^{2},$$
where

$${r}_{i}=\sum _{j=1}^{n}{a}_{ij}{x}_{j}-{b}_{i},i=1,2,...,m.$$

The matrix $A={a}_{ij}$
must have rank $n$,
that is its columns must be linearly independent. Also the ﬁrst
${m}_{1}$ rows
of $A$
must be linearly independent.

There is a re-entry facility which allows further systems having the same left-hand
sides to be solved economically.

There is an entry to obtain solution standard deviations and the
variance-covariance matrix. These are calculated on the assumption that the ﬁrst
${m}_{1}$
equations are exact and that the remaining equations have errors which are
independent random variables with the same variance.

The automatic printing of results and the calculation of equation residuals are
options.

The subroutine can be used to solve the general linear least squares data ﬁtting
problem with or without equality side conditions.