(self, substitutions: Union[int, float, Fraction, Dict[int, Union[int, float, Fraction]]])
return Monomial._rationalize_if_possible(ans)
Substitute the variables in the
        monomial for values defined by
        the substitutions dictionary.
Substitute the variables in the
        monomial for values defined by
        the substitutions dictionary.
Substitute the variables in the monomial for values defined by the substitutions dictionary .
def substitute(self, substitutions: Union[int, float, Fraction, Dict[int, Union[int, float, Fraction]]]) -> Fraction:
        """
        Substitute the variables in the
        monomial for values defined by
        the substitutions dictionary.
        """
        if isinstance(substitutions, int) or isinstance(substitutions, float) or isinstance(substitutions, Fraction):
            substitutions = {v: Monomial._rationalize_if_possible(substitutions) for v in self.all_variables()}
        else:
            if not self.all_variables().issubset(set(substitutions.keys())):
                raise ValueError('Some variables didn\'t receive their values.')
        if self.coeff == 0:
            return Fraction(0, 1)
        ans = Monomial._rationalize_if_possible(self.coeff)
        for k in self.variables:
            ans *= Monomial._rationalize_if_possible(substitutions[k]**self.variables[k])
        return Monomial._rationalize_if_possible(ans)
def substitute ( self , substitutions : Union [ int , float , Fraction , Dict [ int , Union [ int , float , Fraction ] ] ] ) -> Fraction : if isinstance ( substitutions , int ) or isinstance ( substitutions , float ) or isinstance ( substitutions , Fraction ) : substitutions = { v : Monomial . _rationalize_if_possible ( substitutions ) for v in self . all_variables ( ) } else : if not self . all_variables ( ) . issubset ( set ( substitutions . keys ( ) ) ) : raise ValueError ( 'Some variables didn\'t receive their values.' ) if self . coeff == 0 : return Fraction ( 0 , 1 ) ans = Monomial . _rationalize_if_possible ( self . coeff ) for k in self . variables : ans *= Monomial . _rationalize_if_possible ( substitutions [ k ] ** self . variables [ k ] ) return Monomial . _rationalize_if_possible ( ans )