%I #39 Mar 21 2026 21:43:42
%S 1,3,6,5,72,60,18,7,660,556920,770,1008,985320,339660,34320,9,1670760,
%T 15300,61261200,1244880,6284880,3006556993440,199767760920,15048,
%U 26466884524080,61710920040,1163962800,3661447149360,50821170440040,205980334560,3262313854800,11,168473954880
%N Return time for an n X n picture by the baker's map.
%C The baker's map is defined on [0,n-1]^2 by baker(i,j). Define (i1,j1) = ([i/2], 2*j + i mod 2). If j1 < n then baker(i,j) = (i1,j1); otherwise baker(i,j) = (n-1-i1, 2*n - 1 - j1).
%C a(n) is the smallest k so that baker^k(i,j) = (i,j) for each (i,j).
%D Jean-Paul Delahaye, Jeux finis et infinis, Seuil, coll. Science ouverte, chap. 5 (Le retour surprise d'une image), p. 129-160.
%H Jean-Paul Delahaye and Philippe Mathieu, <a href="https://www.cristal.univ-lille.fr/profil/jdelahay/pls/048.pdf">Images brouillées, Images retrouvées</a>, Pour la Science, no 242, décembre 1997, p. 102-106.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Baker%27s_map">Baker's map</a>.
%F a(2^k) = 2*k + 1.
%e For n = 2:
%e a b
%e c d
%e becomes
%e a c
%e d b
%e then
%e a d
%e b c
%e then
%e a b
%e c d
%e so a(2) = 3.
%p baker:=proc(i,j,n) local i1,j1: i1:=iquo(i,2);j1:=2*j+irem(i,2); if j1<n then [i1,j1] else [n-1-i1,2*n-1-j1] fi end:
%p pixelperiod:=proc(i,j,n) local U,m: U:=baker(i,j,n) : for m while not(U=[i,j]) do U:=baker(U[1],U[2],n) od : return(m) end:
%p U:=NULL:for n to 20 do period:=1:for i from 0 to n-1 do for j from 0 to n-1 do per:=pixelperiod(i,j,n): period:=lcm(period,per) od od:U:=U,period od:U;
%o (Python)
%o from math import lcm
%o def baker(i, j, n):
%o i1 = i // 2
%o j1 = 2 * j + (i % 2)
%o if j1 < n:
%o return [i1, j1]
%o else:
%o return [n - 1 - i1, 2 * n - 1 - j1]
%o def pixelperiod(i, j, n):
%o U = baker(i, j, n)
%o m = 1
%o while U != [i, j]:
%o U = baker(U[0], U[1], n)
%o m += 1
%o return m
%o U = []
%o for n in range(1,33):
%o period = 1
%o for i in range(n):
%o for j in range(n):
%o per = pixelperiod(i, j, n)
%o period = lcm(period, per)
%o U.append(period)
%o print(U)
%o (PARI) baker(i, j, n) = my(i1 = i\2, j1 = 2*j + (i % 2)); if (j1 < n, [i1, j1], [n - 1 - i1, 2*n - 1 - j1]);
%o pixelp(i, j, n) = my(U = baker(i, j, n), m = 1); while (U != [i, j], U = baker(U[1], U[2], n); m ++); m;
%o a(n) = my(period = 1); for (i=0, n-1, for (j=0, n-1, period = lcm(period, pixelp(i, j, n);););); period; \\ _Michel Marcus_, Mar 05 2026
%K nonn
%O 1,2
%A _Robert FERREOL_, Mar 01 2026
%E More terms from _Michel Marcus_, Mar 05 2026