1math::figurate(n) Tcl Math Library math::figurate(n)
2
3
4
5______________________________________________________________________________
6
8 math::figurate - Evaluate figurate numbers
9
11 package require Tcl 8.6
12
13 package require math::figurate 1.0
14
15 ::math::figurate::sum_sequence n
16
17 ::math::figurate::sum_squares n
18
19 ::math::figurate::sum_cubes n
20
21 ::math::figurate::sum_4th_power n
22
23 ::math::figurate::sum_5th_power n
24
25 ::math::figurate::sum_6th_power n
26
27 ::math::figurate::sum_7th_power n
28
29 ::math::figurate::sum_8th_power n
30
31 ::math::figurate::sum_9th_power n
32
33 ::math::figurate::sum_10th_power n
34
35 ::math::figurate::sum_sequence_odd n
36
37 ::math::figurate::sum_squares_odd n
38
39 ::math::figurate::sum_cubes_odd n
40
41 ::math::figurate::sum_4th_power_odd n
42
43 ::math::figurate::sum_5th_power_odd n
44
45 ::math::figurate::sum_6th_power_odd n
46
47 ::math::figurate::sum_7th_power_odd n
48
49 ::math::figurate::sum_8th_power_odd n
50
51 ::math::figurate::sum_9th_power_odd n
52
53 ::math::figurate::sum_10th_power_odd n
54
55 ::math::figurate::oblong n
56
57 ::math::figurate::pronic n
58
59 ::math::figurate::triangular n
60
61 ::math::figurate::square n
62
63 ::math::figurate::cubic n
64
65 ::math::figurate::biquadratic n
66
67 ::math::figurate::centeredTriangular n
68
69 ::math::figurate::centeredSquare n
70
71 ::math::figurate::centeredPentagonal n
72
73 ::math::figurate::centeredHexagonal n
74
75 ::math::figurate::centeredCube n
76
77 ::math::figurate::decagonal n
78
79 ::math::figurate::heptagonal n
80
81 ::math::figurate::hexagonal n
82
83 ::math::figurate::octagonal n
84
85 ::math::figurate::octahedral n
86
87 ::math::figurate::pentagonal n
88
89 ::math::figurate::squarePyramidral n
90
91 ::math::figurate::tetrahedral n
92
93 ::math::figurate::pentatope n
94
95______________________________________________________________________________
96
98 Sums of numbers that follow a particular pattern are called figurate
99 numbers. A simple example is the sum of integers 1, 2, ... up to n.
100 You can arrange 1, 1+2=3, 1+2+3=6, ... objects in a triangle, hence the
101 name triangular numbers:
102
103
104 *
105 * *
106 * * *
107 * * * *
108 ...
109
110 The math::figurate package consists of a collection of procedures to
111 evaluate a wide variety of figurate numbers. While all formulae are
112 straightforward, the details are sometimes puzzling. Note: The proce‐
113 dures consider arguments lower than zero as to mean "no objects to be
114 counted" and therefore return 0.
115
117 The procedures can be arranged in a few categories: sums of integers
118 raised to a particular power, sums of odd integers and general figurate
119 numbers, for instance the pentagonal numbers.
120
121 ::math::figurate::sum_sequence n
122 Return the sum of integers 1, 2, ..., n.
123
124 int n Highest integer in the sum
125
126
127 ::math::figurate::sum_squares n
128 Return the sum of squares 1**2, 2**2, ..., n**2.
129
130 int n Highest base integer in the sum
131
132
133 ::math::figurate::sum_cubes n
134 Return the sum of cubes 1**3, 2**3, ..., n**3.
135
136 int n Highest base integer in the sum
137
138
139 ::math::figurate::sum_4th_power n
140 Return the sum of 4th powers 1**4, 2**4, ..., n**4.
141
142 int n Highest base integer in the sum
143
144
145 ::math::figurate::sum_5th_power n
146 Return the sum of 5th powers 1**5, 2**5, ..., n**5.
147
148 int n Highest base integer in the sum
149
150
151 ::math::figurate::sum_6th_power n
152 Return the sum of 6th powers 1**6, 2**6, ..., n**6.
153
154 int n Highest base integer in the sum
155
156
157 ::math::figurate::sum_7th_power n
158 Return the sum of 7th powers 1**7, 2**7, ..., n**7.
159
160 int n Highest base integer in the sum
161
162 ::math::figurate::sum_8th_power n
163 Return the sum of 8th powers 1**8, 2**8, ..., n**8.
164
165 int n Highest base integer in the sum
166
167
168 ::math::figurate::sum_9th_power n
169 Return the sum of 9th powers 1**9, 2**9, ..., n**9.
170
171 int n Highest base integer in the sum
172
173
174 ::math::figurate::sum_10th_power n
175 Return the sum of 10th powers 1**10, 2**10, ..., n**10.
176
177 int n Highest base integer in the sum
178
179
180 ::math::figurate::sum_sequence_odd n
181 Return the sum of odd integers 1, 3, ..., 2n-1
182
183 int n Highest integer in the sum
184
185
186 ::math::figurate::sum_squares_odd n
187 Return the sum of odd squares 1**2, 3**2, ..., (2n-1)**2.
188
189 int n Highest base integer in the sum
190
191
192 ::math::figurate::sum_cubes_odd n
193 Return the sum of odd cubes 1**3, 3**3, ..., (2n-1)**3.
194
195 int n Highest base integer in the sum
196
197
198 ::math::figurate::sum_4th_power_odd n
199 Return the sum of odd 4th powers 1**4, 2**4, ..., (2n-1)**4.
200
201 int n Highest base integer in the sum
202
203
204 ::math::figurate::sum_5th_power_odd n
205 Return the sum of odd 5th powers 1**5, 2**5, ..., (2n-1)**5.
206
207 int n Highest base integer in the sum
208
209
210 ::math::figurate::sum_6th_power_odd n
211 Return the sum of odd 6th powers 1**6, 2**6, ..., (2n-1)**6.
212
213 int n Highest base integer in the sum
214
215
216 ::math::figurate::sum_7th_power_odd n
217 Return the sum of odd 7th powers 1**7, 2**7, ..., (2n-1)**7.
218
219 int n Highest base integer in the sum
220
221 ::math::figurate::sum_8th_power_odd n
222 Return the sum of odd 8th powers 1**8, 2**8, ..., (2n-1)**8.
223
224 int n Highest base integer in the sum
225
226
227 ::math::figurate::sum_9th_power_odd n
228 Return the sum of odd 9th powers 1**9, 2**9, ..., (2n-1)**9.
229
230 int n Highest base integer in the sum
231
232
233 ::math::figurate::sum_10th_power_odd n
234 Return the sum of odd 10th powers 1**10, 2**10, ..., (2n-1)**10.
235
236 int n Highest base integer in the sum
237
238
239 ::math::figurate::oblong n
240 Return the nth oblong number (twice the nth triangular number)
241
242 int n Required index
243
244
245 ::math::figurate::pronic n
246 Return the nth pronic number (synonym for oblong)
247
248 int n Required index
249
250
251 ::math::figurate::triangular n
252 Return the nth triangular number
253
254 int n Required index
255
256
257 ::math::figurate::square n
258 Return the nth square number
259
260 int n Required index
261
262
263 ::math::figurate::cubic n
264 Return the nth cubic number
265
266 int n Required index
267
268
269 ::math::figurate::biquadratic n
270 Return the nth biquaratic number (i.e. n**4)
271
272 int n Required index
273
274
275 ::math::figurate::centeredTriangular n
276 Return the nth centered triangular number (items arranged in
277 concentric squares)
278
279 int n Required index
280
281
282 ::math::figurate::centeredSquare n
283 Return the nth centered square number (items arranged in concen‐
284 tric squares)
285
286 int n Required index
287
288
289 ::math::figurate::centeredPentagonal n
290 Return the nth centered pentagonal number (items arranged in
291 concentric pentagons)
292
293 int n Required index
294
295
296 ::math::figurate::centeredHexagonal n
297 Return the nth centered hexagonal number (items arranged in con‐
298 centric hexagons)
299
300 int n Required index
301
302
303 ::math::figurate::centeredCube n
304 Return the nth centered cube number (items arranged in concen‐
305 tric cubes)
306
307 int n Required index
308
309
310 ::math::figurate::decagonal n
311 Return the nth decagonal number (items arranged in decagons with
312 one common vertex)
313
314 int n Required index
315
316
317 ::math::figurate::heptagonal n
318 Return the nth heptagonal number (items arranged in heptagons
319 with one common vertex)
320
321 int n Required index
322
323
324 ::math::figurate::hexagonal n
325 Return the nth hexagonal number (items arranged in hexagons with
326 one common vertex)
327
328 int n Required index
329
330
331 ::math::figurate::octagonal n
332 Return the nth octagonal number (items arranged in octagons with
333 one common vertex)
334
335 int n Required index
336
337
338 ::math::figurate::octahedral n
339 Return the nth octahedral number (items arranged in octahedrons
340 with a common centre)
341
342 int n Required index
343
344
345 ::math::figurate::pentagonal n
346 Return the nth pentagonal number (items arranged in pentagons
347 with one common vertex)
348
349 int n Required index
350
351
352 ::math::figurate::squarePyramidral n
353 Return the nth square pyramidral number (items arranged in a
354 square pyramid)
355
356 int n Required index
357
358
359 ::math::figurate::tetrahedral n
360 Return the nth tetrahedral number (items arranged in a triangu‐
361 lar pyramid)
362
363 int n Required index
364
365
366 ::math::figurate::pentatope n
367 Return the nth pentatope number (items arranged in the four-di‐
368 mensional analogue of a triangular pyramid)
369
370 int n Required index
371
372
374 This document, and the package it describes, will undoubtedly contain
375 bugs and other problems. Please report such in the category math ::
376 figurate of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist].
377 Please also report any ideas for enhancements you may have for either
378 package and/or documentation.
379
380 When proposing code changes, please provide unified diffs, i.e the out‐
381 put of diff -u.
382
383 Note further that attachments are strongly preferred over inlined
384 patches. Attachments can be made by going to the Edit form of the
385 ticket immediately after its creation, and then using the left-most
386 button in the secondary navigation bar.
387
389 figurate numbers, mathematics
390
392 Mathematics
393
394
395
396tcllib 1.0 math::figurate(n)