Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 2738d2c

Browse files
doc(algebra/continued_fractions/*): TeXify docstrings (#18459)
Improve readability of continued fractions in the docstrings by randering them via LaTeX.
1 parent 0324bd3 commit 2738d2c

3 files changed

Lines changed: 29 additions & 45 deletions

File tree

src/algebra/continued_fractions/basic.lean

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,13 @@ variable (α)
8080

8181
/--
8282
A *generalised continued fraction* (gcf) is a potentially infinite expression of the form
83-
84-
a₀
85-
h + ---------------------------
86-
a₁
87-
b₀ + --------------------
88-
a₂
89-
b₁ + --------------
90-
a₃
91-
b₂ + --------
92-
b₃ + ...
93-
83+
$$
84+
h + \dfrac{a_0}
85+
{b_0 + \dfrac{a_1}
86+
{b_1 + \dfrac{a_2}
87+
{b_2 + \dfrac{a_3}
88+
{b_3 + \dots}}}}
89+
$$
9490
where `h` is called the *head term* or *integer part*, the `aᵢ` are called the
9591
*partial numerators* and the `bᵢ` the *partial denominators* of the gcf.
9692
We store the sequence of partial numerators and denominators in a sequence of
@@ -150,17 +146,13 @@ end generalized_continued_fraction
150146
/--
151147
A generalized continued fraction is a *simple continued fraction* if all partial numerators are
152148
equal to one.
153-
154-
1
155-
h + ---------------------------
156-
1
157-
b₀ + --------------------
158-
1
159-
b₁ + --------------
160-
1
161-
b₂ + --------
162-
b₃ + ...
163-
149+
$$
150+
h + \dfrac{1}
151+
{b_0 + \dfrac{1}
152+
{b_1 + \dfrac{1}
153+
{b_2 + \dfrac{1}
154+
{b_3 + \dots}}}}
155+
$$
164156
-/
165157
def generalized_continued_fraction.is_simple_continued_fraction
166158
(g : generalized_continued_fraction α) [has_one α] : Prop :=
@@ -170,17 +162,13 @@ variable (α)
170162
/--
171163
A *simple continued fraction* (scf) is a generalized continued fraction (gcf) whose partial
172164
numerators are equal to one.
173-
174-
1
175-
h + ---------------------------
176-
1
177-
b₀ + --------------------
178-
1
179-
b₁ + --------------
180-
1
181-
b₂ + --------
182-
b₃ + ...
183-
165+
$$
166+
h + \dfrac{1}
167+
{b_0 + \dfrac{1}
168+
{b_1 + \dfrac{1}
169+
{b_2 + \dfrac{1}
170+
{b_3 + \dots}}}}
171+
$$
184172
For convenience, one often writes `[h; b₀, b₁, b₂,...]`.
185173
It is encoded as the subtype of gcfs that satisfy
186174
`generalized_continued_fraction.is_simple_continued_fraction`.

src/algebra/continued_fractions/computation/approximation_corollaries.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ lemma of_convergents_eq_convergents' :
7070
The recurrence relation for the `convergents` of the continued fraction expansion
7171
of an element `v` of `K` in terms of the convergents of the inverse of its fractional part.
7272
-/
73-
lemma convergents_succ (n : ℕ):
73+
lemma convergents_succ (n : ℕ) :
7474
(of v).convergents (n + 1) = ⌊v⌋ + 1 / (of (int.fract v)⁻¹).convergents n :=
7575
by rw [of_convergents_eq_convergents', convergents'_succ, of_convergents_eq_convergents']
7676

src/algebra/continued_fractions/convergents_equiv.lean

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@ direct evaluation (`convergents'`)) for `gcf`s on linear ordered fields. We foll
1818
[hardy2008introduction], Chapter 10. Here's a sketch:
1919
2020
Let `c` be a continued fraction `[h; (a₀, b₀), (a₁, b₁), (a₂, b₂),...]`, visually:
21-
22-
a₀
23-
h + ---------------------------
24-
a₁
25-
b₀ + --------------------
26-
a₂
27-
b₁ + --------------
28-
a₃
29-
b₂ + --------
30-
b₃ + ...
31-
21+
$$
22+
c = h + \dfrac{a_0}
23+
{b_0 + \dfrac{a_1}
24+
{b_1 + \dfrac{a_2}
25+
{b_2 + \dfrac{a_3}
26+
{b_3 + \dots}}}}
27+
$$
3228
One can compute the convergents of `c` in two ways:
3329
1. Directly evaluating the fraction described by `c` up to a given `n` (`convergents'`)
3430
2. Using the recurrence (`convergents`):

0 commit comments

Comments
 (0)