1Math::NumSeq::SqrtContiUnsueerdPCeornitordi(b3u)ted PerlMaDtohc:u:mNeunmtSaetqi:o:nSqrtContinuedPeriod(3)
2
3
4

NAME

6       Math::NumSeq::SqrtContinuedPeriod -- period of the continued fraction
7       for sqrt(i)
8

SYNOPSIS

10        use Math::NumSeq::SqrtContinuedPeriod;
11        my $seq = Math::NumSeq::SqrtContinuedPeriod->new;
12        my ($i, $value) = $seq->next;
13

DESCRIPTION

15       This the period of the repeating part of the continued fraction
16       expansion of sqrt(i).
17
18           0, 1, 2, 0, 1, 2, 4, 2, etc
19
20       For example sqrt(12) is 3 then terms 2,6 repeating, which is period 2.
21
22                           1
23          sqrt(12) = 3 + -----------
24                         2 +   1
25                             -----------
26                             6 +   1
27                                 ----------
28                                 2 +   1
29                                     ---------
30                                     6 + ...        2,6 repeating
31
32       All square root continued fractions like this comprise an integer part
33       followed by repeating terms of some length.  Perfect squares are an
34       integer part only, nothing further, and the period for them is taken to
35       be 0.
36
37       The continued fraction calculation has denominator value at each stage
38       of the form
39
40          den =(P+sqrt(S)) / Q
41
42          with
43
44          0 <= P <= root
45          0 < Q <= 2*root+1
46          where root=floor(sqrt(S))
47
48       The limited range of P,Q means a finite set of combinations at most
49       root*(2*root+1), which is roughly 2*S.  In practice it's much less.
50

FUNCTIONS

52       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
53       classes.
54
55       "$seq = Math::NumSeq::SqrtContinuedPeriod->new (sqrt => $s)"
56           Create and return a new sequence object giving the Continued
57           expansion terms of "sqrt($s)".
58
59       "$value = $seq->ith ($i)"
60           Return the period of sqrt($i).
61

SEE ALSO

63       Math::NumSeq, Math::NumSeq::SqrtContinued
64

HOME PAGE

66       <http://user42.tuxfamily.org/math-numseq/index.html>
67

LICENSE

69       Copyright 2011, 2012, 2013, 2014, 2016, 2019 Kevin Ryde
70
71       Math-NumSeq is free software; you can redistribute it and/or modify it
72       under the terms of the GNU General Public License as published by the
73       Free Software Foundation; either version 3, or (at your option) any
74       later version.
75
76       Math-NumSeq is distributed in the hope that it will be useful, but
77       WITHOUT ANY WARRANTY; without even the implied warranty of
78       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
79       General Public License for more details.
80
81       You should have received a copy of the GNU General Public License along
82       with Math-NumSeq.  If not, see <http://www.gnu.org/licenses/>.
83
84
85
86perl v5.32.0                      2020-07-2M8ath::NumSeq::SqrtContinuedPeriod(3)
Impressum