Does this function hit every odd number for some integers $n$ and $m$

elementary-number-theory

I have recently been looking into a problem and created a function that looked interesting and I wondered if it would hit all odd numbers on a graph.

For integer $n$, define
$$g_n(x) = \frac13\cdot \begin{cases}
(3n-1) \cdot 2^{2x-1} – 1, & n \text{ even} \\[4pt]
(3n-2) \cdot 2^{2x\phantom{-1}} – 1, & n \text{ odd}
\end{cases} \tag{$\star$}$$

Is it true that, for any positive odd integer $k$, there are integers $n$ and $m$ such that $g_n(m)=k$?


PS: I think is easier to see as a graph: desmos graph


Note: The form of $(\star)$ is dramatically different than what appeared in the original version of this question. See answer by @Blue for the derivation, which matches coincident work by @automaticallyGenerated.

Best Answer

Too long for a comment.


We can re-write a bit:

$$\begin{align} f_n &= \tfrac12 (6n-3+\cos(\pi n)) \\ &= \tfrac12 (6n-3+(-1)^n) & \text{(since $n$ is an integer)}\\ &= \tfrac12 (6n -4 + 1 +(-1)^n) \\ &= 3n-2+\color{red}{\tfrac12\left(1+(-1)^n\right)} \\ &= 3n-2+ \color{red}{\left( 1 - (n \bmod 2) \right)} & \text{(getting clever)} \\ &= 3n-3+ 2 - (n \bmod 2) \\ &= 3(n-1)+ 2 - (n \bmod 2) \\ \end{align}$$ The last steps are to prepare for this: $$f_n \bmod 3 = 2 - (n\bmod 2)$$ Now, the $g_n$ function becomes:

$$g_n(x) = \tfrac13 \left(f_n \cdot 2^{2x-1+ (n\bmod 2)} - 1 \right)$$

At this point, having to refer back to $f_n$ is a bother, but inserting the expression for $f_n$ is cumbersome. Since there's only even/odd-ness to consider, the best option might be just to write-out the cases explicitly:

$$g_n(x) = \frac13\cdot \begin{cases} (3n-1) \cdot 2^{2x-1} - 1, & n \text{ even} \\[4pt] (3n-2) \cdot 2^{2x\phantom{-1}} - 1, & n \text{ odd} \end{cases}$$

This makes the $g_n$ function completely self-contained and easier to analyze.

Related Question