def second_tensor_invariant(A):
    """
    Calculates the second tensor invariant of a symmetric 3x3 matrix.

    Returns a scalar.
    """
    I2 = ( (A[1,1] * A[2,2]) + (A[2,2] * A[0,0]) + (A[0,0] * A[1,1]) 
          - A[1,2]**2 - A[2,0]**2 - A[0,1]**2 )
    
    return I2