Re: Rational functions

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

```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] &&
PolynomialQ[Denominator[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?