# linsolve

Solving Ax = B for x

### x = linsolve(A, B)

• A should be m×n, and B m×k for any positive integers m and k.
• It solves the system of linear equations Ax = B for x.
• If A is not square, QR decomposition is used to obtain a least square solution of Ax = B. It reports a warning, and proceeds to compute a solution anyway, if A is rank deficient.
• If A is a square matrix, LU decomposition is used. It returns an error if A is singular. It reports a warning, and proceeds to compute a solution anyway, if the reciprocal of the condition number of A is less than norm(A)*eps (i.e., A nearly singular or badly conditioned).

### [x,r] = linsolve(A, B)

• A and B are matrices as specified for x=linsolve(A,B) above.
• The output x is the same as that obtained by x=linsolve(A,B).
• r is
• the rank of A when A is not square,
• the reciprocal of the condition number of A when A is square.
• Warning messages for rank deficiency and badly conditioned matrix are suppressed.