Opened 3 years ago
Closed 2 years ago
#27986 closed enhancement (fixed)
Add function to return the nth sgonal number
Reported by:  ghsheareralexj  Owned by:  

Priority:  trivial  Milestone:  sage9.2 
Component:  combinatorics  Keywords:  
Cc:  Merged in:  
Authors:  Alex Shearer  Reviewers:  Jonathan Kliem 
Report Upstream:  N/A  Work issues:  
Branch:  e10fd35 (Commits, GitHub, GitLab)  Commit:  e10fd35298dd5340dc38a0665c407370178e8610 
Dependencies:  Stopgaps: 
Description (last modified by )
This ticket adds a function to return elements of the sgonal sequences. For example, this enables:
sage: tri = [polygonal_number(3, n) for n in [0..9]] sage: tri [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]
sage: square = [polygonal_number(4, n) for n in [0..9]] sage: square [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Change History (31)
comment:1 Changed 3 years ago by
Description:  modified (diff) 

comment:2 Changed 3 years ago by
comment:3 Changed 3 years ago by
Milestone:  sage8.8 

As the Sage8.8 release milestone is pending, we should delete the sage8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage8.9).
comment:4 Changed 3 years ago by
Owner:  set to ghsheareralexj 

comment:5 Changed 3 years ago by
Milestone:  → sage8.9 

comment:6 Changed 3 years ago by
Authors:  → ghsheareralexj 

comment:7 Changed 3 years ago by
Authors:  ghsheareralexj → sheareralexj 

comment:8 Changed 3 years ago by
Branch:  → u/ghsheareralexj/27986 

comment:9 Changed 3 years ago by
Branch:  u/ghsheareralexj/27986 → u/sheareralexj/27986 

comment:10 Changed 3 years ago by
Branch:  u/sheareralexj/27986 → t/27986/add_function_to_return_the_nth_s_gonal_number 

comment:11 Changed 3 years ago by
Authors:  sheareralexj 

Branch:  t/27986/add_function_to_return_the_nth_s_gonal_number 
Owner:  ghsheareralexj deleted 
Priority:  minor → trivial 
comment:12 Changed 3 years ago by
Branch:  → u/ghsheareralexj/add_function_to_return_the_nth_s_gonal_number 

comment:13 Changed 3 years ago by
Authors:  → Alex Shearer 

Commit:  → b829a434d304f05bc6a3a9257604a3cfc901d3b9 
Status:  new → needs_review 
New commits:
b829a43  27986: Added function to return polygonal numbers

comment:14 Changed 3 years ago by
Commit:  b829a434d304f05bc6a3a9257604a3cfc901d3b9 → c3250281b530f2729e0e37951bbd102a49a4c224 

Branch pushed to git repo; I updated commit sha1. New commits:
c325028  27986: Removed restriction on n  can now find polygonal numbers for negative indices

comment:15 Changed 3 years ago by
Milestone:  sage8.9 → sage9.1 

Ticket retargeted after milestone closed
comment:16 Changed 3 years ago by
Reviewers:  → Jonathan Kliem 

Status:  needs_review → needs_work 
Three minor things.
 OUTPUT:   integer + OUTPUT: an integer
and
  ``s``  integer; the size of the polygon. For example, s = 3 +  ``s``  integer; the size of the polygon. For example, `s = 3`
and
 return (((n**2) * (s2))  (n * (s4))) / 2 + return (((n**2) * (s2))  (n * (s4))) // 2
(the output should be an integer and not a rational).
comment:17 Changed 2 years ago by
Milestone:  sage9.1 → sage9.2 

Batch modifying tickets that will likely not be ready for 9.1, based on a review of the ticket title, branch/review status, and last modification date.
comment:18 Changed 2 years ago by
Commit:  c3250281b530f2729e0e37951bbd102a49a4c224 → a616782708f55c17920909e3e00ea645112be405 

comment:20 Changed 2 years ago by
Status:  needs_work → needs_review 

comment:21 Changed 2 years ago by
Status:  needs_review → needs_work 

Some more minor things I missed before.
 The arguments in the INPUT block are usually not sentences and end not with a period. See https://doc.sagemath.org/html/en/developer/coding_basics.html#input
 I would propose the following:
  ``s``  integer; the size of the polygon. For example, `s = 3`  returns a 3gonal (triangular) number. `s` must be greater than 1. +  ``s``  integer greater than 1; the number of sides of the polygon
 The details from the input block about
s
are probably easier to read for a user on the example block as in:
EXAMPLES: The triangular numbers:: sage: [polygonal_number(3, n) for n in range(10)] [0, 1, 3, 6, 10, 15, 21, 28, 36, 45] The square numbers:: sage: [polygonal_number(4, n) for n in range(10)] [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] The pentagonal numbers:: sage: [polygonal_number(5, n) for n in range(10)] [0, 1, 5, 12, 22, 35, 51, 70, 92, 117] The hexagonal numbers:: sage: [polygonal_number(6, n) for n in range(10)] [0, 1, 6, 15, 28, 45, 66, 91, 120, 153]
 It would be great if the other examples could be shortly illustrated by half a sentence or so. (Maybe something as
The input is converted to an integer
).
comment:22 Changed 2 years ago by
Commit:  a616782708f55c17920909e3e00ea645112be405 → 856d669955c7797ece5d6636cf3f698ab522840e 

Branch pushed to git repo; I updated commit sha1. New commits:
856d669  27986: Updated input block and example documentation

comment:23 Changed 2 years ago by
Status:  needs_work → needs_review 

Thank you Jonathan, I made your suggested edits
comment:24 Changed 2 years ago by
Commit:  856d669955c7797ece5d6636cf3f698ab522840e → cccb629145a38c604412986b010f6af4411c9da2 

Branch pushed to git repo; I updated commit sha1. New commits:
cccb629  27986: updated documentation

comment:25 Changed 2 years ago by
One last thing I noticed by the the bots:
 EXAMPLES:: + EXAMPLES: The triangular numbers::
comment:26 Changed 2 years ago by
Commit:  cccb629145a38c604412986b010f6af4411c9da2 → 1cbb3ac67ab822b4b41ad087889ca529b5d1cc41 

Branch pushed to git repo; I updated commit sha1. New commits:
1cbb3ac  27986: Updated examples block

comment:28 Changed 2 years ago by
One other trivial thing:
REFERENCES:  :wikipedia:`Polygonal_number` + :wikipedia:`Polygonal_number`
(or possibly with a bullet point  :wikipedia:...
).
comment:29 Changed 2 years ago by
Commit:  1cbb3ac67ab822b4b41ad087889ca529b5d1cc41 → e10fd35298dd5340dc38a0665c407370178e8610 

Branch pushed to git repo; I updated commit sha1. New commits:
e10fd35  27986: updated references block

comment:30 Changed 2 years ago by
Status:  needs_review → positive_review 

Sorry, forgot about this. It has been fine for a while now.
comment:31 Changed 2 years ago by
Branch:  u/ghsheareralexj/add_function_to_return_the_nth_s_gonal_number → e10fd35298dd5340dc38a0665c407370178e8610 

Resolution:  → fixed 
Status:  positive_review → closed 
As the Sage8.8 release milestone is pending, we should delete the sage8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage8.9).