Michael Somos on Sun, 31 Oct 1999 17:11:15 -0500 (EST)


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

ceil,floor,frac,truncate undocumented behavior


In GP/PARI CALCULATOR Version 2.0.17 (beta)

gp> y=sum(n=-5,5,x^n)
%1 = (x^10 + x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + x + 1)/x^5
gp> ceil(y)
%2 = x^5 + x^4 + x^3 + x^2 + x + 1
gp> floor(y)
%3 = x^5 + x^4 + x^3 + x^2 + x + 1
gp> frac(y)
%4 = (x^4 + x^3 + x^2 + x + 1)/x^5
gp> round(y)
%5 = (x^10 + x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + x + 1)/x^5
gp> truncate(y)
%6 = x^5 + x^4 + x^3 + x^2 + x + 1

gp> ??truncate
truncate(x,{&e}):

   truncate x and set e to the number of error bits. When x is in R, this means
that the part after the decimal point is chopped away, integer and set e to the
number  of error bits that is the binary exponent of the difference between the
original and the truncated value (the "fractional part").  If the exponent of x
is  too large compared to its precision  (i.e. e > 0),  the result is undefined
and an error occurs if e was not given.

   Note  a  very  special  use of truncate: when applied to a power series,  it
transforms it into a polynomial or a rational function with denominator a power
of X, by chopping away the O(X^k).  Similarly, when applied to a p-adic number,
it  transforms  it  into  an  integer or a rational number by chopping away the
O(p^k).

Although there is some discussion in the documentation for truncate(), it
does not mention what applies to a rational function. The behavior of
ceil, floor, frac, and round in this case does not seem to be documented.
Shalom, Michael

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