Recovering numbers from continued fraction

Okay, not really, since we won't type in infinitely many numbers. But it would be nice to have a way to convert [1,1,1,1,1,1,1,1,1] to a rational approximation of the golden ratio. I couldn't find anything built-in, but maybe I didn't look hard enough?

2 answers

It used to be that continued_fraction could only deal with finite continued fraction expansions. Thanks to work made in 2014 by Vincent Delecroix and other authors/reviewers, Sage deals with ultimately periodic CF expansions (i.e., quadratic irrationals). If you look at the documentation of continued_fraction?, you will see this example: