.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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 >0, 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::DiagonalRationals 3pm" .TH Math::PlanePath::DiagonalRationals 3pm "2021-01-23" "perl v5.32.0" "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::DiagonalRationals \-\- rationals X/Y by diagonals .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::DiagonalRationals; \& my $path = Math::PlanePath::DiagonalRationals\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This path enumerates positive rationals X/Y with no common factor, going in diagonal order from Y down to X. .PP .Vb 10 \& 17 | 96... \& 16 | 80 \& 15 | 72 81 \& 14 | 64 82 \& 13 | 58 65 73 83 97 \& 12 | 46 84 \& 11 | 42 47 59 66 74 85 98 \& 10 | 32 48 86 \& 9 | 28 33 49 60 75 87 \& 8 | 22 34 50 67 88 \& 7 | 18 23 29 35 43 51 68 76 89 99 \& 6 | 12 36 52 90 \& 5 | 10 13 19 24 37 44 53 61 77 91 \& 4 | 6 14 25 38 54 69 92 \& 3 | 4 7 15 20 30 39 55 62 78 93 \& 2 | 2 8 16 26 40 56 70 94 \& 1 | 1 3 5 9 11 17 21 27 31 41 45 57 63 71 79 95 \& Y=0 | \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& X=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 .Ve .PP The order is the same as the \f(CW\*(C`Diagonals\*(C'\fR path, but only those X,Y with no common factor are numbered. .PP .Vb 5 \& 1/1, N = 1 \& 1/2, 1/2, N = 2 .. 3 \& 1/3, 1/3, N = 4 .. 5 \& 1/4, 2/3, 3/2, 4/1, N = 6 .. 9 \& 1/5, 5/1, N = 10 .. 11 .Ve .PP N=1,2,4,6,10,etc at the start of each diagonal (in the column at X=1) is the cumulative totient, .PP .Vb 1 \& totient(i) = count numbers having no common factor with i \& \& i=K \& cumulative_totient(K) = sum totient(i) \& i=1 .Ve .SS "Direction Up" .IX Subsection "Direction Up" Option \f(CW\*(C`direction => \*(Aqup\*(Aq\*(C'\fR reverses the order within each diagonal to count upward from the X axis. .PP .Vb 1 \& direction => "up" \& \& 8 | 27 \& 7 | 21 26 \& 6 | 17 \& 5 | 11 16 20 25 \& 4 | 9 15 24 \& 3 | 5 8 14 19 \& 2 | 3 7 13 23 \& 1 | 1 2 4 6 10 12 18 22 \& Y=0| \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& X=0 1 2 3 4 5 6 7 8 .Ve .SS "N Start" .IX Subsection "N Start" The default is to number points starting N=1 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 0, .PP .Vb 1 \& n_start => 0 \& \& 8 | 21 \& 7 | 17 22 \& 6 | 11 \& 5 | 9 12 18 23 \& 4 | 5 13 24 \& 3 | 3 6 14 19 \& 2 | 1 7 15 25 \& 1 | 0 2 4 8 10 16 20 26 \& Y=0| \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& X=0 1 2 3 4 5 6 7 8 .Ve .SS "Coprime Columns" .IX Subsection "Coprime Columns" The diagonals are the same as the columns in \f(CW\*(C`CoprimeColumns\*(C'\fR. For example the diagonal N=18 to N=21 from X=0,Y=8 down to X=8,Y=0 is the same as the \&\f(CW\*(C`CoprimeColumns\*(C'\fR vertical at X=8. In general the correspondence is .PP .Vb 2 \& Xdiag = Ycol \& Ydiag = Xcol \- Ycol \& \& Xcol = Xdiag + Ydiag \& Ycol = Xdiag .Ve .PP \&\f(CW\*(C`CoprimeColumns\*(C'\fR has an extra N=0 at X=1,Y=1 which is not present in \&\f(CW\*(C`DiagonalRationals\*(C'\fR. (It would be Xdiag=1,Ydiag=0 which is 1/0.) .PP The points numbered or skipped in a column up to X=Y is the same as the points numbered or skipped on a diagonal, simply because X,Y no common factor is the same as Y,X+Y no common factor. .PP Taking the \f(CW\*(C`CoprimeColumns\*(C'\fR as enumerating fractions F = Ycol/Xcol with 0 < F < 1 the corresponding diagonal rational 0 < R < infinity is .PP .Vb 3 \& 1 F \& R = \-\-\-\-\-\-\- = \-\-\- \& 1/F \- 1 1\-F \& \& 1 R \& F = \-\-\-\-\-\-\- = \-\-\- \& 1/R + 1 1+R .Ve .PP which is a one-to-one mapping between the fractions F < 1 and all rationals. .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::DiagonalRationals\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::DiagonalRationals\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::DiagonalRationals->new ()" .PD 0 .ie n .IP """$path = Math::PlanePath::DiagonalRationals\->new (direction => $str, n_start => $n)""" 4 .el .IP "\f(CW$path = Math::PlanePath::DiagonalRationals\->new (direction => $str, n_start => $n)\fR" 4 .IX Item "$path = Math::PlanePath::DiagonalRationals->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 \& "down" (the default) \& "up" .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 1 and if \f(CW\*(C`$n < 1\*(C'\fR then the return is an empty list. .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 for the diagonal d=X+Y. .SH "OEIS" .IX Header "OEIS" This enumeration of rationals is in Sloane's Online Encyclopedia of Integer Sequences in the following forms .Sp .RS 4 (etc) .RE .PP .Vb 6 \& direction=down, n_start=1 (the defaults) \& A020652 X, numerator \& A020653 Y, denominator \& A038567 X+Y sum, starting from X=1,Y=1 \& A054431 by diagonals 1=coprime, 0=not \& (excluding X=0 row and Y=0 column) \& \& A054430 permutation N at Y/X \& reverse runs of totient(k) many integers \& \& A054424 permutation DiagonalRationals \-> RationalsTree SB \& A054425 padded with 0s at non\-coprimes \& A054426 inverse SB \-> DiagonalRationals \& A060837 permutation DiagonalRationals \-> FactorRationals \& \& direction=down, n_start=0 \& A157806 abs(X\-Y) difference .Ve .PP direction=up swaps X,Y. .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::CoprimeColumns, Math::PlanePath::RationalsTree, Math::PlanePath::PythagoreanTree .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 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 .