solve the linear equations A . x = b
LinearSolve(A, B, m, t, c, ip, options, methopts)
Matrix or list
(optional) Matrix or column Vector
(optional) equation of the form method = name where name is one of 'none', 'solve', 'subs', 'Cholesky', 'LU', 'QR', 'hybrid', 'modular', 'SparseLU', 'SparseDirect', or 'SparseIterative'; method to use
(optional) equation of the form free=name; base name to use for free variables in parametrized solutions
(optional) equation of the form conjugate=true or false; specifies whether to use the Hermitian transpose in the case of Cholesky or QR decomposition methods
(optional) equation of the form inplace=true or false; specifies if output overwrites the second argument B
(optional); constructor options for the result object
(optional) equation of the form methodoptions = list; options to control the solution method
The LinearSolve function returns the Vector or Matrix x that satisfies the linear system A·x=B.
If B is included in the calling sequence as a Matrix or a Vector, then the returned object is of the same type.
If B is omitted, then the linear system is interpreted from the first argument, which is taken to be the augmented linear system A|B, where B is a column Vector.
The dimensions of the returned object agree with the Matrix equation A·x=B. If A is m x n and B is m x p, then the solution x will be n x p.
If the solution x is computed inplace upon B, then n must be at least as large as m.
If method='subs' is specified in the calling sequence, then the first argument must be a Matrix with triangular shape. If it is upper triangular, then the Matrix is assumed to be in upper echelon form and back substitution is performed by using BackwardSubstitute. If the Matrix is lower triangular, then forward substitution is performed by using ForwardSubstitute.
If the first argument is a list, then the elements of the list are taken as the Matrix factors of the Matrix A, due to some prefactorization. These factors are interpreted, uniquely, as follows:
A list of Vector, Matrix items, ipiv,LU, is interpreted as the result of calling LUDecomposition with the output='NAG' option. The first member is taken as the pivot Vector and the second member as the superimposed LU factors. The implied option is method=LU.
A list of Matrix, Matrix, Matrix items, P,L,U, is interpreted as the result of calling LUDecomposition with the output=P,L,U option. The implied option is method=LU.
A list of a Matrix item, L, is interpreted as the result of a Cholesky decomposition. The data is taken as the lower triangle of the Matrix. The implied option is method=Cholesky.
A list of Matrix, Vector items, QR,τ, is interpreted as the result of calling QRDecomposition with the output='NAG' option. The implied option is method=QR.
A list of Matrix, Matrix items, Q,R, is interpreted as the result of calling QRDecomposition with the output=['Q', 'R'] option. The implied option is method=QR.
The sparse methods cannot be used with prefactored input.
The method='SparseIterative' option is compatible with real symmetric or complex hermitian Matrices having storage mode sparse[lower] or sparse[upper]. It is also compatible with real nonsymmetric or complex nonhermitian Matrices which are square and have storage mode sparse. This is the default method when such a matrix is specified. The method='SparseDirect' option is compatible with real, square Matrices having storage mode sparse.
The method='hybrid' option provides a LU-based solver which operates in part in both hardware and software float modes. This can be a more efficient solver at high settings of Digits. It computes the LU decomposition in hardware floating-point mode and then does iterative refinement in software floating-point mode.
The use of the method='modular' option invokes the LinearAlgebra[Modular][IntegerLinearSolve] routine. It can compute rational solutions for an integer input Matrix. The system is solved mod 'p' for a machine-size prime and p-adic lifting is used to construct the rational solutions.
The inplace option (ip) determines where the result is returned. In the case of a non-augmented system, if inplace=true is specified in the calling sequence, the computation is performed directly on the second argument. The inplace option is not allowed for an augmented system, or with method='solve'.
The inplace=true condition can be abbreviated to inplace.
The inplace option must be used with caution since, if the operation fails, the original argument may be corrupted.
The conjugate option (c) specifies whether to use HermitianTranspose in the solution of a system using Cholesky or QRDecomposition methods. The default is true. The conjugate=true condition can be abbreviated as conjugate.
The constructor options provide additional information (readonly, shape, storage, order, datatype, and attributes) to the Vector or Matrix constructor that builds the result. These options may also be provided in the form outputoptions=[...], where [...] represents a Maple list. If a constructor option is provided in both the calling sequence directly and in an outputoptions option, the latter takes precedence (regardless of the order).
The methodoptions option (methopts) provides ways to control the behavior of the solution method. Currently, the only options available are used with method=SparseIterative. For more information, see Sparse Iterative Solver Options.
The inplace and constructor options are mutually exclusive.
This function is part of the LinearAlgebra package, and so it can be used in the form LinearSolve(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[LinearSolve](..).
M ≔ 1,1,1,4|1,1,−2,1|3,1,1,8|−1,1,−1,−1|0,1,1,0:
M_sol ≔ LinearSolve⁡M
A ≔ 1,0,0|2,1,0|1,0,0|−1,−1,−3:
b ≔ 2,−1,−9:
P ≔ 4,2,−1|2,4,3|−1,3,5:
z ≔ 1,0,0:
S ≔ Matrix⁡5,0,0,0,0,0,0,2,−1,2,0,0,0,0,3,0,0,0,−2,0,0,1,1,0,1,0,0,1,2,3,1,1,0,0,0,6,datatype=float,storage=sparse:
t ≔ Vector⁡15,12,18,3,−6,0,datatype=float:
N ≔ 0,1,1,1,1|2,−2,0,−2,−3|0,0,1,1,3|−6,0,−3,−1,−3|2,2,2,2,4:
q,r ≔ QRDecomposition⁡N,output='Q','R':
C ≔ 1,6,0,9,4|1,2,3,4,5:
C_sol ≔ LinearSolve⁡q,r,C
Download Help Document
What kind of issue would you like to report? (Optional)