[PURRS-devel] Re: What is a polynomial in x?

Roberto Bagnara bagnara at cs.unipr.it
Thu Mar 7 19:09:11 CET 2002


Christian Bauer wrote:
 >>2) It is legal to say degree(sqrt(2)*x).
 >>
 >
 > Yes.
 >
 >
 >>But then it would be useful to precisely characterize the class of
 >>expressions e and x such that degree(e, x) is well defined.
 >>
 >
 > Is this possible? There might be terms sqrt(x) in e that cancel each other
 > after some transformations, so while the input expression might logically
 > be a polynomial, it is syntactically not.

I perfectly agree.  In fact, what we are looking for is a _syntactic_
characterization of those GiNaC expressions for which degree, ldegree,
coeff, tcoeff and lcoeff are guaranteed to give the right result.

 > But this is the intended behavior:
 > If e is of the form e = sum(i=n1..n2, a_i * x^i) with n1, n2 integer and
 > expressions a_i that satisfy has(a_i, x) == false, then degree(e, x) and
 > ldegree(e, x) are well defined and accurate.
 >
 > I think this should even cover cases like
 >
 >   degree(sin(y)^3-sin(y),sin(y))
 >
 > which is guaranteed to return 3.

This is one possible syntactic characterization.  Is this the one
that the authors of GiNaC would like to adopt as _the_ definition
of the syntactic domain where degree() and friends return a sensible
result?  Moreover, when degree() is called on something outside this
domain, wouldn't it be better to throw an exception instead of returning
with a value obtained in an undocumented way?  Providing a function
checking whether a given expression is inside the syntactic domain
would also be useful (yes, we have been bitten by this kind of problem ;-)
What do you think?

      Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it




More information about the PURRS-devel mailing list