Karim BELABAS on Tue, 17 Jun 2003 14:50:56 +0200 (MEST)

 Re: ceil bug

```On Tue, 17 Jun 2003, Jon Perry wrote:
> Working upon A001399, I developed the formula:
>
> s(n)=6*t(floor(n/6))+(n%6)*(floor(n/6)+1)
>
> with t(n)=n*(n+1)/2
>
> Due to a typing mistake, I inadvertently typed:
>
> s=6*t(floor(n/6))+(n%6)*(floor(n/6)+1)
>
> and Pari produced 1/12*n^2 + 1/2*n
>
> Testing this doesn't produce the sequence in question

It is not a bug: PARI is not a Computer Algebra System and makes no attempt
at handling _formulas_, and simplifying them to equivalent forms. All results
are immediately evaluated, according to some (more or less) formal definition
(hopefully) present in the documentation.

(14:37) gp > ??floor
floor(x):
[...] Applied to a rational function, floor(x) returns the euclidian
quotient of the numerator by the denominator.

[ Note: numerator and denominator are themselves defined according to
"Variable priority" rules, with possibly surprising side effects, see Manual,
section 2.6.2. ]

In particular, for a polynomial, floor(z) := z.

Again, results may be surprising due to variable priorities:

(14:34) gp > floor(x/y)  \\ polynomial (1/y) * x
%1 = 1/y*x
(14:37) gp > floor(y/x)  \\ rational function (y * x^0) / (x)
%2 = 0

Karim.

P.S: I have just added explicit pointers to section 2.6.2 in the extended help
for "numerator" and "denominator", and fixed an indexing bug which caused

(14:48) gp > ??"Variable priorities"@

to fail ( needed ??"Variable priorities:"@ ). Cf

(14:48) gp > ???priority@2
?           Polmods     Polynomials