up previous next
LinSol

find a solution to a linear system

Syntax
LinSol(M:MAT, RHS:MAT):MAT or STRING

where M is an m x n matrix over ZZ or QQ, and RHS is an m x k matrix
with entries in ZZ or QQ.

Description
***** NOT YET IMPLEMENTED *****

This function finds a solution to the inhomogeneous linear system of equations represented by M and RHS. Specifically, if no solution exists then it returns the string "no solution"; otherwise it returns a matrix, X, with entries in ZZ or QQ, such that M*X = RHS . Once one solution has been found, all solutions may be found with the help of the function LinKer .

NOTE: an easy way of converting a list into a column matrix (for the second argument) is to use the function ColMat .

Example
  M := Mat([[3,1,4],[1,5,9],[2,6,5]]);
  L := [123,456,789];
  LinSol(M, ColMat(L));
Mat([
  [199/5],
  [742/5],
  [-181/5]
])
-------------------------------
  M*It;
Mat([
  [123],
  [456],
  [789]
])
-------------------------------
  LinSol(M,Transposed(Mat([L,[1,2,3]])));
Mat([
  [199/5, 4/15],
  [742/5, 7/15],
  [-181/5, -1/15]
])
-------------------------------
There is an experimental low-level interface: $builtin.LinSol which expects as second argument a list of lists [L_1,...,L_k] where each L_i is a list of length m with entries in ZZ or QQ (to be considered as a list of column vectors). The result is a list of lists [X_1,...,X_k] where each X_i is either a solution to the linear system M X_i = L_i or it is the empty list (meaning that no solution exists to the equation M X_i = L_i).
See Also