Math::NumSeq::SqrtContinued -- continued fraction expansion of a square root
use Math::NumSeq::SqrtContinued; my $seq = Math::NumSeq::SqrtContinued->new (sqrt => 2); my ($i, $value) = $seq->next;
This is terms in the continued fraction expansion of a square root. It approaches the root by
1 sqrt(s) = a[0] + ----------- a[1] + 1 ----------- a[2] + 1 ---------- a[3] + ...
The first term a[0] is the integer part of the root, leaving a remainder 0 < r < 1 which is expressed as r=1/R with R > 1. Then a[1] is the integer part of that R, and so on recursively.
Values a[1] onwards always repeat in a fixed sequence. For example sqrt(14) is a[0]=3 and then 1,2,1,6 repeating. For some a single value repeats, for example sqrt(2) is a[0]=1 then 2 repeating. See SqrtContinuedPeriod for just the length of the period.
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).
sqrt($s)
Math::NumSeq, Math::NumSeq::SqrtContinuedPeriod, Math::NumSeq::SqrtDigits, Math::NumSeq::SqrtEngel
Math::Pell, Math::ContinuedFraction
http://user42.tuxfamily.org/math-numseq/index.html
Copyright 2011, 2012 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/>.
To install Math::NumSeq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::NumSeq
CPAN shell
perl -MCPAN -e shell install Math::NumSeq
For more information on module installation, please visit the detailed CPAN module installation guide.