MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Rational functions

  • To: mathgroup at
  • Subject: [mg26164] Re: [mg26080] Rational functions
  • From: Daniel Lichtblau <danl at>
  • Date: Thu, 30 Nov 2000 01:04:07 -0500 (EST)
  • References: <>
  • Sender: owner-wri-mathgroup at

Jack Goldberg wrote:
> Hi group,
> In my work I need to know whether the expression f[x] is a rational
> function of x (the quotient of two polynomials).  I devised the following
> obvious test:
>         RationalQ[f_,x_] := Module[ { f1 = Together[f] },
>                 PolynomialQ[ Numerator[f1]*Denominator[f1], x ]
>                         ]
> I would like to hear from those who can find a flaw in this code, or who
> can offer a better solution.  I probably should mention that I want
> RationalQ to return True when f is a polynomial in x and that I don't
> expect RationalQ to free of the subtle peculiarities that are inherent in
> PolynomialQ.
> Thanks,
> Jack

It relies too much on internal implementation details of PolynomialQ
that are not terribly subtle. Specifically, if PolynomialQ expanded its
input (at present it does not, at least in the example below) then you
would have trouble with

notrat = (1+Sqrt[1-x])/(1-Sqrt[1-x]);

A safer test might be

RationalQ[f_,x_] := With[{f1=Together[f]},
    PolynomialQ[Numerator[f1],x] &&

Daniel Lichtblau
Wolfram Research

  • Prev by Date: Re: polynomial congruence
  • Next by Date: Re: "up" in 3D animations
  • Previous by thread: Rational functions
  • Next by thread: Indefinite Integrals?