# Solving an equation that involves both ROUND and ROUND-DOWN

$$\left [ x,2 \right ]$$ means to round $$x$$ to $$2$$ decimal places. For examples, $$\left [ \pi,2 \right ]=3.14, \left [ \sqrt{9},2 \right ]=3.00,\left [ \sqrt{5},2 \right ]=2.24$$

$$\left \lfloor x,2 \right \rfloor$$ means to round $$x$$ down to $$2$$ decimal places. For examples, $$\left \lfloor 1.978,2 \right \rfloor=1.97,\left \lfloor 5.019,2 \right \rfloor=5.01,\left \lfloor 8.999,2 \right \rfloor=8.99$$

How to find the minimum value of $$\left [ s,2 \right ]$$ such that

$$n\left [ b,2 \right ]+\left [ 0.00155n\left [ b,2 \right ],2 \right ]+\left \lfloor 0.15 \left [ 0.00155n\left [ b,2 \right ],2 \right ],2 \right \rfloor$$ $$\le n\left [ s,2 \right ]-\left [ 0.00155n\left [ s,2 \right ],2 \right ]-\left \lfloor 0.15 \left [ 0.00155n\left [ s,2 \right ],2 \right ],2 \right \rfloor$$

Where $$n$$ is a natural number, $$b,s$$ are positive real numbers.

Clarification with an example: (This example is taken from a real scenario):

$$n$$ is the number of units to be bought, say $$350$$

$$\left [ b,2 \right ]$$ is the buying (without commission and tax) price of one unit, say $$28.62$$

Commission is calculated as $$0.00155 \times 350 \times 28.62 = 15.52635$$ but rounding that to the nears $$2$$ decimal places, that is $$15.53$$

Tax is $$15 \text{%}$$ of that commission $$=0.15 \times 15.53 = 2.3295$$ but rounding that down to $$2$$ decimal places, that is $$2.32$$

So, this costs $$350 \times 28.62 + 15.53 +2.32=10034.85$$

So, the question is about finding the selling price $$\left [ s,2 \right ]$$ so that we have no losses.

By trial and error, $$\left [ s,2 \right ]=28.73$$

I think, it only looks complicated but actually easy for some of you. Please help me, your help would be appreciated. Thanks!

• I would first simplify the $2$-decimal-place rounding functions to common integer rounding functions: $$\lfloor x, 2\rfloor = \frac{\lfloor 100x\rfloor}{100}$$ Then many $100$'s will cancel out, and the inequality will be in terms of $100b$ and $100s$, i.e. prices in cents. Dec 2 '20 at 12:25

With $$B=100b$$ and $$S=100s$$ (which are already integers without rounding!), multiply your inequality with $$100$$ to arrive at $$nB+\left [ 0.00155nB \right ]+\left \lfloor 0.15 \left [ 0.00155nB\right ] \right \rfloor\\ \le nS-\left [ 0.00155nS \right ]-\left \lfloor 0.15 \left [ 0.00155nS \right ] \right \rfloor$$ In math, we are happier with the floor function, so rewrite as $$nB+\lfloor 0.00155nB +0.5\rfloor+\bigl \lfloor 0.15 \lfloor 0.00155nB+0.5\rfloor \bigr \rfloor\\ \le nS-\lfloor 0.00155nS +0.5\rfloor -\bigl \lfloor 0.15 \lfloor 0.00155nS +0.5\rfloor \bigr \rfloor$$ Now note that $$\lfloor x\rfloor = x-\theta$$ for some $$\theta$$ (depending on $$x$$) with $$0\le \theta<1$$. This allows us to write $$nB+ 0.00155nB +0.5-\theta_1+ 0.15 ( 0.00155nB+0.5) -0.15\theta_2 -\theta_3\\ \le nS-0.00155nS -0.5+\theta_4 - 0.15( 0.00155nS +0.5)+0.15\theta_5+\theta_6$$ and rearrange as $$1.0017825nB +0.575-2.15\theta_7\le 0.9982175 nS-0.575+2.15\theta_8,$$ or $$S\ge B+\frac{1426}{399287} B +\frac{460000}{399287n}-\frac{1720000\theta_9}{399287n}\approx B+\frac{1426}{399287} B + (1.152-4.3\theta_9)\frac1n$$ It seems natural to let $$S$$ be the right hand side rounded up, but we don't know $$\theta_9$$. Hence with
$$S_0=B+\left\lceil\frac{1426 B-1260000}{399287} \right\rceil$$ we can simply try if $$S=S_0$$ fulfills the original inequality. If it doesn't, try $$S=S_0+1$$ and after that $$S=S_0+2$$ and so on. Note that for $$n>4$$, we will never have to check $$S_0+2$$, for $$n>2$$, we will never have to check $$S_0+3$$, and even for $$n=1$$, we need not check $$S_0+5$$ or above.