(f, g)
Subtract rational functions ``f`` and ``g``.
Subtract rational functions ``f`` and ``g``.
Subtract rational functions f and g .
def __sub__(f, g):
        """Subtract rational functions ``f`` and ``g``. """
        field = f.field

        if not g:
            return f
        elif not f:
            return -g
        elif isinstance(g, field.dtype):
            if f.denom == g.denom:
                return f.new(f.numer - g.numer, f.denom)
            else:
                return f.new(f.numer*g.denom - f.denom*g.numer, f.denom*g.denom)
        elif isinstance(g, field.ring.dtype):
            return f.new(f.numer - f.denom*g, f.denom)
        else:
            if isinstance(g, FracElement):
                if isinstance(field.domain, FractionField) and field.domain.field == g.field:
                    pass
                elif isinstance(g.field.domain, FractionField) and g.field.domain.field == field:
                    return g.__rsub__(f)
                else:
                    return NotImplemented
            elif isinstance(g, PolyElement):
                if isinstance(field.domain, PolynomialRing) and field.domain.ring == g.ring:
                    pass
                else:
                    return g.__rsub__(f)

        op, g_numer, g_denom = f._extract_ground(g)

        if op == 1:
            return f.new(f.numer - f.denom*g_numer, f.denom)
        elif not op:
            return NotImplemented
        else:
            return f.new(f.numer*g_denom - f.denom*g_numer, f.denom*g_denom)
def __sub__ ( f , g ) : field = f . field if not g : return f elif not f : return - g elif isinstance ( g , field . dtype ) : if f . denom == g . denom : return f . new ( f . numer - g . numer , f . denom ) else : return f . new ( f . numer * g . denom - f . denom * g . numer , f . denom * g . denom ) elif isinstance ( g , field . ring . dtype ) : return f . new ( f . numer - f . denom * g , f . denom ) else : if isinstance ( g , FracElement ) : if isinstance ( field . domain , FractionField ) and field . domain . field == g . field : pass elif isinstance ( g . field . domain , FractionField ) and g . field . domain . field == field : return g . __rsub__ ( f ) else : return NotImplemented elif isinstance ( g , PolyElement ) : if isinstance ( field . domain , PolynomialRing ) and field . domain . ring == g . ring : pass else : return g . __rsub__ ( f ) op , g_numer , g_denom = f . _extract_ground ( g ) if op == 1 : return f . new ( f . numer - f . denom * g_numer , f . denom ) elif not op : return NotImplemented else : return f . new ( f . numer * g_denom - f . denom * g_numer , f . denom * g_denom )