### Generalized 3x+1 functions and Markov matrices

We study a function T: ℤ→ℤ with d (> 1) branches, defined in terms of d non-zero integers m0,...,md-1 and d integers x0,...,xd-1.

Then T(x)=int(mix ⁄ d)+xi, if x≡ i (mod d).

Example. The 3x+1 mapping T(x)=x ⁄ 2 if x is even, (3x+1) ⁄ 2 if x is odd, corresponds to m0=1, m1=3, x0=0, x1=1.

Starting in 1982, Tony Watts and I investigated the frequencies of occupation of congruence classes (mod m)
of trajectories arising from generalized 3x+1 functions. (See earlier 3x+1 interests)
Experimentally we observed in cases (a) and (b) below, that divergent trajectories were attracted to ergodic sets (mod m)
of a Markov matrix Q(m) and with predictable frequencies. (See properties of Q(m).)

(a) gcd(mi, d) = 1 for 0 ≤ i ≤ d-1, or
(b) gcd(mi, d2) = gcd(mi, d) for 0 ≤ i ≤ d-1 and d divides m.

Here Qij(m)=pij(m)/d,
where pij(m) is the number of congruence classes (mod md)
which comprise B(i,m) ∩ T-1(B(j,m)),
where B(i,m) denotes the congruence class of integers x ≡ i (mod m).

The present program constructs Q(m) and finds the ergodic sets and transient classes, using the Fox_Landi algorithm with labels 0,1,...,m-1.

Enter d (1 < d ≤ 20):
Enter m (1 < m ≤ 200):
Enter the d non-zero integers mi (separated by spaces):
Enter the d integers xi (separated by spaces):