Michael Somos on Sat, 30 Oct 1999 08:43:45 -0400 (EDT)

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 Re: sqr() bug?

```Bill Allombert has pointed out something that I missed before. Namely:

gp> 5+O(2^10)
%1 = 1 + 2^2 + O(2^10)
gp> %1^2
%2 = 1 + 2^3 + 2^4 + O(2^11)
gp> %1*%1
%3 = 1 + 2^3 + 2^4 + O(2^11)
gp> (5+O(2^10))*(5+O(2^10))
%4 = 1 + 2^3 + 2^4 + O(2^10)

This reminds me of a similar kind of phenomenon in interval arithmetic
which might be closely related. Since this is obvious in hindsight, I
may suggest that a few more sentences in the documentation could point
out this phenomenon very explicitly. As it is now written, documentation
seems incorrect. That is, *both* x^2 and x*x give exactly the same result
as sqr(x). What gives a different result is the product of two p-adic
numbers which are not identical but which have the same value. Thus :

gp> x=5+O(2^10)
%5 = 1 + 2^2 + O(2^10)
gp> x^2
%6 = 1 + 2^3 + 2^4 + O(2^11)
gp> x*x
%7 = 1 + 2^3 + 2^4 + O(2^11)
gp> sqr(x)
%8 = 1 + 2^3 + 2^4 + O(2^11)
gp> y=x
%9 = 1 + 2^2 + O(2^10)
gp> x*y
%10 = 1 + 2^3 + 2^4 + O(2^10)

This is a subtle point which I think needs to be clearly desribed. Thus,
this is not a bug in GP/PARI itself, but a feature which could be better
documented. The current documentation seems to indicate that "x*x" and
perhaps "x^2" (which is not mentioned) would give a different result than
"sqr(x)". This is clearly not the case. Again, the situation is clear in
hindsight, but only if the correct explanation is given. Shalom, Michael

--
Michael Somos <somos@grail.cba.csuohio.edu>     Cleveland State University
http://grail.cba.csuohio.edu/~somos/            Cleveland, Ohio, USA 44115
```

• References:
• sqr() bug?
• From: Michael Somos <somos@grail.cba.csuohio.edu>
• Re: sqr() bug?
• From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>