This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / Lists and Matrices / Matrix Operations  /
LinearSolve

  • LinearSolve[ m , b ] finds an x which solves the matrix equation m . x == b.
  • LinearSolve works on both numerical and symbolic matrices.
  • The argument b can be either a vector or a matrix.
  • The matrix m can be square or rectangular.
  • For underdetermined systems, LinearSolve will return one of the possible solutions; Solve will return a general solution.
  • For sparse systems of linear equations, it will usually be much more efficient to use Solve than LinearSolve.
  • If you need to solve the same approximate numerical linear system many times, it is usually more efficient to use LUDecomposition and LUBackSubstitution.
  • LinearSolve[ m , b , Modulus -> n ] takes the matrix equation to be modulo n.
  • LinearSolve[ m , b , ZeroTest -> test ] evaluates test [ m [[ i , j ]] ] to determine whether matrix elements are zero. The default setting is ZeroTest -> (# == 0 &).
  • A Method option can also be given. Possible settings are CofactorExpansion, DivisionFreeRowReduction and OneStepRowReduction. The default setting of Automatic switches between these methods depending on the matrix given.
  • See the Mathematica book: Section 3.7.8.
  • See also Implementation NotesA.9.44.27MainBookLinkOldButtonDataA.9.44.27Implementation NotesA.9.44.29MainBookLinkOldButtonDataA.9.44.29.
  • See also: Inverse, PseudoInverse, Solve, NullSpace.
  • Related package: LinearAlgebra`Tridiagonal`.

    Further Examples

    This is the solution of the linear system m.s == v.

    In[1]:=

    In[2]:=

    In[3]:=

    Out[3]=

    This checks the answer.

    In[4]:=

    Out[4]=

    In[5]:=

    In[6]:=

    Modular systems
    You can solve matrix equations over the integers modulo .

    In[7]:=

    In[8]:=

    In[9]:=

    Out[9]=

    This checks the result and clears the variables.

    In[10]:=

    Out[10]=

    This checks the result and clears the variables.

    In[11]:=