Continued fraction convergents: Difference between revisions
Content added Content deleted
imported>CosmiaNebula (two examples) |
(draft task, clarify task) |
||
Line 1: | Line 1: | ||
{{ |
{{draft task}} |
||
{{clarify task}} |
|||
Given a positive real number, if we truncate its [[continued fraction]] representation at a certain depth, we obtain a rational approximation to the real number. The sequence of successively better such approximations is its convergent sequence. |
Given a positive real number, if we truncate its [[continued fraction]] representation at a certain depth, we obtain a rational approximation to the real number. The sequence of successively better such approximations is its convergent sequence. |
||
Revision as of 07:27, 1 February 2024
Continued fraction convergents is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Given a positive real number, if we truncate its continued fraction representation at a certain depth, we obtain a rational approximation to the real number. The sequence of successively better such approximations is its convergent sequence.
Problem:
- Given a positive rational number , specified by two positive integers , output its entire sequence of convergents.
- Given a quadratic real number , specified by integers , where is not a perfect square, output the first convergents when given a positive number .
The output format can be whatever is necessary to represent rational numbers, but it probably should be a 2-tuple of integers.
For example, given , since
the program should output .
A simple check is to do this for the golden ratio , that is, , which would just output the Fibonacci sequence.