On 2018-11-15 15:06, Allan Wechsler wrote:
For a polynomial P with coefficients in Z, it's trivial that P(n) is integer if n is.
The converse is not true. There are lots of polynomials that always give integer answers to integer questions, but whose coefficients are not integers. For example, n(n+1)/2 = (1/2)n + (1/2)n^2 always takes integer values for integer n, even though the coefficients aren't integers.
Is there a way to quickly eyeball a polynomial in general to see if it is Z -> Z?
If the coefficients are rational, one can find K = the LCM of the denominators, multiply through by K, and test it for all the integers from 0 to K-1 to see if the result is always divisible by K. But I am hoping there is a simpler way.
If any of the coefficients are irrational, my intuition is that the polynomial is never Z->Z, but I haven't been able to think of an easy proof.
That's how Macsyma did it, in an internal three-valued Lisp function named divby1: (c59) COS(ODD^2*%PI/8); 2 odd ---- + 7/8 %pi 8 (d59) - cos(---) (- 1) 8 (c60) ?LSP("(divby1 '((MEXPT SIMP) $ODD 2)))"); (d60) 8 1 true —rwg