Solving advanced equation

86 Views Asked by At

In the grid, which I described in my last question, every number $x$ has a unique set of $r$ (row number) and $c$ coloumn number.
$x$ is given and $x \in \Bbb N$, we want to get $r$.
This formula lets us calculate $x$ based off the row and coloumn number.
$$2^rc+2^{r-1}=x,\; r \in \Bbb N,\; c \in \Bbb N,\; x \in \Bbb N$$


False part start

solving this equation for $c$ gives us the following equation: $$2^{-r}x-\frac{1}{2}=c$$ If we insert this for c in our original equation we get $$2^r(2^{-r}x-\frac{1}{2})+2^{r-1}=x$$


False part end

The part where I'm struggling is to solve this equation for $r$, so I can insert $x$ and get $r$.
I hope somebody can help me with this...

Edit: the equation I made is stupid. If you were able to follow my thoughts you might got what I'm trying to achieve.

Any help is appreciated :-)

2

There are 2 best solutions below

2
On BEST ANSWER

If you know x, divide x by 2 repeatedly until the result is odd. The number of divisions is r-1.

If you know both x and c, then, noting that x = 2^(r-1))(2c + 1), you get r = 1 + log_2((x/(2c+1)).

0
On

\begin{align} 2^r\left(2^{-r}x-\frac{1}{2}\right)+2^{r-1}&=x \\ 1x-\frac{1}{2}2^r+2^{r-1}&=x \\ x-2^{r-1}+2^{r-1}&=x \\ x&=x \end{align} The value of $x$ is independent of the value of $r$ in the equation you've set up. Since you have two variables, you need two distinct equations relating $x$ and $r$ to solve for them, where you've only used one.