(self)
return Monomial(mono, Monomial._rationalize_if_possible(1/self.coeff)).clean()
Compute the inverse of a monomial.

        Examples:

            Monomial({1:1, 2:-1, 3:2}, 2.5).inverse() = Monomial({1:-1, 2:1, 3:-2} ,2/5)
Compute the inverse of a monomial.
Compute the inverse of a monomial .
def inverse(self):
        """
        Compute the inverse of a monomial.

        Examples:

            Monomial({1:1, 2:-1, 3:2}, 2.5).inverse() = Monomial({1:-1, 2:1, 3:-2} ,2/5)


        """
        mono = {i: self.variables[i] for i in self.variables if self.variables[i] != 0}
        for i in mono:
            mono[i] *= -1
        if self.coeff == 0:
            raise ValueError("Coefficient must not be 0.")
        return Monomial(mono, Monomial._rationalize_if_possible(1/self.coeff)).clean()
def inverse ( self ) : mono = { i : self . variables [ i ] for i in self . variables if self . variables [ i ] != 0 } for i in mono : mono [ i ] *= - 1 if self . coeff == 0 : raise ValueError ( "Coefficient must not be 0." ) return Monomial ( mono , Monomial . _rationalize_if_possible ( 1 / self . coeff ) ) . clean ( )