# Discretizing a mathematical equation This is a 3D map that maps every $$(x,y,z)\to (x',y',z')$$ uniquely. If i want to implement it's discrete counterpart on matlab platform, i do the following $$\text{if} (i<=\dfrac{n}{2} \wedge j\leq \dfrac{n}{2})$$ $$\begin{eqnarray*} x'=2\cdot (i-1)+1\\ y'=2\cdot (j-1)+1\\ z'= \lfloor 0.25\cdot(k-\mod(k-1,2))\rfloor+1; \end{eqnarray*}$$ The input to discretized equatin are integers and the output should also be integers that is why i have used the floor function and since the function is part of some algorithm that involves indexing that starts from $$(1,1)$$ ex Matlab that is why the $$mod$$ function is used. But this is clearly not a unique mapping because $$(1,1,1)\to (1,1,1), (1,1,2)\to (1,1,1), (1,1,3)\to (1,1,1), (1,1,4)\to (1,1,1)$$. So there has to be some minor adjustments or major ajdustments in the discretizing part that retains the uniqueness of the equation. Can somebody suugest ?

Edit: After the answer: I have added the code where $$n=36$$, but still it is not giving the unique mapping.

• Please, don't use images as main content of your post. This makes your question impossible to search and inaccessible to the visually impaired. Please transcribe text and mathematics (note that you can use LaTeX) and don't forget to give proper attribution to your sources. Avoid using $*$ to denote multiplication as it typically denotes other operations in mathematics (e.g., convolution); use \cdot instead). – Pantelis Sopasakis May 15 at 16:10

This solution assumes $$n$$ is a multiple of $$4$$. Let $$\def\1{{\bf 1}}\1[S]$$ be a function which is equal to $$1$$ if the statement $$S$$ is true, and zero otherwise. This is a bijective mapping from the set of ordered tuples $$(x,y,z)$$ where each $$x,y,z\in \{1,2,\dots,n\}$$ to itself. \begin{align} x'&=\text{mod}(2(x-1),n)+1+\1[\text{mod}(z,4)= 2\text{ or }\text{mod}(z,4)=0] \\ y'&=\text{mod}(2(y-1),n)+1+\1[\text{mod}(z,4)= 3\text{ or }\text{mod}(z,4)=0] \\ z'&=\lceil z/4\rceil + (n/4)\Big(\1[n/2

Brief explanation:

The $$\text{mod}(2(x-1),n)+1$$ part simultaneously captures the $$2x$$ and $$2x-1$$ parts of the original, similarly for the $$y$$.

The original problem works for continuous space, where stretching and compressing is bijective. In the discrete space, when you stretch by a factor of $$2$$ you leave gaps, and when you compress you get collisions. We simultaneously fix both of these problems with the $$\1[n/4< z\le n/2\;\;\text{ or }\;\;3n/4< z\le n]$$ and $$\1[n/2 parts. Essentially, when you try to compress the $$z$$ part by $$4$$, you need to instead divide the column into four parts and move some of these parts slightly out of the way.

The expression for $$z$$ just captures the $$z'=z/4 +\{0,1/4,1/2\text{ or }3/4\}$$ all in one go.

• Can you explain the equivalence of your answer with the given mathematical equation or just hint the main part? – Upstart May 14 at 20:02
• @Upstart See edits. – Mike Earnest May 14 at 20:20
• That was some reasoning, a doubt : in that $z'$ term what is that $+$ in the middle $+2\mathbf{1}$ does this mean AND? – Upstart May 14 at 20:26
• @Upstart No, it means addition. We have ${{\bf 1}}[n/2<x]$; this is a number which is equal to $0$ or $1$. Next we have ${{\bf 1}}[n/2<y]$; this is another number which is $0$ or $1$. We multiply the second number by two, then add ($+$) the two numbers together. – Mike Earnest May 14 at 20:29
• I have added the code that i implemented using your discretized equations, but it is still not giving the unique results, i guess there is something missing in my code, can you have a look? – Upstart May 15 at 13:06