About A094234
Thomas Baruchel
thomas.baruchel at laposte.net
Thu Aug 26 11:50:26 CEST 2004
Two months ago, I described a family of sequences based on Hurwitz-numbers.
The general definition was:
let x be a Hurwitz number ;
then a(n) = pseudo-period of (2^n * x)
I chose to illustrate this definition with the beautiful continued
fraction:
tanh(1) = [1,3,5,7,9,11,...]
I said I would give more terms a few days later, but I didn't do it for
lack of time.
I now give a Haskell program (to be compiled with ghc) which may help
computing the sequence for numbers of the form :
[ ... , aX+k, bX+l, cX+m, dX+n, ...]
The initial function is quite pretty ; the other ones are a quick and dirty
hack, but it seems to work very well.
Here are a few more terms (for x=tanh(1)) :
1,5,10,32,76,184,408,944,2088,4680,10168,22192,47952
(a funny thing is that for x = 1/tanh(1), the sequence is almost the same
for the 12 initial terms except for the 5th index:
1,5,10,32,68,184,408,944,2088,4680,10168,22192,... (13th was not computed)
with 68 instead of 76 ; strange, isn't it ? Or did I make a mistake ?)
Of course the program may be used for computing other sequences
(just change the definition of 't' at the end of the program ; it has to
be an infinite list standing for the continued fraction expansion of x):
for x = exp(1): sequence is 3,6,6,14,32,68,160,368,880,1936,4360,9088,...
for x = [0,2,4,6,8,10,...] sequence is:
1,2,8,8,20,48,120,272,624,1376,3104,6784,14816
for x = tan(1) sequence is: 2,6,12,36,84,204,428,964,2244,5044,10692
Conjecture: when n --> \infty then a(n+1)/a(n) --> 2 ???
Regards,
=== BEGINNING OF THE PROGRAM ===
{-
A generic algorithm to compute 2x with x irrational
(not to try with the golden mean because of infinite looping)
2[0,2a,b,c,...] = [0,a,2b+2[0,c,...]]
2[0,2a+1,b,c,...] = [0,a,1,1+2[0,b-1,c,...]]
(See A. Hurwitz, 1891, described in Knuth, vol. 2, 4.5.3, exercise 14,
p. 360)
-}
cf_double (0:a:b:c) = if (head (tail cf))==0 then (tail (tail cf)) else cf
where
cf = if even a then 0:(quot a 2):(if (head (tail i)) == 0
then ((head i)+(head (tail (tail i)))):(tail (tail (tail i)))
else i) else 0:(quot (a-1) 2):1:(if (head (tail j)) == 0
then ((head j)+(head (tail (tail j)))):(tail (tail (tail j)))
else j)
i = (2*b+(head q)):(tail q)
j = (1+(head r)):(tail r)
q = (cf_double (0:c))
r = (cf_double (0:(b-1):c))
cf_double (a:as) = ((2*a)+(head l)):(tail l)
where l = cf_double (0:as)
car (x:y) = x
estimate_period l = ep l (drop 100 l) 1 100
ep l l0 p 0 = p
ep l l0 p q = if (z-y)==(y-x)
then ep l (drop 1 l0) p (q-1)
else ep l (drop (100+4*p) l) (p+1) 100
where
x = car l0
y = car (drop p l0)
z = car (drop (2*p) l0)
ll l = l:(ll (cf_double l))
build_sequence l = map estimate_period (ll l)
{- t = [0,1,3,5,...] --}
t = 0:(x 1) where x n = n:(x (n+2))
main = sequence (map print (build_sequence t))
=== END OF THE PROGRAM ===
--
Thomas Baruchel
More information about the SeqFan
mailing list