Proto: enhance function `round_and_offset` in module `Round_repr` -- Follow-up from "Draft: User linear representation for round durations in Tenderbake"
The following discussion from !3984 (merged) should be addressed:
-
@mbouaziz started a discussion: (+11 comments) We've got
r_n = r_0 + incr * n * (n + 1) / 2
Now, given
R
, let's findn
such thatR = r_0 + incr * n * (n + 1) / 2
I.e.
(incr / 2) * n ^ 2 + (incr / 2) * n + (r_0 - R) = 0
delta = (incr / 2) ^ 2 - 4 * (incr / 2) * (r_0 - R) = (incr / 2) ^ 2 + 4 * (incr / 2) * (R - r_0)
which is obviously positive as soon as
R >= r_0
The solutions are then
n = (- (incr / 2) +/- sqrt(delta)) / (2 * (r_0 - R)) = (incr / 2 +/- sqrt(delta)) / (2 * (R - r_0))
The positive solution will be
n = (incr + sqrt(delta) / 2) / (R - r_0)
Now I'm not sure that's what we want to do
😁 EDIT:
⚠ this is wrong, it was based on the wrong equation