and 1 contributors

# NAME

Math::NumSeq::SqrtContinued -- continued fraction expansion of a square root

# SYNOPSIS

`````` use Math::NumSeq::SqrtContinued;
my \$seq = Math::NumSeq::SqrtContinued->new (sqrt => 2);
my (\$i, \$value) = \$seq->next;``````

# DESCRIPTION

This is terms in the continued fraction expansion of a square root. It approaches the root by

``````                      1
sqrt(S) = a + -----------
a +   1
-----------
a +   1
----------
a + ...``````

The first term a is the integer part of the root, leaving a remainder 0 < r < 1 which is expressed as r=1/R with R > 1

``````                     1
sqrt(S) = a + ---
R``````

Then a is the integer part of that R, and so on recursively.

Values a onwards are always a fixed-period repeating sequence. For example sqrt(14) is a=3 and then 1,2,1,6 repeating. For some roots a single value repeats. For example sqrt(2) is a=1 then 2 repeating. See SqrtContinuedPeriod for just the length of the period.

# FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

`\$seq = Math::NumSeq::SqrtContinued->new (sqrt => \$s)`

Create and return a new sequence object giving the Continued expansion terms of `sqrt(\$s)`.

`\$value = \$seq->ith (\$i)`

Return the i'th term in the continued fraction, starting from i=0 for the integer part of the sqrt.

`\$i = \$seq->i_start ()`

Return 0, the first term in the sequence being i=0.

# SEE ALSO

Math::ContinuedFraction

# HOME PAGE

http://user42.tuxfamily.org/math-numseq/index.html

# LICENSE

Copyright 2011, 2012, 2013, 2014, 2016 Kevin Ryde

Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.