finds an x that solves the matrix equation m.x==b.


generates a LinearSolveFunction[] that can be applied repeatedly to different b.

Details and Options

  • LinearSolve works on both numerical and symbolic matrices, as well as SparseArray objects.
  • The argument b can be either a vector or a matrix. »
  • The matrix m can be square or rectangular. »
  • LinearSolve[m] and LinearSolveFunction[] provide an efficient way to solve the same approximate numerical linear system many times.
  • LinearSolve[m,b] is equivalent to LinearSolve[m][b].
  • For underdetermined systems, LinearSolve will return one of the possible solutions; Solve will return a general solution. »
  • LinearSolve has the following options and settings:
  • MethodAutomaticmethod to use
    Modulus0whether to solve modulo n
    ZeroTestAutomatictest to determine when expressions are zero
  • The ZeroTest option only applies to exact and symbolic matrices.
  • With Method->Automatic, the method is automatically selected depending upon input.
  • Explicit Method settings for exact and symbolic matrices include:
  • "CofactorExpansion"Laplace cofactor expansion
    "DivisionFreeRowReduction"Bareiss method of division-free row reduction
    "OneStepRowReduction"standard row reduction
  • Explicit Method settings for approximate numeric matrices include:
  • "Banded"banded matrix solver
    "Cholesky"Cholesky method for positive definite Hermitian matrices
    "Krylov"iterative Krylov sparse solver
    "Multifrontal"direct sparse LU decomposition


open all close all

Basic Examples  (2)

Click for copyable input

With no righthand side, a LinearSolveFunction is returned:

Click for copyable input
Click for copyable input

Scope  (6)

Options  (6)

Applications  (2)

Properties & Relations  (4)

Possible Issues  (2)

Neat Examples  (3)

Introduced in 1988
Updated in 2014