diff --git a/mathics/builtin/atomic/numbers.py b/mathics/builtin/atomic/numbers.py
index 6b30bf924..4459ce3ad 100644
--- a/mathics/builtin/atomic/numbers.py
+++ b/mathics/builtin/atomic/numbers.py
@@ -301,26 +301,37 @@ class NumberDigit(Builtin):
https://reference.wolfram.com/language/ref/NumberDigit.html
+ - 'NumberDigit[$x$, $n$]'
+
- returns the digit coefficient of 10^$n$ for the real-valued number $x$.
+
- 'NumberDigit[$x$, $n$, $b$]'
-
- returns the coefficient of $b^n$ in the base-$b$ representation of $x$.
+
- returns the coefficient of $b$^$n$ in the base-$b$ representation of $x$.
- >> NumberDigit[123456, 2]
- = 4
- >> NumberDigit[12.3456, -1]
+ Get the 10^2 digit of a 210.345:
+ >> NumberDigit[210.345, 2]
+ = 2
+
+ Get the 10^-1 digit of a 210.345:
+ >> NumberDigit[210.345, -1]
= 3
+ >> BaseForm[N[Pi], 2]
+ = 11.00100100001111110_2
+
+ Get the 2^0 bit of the Pi:
+ = 1
"""
attributes = A_PROTECTED | A_READ_PROTECTED
- summary_text = "digits of a real number"
-
rules = {
"NumberDigit[x_, n_Integer]": "NumberDigit[x, n, 10]",
"NumberDigit[x_, n_Integer, b_Integer]": "RealDigits[x, b, 1, n][[1]][[1]]",
}
+ summary_text = "get digits of a real number"
+
class RealDigits(Builtin):
"""
@@ -776,7 +787,7 @@ class Precision(Builtin):
summary_text = "find the precision of a number"
- def eval(self, z, evaluation):
+ def eval(self, z, evaluation: Evaluation):
"""Precision[z_]"""
if isinstance(z, MachineReal):
return SymbolMachinePrecision
diff --git a/mathics/builtin/intfns/combinatorial.py b/mathics/builtin/intfns/combinatorial.py
index bd145321b..3ecb4a575 100644
--- a/mathics/builtin/intfns/combinatorial.py
+++ b/mathics/builtin/intfns/combinatorial.py
@@ -387,23 +387,39 @@ class PolygonalNumber(Builtin):
:Polygonal number: https://en.wikipedia.org/wiki/Polygonal_number (
:WMA: https://reference.wolfram.com/language/ref/PolygonalNumber.html)
+ - 'PolygonalNumber[$n$]'
+
- gives the $n$th triangular number.
+
- 'PolygonalNumber[$r$, $n$]'
- gives the $n$th $r$-gonal number.
>> Table[PolygonalNumber[n], {n, 10}]
= {1, 3, 6, 10, 15, 21, 28, 36, 45, 55}
- >> Table[PolygonalNumber[r, 10], {r, 3, 10}]
- = {55, 100, 145, 190, 235, 280, 325, 370}
+
+ The sum of two consecutive Polygonal numbers is the square of the larger number:
+ >> Table[PolygonalNumber[n-1] + PolygonalNumber[n], {n, 10}]
+ = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}
+
+ 'PolygonalNumber'[$r$, $n$] can be interpreted as the number of points arranged in the form of $n$-1 polygons of $r$ sides.
+
+ List the tenth $r-gonal number of regular polygons from 3 to 8:
+ >> Table[PolygonalNumber[r, 10], {r, 3, 8}]
+ = {55, 100, 145, 190, 235, 280}
+
+ See also
+ :Binomial:
+ doc/reference-of-built-in-symbols/integer-functions/combinatorial-functions/binomial/, and
+ :RegularPolygon:
+ doc/reference-of-built-in-symbols/drawing-graphics/regularpolygon/.
"""
attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED | A_READ_PROTECTED
- summary_text = "polygonal number"
-
rules = {
"PolygonalNumber[n_Integer]": "PolygonalNumber[3, n]",
"PolygonalNumber[r_Integer, n_Integer]": "(1/2) n (n (r - 2) - r + 4)",
}
+ summary_text = "get polygonal number"
class RogersTanimotoDissimilarity(_BooleanDissimilarity):