# definition of doubling map in Maxima
# n = numerator
# d = denominator
doub_m(n,d):=block(n:2*n,if n>d then n-d else n);
or better
doub_m(n,d):=mod(2*n,d);
# example of use:
(%i8) a:doub_m(2,3);
(%o8) 1
# so d(2/3) = 1/3

# display iterations
(%i9) nn:doub_m(2,3);
for i:1 thru 10 step 1 do display(nn:doub_m(nn,3));
(%o9) 1
nn=2
nn=1
nn=2
nn=1
nn=2
nn=1
nn=2
nn=1
nn=2
nn=1
(%o10) done

# or save to a list :
(%i19) nn:2;
makelist(nn:doub_m(nn,3),i,1,10);
(%o19) 2
(%o20) [1,2,1,2,1,2,1,2,1,2]
# or full function :
(%i27) orbit_d(n,d,i):=block(nn:n,a:makelist(nn:doub_m(nn,56),i,1,10));
(%o27) orbit_d(n,d,i):=block(nn:n,a:makelist(nn:doub_m(nn,56),i,1,10))
(%i28) orbit_d(15,56,10);
(%o28) [30,4,8,16,32,8,16,32,8,16]