Mediant
johndcook.com
johndcook.com
The mediant inequation is: a/b < (a+c)/(b+d) < c/d
If a=1, b=2, c=-1, d=-1
1/2 < 0/1 < -1/-1
1/2 < 0 is obviously wrong
If you remove negative signs in the denominators by multiplying by -1/-1, it works
1/2 < 2/3 < 1
The equality is more fun & shows up frequently on the Nationals. It states:
a/b = c/d => a/b = c/d = (a+c)/(b+d)
For example - On the AIME 2023 this Tuesday (Feb 7), Problem 12 was literally this equality. (see solution 2 below) https://artofproblemsolving.com/wiki/index.php/2023_AIME_I_P...
To iterate, we need to know if our mediant is larger or smaller than the true value.
How do we know that?
Edit: elsewhere in the thread someone explained that the purpose of iterating is to find an approximation with small denominator.
To say such a thing, we need:
1. Some assumption about the distribution of the true value. 2. And a metric measuring the "cost" of being wrong.
Assuming a uniform distribution, and measuring cost as the expected absolute value of the error, we find that the average of the interval is the best guess.
Using the same assumptions, any number in the interval is a better estimate than the endpoints.
From that it (obviously) follows that the mediant is a better approximation than both endpoints.
In this case, [106/39, 87/32] has width 1/1248 and contains e, whereas using the mean would give you the interval [1217/448, 87/32] of width 1/448.
> assume that the pair of reduced fractions a/c < b/d has the property that the reduced fraction with smallest denominator lying in the interval (a/c, b/d) is equal to the mediant of the two fractions. Then the determinant relation bc − ad = 1 holds.
Okay sounds reasonable...
> This fact may be deduced e.g. with the help of Pick's theorem
Wait what?
Then your next interval would be (1/2, 2/3) or (2/3, 3/4) depending on whether s > 2/3 or s < 2/3, where s is your search term.
a/b < (a+c)/(b+d) < c/d
If one of the denominators (not both) is negative, you are guaranteed to be outside of the range.
I found a potential optimization though. If you find that you're repeatedly adjusting the upper/lower bound, you can start adding increasing multiples. It's a provisional step, dependent on the result still being on the same side of the target.
https://www.johndcook.com/blog/2010/10/20/best-rational-appr...