# [Maxima] determine if expression is polynomial P(x,y/Q(x,y)

Stavros Macrakis macrakis at alum.mit.edu
Sat Feb 25 11:34:43 CST 2012

```It is very easy to determine whether an expression is *of the form*
P(x,y)/Q(x,y),
where P and Q are polynomials in a given list of variables:

ratfunp(ex,vars) := polynomialp(num(ex),vars) and
polynomialp(denom(ex),vars)\$

If you need them, polynomialp has additional arguments that let you specify
symbolic parameters etc. so that you can consider (a*x+1)/(b*y-1) a
polynomial in variables x and y, with parameters a and b.

Other people's solutions test whether an expression *can be written* in the
form P(x,y)/Q(x,y) -- a problem which is in the general case unsolvable,
but in many practical cases perfectly tractable.  But beware of things like
trigonometric identities (as RJF says), radicals, etc.

-s

On Sat, Feb 25, 2012 at 09:02, nijso beishuizen <nijso at hotmail.com> wrote:

>  Dear all,
>
> The problem I am dealing with now is related to my previous question about
> determining if an expression is polynomial. I now want to determine if an
> expression is of the form P(x,y)/Q(x,y), where P and Q are bivariate
> polynomials in x and y. Like my previous problem, it should also accept
> expressions that contain e.g. sin(x) but then return something meaningful
> when it is not a polynomial.
>
> I think this can be done by putting the expression in CRE form and
> determine the numerator and denominator using Q:ratdenom(expr) and
> P:ratnumer(expr).
> If I call showratvars(Q), will Q then always be a polynomial in x and y if
> it returns [x,y]?
>
>
> Regards,
> Nyso
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20120225/3c9b5820/attachment.html>
```