.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Math::PlanePath::CoprimeColumns 3pm" .TH Math::PlanePath::CoprimeColumns 3pm "2016-05-03" "perl v5.22.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Math::PlanePath::CoprimeColumns \-\- coprime X,Y by columns .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::CoprimeColumns; \& my $path = Math::PlanePath::CoprimeColumns\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "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. .PP .Vb 10 \& 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 .Ve .PP 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. .PP 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 .PP .Vb 3 \& i=K \& cumulative totient = sum phi(i) \& i=1 .Ve .PP Anything making a straight line etc in the path will probably be related to totient sums in some way. .PP 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. .SS "Direction Down" .IX Subsection "Direction Down" Option \f(CW\*(C`direction => \*(Aqdown\*(Aq\*(C'\fR reverses the order within each column to go downwards to the X axis. .PP .Vb 1 \& 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 .Ve .SS "N Start" .IX Subsection "N Start" The default is to number points starting N=0 as shown above. An optional \&\f(CW\*(C`n_start\*(C'\fR can give a different start with the same shape, For example to start at 1, .PP .Vb 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 .Ve .SH "FUNCTIONS" .IX Header "FUNCTIONS" See \*(L"\s-1FUNCTIONS\*(R"\s0 in Math::PlanePath for behaviour common to all path classes. .ie n .IP """$path = Math::PlanePath::CoprimeColumns\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::CoprimeColumns\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::CoprimeColumns->new ()" .PD 0 .ie n .IP """$path = Math::PlanePath::CoprimeColumns\->new (direction => $str, n_start => $n)""" 4 .el .IP "\f(CW$path = Math::PlanePath::CoprimeColumns\->new (direction => $str, n_start => $n)\fR" 4 .IX Item "$path = Math::PlanePath::CoprimeColumns->new (direction => $str, n_start => $n)" .PD Create and return a new path object. \f(CW\*(C`direction\*(C'\fR (a string) can be .Sp .Vb 2 \& "up" (the default) \& "down" .Ve .ie n .IP """($x,$y) = $path\->n_to_xy ($n)""" 4 .el .IP "\f(CW($x,$y) = $path\->n_to_xy ($n)\fR" 4 .IX Item "($x,$y) = $path->n_to_xy ($n)" Return the X,Y coordinates of point number \f(CW$n\fR on the path. Points begin at 0 and if \f(CW\*(C`$n < 0\*(C'\fR then the return is an empty list. .ie n .IP """$bool = $path\->xy_is_visited ($x,$y)""" 4 .el .IP "\f(CW$bool = $path\->xy_is_visited ($x,$y)\fR" 4 .IX Item "$bool = $path->xy_is_visited ($x,$y)" Return true if \f(CW\*(C`$x,$y\*(C'\fR is visited. This means \f(CW$x\fR and \f(CW$y\fR have no common factor. This is tested with a \s-1GCD\s0 and is much faster than the full \&\f(CW\*(C`xy_to_n()\*(C'\fR. .SH "BUGS" .IX Header "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. .SH "OEIS" .IX Header "OEIS" This pattern is in Sloane's Online Encyclopedia of Integer Sequences in a couple of forms, .Sp .RS 4 (etc) .RE .PP .Vb 4 \& 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 .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::DiagonalRationals, Math::PlanePath::RationalsTree, Math::PlanePath::PythagoreanTree, Math::PlanePath::DivisibleColumns .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2011, 2012, 2013, 2014, 2015, 2016 Kevin Ryde .PP Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. .PP Math-PlanePath is distributed in the hope that it will be useful, but \&\s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE. \s0 See the \s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with Math-PlanePath. If not, see .