up previous next
LinSol

find a solution to a linear system
Syntax

LinSol(M:MAT, L:LIST):LIST

where M is an m x n matrix over Z or Q, and L is a list of length m
with entries in Z or Q (or a list of such lists).


Description
This function finds a solution to the inhomogeneous system of equations represented by M and L. Specifically, it returns a list, X, of length n with entries in Z or Q, such that M*Transposed(Mat(X)) = Transposed(Mat([L])), if such X exists; otherwise, it returns the empty list. Once a solution is found, all solutions may be found using the function LinKer .

NOTE: LinSol can solve several inhomogeneous systems at once. If L has the form [L_1,...,L_k] where each L_i is a list of length m with entries in Z or Q, then LinSol(M, L) returns a list [X_1,...,X_k] where X_i is a solution to the system of linear equations represented by M and L_i.

Example
  M := Mat([[3,1,4],[1,5,9],[2,6,5]]);
  L := [123,456,789];
  LinSol(M, L);
[199/5, 742/5, -181/5]
-------------------------------
  M*Transposed(Mat([It]));
Mat([
  [123],
  [456],
  [789]
])
-------------------------------
  LinSol(M,[L,[1,2,3]]);
[[199/5, 742/5, -181/5], [4/15, 7/15, -1/15]]
-------------------------------


See Also