def solve_linear_system_LU(matrix, syms):
 if (matrix.rows != (matrix.cols - 1)):
  raise ValueError('Rows should be equal to columns - 1')
 A = matrix[:matrix.rows, :matrix.rows]
 b = matrix[:, (matrix.cols - 1):]
 soln = A.LUsolve(b)
 solutions = {}
 for i in range(soln.rows):
  solutions[syms[i]] = soln[(i, 0)]
 return solutions

def solve_linear_system_LU ( matrix , syms ) : if ( matrix . rows != ( matrix . cols - 1 ) ) : raise ValueError ( 'Rows should be equal to columns - 1' ) A = matrix [ : matrix . rows , : matrix . rows ] b = matrix [ : , ( matrix . cols - 1 ) : ] soln = A . LUsolve ( b ) solutions = { } for i in range ( soln . rows ) : solutions [ syms [ i ] ] = soln [ ( i , 0 ) ] return solutions
solves the augmented matrix system using lusolve and returns a dictionary in which solutions are keyed to the symbols of syms *as ordered* .