(new) exquo and therefore gcd cannot handle UP(x, EXPR INT) --Bill Page, Mon, 11 Jul 2005 15:56:25 -0500 reply
Update of bug #10530 (project axiom):Status: None => transferred fricas (1) -> gcd((x-2^a)::UP(x,
Type: UnivariatePolynomial(x,
Gives 1, while the correct answer should be fricas gcd((x-2^a)::UP(x,
Type: UnivariatePolynomial(x,
In fact, to ensure that algebraic relations are respected inside expressions one has to normalize all involved expressions: fricas uP := UP(x,
Type: Type
fricas p1 := (x-2^a)::uP
Type: UnivariatePolynomial(x,
fricas p2 := simplify((x-2^a)*(x+2^a))::uP
Type: UnivariatePolynomial(x,
fricas cl1 := coefficients(p1)
Type: List(Expression(Integer))
fricas cl2 := coefficients(p2)
Type: List(Expression(Integer))
fricas ncl := normalize(concat(cl1,
Type: List(Expression(Integer))
fricas ncl1 := first(ncl,
Type: List(Expression(Integer))
fricas ncl2 := rest(ncl,
Type: List(Expression(Integer))
fricas np1 := reduce(_+,
Type: UnivariatePolynomial(x,
fricas np2 := reduce(_+,
Type: UnivariatePolynomial(x,
fricas gcd(np1,
Type: UnivariatePolynomial(x,
Not nice, but in general this is what is needed (below are simpler attempts which sometimes work, but may fail). Internal Cause In EXPR INT, fricas simplify((x-2^a)*(x+2^a))::UP(x,
Type: UnivariatePolynomial(x,
Therefore exquo in: exquo(simplify((x-2^a)*(x+2^a))::UP(x,EXPR INT),(x-2^a)::UP(x,EXPR INT)) fails. In details, it calls Thus, in our case, at one point p1 is To get correct result we need to express coefficients of p1 and p2
in terms of independent kernels. In more general contexts (in
particular involving Wed 09/29/2004 at 16:02, comment #1:I should have added: fricas exquo(normalize(simplify(((A-2^a)*(A+2^a)))::EXPR INT),
Type: Union(Expression(Integer),
fricas exquo(simplify((A-2^a)*(A+2^a))::UP(A,
Type: Union("failed",
This shows that using normalize separately on polynomials does not help, we need to normalize list of coefficients as a whole. Few examples showing that without normalization FriCAS does not always treat fricas dom:=UP('x,
Type: Type
fricas p:dom:=x-2^a
Type: UnivariatePolynomial(x,
fricas q:=(x-2^a)*(x+2^a)
Type: Expression(Integer)
fricas qq:= simplify(q)
Type: Expression(Integer)
fricas r:= q::dom
Type: UnivariatePolynomial(x,
fricas rr:= qq::dom
Type: UnivariatePolynomial(x,
fricas gcd(p,
Type: UnivariatePolynomial(x,
fricas exquo(q,
Type: Union(Expression(Integer),
fricas gcd(p,
Type: UnivariatePolynomial(x,
fricas gcd(p,
Type: UnivariatePolynomial(x,
fricas gcd(p,
Type: UnivariatePolynomial(x,
fricas q - qq
Type: Expression(Integer)
fricas simplify q - qq
Type: Expression(Integer)
fricas simplify ((r - rr)::EXPR INT)
Type: Expression(Integer)
fricas t:Boolean:=(r = rr)
Type: Boolean
Status: open => closed
|