How can this equation be simplified to give $y$?: $x = \frac{(-1)^y ( 5 (-1)^y y - y + (-1)^y - 1))}4$ I'm trying to convert this equation to the form $y = ...$, but I am stuck. It seems the $y$-root of $(-1)^y$ is not $-1$, but is instead a beast. Here is the overall equation:
$$x = \frac{(-1)^y  ( 5  (-1)^y  y - y + (-1)^y - 1))}4$$
Note: y is an integer, x is an integer.
I could be open to x needing to be a complex number as long as there are solutions where x ∈ { 3+0i, 5+0i, 7+0i, ...} and y ∈ { 5, 8, 11, ...}.
Note: the point is to avoid using separate equations for even vs. odd, but to have one equation that handles both. That's why the first equation has (-1)^n in it; it makes the equation = y when y is even, and (3y+1)/2 when y is odd. However that trick is not as helpful when we only care about every third number instead of every second number.
Context: I'm an old man trying to refresh my math skills by learning about groups and branch groups. I'm not sure how much extra context you want. Trying to build a map between 2n+1 and 3n+2, kind of.
 A: You can make a case decision. Let $y$ be an even integer  then
$$x= \frac{1\cdot   ( 5 \cdot  1\cdot  y - y + 1 - 1))}4=\frac{  4y }4=y$$.
Let $y$ be an odd integer  then
$$x=\frac{-( -5   y - y -1 - 1))}4=\frac{-(-6y-2)}{4}=\frac{6y+2}{4}$$
Solving for y gives $y=\frac{4x-2}{6}=\frac23x-\frac13$. So the function is
$$y=\begin{cases} x, \quad\ \ \ \ \ \ \textrm{if y is an even integer}  \\ \frac23x-\frac13, \textrm{if y is an odd integer}\end{cases}$$
So you calculate both cases, and then you make the decision which one case is right. IMHO it is the easiest approach. I don't see a handy way for non-integers.
A: This is an answer to the question implied by the comment, "Seems like there ought to be a way to encode if statements into the math itself."
Indeed there is a way to encode if statements. First we have to craft a function whose value depends on whether the condition of the "if" is true. Ideally the function will produce just two values, $1$ if the condition is true and $0$ if it is false; then the function is called an indicator function (or sometimes a characteristic function, but that term has other meanings in some contexts).
For example, for "$n$ is odd," we want a function $I_\text{odd}$ (where the $I$ stands for "indicator") with the domain of integers defined by
$$
I_\text{odd}(n) =
 \begin{cases} 1 & \text{if $n$ is odd,}\\ 0 & \text{if $n$ is even,} \end{cases}
$$
which can be implemented by
$$
I_\text{odd}(n) = n - 2 \left\lfloor \frac n2\right\rfloor.
$$
For "$n \equiv 2 \pmod5$" (which is another way of saying that $n=5t+2$ for some integer $t$) we can define a function $I_{(2\bmod5)}$ over integers such that
$$
I_{(2\bmod5)}(n) = \left\lfloor \cos^2\left(\frac{n-2}5 \pi\right) \right\rfloor
$$
which works because $\frac{n-2}5 \pi$ is an exact integer multiple of $\pi$ if and only if $n-2$ is divisible by $5,$ and the only time when $\cos^2(x)=1$ is when $x$ is an exact integer multiple of $\pi$; for all other $x,$ $0\leq \cos^2(x) < 1.$
More generally for "$n \equiv k \pmod m$" we can define a function $I_{(k\bmod m)}$ over integers by
$$
I_{(k\bmod m)}(n) = \left\lfloor \cos^2\left(\frac{n-k}m \pi\right) \right\rfloor.
$$
Now let's suppose that for some particular function $f$ that we want to define, we have defined sets $A,$ $B,$ and $C$ that are a partition of the integers
(that is, $A,$ $B,$ and $C$ are pairwise disjoint and $A\cup B\cup C = \mathbb Z$)
so that we can define $f$ using "if" conditions as follows:
$$
f(n) = \begin{cases}
 f_A(n) & \text{if $n \in A$,}\\
 f_B(n) & \text{if $n \in B$,}\\
 f_C(n) & \text{if $n \in C$.}\end{cases} \tag1
$$
Then if we can construct indicator functions $I_A,$ $I_B,$ and $I_C$ such that
$I_A(n) = 1$ if $n\in A,$ $I_A(n)=0$ otherwise,
and similarly for $I_B$ and $I_C,$ we can define $f$ like this:
$$
f(n) = I_A(n) f_A(n) + I_B(n) f_B(n) + I_C(n) f_C(n).
$$
Simple, right? The difficulty only comes when you try to write out this function's formula in detail (because you have to figure out the three indicator functions, which could get pretty weird) and when someone else tries to figure out what you've written.
It will usually be a lot harder to read and to work with than something that looks like Equation $(1)$.
