1Math::NumSeq::SpiroFiboUnsaecrciC(o3n)tributed Perl DocuMmaetnht:a:tNiuomnSeq::SpiroFibonacci(3)
2
3
4

NAME

6       Math::NumSeq::SpiroFibonacci -- recurrence around a square spiral
7

SYNOPSIS

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

DESCRIPTION

14       This is the spiro-Fibonacci numbers by Neil Fernandez.  The sequence is
15       a recurrence
16
17           SF[0] = 0
18           SF[1] = 1
19           SF[i] = SF[i-1] + SF[i-k]
20
21       where the offset k is the closest point on the on the preceding loop of
22       a square spiral.  The initial values are
23
24           0, 1, 1, ..., 1, 2, 3, 4, ... 61, 69, 78, 88, 98, 108, ...
25           starting i=0
26
27       On the square spiral this is
28
29            98-88-78-69-61-54-48
30             |                 |
31           108 10--9--8--7--6 42
32             |  |           |  |
33               11  1--1--1  5 36
34                |  |     |  |  |
35               12  1  0--1  4 31
36                |  |        |  |
37               13  1--1--2--3 27
38                |              |
39               14-15-16-18-21-24
40
41       Value 36 on the right is 31+5, being the immediately preceding 31 and
42       the value on the next inward loop closest to that new 36 position.
43
44       At the corners the same inner value is used three times, so for example
45       42=36+6, then 48=42+6 and 54=48+6, all using the corner "6".  For the
46       innermost loop SF[2] through SF[7] the "0" at the origin is the inner
47       value, hence the run of seven 1s at the start.
48
49   Absolute Differences
50       Optional "recurrence_type => 'absdiff'" changes the recurrence formula
51       to an absolute difference
52
53           SF[i] = abs (SF[i-1] - SF[i-k])
54
55       With the default initial values SF[0]=0 and SF[1]=1 this behaves as an
56       XOR, always giving 0 or 1.
57
58           0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, ...
59
60       The result plotted around the square spiral is similar to some of the
61       cellular automaton patterns which work on xor feedback.
62
63           *** *    *  **       *     **  **      * * * *  * * **
64           * *  *****   *        *** * * * *      ******** *****
65            **   * * ****         * ********      *       **    *
66             *    **  * *          **      *      **      * *   *
67           ***     *   **           *     **      * *     ****  *
68            * ******    *            *** * *      ****    *   * *
69             ** * * *****             * ***       *   *   **  ***
70           *** **  ** * *              **o**      **  **  * * *
71           * *  *   *  **               * * *     * * * * ******
72            **   ****   *              *  * **    *********     *
73           ** **** * ****              ***    *   *        *    *
74           * ** * **  * *              * *******  **       **   *
75            ** **  *   **              ** * * * * * *      * *  *
76           ** ** ***    *              *  **  * ******     **** *
77            *  *  * *****              *** ***        *    *   **
78
79   Initial Values
80       Optional "initial_0" and "initial_1" can give different initial i=0 and
81       i=1 values.  For example "initial_0=>1, initial_1=>0" gives
82
83           1, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 7, 8, 9, 11, 14, 17, 20, ...
84

FUNCTIONS

86       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
87       classes.
88
89       "$seq = Math::NumSeq::SpiroFibonacci->new ()"
90           Create and return a new sequence object.
91
92       "($i, $value) = $seq->next()"
93           Return the next index and value in the sequence.
94
95           When $value exceeds the range of a Perl unsigned integer the return
96           is promoted to a "Math::BigInt" to keep full precision.
97

SEE ALSO

99       Math::NumSeq, Math::NumSeq::Fibonacci
100
101       Math::PlanePath::SquareSpiral
102

HOME PAGE

104       <http://user42.tuxfamily.org/math-numseq/index.html>
105

LICENSE

107       Copyright 2012, 2013, 2014, 2016 Kevin Ryde
108
109       Math-NumSeq is free software; you can redistribute it and/or modify it
110       under the terms of the GNU General Public License as published by the
111       Free Software Foundation; either version 3, or (at your option) any
112       later version.
113
114       Math-NumSeq is distributed in the hope that it will be useful, but
115       WITHOUT ANY WARRANTY; without even the implied warranty of
116       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
117       General Public License for more details.
118
119       You should have received a copy of the GNU General Public License along
120       with Math-NumSeq.  If not, see <http://www.gnu.org/licenses/>.
121
122
123
124perl v5.30.1                      2020-01-30   Math::NumSeq::SpiroFibonacci(3)
Impressum