(expr)
return list_to_tuple_rec(christoffel)
Return the nested list of Christoffel symbols for the given metric.

    This returns the Christoffel symbol of second kind that represents the
    Levi-Civita connection for the given metric.

    Examples
    ========

    >>> from sympy.diffgeom.rn import R2
    >>> from sympy.diffgeom import metric_to_Christoffel_2nd, TensorProduct
    >>> TP = TensorProduct
    >>> metric_to_Christoffel_2nd(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
    (((0, 0), (0, 0)), ((0, 0), (0, 0)))
    >>> metric_to_Christoffel_2nd(R2.x*TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
    (((x**(-1)/2, 0), (0, 0)), ((0, 0), (0, 0)))
Return the nested list of Christoffel symbols for the given metric.
Return the nested list of Christoffel symbols for the given metric .
def metric_to_Christoffel_2nd(expr):
    """Return the nested list of Christoffel symbols for the given metric.

    This returns the Christoffel symbol of second kind that represents the
    Levi-Civita connection for the given metric.

    Examples
    ========

    >>> from sympy.diffgeom.rn import R2
    >>> from sympy.diffgeom import metric_to_Christoffel_2nd, TensorProduct
    >>> TP = TensorProduct
    >>> metric_to_Christoffel_2nd(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
    (((0, 0), (0, 0)), ((0, 0), (0, 0)))
    >>> metric_to_Christoffel_2nd(R2.x*TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
    (((x**(-1)/2, 0), (0, 0)), ((0, 0), (0, 0)))

    """
    ch_1st = metric_to_Christoffel_1st(expr)
    coord_sys = expr.atoms(CoordSystem).pop()
    indices = list(range(coord_sys.dim))
    # XXX workaround, inverting a matrix does not work if it contains non
    # symbols
    #matrix = twoform_to_matrix(expr).inv()
    matrix = twoform_to_matrix(expr)
    s_fields = set()
    for e in matrix:
        s_fields.update(e.atoms(BaseScalarField))
    s_fields = list(s_fields)
    dums = coord_sys._dummies
    matrix = matrix.subs(list(zip(s_fields, dums))).inv().subs(list(zip(dums, s_fields)))
    # XXX end of workaround
    christoffel = [[[Add(*[matrix[i, l]*ch_1st[l][j][k] for l in indices])
                     for k in indices]
                    for j in indices]
                   for i in indices]
    return list_to_tuple_rec(christoffel)
def metric_to_Christoffel_2nd ( expr ) : ch_1st = metric_to_Christoffel_1st ( expr ) coord_sys = expr . atoms ( CoordSystem ) . pop ( ) indices = list ( range ( coord_sys . dim ) ) # XXX workaround, inverting a matrix does not work if it contains non # symbols #matrix = twoform_to_matrix(expr).inv() matrix = twoform_to_matrix ( expr ) s_fields = set ( ) for e in matrix : s_fields . update ( e . atoms ( BaseScalarField ) ) s_fields = list ( s_fields ) dums = coord_sys . _dummies matrix = matrix . subs ( list ( zip ( s_fields , dums ) ) ) . inv ( ) . subs ( list ( zip ( dums , s_fields ) ) ) # XXX end of workaround christoffel = [ [ [ Add ( * [ matrix [ i , l ] * ch_1st [ l ] [ j ] [ k ] for l in indices ] ) for k in indices ] for j in indices ] for i in indices ] return list_to_tuple_rec ( christoffel )