(m1: Monomial, m2: Monomial)
return Monomial(result_variables, Fraction(m1.coeff * m2.coeff, 1))
Given two monomials (from the
    cycle index of a symmetry group),
    compute the resultant monomial
    in the cartesian product
    corresponding to their merging.
Given two monomials (from the
    cycle index of a symmetry group),
    compute the resultant monomial
    in the cartesian product
    corresponding to their merging.
Given two monomials ( from the cycle index of a symmetry group ) compute the resultant monomial in the cartesian product corresponding to their merging .
def cycle_product(m1: Monomial, m2: Monomial) -> Monomial:
    """
    Given two monomials (from the
    cycle index of a symmetry group),
    compute the resultant monomial
    in the cartesian product
    corresponding to their merging.
    """
    assert isinstance(m1, Monomial) and isinstance(m2, Monomial)
    A = m1.variables
    B = m2.variables
    result_variables = dict()
    for i in A:
        for j in B:
            k = lcm(i, j)
            g = (i * j) // k
            if k in result_variables:
                result_variables[k] += A[i] * B[j] * g
            else:
                result_variables[k] = A[i] * B[j] * g

    return Monomial(result_variables, Fraction(m1.coeff * m2.coeff, 1))
def cycle_product ( m1 : Monomial , m2 : Monomial ) -> Monomial : assert isinstance ( m1 , Monomial ) and isinstance ( m2 , Monomial ) A = m1 . variables B = m2 . variables result_variables = dict ( ) for i in A : for j in B : k = lcm ( i , j ) g = ( i * j ) // k if k in result_variables : result_variables [ k ] += A [ i ] * B [ j ] * g else : result_variables [ k ] = A [ i ] * B [ j ] * g return Monomial ( result_variables , Fraction ( m1 . coeff * m2 . coeff , 1 ) )