Language Reference

SOLVE Function

SOLVE (A, B) ;

This function is supported by the IML procedure and the iml action.

The SOLVE function solves a system of linear equations.

The arguments to the SOLVE function are as follows:

A

is an n times n nonsingular matrix.

B

is an n times p matrix.

The SOLVE function solves the set of linear equations bold upper A bold upper X equals bold upper B for bold upper X. The matrix bold upper A must be square and nonsingular.

The expression X = SOLVE(A,B) is mathematically equivalent to using the INV function in the expression X = INV(A)*B. However, the SOLVE function is recommended over the INV function because it is more efficient and more accurate.

The following example uses the SOLVE function:

A = {0 0 1 0 1,
     1 0 0 1 0,
     0 1 1 0 1,
     1 0 0 0 1,
     0 1 0 1 0};

 b = {9, 4, 10, 8, 2};

 /* solve linear system */
 x = solve(A,b);
 print x;

Figure 418: Solving a Linear System

x
3
1
4
1
5


The solution method that is used is discussed in Forsythe, Malcom, and Moler (1967). The SOLVE function uses a criterion to determine whether the input matrix is singular. See the INV function for details.

If bold upper A is an n times n matrix, the SOLVE function temporarily allocates an n squared array in addition to the memory allocated for the return matrix.

Last updated: May 07, 2026