Triangular numbers: Difference between revisions
Content added Content deleted
m (→{{header|jq}}: explain `def figurates:`) |
(→{{header|jq}}: cbrt) |
||
Line 638: | Line 638: | ||
'''Also works with gojq and fq, the Go implementations of jq''' |
'''Also works with gojq and fq, the Go implementations of jq''' |
||
The main point of interest in the following is probably `figurates/0`, which generates |
|||
an indefinitely long stream of the $r-simplex numbers if $r >= 2. |
an indefinitely long stream of the $r-simplex numbers if $r >= 2, where $r is the input to the filter. |
||
For the sake of illustration, however, `tetrahedrals` and `pentatopics` are defined without reference to `figurates/0`. |
|||
'''Preliminaries''' |
'''Preliminaries''' |
||
Line 694: | Line 695: | ||
def tetrahedralRoot: |
def tetrahedralRoot: |
||
def cubrt: pow(.; 1/3); |
|||
def term(sign): |
def term(sign): |
||
(3 * .) as $y |
(3 * .) as $y |
||
| ($y + sign * ( (($y*$y) - (1/27))|sqrt)) | |
| ($y + sign * ( (($y*$y) - (1/27))|sqrt)) | cbrt; |
||
term(1) + term(-1) -1; |
term(1) + term(-1) -1; |
||