def metric_to_Christoffel_1st(expr):
 matrix = twoform_to_matrix(expr)
 if (not matrix.is_symmetric()):
  raise ValueError('The two-form representing the metric is not symmetric.')
 coord_sys = expr.atoms(CoordSystem).pop()
 deriv_matrices = [matrix.applyfunc((lambda a: d(a))) for d in coord_sys.base_vectors()]
 indices = list(range(coord_sys.dim))
 christoffel = [[[(((deriv_matrices[k][(i, j)] + deriv_matrices[j][(i, k)]) - deriv_matrices[i][(j, k)]) / 2) for k in indices] for j in indices] for i in indices]
 return ImmutableDenseNDimArray(christoffel)

def metric_to_Christoffel_1st ( expr ) : matrix = twoform_to_matrix ( expr ) if ( not matrix . is_symmetric ( ) ) : raise ValueError ( 'The two-form representing the metric is not symmetric.' ) coord_sys = expr . atoms ( CoordSystem ) . pop ( ) deriv_matrices = [ matrix . applyfunc ( ( lambda a : d ( a ) ) ) for d in coord_sys . base_vectors ( ) ] indices = list ( range ( coord_sys . dim ) ) christoffel = [ [ [ ( ( ( deriv_matrices [ k ] [ ( i , j ) ] + deriv_matrices [ j ] [ ( i , k ) ] ) - deriv_matrices [ i ] [ ( j , k ) ] ) / 2 ) for k in indices ] for j in indices ] for i in indices ] return ImmutableDenseNDimArray ( christoffel )
return the nested list of christoffel symbols for the given metric .