def forward_substitution(lower_triangle, variable, constant, K):
 copy_lower_triangle = copy.deepcopy(lower_triangle)
 nrow = len(copy_lower_triangle)
 result = []
 for i in range(nrow):
  a = K.zero
  for j in range(i):
   a += (copy_lower_triangle[i][j] * variable[j][0])
  variable[i][0] = ((constant[i][0] - a) / copy_lower_triangle[i][i])
 return variable

def forward_substitution ( lower_triangle , variable , constant , K ) : copy_lower_triangle = copy . deepcopy ( lower_triangle ) nrow = len ( copy_lower_triangle ) result = [ ] for i in range ( nrow ) : a = K . zero for j in range ( i ) : a += ( copy_lower_triangle [ i ] [ j ] * variable [ j ] [ 0 ] ) variable [ i ] [ 0 ] = ( ( constant [ i ] [ 0 ] - a ) / copy_lower_triangle [ i ] [ i ] ) return variable
performs forward substitution given a lower triangular matrix .