Anonymous user
Sturmian word: Difference between revisions
Continued fraction convergents
imported>CosmiaNebula No edit summary |
imported>CosmiaNebula (Continued fraction convergents) |
||
Line 11:
* Given a positive rational number <math>\frac mn</math>, specified by two positive integers <math>m, n</math>, output its entire Sturmian word.
* Given a quadratic real number <math>\frac{b\sqrt{a} + m}{n} > 0</math>, specified by
(If the programming language can represent infinite data structures, then that works too.)
Line 19:
The key difficulty is accurately calculating <math>floor(k\sqrt a) </math> for large <math>k</math>. Floating point arithmetic would lose precision. One can either do this simply by directly searching for some integer <math>a'</math> such that <math>a'^2 \leq k^2a < (a'+1)^2</math>, or by more trickly methods, such as the continued fraction approach.
First calculate the [[continued fraction
In summary,<math display="block">floor(k\sqrt a) = floor(mk/n)</math>where <math>m/n</math> is the first continued fraction approximant to <math>\sqrt a</math> with a denominator <math>n \geq k</math>
where <math>m/n</math> is the first continued fraction approximant to <math>\sqrt a</math> with a denominator <math>n \geq k</math>
|