A Collatz-like function that bifurcates on primes This is likely piling one mystery on another, but ...
I was exploring a function $f(n): \mathbb{N} \mapsto \mathbb{N}$ defined as follows:
$$
f(n) = 
\begin{cases}
n^2 & \text{if} \;n \;\text{is prime} \\
\lfloor n/2 \rfloor & \text{if} \;n \;\text{is composite}
\end{cases}
$$
For example,
$$
\begin{eqnarray*}
f(11) &=& 121 \\
f(121) &=& 60 \\
f(60) &=& 30 \\
f(30) &=& 15 \\
f(15) &=& 7 \\
f(7) &=& 49 \\
f(49) &=& 24 \\
f(24) &=& 12 \\
f(12) &=& 6 \\
f(6) &=& 3 \\
f(3) &=& 9 \\
f(9) &=& 4 \\
f(4) &=& 2 \\
\end{eqnarray*}
$$
and now we are in a $2/4$ cycle.
For all $n=2,\ldots,228$, repeated applications of $f(n)$ leads to a $2/4$ cycle.
For $n=229$ (a prime), $f(229)$ seems to shoot off, in spurts, to large values:
$$229, 52441, 26220, 13110, 6555, 3277, 1638, 819, 409, 167281, 83640,
41820, 20910, 10455, 5227, 27321529, \ldots $$

     


     


For $n=2,\ldots,10^4$, about $87$% end in a $2/4$ cycle, and $13$% seem to shoot off
into the realm of large numbers.


Q0. Have iterates of this function $f(n)$ (or its close analogs) been studied before?
Q1. Is there any hope of explaining the behavior of iterates of $f(n)$?
Q2. Can the convergence of iterates of $f(n)$ be proved for selected classes of values of $n$?

For example, $n=2^k$ always ends in the $2/4$ cycle.

Q3. For which values of $n$ can it be proved that $f^k(n) \to \infty$?


(Added 8Aug15): Here are the trajectories of the first 20 primes (in red),
all heading toward the $2/4$ cycle (green). It remains unsettled if (a) any integer starting
value diverges to $\infty$, and (b) whether the only cycle is the $2/4$ cycle.

     


 A: Let us use a rough estimate for the probability of a large integer $n$ being prime as $\frac{1}{\ln n}$ (as suggested by PNT). Then the expectation of $\ln f(n)$ can be estimated as
$$\frac{1}{\ln n}\cdot \ln n^2 + \left(1-\frac{1}{\ln n}\right)\cdot \ln \lfloor \frac{n}{2}\rfloor = \ln n + 1 - \ln 2 + O(\frac{1}{\ln n}).$$
Since $1-\ln 2>0$, we have that the expectation of $\ln f(n)$ is larger than $\ln n$, which suggests that iterations of $f()$ may diverge for some large $n$.
This approach also suggests that to eliminate divergence, instead of the divisor 2 in the composite case one needs to take a divisor larger than $e\approx 2.718$ (e.g., 3). 
P.S. Unavoidable divisions after squaring do not change the picture. E.g., if we have $\lfloor\frac{n^2}{2^5}\rfloor$ instead of $n^2$, the expectation of $\ln f(n)$ is still estimated as $\ln n + 1 - \ln 2 + O(\frac{1}{\ln n})$ for large $n$.
A: The full detail of this is of course a complex matter but I can build out some structure and connect the problem to some powerful tools for you; namely that, like the Collatz conjecture, this structure descends linear combinations of Lucas sequences.
The floor function of dividing by two descends the sequences $x_{n+1}=2x_n+1$; e.g.:
$0,1,3,7,15,31,63,\ldots$
Which should be fairly obvious.  Furthermore if you divide alternate numbers in this sequence by $3$ you have the immediate odd predecessors of $1$ in the Collatz graph; namely $\{1,5,21,85,341,\ldots\}$ so the connection is fairly obvious.
Numbers just below any descending sequence converge to the same path.  In fact the catchment gets wider the higher up the sequence you go, so e.g. $\{62,61,60\}$ go to $15$ then $\{62,61,60,59,58,57,56\}$ go to $7$ etc.
Of course your function will descend these sequences and their neighbourhoods until it hits some highest prime so to build the graph it's necessary to break apart the descending sequences at the prime numbers and graph those upwards to $x^2$ instead of down, connecting the next descending sequence.
I happened to choose the Mersenne numbers, and there are likely infinitely many prime examples although like all Lucas sequences of the first kind this is a divisibility sequence and therefore only a number with a prime index can itself be prime.  But this isn't generally the case in all of your function's descending sequences.
The Mersenne numbers are the Lucas sequence $U_n(3,2)$.  You can generate every such descending sequence which your function descends, by the linear combinations of $U_n(3,2)$ with its companion $V_n(3,2)=2,3,5,9,17,33\ldots$
$U_n$ is the sequence $2^n-1$ while $V_n$ is the sequence $2^n+1$ so they converge in $\Bbb{Z}_2^{\times}$ to $\pm1$ giving you a set dense enough in $\lvert\cdot\rvert_2$ that perhaps intuitively hints at them covering a set $\{z_1,z_2\in\Bbb{N}:\lvert z_1-z_2\rvert_2\leq\frac{1}{2}\}$ i.e. having an integrality gap of 2 - the odd numbers.
To fully index your descending sequences, and graph the vertices where they stop descending and go up, you need to identify the set of linear combinations of these such that the least value in the sequence is a prime number.
To do that, you need the set of primes $p$ such that $2p+1$ is not prime and define the sequence $S_p=a\cdot U_n(3,2)+b\cdot V_n(3,2)$ by setting $b\cdot V_0(3,2)=p$ and choosing $a$ such that $S_{p+1}=2p+1$
That gives you the set of sequences:
$S_p=(\frac{p}{2}+1)\cdot U_n(3,2)+(\frac{p}{2})\cdot V_n(3,2)$
Next you need to build the successor relation between these sequences; i.e. from the prime at the base of one, to the next descending sequence via the function $x^2$.  A (fairly obvious) observation is that the floor function of an odd square halved is equal to $\frac{n^2-1}{2}$.  All odd squares are of the form $4n+1$ so the function $p^2$ will always be followed by at least a division by $4$, so we will always have: $\dfrac{p^2-1}{4}$ before possibly more divisions by $2$.
The next part of the exercise is to show that the function $x^2$ totally orders these sequences $S_p(3,2)$.
I could go on but you are probably bored (and answering Collatz-related questions can be risky for low-rep users!)  Hopefully I have built out a good amount of the structure which others with greater skills than me may be able to take further.
Another critical structural note to bear in mind is that once you have eliminated unnecessary structure such as perhaps the even numbers, the leaves of this graph, if there are any, will initially be among the primes $p$ for which $2p+1$ is also a prime since these $p$ are the primes which cannot be descended to down some sequence $S_n$ (as obviously any such descent would stop at $2p+1$ and ascend, if $2p+1$ were prime).  But if I were a betting man I would predict that the "unnecessary structure" is actually pretty complex and there is a vast amount to be whittled away, and that in the final construct of this graph, the Mersenne Primes may actually be the leaves of the graph, and that the proof this converges to a cycle for all inputs is largely equivalent to there being infinitely many Mersenne Primes.  But that is conjecture.
There is a vast array of research into Lucas sequences and numerous algebraic structures underpin any set of linear sequences of them as per the link I gave above.  The next part of the exercise I would suggest is to take a look at that structure and find how it determines that the function $p\to p^2$ preorders the sequences $S_p=(\frac{p}{2}+1)\cdot U_n(3,2)+(\frac{p}{2})\cdot V_n(3,2)$
