3
$\begingroup$

I am trying to isolate a variable that is inside a floor function, and this floor function is inside a ceiling function.

Here is the equation: $$\Large{F = \left\lceil{256 * D_1\over\left\lfloor\left\lfloor{256 * D_2\over\left\lfloor{256 * D_0\over\left\lfloor(100 + W - S) * \frac{A}{100}\right\rfloor}\right\rfloor}\right\rfloor * \frac{E}{100}\right\rfloor}\right\rceil - O}$$

I am solving for variable $E$. This is being used with JavaScript, so while every other variable is considered a constant, the constants change in the runtime, so I need to be able to calculate $E$ in the runtime, rather than just manually calculate it on paper and then plug it in.

As a example, where $D_1=13, D_2=9, D_0=19, A=256, W=0, S=-30$ and $E=130$, then $F=15$. But at runtime, I know $F$ but do not know $E$, and so I wish to calculate it. I do not need to know the range of values it could be, only the smallest integer within that range.

Assumptions that are safe to make: all variable constants are integers. Of course, intermediate calculations will result in decimal numbers (floats) until a floor or ceiling is reached. $F$ will always be an integer. $E$ will always be an integer. Where there could be several integers $E$ that could obtain one $F$, the answer is always the smallest of the integer $E$s. Where there could be several integers $F$ to obtain one $E$, the answer is always the smallest of the integer $F$s. Additionally, $15 <= E <= 175$ in all regards and $F>=2$ in practice. I can look up the correct values for both $E$ and $F$ at any given time manually to confirm whether or not it is correct, but it is impractical to use this information in the coding environment.

I've spent about a week off and on looking at this, testing various things in code, writing it out on paper and seeing if I can get anywhere, and I'm fairly stumped. I've asked friends who are particularly good at math for help and they're getting stumped as well, so I figure I would try StackOverflow. I'm beginning to wonder if this is even possible.

Among the "guesstimations" I've done with coding, the closest result I observed to the correct answers was simply moving $O$ to the other side of the equation, then swapping the positions of $F + O$ and $E$ in the equation. It is still off the mark by a notable margin though.

For more information, a less complex equation has been solved in the way that I am asking which, as far as I've seen so far, is correct in practice. Maybe it is useful in solving the more complex equation. For clarification, these two formulas below are mutually exclusive to the given formula above, and cannot be used to solve the original formula in the literal sense. It may be that these formulas are completely useless in determining the answer for the more complex formula. I provided them as a "this is how we solved a different equation with similar constants", but they do not directly help solve the given equation above.

The original equation was: $$F=\Biggl\lceil\frac{256 * D_0}{\lfloor A * \frac{E}{100}\rfloor}\Biggr\rceil - O$$

The equation solved for $E$ that has been correct so far: $$E=\Biggl\lceil\biggl\lceil\frac{256 * D_0}{F + O}\biggr\rceil * \frac{100}{A}\Biggr\rceil$$

$\endgroup$
7
  • $\begingroup$ This is hard to read. Here is a good tutorial for typesetting on this site. $\endgroup$
    – lulu
    Dec 27, 2021 at 19:27
  • $\begingroup$ @lulu hopefully this is better? just putting it into display mode didnt really make much difference $\endgroup$ Dec 27, 2021 at 19:46
  • 2
    $\begingroup$ If you have solved the less complex, original equation, then you're done. All you have to do is substitute your calculated value for $A$ ... or what I might write as, say, $K$ to avoid confusion with the $A$ deeper in the floor nest. (So, your valiant formatting struggle has been unnecessary. :) Solving for $E$ doesn't require knowing the nature of $K$; it's just "some integer". Your less complex, original equation is really all you need to present here. (You can even replace $256D_0$ and $F+O$ with, say, $D$ and $G$, to reduce visual clutter.)) $\endgroup$
    – Blue
    Dec 27, 2021 at 20:13
  • 2
    $\begingroup$ @TarrantWalter: But your less complex version is your more complex version (ignoring confusion over the re-use of $A$), just with distractingly-complicated expressions replaced by simple variable names. Solving $p = q \sin( r x/\sqrt{s} ) + t^3$ for $x$ is exactly the process of solving $f=\sin(gx)$, where $f=(p-t^3)/q$ and $g=r/\sqrt{s}$. Since $p$, $q$, $r$, $s$, $t$ are "just constants", then so are $f$ and $g$. And, once I get my formula for $x$ in terms of $f$ and $g$, I can make the substitutions to restore $p$, $q$, $r$, $s$, $t$. $\endgroup$
    – Blue
    Dec 27, 2021 at 20:30
  • 1
    $\begingroup$ @Blue you're a genius. i like looking for shortcuts and easy ways but never saw the correlation to what I already had versus what I was working with. What you said is definitely correct. thank you very much. $\endgroup$ Dec 27, 2021 at 20:49

1 Answer 1

1
$\begingroup$

Blue's comment in the original post had the answer. My simple formula given at the bottom was just a different way of writing my more complex formula. Once Blue pointed that out, I was able to make the necessary substitutions to find what I was looking for.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .