TITLE: Question about functions $f: \mathbb{Z}^+ \to \mathbb{Z}^+$ such that $x$ is prime whenever $f(x)$ is prime
QUESTION [8 upvotes]: Let $f: \mathbb{\mathbb{Z}^+} \to \mathbb{Z^+}$ be a function and suppose
$(\star)$ For all integers $x \geq 3$, if $f(x)$ is prime, then $x$ is prime.
A trivial example of such a function is the identity $f(x) = x$.  However, a possible non-trivial example which I have come across is
\begin{align*}
f(x) = \left\lfloor \frac{\cosh(x\ln(2 + \sqrt{3}))}{2}\right\rfloor.
\end{align*}
This function seems to satisfies $(\star)$ (see OEIS A198196).  I have two questions:

How might one go about proving $f$ satisfies $(\star)$?  I'm not sure where to begin with this, and it seems like a difficult task.
Have functions with property $(\star)$ been studied before?

Thanks for any information you can give me.

Edits: I've composed the floor function with $f$, and added the condition to $(\star)$ that $x$ must be an integer.

REPLY [15 votes]: As observed in comments, we have $f(n) = \lfloor g(n) \rfloor$ where $g(n) = \frac{\alpha^n + \alpha^{-n}}{4}$ and $\alpha = 2 + \sqrt{3}$.  From the recurrence $g(n+1) = 4 g(n) - g(n-1)$ we see that $g(n)$ is a half-integer when $n$ is even and an integer when $n$ is odd.  In fact we see from induction that for even $n$ we have $g(n) = \frac{1}{2} \hbox{ mod } 3$ and for odd $n$ we have $g(n) = 1 \hbox{ mod } 3$.  Hence for even $n$, $f(n)$ is divisible by $3$ and thus not prime except when $n=2$.  For odd $n$, we have $f(n)=g(n)$, and for odd $n,m$ we then have
$$ f(nm) = f(n) (\alpha^{n(m-1)} + \alpha^{n(m-3)} + \dots + \alpha^{n(1-m)})$$
thanks to the formula $a^m+b^m = (a+b)(a^{m-1} + a^{m-2} b + \dots + b^{m-1})$.  From the Galois group action interchanging $\alpha$ and $\alpha^{-1}$ we see that $\alpha^{n(m-1)} + \alpha^{n(m-3)} + \dots + \alpha^{n(1-m)}$ is an integer, and for $n,m \geq 3$ this integer is larger than $1$.  Thus $f(nm)$ is composite when $n,m \geq 3$ are odd, so the only remaining possible values of $n$ for which $f(n)$ can be prime are the primes.
In the language of divisibility sequences, $f(n)$ is a divisibility sequence on the odd natural numbers, though not on the even ones.  In retrospect this is not so surprising given that $f$ is so similar to the Fibonacci sequence $F_n = \frac{\phi^n - \phi^{-n}}{\sqrt{5}}$, which is well known to be a divisibility sequence.