
Dear all,
this message is a first of a small series where we try to summarize our difficulties with GiNaC and its (lack of) documentation. As a general remark, several concepts are defined only through examples whereas formal definitions would help greatly. In this message we concentrate on one concept that is central to our application: the concept of "polynomial". Here are our sources of information:
1) The tutorial: a bunch of examples are presented that, however do not clarify the general idea.
2) The method `info(info_flags::polynomial)' should constitute, we used to believe, the very formal specification of the notion of "being a polynomial".
3) The message by Christian Bauer (March 7th, 2002, see http://www.ginac.de/lists/ginac-list/msg00232.html):
"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."
The problem is that, while 1 is inconclusive, 2 and 3 (with the correction replacing "integer" by "nonnegative integer") conflict with each other. Let us consider the expression
e = sqrt(2)*x.
Since, clearly, has(sqrt(2), x) == false, `e' is a polynomial for 3. But, since e.info(info_flags::polynomial) == false, `e' is not a polynomial according to 2.
The point here is to decide _exactly_ for which class of expressions are the functions degree(), ldegree(), coeff(), lcoeff(), tcoeff(), expand(), collect(), quo(), rem(), prem(), gcd(), lcm(), sqrfree() and so forth guaranteed to work. All the best
Roberto Bagnara Alessandro Zaccagnini Enea Zaffanella Tatiana Zolo
/***************************************************************************/ #include <ginac/ginac.h> #include <iostream>
using namespace GiNaC; using namespace std;
int main() { symbol x("x"); ex coeff = sqrt(ex(2)); ex e = coeff*x; cout << (e.info(info_flags::polynomial) ? "true" : "false") << endl; cout << (!has(coeff, x) ? "true" : "false") << endl; return 0; } /***************************************************************************/
participants (1)
-
Roberto Bagnara