Skip to content

Commit 0f20557

Browse files
Apply batched suggestions from code review
Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 6e3843b commit 0f20557

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎InternalDocs/fractions.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,11 @@ In addition to the above proof, a formal, computer-verified proof
364364
of correctness (using Lean) of the algorithm can be found here:
365365
https://github.com/mdickinson/snippets/tree/1f47f8cc33185c646b679647e88cb24f29fd6a4e/proofs/limit_denominator
366366

367-
# Algorithms for rational arithmetics
367+
# Algorithms for rational arithmetic
368368

369-
In following we assume, that rational numbers $\frac{p}{q}$ are
370-
represented by fractions in lowest terms. I.e. $p$ and $q$
371-
are coprime, $\gcd(p, q) = 1$. Also, denominator $q$ is positive.
369+
In following we assume that rational numbers $\frac{p}{q}$ are
370+
represented by fractions in lowest terms. That is, $p$ and $q$
371+
are coprime, $\gcd(p, q) = 1$. And, the denominator $q$ is positive.
372372

373373
Consider fractions $a/b$ and $c/d$.
374374

@@ -390,7 +390,7 @@ $$\gcd\left(p, b/g\right)
390390
=\gcd\left(a \left(d/g\right) \pm c \left(b/g\right), b/g\right)
391391
=\gcd\left(a \left(d/g\right), b/g\right) = 1$$
392392

393-
and similary\
393+
and similarly\
394394
$$\gcd\left(p, d/g\right) = \gcd\left(c\left(b/g\right), d/g\right) = 1$$
395395

396396
Above allows us optimize reduction of the result to lowest
@@ -410,8 +410,8 @@ denominator $q$ could be much larger than $g$.
410410

411411
We should special-case $g = 1$ and $h = 1$, since 61% of randomly-chosen
412412
integers [are
413-
coprime](https://en.wikipedia.org/wiki/Coprime_integers#Probability_of_coprimality).
414-
Note, that second case always holds for fractions, obtained from floats: here
413+
integers [are coprime](https://en.wikipedia.org/wiki/Coprime_integers#Probability_of_coprimality).
414+
Note that second case always holds for fractions, obtained from floats: here
415415
$g$ is a power of 2 and the unnormalized numerator $p$ is an odd integer.
416416

417417
## Multiplication
@@ -421,7 +421,7 @@ $$\frac{a}{b}\times\frac{c}{d}
421421
=\frac{\left(a/g\right)\left(c/h\right)}
422422
{\left(d/g\right)\left(b/h\right)}$$
423423

424-
Note, that after divisions we're multiplying smaller integers.
424+
Note that after divisions we're multiplying smaller integers.
425425

426426
Also, the resulting fraction is normalized, because each of
427427
two factors in the numerator is coprime to each of the two factors
@@ -430,8 +430,8 @@ in the denominator.
430430
Indeed, pick $a/g$. It's coprime with $b/h$, because input
431431
fractions are in lowest terms. It's also coprime with $d/g$,
432432
because common factors are removed by $g = \gcd\left(a, d\right)$.
433-
By symmetry, $c/h$ also coprime with both factors in the denominator.
433+
By symmetry, $c/h$ is also coprime with both factors in the denominator.
434434

435435
As for addition/subtraction, we should special-case $g = 1$
436-
and $h = 1$ for same reason. That happens also for multiplying
436+
and $h = 1$ for the same reason. That happens also for multiplying
437437
rationals, obtained from floats.

0 commit comments

Comments
 (0)