Pattern concerning the differences between powers of $2$ and $3$

exponentiationfractions

Background
While joyfully wasting my time with the Collatz conjecture, I noticed a pattern concerning the differences (or ratios?) between powers of $2$ and $3$.

Every integer $n$ can be represented as
$$n = \frac{2^x-q}{3^b}$$
for some $x,q,b \in \mathbb{N}$.

Now the following seems to hold:
$$n = \frac{2^{x+2}-(4q+3^{b}n)}{3^{b+1}}$$

Question
Why does this equivalence (seem to) hold?
I guess it somehow follows trivially from factoring but I can't see it, despite having looked at it really hard.

Examples
$$ 1 = \frac{2^2-1}{3} = \frac{2^4-7}{3^2} = \frac{2^6-37}{3^3} \dots$$
$$ 5 = \frac{2^4-1}{3} = \frac{2^6-19}{3^2} = \frac{2^8-121}{3^3} \dots$$
$$ 13 = \frac{2^7-11}{3^2} = \frac{2^9-161}{3^3} = \frac{2^{11}-995}{3^4} \dots$$
$$ 21 = \frac{2^6-1}{3} = \frac{2^8-67}{3^2} = \frac{2^{10}-457}{3^3} \dots$$

Best Answer

You made a slight (but crucial) mistake. The correct formula should be

$$n = \frac{2^{x+2}-(4q+3^{\color{red}b}n)}{3^{b+1}}$$

And then it is indeed a trivial conclusion as

\begin{align*} n&=\frac{2^{x+2}-(4q+3^bn)}{3^{b+1}}\\ n&=4\frac{2^x-q}{3^{b+1}}-\frac n3\\ 3n&=4\frac{2^x-q}{3^b}-n\\ 4n&=4\frac{2^x-q}{3^b}\\ \end{align*}

$$\therefore~n=\frac{2^x-q}{3^b}$$

And the last line is just the original assumption.

Related Question