# What are “least square solutions”

## Description

computes a matrix X that solves the linear matrix equation AX = B in the least squares sense: the columns Xj of minimize where the Bj are the columns of .

For a given vector B, a vector X minimizes if and only if X is a solution of the “normal equations” AHAX = AHB, where AH is the Hermitian transpose of the m×n matrix A. The solution is unique if rank(A) = n.

allows to solve several least squares problems simultaneously by combining several ‘right hand sides’ Bj columnwise to a matrix .

If no return type is specified via the option , the domain type of the return data depends on the type of the input matrix :

• The special solution X as well as the kernel of an arrayA are returned as arrays.

• The special solution and the kernel of an hfarray of domain type are returned as hfarrays.

• For a dense matrixA of type , both the special solution X as well as the kernel are returned as matrices of type over the ring of MuPAD® expressions.

• For all other matrices of category , both the special solution X as well as the kernel are returned as matrices of type over the ring of MuPAD expressions. This includes input matrices of type , , etc.

Without , the input data are converted to floating-point numbers. The matrix A must not contain non-convertible parameters, unless is used. If such objects are found, automatically switches to its symbolic mode, issuing a warning. This warning may be suppressed via .

Symbolic parameters in B are accepted without warning. However, cannot be used if there are any symbolic parameters in A or B.

If AHA has a non-trivial kernel, the least squares solution X is not unique. The return value is a special solution of the equation AHAX = AHB. With the method, is the special solution with columns of minimal Euclidean length.

### Note

The result computed with may differ from the solution computed with or ! In particular, this is the case for systems with a non-trivial kernel. Further, the The results computed with and may differ.

The kernel is computed only in the symbolic mode (option ). All floating-point methods return the value for the kernel.

With , the n×d matrix is the most general solution of AHAX = 0. Its columns span the d-dimensional kernel of AHA.

If the kernel is 0-dimensional, the return value of is the integer 0. If is returned as an array, the dimension d of the kernel is = . If is returned as a matrix of type or , the dimension d of the kernel is = .

### Note

Without the option , the implemented algorithms take care of numerical stabilization.

With , exact data are assumed. The least squares solutions is computed via . The symbolic strategy tries do maximize speed and does not take care of numerical stabilization! Do not use for systems involving floating-point entries! In particluar, due to round-off, it may happen that no solution of AHAX = AHB is found. In such a case, is returned. Cf. Example 4.

All entries of and must be arithmetical expressions.

### Note

Apart from matrices of type , objects from matrix domains such as or are internally converted to arrays over expressions via . Note that the option should be used if the entries cannot be converted to numerical expressions.

The same holds true for matrices passed as objects.

## Return Values

A list is returned.

The (special) least squares solution is an n×p matrix.

With , is an n×d matrix (d is the dimension of the kernel of AHA). Its columns span the kernel of AHA. If the kernel is trivial, is the integer 0.

Without , the kernel is not computed. The value is returned for the .

The list of arithmetical expressions consists of the minimized least squares deviations corresponding to the columns of and .