Improving PolynomialQ
- To: mathgroup at smc.vnet.net
- Subject: [mg16626] Improving PolynomialQ
- From: Jack Goldberg <jackgold at math.lsa.umich.edu>
- Date: Fri, 19 Mar 1999 12:53:51 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Hi Group, Here is a programming challange: Design a predicate NewPolynomialQ[ expr ] which takes an expression "expr" as an SINGLE argument and returns True if expr is a polynomial and False if it is not. The argument "expr" may contain any number of variables and the variables may have any names. (This makes the problem much more difficult than those handled by PolynomialQ which requires the names of the variables.) From some experimentation I did, here are a small group of test expr's which are not handled well by PolynomailQ x, x+(-1)^y, x+Cos[Pi x], 2^x If this challange is too difficult (I have a sneaking suspicion that it just might well be insoluble) how about a "semi" predicate NewPolynomial[ expr ] which returns True only when it is manifestly clear that expr is a polynomial in all its variables and returns NewPolynomial[ expr] otherwise - much like Positive[ expr ]? While trying out various possibilities, I ran into some unexpected outputs from Variables[ expr ]. Compare, for instance, Variables[x+(-1)^y] with Variables[x+Cos[y]] Since Variables[expr] is designed to work only with polynomials, one might argue that Mathematica is not responsible for its misuse as above. However, if the argument to variables is not a polynomial, shouldn't Variables be designed to return Variables[expr] instead of a misleading answer? So, one should reprogram Variables[expr] to detect whether expr is a polynomial... ah ha! so that's the motivation behind the challange. Jack