.\" 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::PyramidRows 3pm" .TH Math::PlanePath::PyramidRows 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::PyramidRows \-\- points stacked up in a pyramid .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::PyramidRows; \& my $path = Math::PlanePath::PyramidRows\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This path arranges points in successively wider rows going upwards so as to form an upside-down pyramid. The default step is 2, ie. each row 2 wider than the preceding, an extra point at the left and the right, .PP .Vb 5 \& 17 18 19 20 21 22 23 24 25 4 \& 10 11 12 13 14 15 16 3 \& 5 6 7 8 9 2 \& 2 3 4 1 \& 1 <\- Y=0 \& \& \-4 \-3 \-2 \-1 X=0 1 2 3 4 ... .Ve .PP The right end N=1,4,9,16,etc is the perfect squares. The vertical 2,6,12,20,etc at x=\-1 is the pronic numbers s*(s+1), half way between those successive squares. .IX Xref "Square numbers Pronic numbers" .PP The step 2 is the same as the \f(CW\*(C`PyramidSides\*(C'\fR, \f(CW\*(C`Corner\*(C'\fR and \f(CW\*(C`SacksSpiral\*(C'\fR paths. For the \f(CW\*(C`SacksSpiral\*(C'\fR, spiral arms going to the right correspond to diagonals in the pyramid, and arms to the left correspond to verticals. .SS "Step Parameter" .IX Subsection "Step Parameter" A \f(CW\*(C`step\*(C'\fR parameter controls how much wider each row is than the preceding, to make wider pyramids. For example step 4 .PP .Vb 1 \& my $path = Math::PlanePath::PyramidRows\->new (step => 4); .Ve .PP makes each row 2 wider on each side successively .PP .Vb 5 \& 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 4 \& 16 17 18 19 20 21 22 23 24 25 26 27 28 3 \& 7 8 9 10 11 12 13 14 15 2 \& 2 3 4 5 6 1 \& 1 <\- Y=0 \& \& \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 ... .Ve .PP If the step is an odd number then the extra is at the right, so step 3 gives .PP .Vb 4 \& 13 14 15 16 17 18 19 20 21 22 3 \& 6 7 8 9 10 11 12 2 \& 2 3 4 5 1 \& 1 <\- Y=0 \& \& \-3 \-2 \-1 X=0 1 2 3 4 ... .Ve .PP Or step 1 goes solely to the right. This is equivalent to the Diagonals path, but columns shifted up to make horizontal rows. .PP .Vb 1 \& step => 1 \& \& 11 12 13 14 15 4 \& 7 8 9 10 3 \& 4 5 6 2 \& 2 3 1 \& 1 <\- Y=0 \& \& X=0 1 2 3 4 ... .Ve .PP Step 0 means simply a vertical, each row 1 wide and not increasing. This is unlikely to be much use. The Rows path with \f(CW\*(C`width\*(C'\fR 1 does this too. .PP .Vb 1 \& step => 0 \& \& 5 4 \& 4 3 \& 3 2 \& 2 1 \& 1 <\-y=0 \& \& X=0 .Ve .PP Various number sequences fall in regular patterns positions depending on the step. Large steps are not particularly interesting and quickly become very wide. A limit might be desirable in a user interface, but there's no limit in the code as such. .SS "Align Parameter" .IX Subsection "Align Parameter" An optional \f(CW\*(C`align\*(C'\fR parameter controls how the points are arranged relative to the Y axis. The default shown above is \*(L"centre\*(R". .PP \&\*(L"right\*(R" means points to the right of the axis, .PP .Vb 1 \& align=>"right" \& \& 26 27 28 29 30 31 32 33 34 35 36 5 \& 17 18 19 20 21 22 23 24 25 4 \& 10 11 12 13 14 15 16 3 \& 5 6 7 8 9 2 \& 2 3 4 1 \& 1 <\- Y=0 \& \& X=0 1 2 3 4 5 6 7 8 9 10 .Ve .PP \&\*(L"left\*(R" is similar but to the left of the Y axis, ie. into negative X. .PP .Vb 1 \& align=>"left" \& \& 26 27 28 29 30 31 32 33 34 35 36 5 \& 17 18 19 20 21 22 23 24 25 4 \& 10 11 12 13 14 15 16 3 \& 5 6 7 8 9 2 \& 2 3 4 1 \& 1 <\- Y=0 \& \& \-10 \-9 \-8 \-7 \-6 \-5 \-4 \-3 \-2 \-1 X=0 .Ve .PP The step parameter still controls how much longer each row is than its predecessor. .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, in the same rows sequence. For example to start at 0, .PP .Vb 1 \& n_start => 0 \& \& 16 17 18 19 20 21 22 23 24 4 \& 9 10 11 12 13 14 15 3 \& 4 5 6 7 8 2 \& 1 2 3 1 \& 0 <\- Y=0 \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& \-4 \-3 \-2 \-1 X=0 1 2 3 4 .Ve .SS "Step 3 Pentagonals" .IX Subsection "Step 3 Pentagonals" For step=3 the pentagonal numbers 1,5,12,22,etc, P(k) = (3k\-1)*k/2, are at the rightmost end of each row. The second pentagonal numbers 2,7,15,26, S(k) = (3k+1)*k/2 are the vertical at x=\-1. Those second numbers are obtained by P(\-k), and the two together are the \*(L"generalized pentagonal numbers\*(R". .PP Both these sequences are composites from 12 and 15 onwards, respectively, and the immediately preceding P(k)\-1, P(k)\-2, and S(k)\-1, S(k)\-2 are too. They factorize simply as .PP .Vb 6 \& P(k) = (3*k\-1)*k/2 \& P(k)\-1 = (3*k+2)*(k\-1)/2 \& P(k)\-2 = (3*k\-4)*(k\-1)/2 \& S(k) = (3*k+1)*k/2 \& S(k)\-1 = (3*k\-2)*(k+1)/2 \& S(k)\-2 = (3*k+4)*(k\-1)/2 .Ve .PP Plotting the primes on a step=3 \f(CW\*(C`PyramidRows\*(C'\fR has the second pentagonal S(k),S(k)\-1,S(k)\-2 as a 3\-wide vertical gap of no primes at X=\-1,\-2,\-3. The the plain pentagonal P(k),P(k\-1),P(k)\-2 are the endmost three N of each row non-prime. The vertical is much more noticeable in a plot. .PP .Vb 11 \& no primes these three columns no primes these end three \& except the low 2,7,13 except low 3,5,11 \& | | | / / / \& 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 \& 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 \& 23 24 25 26 27 28 29 30 31 32 33 34 35 \& 13 14 15 16 17 18 19 20 21 22 \& 6 7 8 9 10 11 12 \& 2 3 4 5 \& 1 \& \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 7 8 9 10 11 ... .Ve .PP With align=\*(L"left\*(R" the end values can be put into columns, .PP .Vb 10 \& no primes these end three \& align => "left" except low 3,5,11 \& | | | \& 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5 \& 23 24 25 26 27 28 29 30 31 32 33 34 35 4 \& 13 14 15 16 17 18 19 20 21 22 3 \& 6 7 8 9 10 11 12 2 \& 2 3 4 5 1 \& 1 <\- Y=0 \& ... \-10 \-9 \-8 \-7 \-6 \-5 \-4 \-3 \-2 \-1 X=0 .Ve .PP In general a constant offset S(k)\-c is a column and from P(k)\-c is a diagonal sloping up dX=2,dY=1 right. The simple factorizations above using the roots of the quadratic P(k)\-c or S(k)\-c is possible whenever 24*c+1 is a perfect square. This means the further columns S(k)\-5, S(k)\-7, S(k)\-12, etc also have no primes. .PP The columns S(k), S(k)\-1, S(k)\-2 are prominent because they're adjacent. There's no other adjacent columns of this type because the squares after 49 are too far apart for 24*c+1 to be a square for successive c. Of course there could be other reasons for other columns or diagonals to have few or many primes. .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::PyramidRows\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::PyramidRows\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::PyramidRows->new ()" .PD 0 .ie n .IP """$path = Math::PlanePath::PyramidRows\->new (step => $integer, align => $str, n_start => $n)""" 4 .el .IP "\f(CW$path = Math::PlanePath::PyramidRows\->new (step => $integer, align => $str, n_start => $n)\fR" 4 .IX Item "$path = Math::PlanePath::PyramidRows->new (step => $integer, align => $str, n_start => $n)" .PD Create and return a new path object. The default \f(CW\*(C`step\*(C'\fR is 2. \f(CW\*(C`align\*(C'\fR is a string, one of .Sp .Vb 3 \& "centre" the default \& "right" points aligned right of the Y axis \& "left" points aligned left of the Y axis .Ve .Sp Points are always numbered from left to right in the rows, the alignment changes where each row begins (or ends). .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. .Sp For \f(CW\*(C`$n <= 0\*(C'\fR the return is an empty list since the path starts at N=1. .ie n .IP """$n = $path\->xy_to_n ($x,$y)""" 4 .el .IP "\f(CW$n = $path\->xy_to_n ($x,$y)\fR" 4 .IX Item "$n = $path->xy_to_n ($x,$y)" Return the point number for coordinates \f(CW\*(C`$x,$y\*(C'\fR. \f(CW$x\fR and \f(CW$y\fR are each rounded to the nearest integer, which has the effect of treating each point in the pyramid as a square of side 1. If \f(CW\*(C`$x,$y\*(C'\fR is outside the pyramid the return is \f(CW\*(C`undef\*(C'\fR. .ie n .IP """($n_lo, $n_hi) = $path\->rect_to_n_range ($x1,$y1, $x2,$y2)""" 4 .el .IP "\f(CW($n_lo, $n_hi) = $path\->rect_to_n_range ($x1,$y1, $x2,$y2)\fR" 4 .IX Item "($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)" The returned range is exact, meaning \f(CW$n_lo\fR and \f(CW$n_hi\fR are the smallest and biggest in the rectangle. .SS "Descriptive Methods" .IX Subsection "Descriptive Methods" .ie n .IP """$x = $path\->sumxy_minimum()""" 4 .el .IP "\f(CW$x = $path\->sumxy_minimum()\fR" 4 .IX Item "$x = $path->sumxy_minimum()" .PD 0 .ie n .IP """$x = $path\->sumxy_maximum()""" 4 .el .IP "\f(CW$x = $path\->sumxy_maximum()\fR" 4 .IX Item "$x = $path->sumxy_maximum()" .PD Return the minimum or maximum values taken by coordinate sum X+Y reached by integer N values in the path. If there's no minimum or maximum then return \&\f(CW\*(C`undef\*(C'\fR. .Sp The path is right and above the X=\-Y diagonal, thus giving a minimum sum, in the following cases. .Sp .Vb 5 \& align condition for sumxy_minimum=0 \& \-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& centre step <= 3 \& right always \& left step <= 1 .Ve .ie n .IP """$x = $path\->diffxy_minimum()""" 4 .el .IP "\f(CW$x = $path\->diffxy_minimum()\fR" 4 .IX Item "$x = $path->diffxy_minimum()" .PD 0 .ie n .IP """$x = $path\->diffxy_maximum()""" 4 .el .IP "\f(CW$x = $path\->diffxy_maximum()\fR" 4 .IX Item "$x = $path->diffxy_maximum()" .PD Return the minimum or maximum values taken by coordinate difference X\-Y reached by integer N values in the path. If there's no minimum or maximum then return \f(CW\*(C`undef\*(C'\fR. .Sp The path is left and above the X=Y leading diagonal, thus giving a minimum X\-Y difference, in the following cases. .Sp .Vb 5 \& align condition for diffxy_minimum=0 \& \-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& centre step <= 2 \& right step <= 1 \& left always .Ve .SH "OEIS" .IX Header "OEIS" Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include .Sp .RS 4 (etc) .RE .PP .Vb 12 \& step=1 \& A002262 X coordinate, runs 0 to k \& A003056 Y coordinate, k repeated k+1 times \& A051162 X+Y sum \& A025581 Y\-X diff, runs k to 0 \& A079904 X*Y product \& A069011 X^2+Y^2, n_to_rsquared() \& A080099 X bitwise\-AND Y \& A080098 X bitwise\-OR Y \& A051933 X bitwise\-XOR Y \& A050873 GCD(X+1,Y+1) greatest common divisor by rows \& A051173 LCM(X+1,Y+1) least common multiple by rows \& \& A023531 dY, being 1 at triangular numbers (but starting n=0) \& A167407 dX\-dY, change in X\-Y (extra initial 0) \& A129184 turn 1=left, 0=right or straight \& \& A079824 N total along each opposite diagonal \& A000124 N on Y axis (triangular+1) \& A000217 N on X=Y diagonal, extra initial 0 \& step=1, n_start=0 \& A109004 GCD(X,Y) greatest common divisor starting (0,0) \& A103451 turn 1=left or right,0=straight, but extra initial 1 \& A103452 turn 1=left,0=straight,\-1=right, but extra initial 1 \& \& step=2 \& A196199 X coordinate, runs \-n to +n \& A000196 Y coordinate, n appears 2n+1 times \& A053186 X+Y, being distance to next higher square \& A010052 dY, being 1 at perfect square row end \& A000290 N on X=Y diagonal, extra initial 0 \& A002522 N on X=\-Y North\-West diagonal (start row), Y^2+1 \& A004201 N for which X>=0, ie. right hand half \& A020703 permutation N at \-X,Y \& step=2, n_start=0 \& A005563 N on X=Y diagonal, Y*(Y+2) \& A000290 N on X=\-Y North\-West diagonal (start row), Y^2 \& step=2, n_start=2 \& A059100 N on north\-west diagonal (start each row), Y^2+2 \& A053615 abs(X), runs k..0..k \& step=2, align=right, n_start=0 \& A196199 X\-Y, runs \-k to +k \& A053615 abs(X\-Y), runs k..0..k \& step=2, align=left, n_start=0 \& A005563 N on Y axis, Y*(Y+2) \& \& step=3 \& A180447 Y coordinate, n appears 3n+1 times \& A104249 N on Y axis, Y*(3Y+1)/2+1 \& A143689 N on X=\-Y North\-West diagonal \& step=3, n_start=0 \& A005449 N on Y axis, second pentagonals Y*(3Y+1)/2 \& A000326 N on diagonal north\-west, pentagonals Y*(3Y\-1)/2 \& \& step=4 \& A084849 N on Y axis \& A001844 N on X=Y diagonal (North\-East) \& A058331 N on X=\-Y North\-West diagonal \& A221217 permutation N at \-X,Y \& step=4, n_start=0 \& A014105 N on Y axis, the second hexagonal numbers \& A046092 N on X=Y diagonal, 4*triangular numbers \& step=4, align=right, n_start=0 \& A060511 X coordinate, amount n exceeds hexagonal number \& A000384 N on Y axis, the hexagonal numbers \& A001105 N on X=Y diagonal, 2*squares \& \& step=5 \& A116668 N on Y axis \& \& step=6 \& A056108 N on Y axis \& A056109 N on X=Y diagonal (North\-East) \& A056107 N on X=\-Y North\-West diagonal \& \& step=8 \& A053755 N on X=\-Y North\-West diagonal \& \& step=9 \& A006137 N on Y axis \& A038764 N on X=Y diagonal (North\-East) .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::PyramidSides, Math::PlanePath::Corner, Math::PlanePath::SacksSpiral, Math::PlanePath::MultipleRings .PP Math::PlanePath::Diagonals, Math::PlanePath::DiagonalsOctant, Math::PlanePath::Rows .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016 Kevin Ryde .PP This file is part of Math-PlanePath. .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 .