1Math::NumSeq::MephistoWUasletrz(C3o)ntributed Perl DocumMeanttha:t:iNounmSeq::MephistoWaltz(3)
2
3
4

NAME

6       Math::NumSeq::MephistoWaltz -- Mephisto waltz sequence
7

SYNOPSIS

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

DESCRIPTION

14       The Mephisto waltz sequence, being the mod 2 count of ternary digit 2s
15       in i.
16
17           0,0,1, 0,0,1, 1,1,0, ...
18           starting i=0
19
20       i=0 has no 2s so value=0, and likewise i=1 value=0.  Then i=2 has one 2
21       so value=1.
22
23       The sequence can also be expressed as starting with 0 and repeatedly
24       expanding
25
26           0 -> 0,0,1
27           1 -> 1,1,0
28
29       So
30
31           0
32           0,0,1
33           0,0,1, 0,0,1, 1,1,0,
34           0,0,1, 0,0,1, 1,1,0, 0,0,1, 0,0,1, 1,1,0, 1,1,0, 1,1,0, 0,0,1
35
36           |   original      |  |     copy        |  |     inverse     |
37           +-----------------+  +-----------------+  +-----------------+
38
39       The effect of the expansion is keep the first third the same, append a
40       copy of it, and append an inverse of it 0<->1.
41

FUNCTIONS

43       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
44       classes.
45
46       "$seq = Math::NumSeq::MephistoWaltz->new ()"
47           Create and return a new sequence object.
48
49   Random Access
50       "$value = $seq->ith($i)"
51           Return the $i'th MephistoWaltz value, being the count mod 2 of the
52           ternary digit 2s in $i.
53
54       "$bool = $seq->pred($value)"
55           Return true if $value occurs in the sequence, which simply means 0
56           or 1.
57

FORMULAS

59       The calculation can be made in a power-of-3 base like 9, 27, 81, etc
60       instead of just 3.  For example in base 9 digits 2, 5, 6, 7 have a one
61       (mod 2) ternary 2.  These base 9 digits correspond to the 1s in the
62       initial sequence 0,0,1, 0,0,1, 1,1,0 shown above.
63

SEE ALSO

65       Math::NumSeq, Math::NumSeq::DigitSumModulo
66

HOME PAGE

68       <http://user42.tuxfamily.org/math-numseq/index.html>
69

LICENSE

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