import sympy


def antal_l_coefficient(index, game_matrix):
    """
    Returns the L_index coefficient, according to Antal et al. (2009), as given by equation 1.
    L_k = \frac{1}{n} \sum_{i=1}^{n} (a_{kk}+a_{ki}-a_{ik}-a_{ii})
    Parameters
    ----------
    index: int
    game_matrix: sympy.Matrix
    
    Returns
    -------
    out: sympy.Expr
    
    
    Examples:
    --------
    >>>a = Symbol('a')
    >>>antal_l_coefficient(0, Matrix([[a,2,3],[4,5,6],[7,8,9]]))
    Out[1]: 2*(a - 10)/3
    
    
    >>>antal_l_coefficient(0, Matrix([[1,2,3],[4,5,6],[7,8,9]]))
    Out[1]: -6
    """
    size = game_matrix.shape[0]
    suma = 0
    for i in range(0, size):
        suma = suma + (game_matrix[index, index] + game_matrix[index, i] - game_matrix[i, index] - game_matrix[i, i])
    return sympy.together(sympy.simplify(suma / size), size)