login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for #191 exquo and therefore gcd cannot handle UP(x, EXPR INT) revision 2 of 6

1 2 3 4 5 6
Editor: kratt6
Time: 2007/12/20 01:07:34 GMT-8
Note:

added:

From kratt6 Thu Dec 20 01:07:34 -0800 2007
From: kratt6
Date: Thu, 20 Dec 2007 01:07:34 -0800
Subject: 
Message-ID: <20071220010734-0800@axiom-wiki.newsynthesis.org>

Category: Axiom Compiler => Axiom Library 


Submitted by : (unknown) at: 2007-11-17T22:05:44-08:00 (16 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

(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

axiom
gcd((x-2^a)::UP(x, EXPR INT), simplify((x-2^a)*(x+2^a))::UP(x, EXPR INT))

\label{eq1}1(1)
Type: UnivariatePolynomial?(x,Expression(Integer))

Gives 1, while the correct answer should be x-2^a, as given by

axiom
gcd((x-2^a)::UP(x, EXPR INT),((x-2^a)*(x+2^a))::UP(x, EXPR INT))

\label{eq2}x -{{2}^{a}}(2)
Type: UnivariatePolynomial?(x,Expression(Integer))

gcd((x-2^a)::UP(x, EXPR INT), simplify((x-2^a)*(x+2^a))::UP(x, EXPR INT))

gives 1, while the correct answer should be x-2^a, as given by

gcd((x-2^a)::UP(x, EXPR INT),((x-2^a)*(x+2^a))::UP(x, EXPR INT))

A workaround is presented on [EXPR_GCD]?

Internal Cause

In EXPR INT, 2^a and 2^{(2a)} are treated as two variables without relations in EXPR INT. Therefore exquo in::

gcdPrimitive(p1:SUPP,p2:SUPP)$PGCD

fails.

Thu 09/30/2004 at 09:31, comment #3

Excuse me, I was to quick again. Here is the (hopefully correct) anaylysis:

  exquo(simplify((A-2^a)*(A+2^a))::UP(A,EXPR INT),(A-2^a)::UP(A,EXPR INT))

calls exquo$SUP(EXPR INT). This implements exact division of polynomials p1 by p2 as usual. After each subtraction - done via fmecg$SUP - the result is again stored in p1. exquo terminates when p1 is the empty list - note that SUPs? are stored as lists of pairs (degree, coefficient) - or the degree of p2 is larger than p1. In the latter case, exquo fails.

Thus, in our case, at one point p1 is 4^a-2^{(2a)}, which is zero mathematically, but axiom does not know it. In particular, p1 is not the empty list, but rather a constant polynomial...

It would be interesting to see how MuPAD? or Aldor handle this.

Martin Rubey

Wed 09/29/2004 at 16:20, comment #2:

The instance of exquo involved is the one in SMP.

Sorry, this is not correct. It is in FIELD (for EXPR INT)

Martin Rubey

Wed 09/29/2004 at 16:02, comment #1:

I should have added:

axiom
exquo(normalize(simplify(((A-2^a)*(A+2^a)))::EXPR INT),normalize((A-2^a)::EXPR INT))

\label{eq3}{{{e}^{a \ {\log \left({4}\right)}}}-{{A}^{2}}}\over{{{e}^{a \ {\log \left({2}\right)}}}- A}(3)
Type: Union(Expression(Integer),...)
axiom
exquo(simplify((A-2^a)*(A+2^a))::UP(A,EXPR INT),(A-2^a)::UP(A,EXPR INT))

\label{eq4}\mbox{\tt "failed"}(4)
Type: Union("failed",...)

I'm afraid that this cannot be fixed easily, since there is no general mechanism to determine whether an expression is zero or not, which is needed in exquo. The instance of exquo involved is the one in SMP.

The problem seems to be that Axiom does not always treat 2^{a2} the same as 4^a.

axiom
dom:=UP('x,EXPR INT)

\label{eq5}\hbox{\axiomType{UnivariatePolynomial}\ } (x , \hbox{\axiomType{Expression}\ } (\hbox{\axiomType{Integer}\ }))(5)
Type: Type
axiom
p:dom:=x-2^a

\label{eq6}x -{{2}^{a}}(6)
Type: UnivariatePolynomial?(x,Expression(Integer))
axiom
q:=(x-2^a)*(x+2^a)

\label{eq7}-{{{2}^{a}}^{2}}+{{x}^{2}}(7)
Type: Expression(Integer)
axiom
qq:= simplify(q)

\label{eq8}-{{4}^{a}}+{{x}^{2}}(8)
Type: Expression(Integer)
axiom
r:= q::dom

\label{eq9}{{x}^{2}}-{{{2}^{a}}^{2}}(9)
Type: UnivariatePolynomial?(x,Expression(Integer))
axiom
rr:= qq::dom

\label{eq10}{{x}^{2}}-{{4}^{a}}(10)
Type: UnivariatePolynomial?(x,Expression(Integer))
axiom
gcd(p,q)

\label{eq11}x -{{2}^{a}}(11)
Type: UnivariatePolynomial?(x,Expression(Integer))
axiom
exquo(q,p)

\label{eq12}{{2}^{a}}+ x(12)
Type: Union(Expression(Integer),...)
axiom
gcd(p,r)

\label{eq13}x -{{2}^{a}}(13)
Type: UnivariatePolynomial?(x,Expression(Integer))
axiom
gcd(p,qq)

\label{eq14}1(14)
Type: UnivariatePolynomial?(x,Expression(Integer))
axiom
gcd(p,rr)

\label{eq15}1(15)
Type: UnivariatePolynomial?(x,Expression(Integer))
axiom
q - qq

\label{eq16}{{4}^{a}}-{{{2}^{a}}^{2}}(16)
Type: Expression(Integer)
axiom
simplify q - qq

\label{eq17}0(17)
Type: Expression(Integer)
axiom
simplify ((r - rr)::EXPR INT)

\label{eq18}0(18)
Type: Expression(Integer)
axiom
t:Boolean:=(r = rr)

\label{eq19} \mbox{\rm false} (19)
Type: Boolean

Comments from wyscc:

Martin wrote:

I'm afraid that this cannot be fixed easily, since there is no general mechanism to determine whether an expression is zero or not, which is needed in exquo.

Your analysis seems to be the correct diagnosis. The problem has nothing to do with gcd or exquo, but with the fact that simplification is an art as there is no canonical form for expressions and hence no way to test equality (which is in general different from testing zero, a special case needed for exquo). More frequent use of simplification will help but will not eliminate the problem. Here, it is because the expressions 4^a and 2^{2a} are not handled by an automatic simplification in UP(x, R) (that is, not pushed down to the level of R).

property change --billpage, Tue, 12 Jul 2005 22:06:08 -0500 reply
Category: => Axiom Compiler Severity: => serious Status: => open

Category: Axiom Compiler => Axiom Library