degree of non-expanded polynomials
Alessandro Zaccagnini
zaccagni at prmat.math.unipr.it
Wed Mar 6 10:54:04 CET 2002
I have been experimenting with GiNaC, and I found that on page 46,
section
5.5.2, of the manual (version 1.0.6) that degree() works reliably also
on non-expanded polynomials. But the following program seems to prove
that it is not the case.
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
typedef GiNaC::ex GExpr;
typedef GiNaC::symbol GSymbol;
int main() {
GSymbol x("x");
GExpr h_a = numeric(1,2) * x * (x-1);
GExpr h_b = - (x+1) * (x-1);
GExpr h_c = numeric(1,2) * x * (x+1);
GExpr p = h_a + h_b + h_c;
std::cout << "p = " << p << " degree " << p.degree(x) << std::endl;
p = p.expand();
std::cout << "p = " << p << " degree " << p.degree(x) << std::endl;
return 0;
}
This is the output that I obtained (from version 1.0.5):
p = 1/2*(1+x)*x+1/2*(-1+x)*x+(-1+x)*(-1-x) degree 2
p = 1 degree 0
Best wishes
Alessandro Zaccagnini
The purrs developers team at the University of Parma
More information about the GiNaC-list
mailing list