finds an x that solves the matrix equation m.x==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:
Method Automatic method to use Modulus 0 whether to solve modulo n ZeroTest Automatic test 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 "Pardiso" parallel direct sparse solver
Examplesopen allclose all
Basic Examples (3)
Basic Uses (7)
When no right‐hand side for is given, a LinearSolveFunction is returned:
Special Matrices (5)
|"BasisSize"||the size of the Krylov basis (GMRES only)|
|"MaxIterations"||the maximum number of iterations|
|"Method"||methods to be used|
|"Preconditioner"||which preconditioner to apply|
|"PreconditionerSide"||how to apply a preconditioner ("Left" or "Right")|
|"ResidualNormFunction"||A norm function that computes a norm of the residual of the solution|
|"StartingVector"||the initial vector to start iterations|
|"Tolerance"||the tolerance used to terminate iterations|
|"BiCGSTAB"||iterative method for arbitrary square matrices|
|"ConjugateGradient"||iterative method for Hermitian positive definite matrices|
|"GMRES"||iterative method for arbitrary square matrices|
|"ILU0"||a preconditioner based on an incomplete LU factorization of the original matrix without fill-in|
|"ILUT"||a variant of ILU0 with fill-in|
|"ILUTP"||a variant of ILUT with column permutation|
|"FillIn"||upper bound on the number of additional nonzero elements in a row introduced by the ILUT preconditioner|
|"PermutationTolerance"||when to permute columns|
|"Tolerance"||drop tolerance (any element of magnitude smaller than this tolerance is treated as zero)|
Spans and Linear Independence (3)
Equation Solving and Invertibility (6)
Use LinearSolve to find a solution:
Show that the solution is unique using NullSpace:
Verify the result using SolveValues:
LinearSolve gives a particular solution:
NullSpace gives a basis for solutions to the homogeneous equation :
Verify the result using Inverse:
Confirm the result using Det:
Verify the result using Inverse:
Solve the system , with several different by means of computing a LinearSolveFunction:
The results are practically identical, even though LinearSolveFunction is multiple times faster:
Compare with the answer found by FindRoot:
Properties & Relations (9)
Confirm that SolveValues gives the same result:
LinearSolve always returns the trivial solution to the homogenous equation :
Use NullSpace to get the complete spanning set of solutions if is singular:
Compare with the result of SolveValues:
Use LeastSquares to minimize :
For a square matrix, LinearSolve[m,b] has a solution for a generic b iff m has full rank:
For a square matrix, LinearSolve[m,b] has a solution for a generic b iff m has an inverse:
For a square matrix, LinearSolve[m,b] has a solution for a generic b iff m has a trivial null space:
Possible Issues (2)
Wolfram Research (1988), LinearSolve, Wolfram Language function, https://reference.wolfram.com/language/ref/LinearSolve.html (updated 2014).
Wolfram Language. 1988. "LinearSolve." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/LinearSolve.html.
Wolfram Language. (1988). LinearSolve. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LinearSolve.html