Continued fraction expansion of square roots
This functionality does not run in MATLAB.
numlib::sqrt2cfrac(a) returns the continued
fraction expansion of the square root of
a as a
sequence of two lists: the first one contains the non-periodic (integer)
part, the second one contains the periodic part of the expansion.
The square root of 87 can be written as 9 + q, where q is a number satisfying :
Since 81 is a perfect square, there is no periodic part in the continued fraction expansion of its square root:
A positive integer
a is a perfect square,
a list with one entry; otherwise
a sequence of two lists, the first consisting of one integer, the
second consisting of one or more integers.