Provided by: libmath-planepath-perl_125-1_all bug

NAME

       Math::PlanePath::CoprimeColumns -- coprime X,Y by columns

SYNOPSIS

        use Math::PlanePath::CoprimeColumns;
        my $path = Math::PlanePath::CoprimeColumns->new;
        my ($x, $y) = $path->n_to_xy (123);

DESCRIPTION

       This path visits points X,Y which are coprime, ie. no common factor so gcd(X,Y)=1, in
       columns from Y=0 to Y<=X.

           13 |                                          63
           12 |                                       57
           11 |                                    45 56 62
           10 |                                 41    55
            9 |                              31 40    54 61
            8 |                           27    39    53
            7 |                        21 26 30 38 44 52
            6 |                     17          37    51
            5 |                  11 16 20 25    36 43 50 60
            4 |                9    15    24    35    49
            3 |             5  8    14 19    29 34    48 59
            2 |          3     7    13    23    33    47
            1 |    0  1  2  4  6 10 12 18 22 28 32 42 46 58
           Y=0|
              +---------------------------------------------
              X=0  1  2  3  4  5  6  7  8  9 10 11 12 13 14

       Since gcd(X,0)=0 the X axis itself is never visited, and since gcd(K,K)=K the leading
       diagonal X=Y is not visited except X=1,Y=1.

       The number of coprime pairs in each column is Euler's totient function phi(X).  Starting
       N=0 at X=1,Y=1 means N=0,1,2,4,6,10,etc horizontally along row Y=1 are the cumulative
       totients

                                 i=K
           cumulative totient = sum   phi(i)
                                 i=1

       Anything making a straight line etc in the path will probably be related to totient sums
       in some way.

       The pattern of coprimes or not within a column is the same going up as going down, since
       X,X-Y has the same coprimeness as X,Y.  This means coprimes occur in pairs from X=3
       onwards.  When X is even the middle point Y=X/2 is not coprime since it has common factor
       2 from X=4 onwards.  So there's an even number of points in each column from X=2 onwards
       and those cumulative totient totals horizontally along X=1 are therefore always even
       likewise.

   Direction Down
       Option "direction => 'down'" reverses the order within each column to go downwards to the
       X axis.

           direction => "down"

            8 |                           22
            7 |                        18 23        numbering
            6 |                     12              downwards
            5 |                  10 13 19 24            |
            4 |                6    14    25            |
            3 |             4  7    15 20               v
            2 |          2     8    16    26
            1 |    0  1  3  5  9 11 17 21 27
           Y=0|
              +-----------------------------
              X=0  1  2  3  4  5  6  7  8  9

   N Start
       The default is to number points starting N=0 as shown above.  An optional "n_start" can
       give a different start with the same shape,  For example to start at 1,

           n_start => 1

            8 |                           28
            7 |                        22 27
            6 |                     18
            5 |                  12 17 21 26
            4 |               10    16    25
            3 |             6  9    15 20
            2 |          4     8    14    24
            1 |    1  2  3  5  7 11 13 19 23
           Y=0|
              +------------------------------
              X=0  1  2  3  4  5  6  7  8  9

FUNCTIONS

       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.

       "$path = Math::PlanePath::CoprimeColumns->new ()"
       "$path = Math::PlanePath::CoprimeColumns->new (direction => $str, n_start => $n)"
           Create and return a new path object.  "direction" (a string) can be

               "up"       (the default)
               "down"

       "($x,$y) = $path->n_to_xy ($n)"
           Return the X,Y coordinates of point number $n on the path.  Points begin at 0 and if
           "$n < 0" then the return is an empty list.

       "$bool = $path->xy_is_visited ($x,$y)"
           Return true if "$x,$y" is visited.  This means $x and $y have no common factor.  This
           is tested with a GCD and is much faster than the full "xy_to_n()".

BUGS

       The current implementation is fairly slack and is slow on medium to large N.  A table of
       cumulative totients is built and retained up to the highest X column number used.

OEIS

       This pattern is in Sloane's Online Encyclopedia of Integer Sequences in a couple of forms,

           <http://oeis.org/A002088> (etc)

           n_start=0 (the default)
             A038567    X coordinate, reduced fractions denominator
             A020653    X-Y diff, fractions denominator by diagonals
                          skipping N=0 initial 1/1

             A002088    N on X axis, cumulative totient
             A127368    by columns Y coordinate if coprime, 0 if not
             A054521    by columns 1 if coprime, 0 if not

             A054427    permutation columns N -> RationalsTree SB N X/Y<1
             A054428      inverse, SB X/Y<1 -> columns
             A121998    Y of skipped X,Y among 2<=Y<=X, those not coprime
             A179594    X column position of KxK square unvisited

           n_start=1
             A038566    Y coordinate, reduced fractions numerator

             A002088    N on X=Y+1 diagonal, cumulative totient

SEE ALSO

       Math::PlanePath, Math::PlanePath::DiagonalRationals, Math::PlanePath::RationalsTree,
       Math::PlanePath::PythagoreanTree, Math::PlanePath::DivisibleColumns

HOME PAGE

       <http://user42.tuxfamily.org/math-planepath/index.html>

LICENSE

       Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde

       Math-PlanePath 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-PlanePath 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-
       PlanePath.  If not, see <http://www.gnu.org/licenses/>.