Reversing an equation To be quick and to the point I have an equation as follows:
arrayPos = X + (Y * R) + (Z * (R ^ 2))
The inputs are X, Y, and Z referring to a position in 3 dimensional space. R is a constant value representing the maximum size of each dimension.
I need to be able to reverse this though, so with arrayPos as an input I can find X, Y, and Z.
My question is: Is this possible to do and if so, how so?
Unfortunately I am not very mathematically minded, and I have spent a fairly long time trying to work it out to no avail. If you feel my question is actually very easy and it comes across as me just being lazy, I can honestly say that is not the case, and I am more than willing to learn if someone here can explain the process to me.
I'm not even sure that I've tagged this correctly so again if I've made error with my tags, please feel free to let me know or to edit this question so that it is tagged properly.
 A: This answer is the algorithm specifically for solving my issue that I later figured out after I had posted the question, and is very specific for this case.
Finding X was as simple as performing a modulo operation with R on arrayPos to get the remained.
Z was found by dividing arrayPos by R, rounding it down to the nearest integer, and then multiplying the result by R to begin with. Step 2 of getting Z was then to divide this again by R^2, and finally rounding the result down to the nearest integer again.
Y was completed by taking the result of the first step of getting Z, subtract the found value of Z after it had been multiplied by R^2, and then divide the overall result by R.
It's a mouthful, and probably not the best way, but its the only way I've got at the moment and it'll hold for now.
A: This is sometimes possible with some other assumptions. Here's a small example using arithmetic in base 2.
Suppose $R=2^5=32$ and each of $X$, $Y$ and $Z$ is an integer between $0$ and $31$. Then the first five bits (reading from the right) of arrayPos tell you $X$, the next five $Y$ and the last five $Z$. Essentially, you are packing three five bit strings in a 15 bit string.
This example works because $R$ and the unknowns are integers. You might be able to adapt it for your purposes by using fractions with a fixed (large) denominator.
