Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Due to the use of <code>PIN</code> and <code>ceiling</code>, I don't see a easy way to invert the calculation. Assuming that <code>bid</code> has a fixed precision (I'd guess two decimals behind the dot) you can always use a binary search (as the functions are monotone).</p> <p>Edit: After thinking about it some more, I observed that, taking <code>x = bid*1.02 + 100</code>, we have that the final costs are between x+15 (exclusive) and x+70 (inclusive) (i.e. <code>x+15 &lt; final cost &lt; x+70</code>). Given the size of this range (<code>70-15=55</code>) and the fact that the special values (see note below) for <code>bid</code> are all apart more than this, you can take <code>x+15 = final cost</code> and <code>x+70 = final cost</code>, get the right cases/values of usage and added costs and simply solve that equation (which no longer has either <code>PIN</code> or <code>ceiling</code> in it).</p> <p>To illustrate, let the final cost be <code>222</code>. From <code>x+15 = 222</code> it follows that <code>bid = 107/1.02 = 104.90</code>. Then we have that the usage costs are given by <code>bid*0.1</code> and that the additional costs are <code>5</code>. In other words, we get <code>final cost = bid*0.1 + bid*0.02 + 5 + 100 + bid = bid*1.12 + 105</code> and therefore <code>bid = (222-105)/1.12 = 104.46</code>. As this value of <code>bid</code> means the right values for usage and additional costs were taken, we know that this is the solution.</p> <p>However, if we would have first looked at <code>x+70 = 222</code>, we would get the following. First we get that for this assumption that <code>bid = 52/1.02 = 50.98</code>. This means that usage costs are <code>10</code> and the additional costs are <code>5</code>. So we get <code>final costs = 10 + bid*0.02 + 5 + 100 + bid = bid*1.02 + 115</code> and therefore <code>bid = (222-115)/1.02 = 104.90</code>. But if <code>bid</code> is <code>104.90</code> then the usage costs are not <code>10</code> but <code>bid*0.1</code>, so this isn't the right solution.</p> <p>I hope I explained it clearly enough. If not, please let me know.</p> <p>N.B.: With special values I mean those for which the function defining the values of usage and added costs change. For example, for usage cost these values are <code>100</code> and <code>500</code>: below <code>100</code> you use <code>10</code>, above <code>500</code> you use <code>50</code> and in between you use <code>bid*0.1</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload