Skip to content

Commit 7b0f820

Browse files
committed
fix formatting
1 parent 2598f89 commit 7b0f820

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

‎InternalDocs/fractions.md‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ as possible without violating the denominator bound.
134134
The main loop, together with that partial Euclidean step, produces candidate
135135
approximations $r/s$ and $t/u$ which bracket the target fraction $m/n$, and
136136
whose denominators are no greater than the limit $\ell$. With just two
137-
additional pieces of information, namely that $ts - ru = ±1$ and that $\ell < s
138-
+ u$, we can deduce that _all_ fractions strictly between $r/s$ and $t/u$ have
139-
denominator greater than $\ell$, hence that either $r/s$ or $t/u$ is a best
140-
approximation. The final line of the code then determines which of these two
141-
fractions is better and returns it.
137+
additional pieces of information, namely that $ts - ru = ±1$ and that
138+
$\ell < s + u$, we can deduce that _all_ fractions strictly between $r/s$ and
139+
$t/u$ have denominator greater than $\ell$, hence that either $r/s$ or $t/u$
140+
is a best approximation. The final line of the code then determines which of
141+
these two fractions is better and returns it.
142142

143143
In more detail, we'll show in the sections below that after exiting the `while`
144144
loop and defining $t$ and $u$, the following five properties hold:
@@ -156,12 +156,12 @@ any fraction $y/z$ strictly between $r/s$ and $t/u$ has $z > \ell$. We have:
156156

157157
$$z = (ts - ru)vz = (tz - yu)vs + (ys - rz)vu.$$
158158

159-
Now $v$ is either $1$ or $-1$. If $v = 1$ then $r/s < t/u$, so $r/s < y/z <
160-
t/u$. So $ys - rz$ and $tz - yu$ are positive, hence $(ys - rz)v$ and $(tz -
161-
yu)v$ are positive integers. Conversely if $v = -1$ then $t/u < r/s$, so $t/u <
162-
y/z < r/s$ and $ys - rz$ and $tz - yu$ are negative. So again $(ys - rz)v$ and
163-
$(tz - yu)v$ are positive integers. So in either case, $(tz - yu)v \ge 1$ and
164-
$(ys - rz)v \ge 1$, hence
159+
Now $v$ is either $1$ or $-1$. If $v = 1$ then $r/s < t/u$, so $r/s < y/z < t/u$.
160+
So $ys - rz$ and $tz - yu$ are positive, hence $(ys - rz)v$ and $(tz - yu)v$
161+
are positive integers. Conversely if $v = -1$ then $t/u < r/s$, so
162+
$t/u < y/z < r/s$ and $ys - rz$ and $tz - yu$ are negative. So again
163+
$(ys - rz)v$ and $(tz - yu)v$ are positive integers. So in either case,
164+
$(tz - yu)v \ge 1$ and $(ys - rz)v \ge 1$, hence
165165
$$z = [(tz-yu)v]s + [(ys - rz)v]u \ge s + u > \ell.$$
166166

167167
At this point $r/s$ and $t/u$ are candidates, there are no candidates strictly
@@ -208,14 +208,14 @@ invariant $b < a$ is smaller than the old value of $a$.
208208
Here we prove that the five properties mentioned earlier hold.
209209

210210
One of our two possible return values, $r/s$, comes directly from the loop. We
211-
construct the second candidate $t/u$ after the loop: $t = p + kr$ and $u = q +
212-
ks$, with $k = \lfloor (\ell - q) / s \rfloor$. Think of $t/u$ as the result of
213-
taking a _partial_ Euclidean step, as a replacement for the full Euclidean step
214-
which would have taken the denominator out of bounds.
211+
construct the second candidate $t/u$ after the loop: $t = p + kr$ and
212+
$u = q + ks$, with $k = \lfloor (\ell - q) / s \rfloor$. Think of $t/u$ as
213+
the result of taking a _partial_ Euclidean step, as a replacement for the
214+
full Euclidean step which would have taken the denominator out of bounds.
215215

216216
That $0 < s \le \ell$ follows directly from the loop invariants. From the
217-
definition of $k$ we have $ks \le \ell - q < s + ks$, hence $ks + q \le \ell <
218-
s + ks + q$, that is
217+
definition of $k$ we have $ks \le \ell - q < s + ks$, hence
218+
$ks + q \le \ell < s + ks + q$, that is
219219
$$u \le \ell < s + u.$$
220220
That $u$ is positive follows from $s \le \ell < s + u$. So $t/u$ is also a
221221
valid candidate approximation.
@@ -225,8 +225,8 @@ analogous relation for $r/s$ and $t/u$:
225225
$$(ts - ru)v = 1.$$
226226

227227
We also define an integer $c = a - kb$, the result of taking the partial
228-
Euclidean step that gives $t$ and $u$. It's immediate from the definitions and
229-
the earlier loop invariants that:
228+
Euclidean step that gives $t$ and $u$. It's immediate from the definitions
229+
and the earlier loop invariants that:
230230
$$(tn - mu)v = c$$
231231
and
232232
$$bt + cr = m$$

0 commit comments

Comments
 (0)