1Math::NumSeq::SqrtEngelU(s3e)r Contributed Perl DocumentaMtaitohn::NumSeq::SqrtEngel(3)
2
3
4
6 Math::NumSeq::SqrtEngel -- Engel expansion of a square root
7
9 use Math::NumSeq::SqrtEngel;
10 my $seq = Math::NumSeq::SqrtEngel->new (sqrt => 2);
11 my ($i, $value) = $seq->next;
12
14 This is terms in the Engel expansion of a square root. The Engel
15 expansion approaches the root by a series
16
17 1 1 1
18 sqrt(S) = ---- + --------- + -------------- + ...
19 a[1] a[1]*a[2] a[1]*a[2]*a[3]
20
21 where each a[i] is chosen to make the term as big as possible without
22 the total exceeding the target sqrt(S).
23
24 The sequence values are each successive a[i]. For example sqrt(2)
25
26 1 1 1 1 1
27 sqrt(2) = --- + --- + ----- + ------- + ---------- + ...
28 1 1*3 1*3*5 1*3*5*5 1*3*5*5*16
29
30 is
31
32 1, 3, 5, 5, 16, etc
33 starting i=1
34
35 For a perfect square, the expansion is a finite sequence of 1s summing
36 to the root. This is unlikely to be interesting, but works as a $seq
37 sequence.
38
39 sqrt(perfect square) = 1/1 + 1/1 + ... + 1/1
40
42 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
43 classes.
44
45 "$seq = Math::NumSeq::SqrtEngel->new (sqrt => $integer)"
46 Create and return a new sequence object giving the Engel expansion
47 terms of "sqrt($integer)".
48
50 The current code requires "Math::BigInt" "sqrt()", which may mean
51 BigInt 1.60 or higher (which comes with Perl 5.8.0).
52
54 Math::NumSeq, Math::NumSeq::SqrtDigits
55
57 <http://user42.tuxfamily.org/math-numseq/index.html>
58
60 Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
61
62 Math-NumSeq is free software; you can redistribute it and/or modify it
63 under the terms of the GNU General Public License as published by the
64 Free Software Foundation; either version 3, or (at your option) any
65 later version.
66
67 Math-NumSeq is distributed in the hope that it will be useful, but
68 WITHOUT ANY WARRANTY; without even the implied warranty of
69 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
70 General Public License for more details.
71
72 You should have received a copy of the GNU General Public License along
73 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
74
75
76
77perl v5.36.0 2022-07-22 Math::NumSeq::SqrtEngel(3)