(self, other: Union[int, float, Fraction, Monomial])
Subtract the given polynomial
        from a copy of self.
Subtract the given polynomial
        from a copy of self.
Subtract the given polynomial from a copy of self .
def __sub__(self, other: Union[int, float, Fraction, Monomial]):
        """
        Subtract the given polynomial
        from a copy of self.

        """
        if isinstance(other, int) or isinstance(other, float) or isinstance(other, Fraction):
            return self.__sub__(Monomial({}, Polynomial._rationalize_if_possible(other)))
        elif isinstance(other, Monomial):
            monos = {m.clone() for m in self.all_monomials()}
            for _own_monos in monos:
                if _own_monos.equal_upto_scalar(other):
                    scalar = _own_monos.coeff
                    monos -= {_own_monos}
                    temp_variables = {i: other.variables[i] for i in other.variables}
                    monos |= {Monomial(temp_variables, Polynomial._rationalize_if_possible(scalar - other.coeff))}
                    return Polynomial([z for z in monos])

            to_insert = other.clone()
            to_insert.coeff *= -1

            monos |= {to_insert}
            return Polynomial([z for z in monos])

        elif isinstance(other, Polynomial):
            p = Polynomial(list(z for z in {m.clone() for m in self.all_monomials()}))
            for o in other.all_monomials():
                p = p.__sub__(o.clone())
            return p
        
        else:
            raise ValueError('Can only subtract int, float, Fraction, Monomials, or Polynomials from Polynomials.')
            return
def __sub__ ( self , other : Union [ int , float , Fraction , Monomial ] ) : if isinstance ( other , int ) or isinstance ( other , float ) or isinstance ( other , Fraction ) : return self . __sub__ ( Monomial ( { } , Polynomial . _rationalize_if_possible ( other ) ) ) elif isinstance ( other , Monomial ) : monos = { m . clone ( ) for m in self . all_monomials ( ) } for _own_monos in monos : if _own_monos . equal_upto_scalar ( other ) : scalar = _own_monos . coeff monos -= { _own_monos } temp_variables = { i : other . variables [ i ] for i in other . variables } monos |= { Monomial ( temp_variables , Polynomial . _rationalize_if_possible ( scalar - other . coeff ) ) } return Polynomial ( [ z for z in monos ] ) to_insert = other . clone ( ) to_insert . coeff *= - 1 monos |= { to_insert } return Polynomial ( [ z for z in monos ] ) elif isinstance ( other , Polynomial ) : p = Polynomial ( list ( z for z in { m . clone ( ) for m in self . all_monomials ( ) } ) ) for o in other . all_monomials ( ) : p = p . __sub__ ( o . clone ( ) ) return p else : raise ValueError ( 'Can only subtract int, float, Fraction, Monomials, or Polynomials from Polynomials.' ) return