Skip to content

Commit 9048440

Browse files
authored
Doc updates part7 (#1314)
Subfactorial is not a mpmath function, SymPy only. SymPy can't handle machine reals that are not integers. Add rule to handle lists. Various summaries have been gone over to have them start with an active verb when possible.
1 parent e9a46fe commit 9048440

File tree

10 files changed

+143
-61
lines changed

10 files changed

+143
-61
lines changed

mathics/builtin/colors/named_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, *args, **kwargs):
3333
"name": strip_context(self.get_name()),
3434
"text_name": text_name,
3535
}
36-
self.summary_text = f"{text_name} color"
36+
self.summary_text = f"specify {text_name} color"
3737
if self.__doc__ is None:
3838
self.__doc__ = doc
3939
else:

mathics/builtin/directories/user_directories.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class UserBaseDirectory(Predefined):
6969
"""
7070

7171
name = "$UserBaseDirectory"
72-
summary_text = "directory where user configurations are stored"
72+
summary_text = "get directory where user configurations are stored"
7373

7474
def evaluate(self, evaluation: Evaluation):
7575
return String(HOME_DIR + os.sep + ".mathics")

mathics/builtin/distance/numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class SquaredEuclideanDistance(Builtin):
300300
= 8
301301
"""
302302

303-
summary_text = "square of the euclidean distance"
303+
summary_text = "compute square of the Euclidean distance"
304304

305305
def eval(self, u, v, evaluation: Evaluation):
306306
"SquaredEuclideanDistance[u_, v_]"

mathics/builtin/graphics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ class Large(Builtin):
14131413
</dl>
14141414
"""
14151415

1416-
summary_text = "large size style or option setting"
1416+
summary_text = "large size symbol for style or option setting"
14171417

14181418

14191419
class Medium(Builtin):
@@ -1426,7 +1426,7 @@ class Medium(Builtin):
14261426
</dl>
14271427
"""
14281428

1429-
summary_text = "medium size style or option setting"
1429+
summary_text = "medium size symbol for style or option setting"
14301430

14311431

14321432
class Offset(Builtin):

mathics/builtin/intfns/combinatorial.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,26 @@ class LucasL(SympyFunction):
295295
<dl>
296296
<dt>'LucasL[$n$]'
297297
<dd>gives the $n$th Lucas number.
298+
299+
<dt>'LucasL[$n$, $x$]'
300+
<dd>gives the $n$th Lucas polynomical $L$_($x$).
298301
</dl>
299302
300303
A list of the first five Lucas numbers:
301304
>> Table[LucasL[n], {n, 1, 5}]
302305
= {1, 3, 4, 7, 11}
306+
303307
>> Series[LucasL[1/2, x], {x, 0, 5}]
304308
= 1 + 1 / 4 x + 1 / 32 x ^ 2 + (-1 / 128) x ^ 3 + (-5 / 2048) x ^ 4 + 7 / 8192 x ^ 5 + O[x] ^ 6
309+
310+
>> Plot[LucasL[1/2, x], {x, -5, 5}]
311+
= -Graphics-
305312
"""
306313

307314
attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED | A_READ_PROTECTED
308315

309-
summary_text = "lucas number"
310316
sympy_name = "lucas"
317+
summary_text = "get a Lucas number or polynomial"
311318

312319
rules = {
313320
"LucasL[n_, 1]": "LucasL[n]",

mathics/builtin/numbers/calculus.py

Lines changed: 86 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,34 +1745,41 @@ def to_sympy(self, expr: Expression, **kwargs):
17451745

17461746
class Series(Builtin):
17471747
"""
1748-
<url>:WMA link:https://reference.wolfram.com/language/ref/Series.html</url>
1748+
<url>:WMA link:https://reference.wolfram.com/language/ref/Series.html</url>
17491749
1750-
<dl>
1751-
<dt>'Series[$f$, {$x$, $x0$, $n$}]'
1752-
<dd>Represents the series expansion around '$x$=$x0$' up to order $n$.
1753-
</dl>
1750+
<dl>
1751+
<dt>'Series[$f$, {$x$, $x0$, $n$}]'
1752+
<dd>Represents the series expansion around '$x$=$x0$' up to order $n$.
1753+
</dl>
17541754
1755-
For elementary expressions, 'Series' returns the explicit power series as a 'SeriesData' expression:
1756-
>> Series[Exp[x], {x,0,2}]
1757-
= 1 + x + 1 / 2 x ^ 2 + O[x] ^ 3
1758-
>> % // FullForm
1759-
= SeriesData[x, 0, {1,1,Rational[1, 2]}, 0, 3, 1]
1760-
Replacing the variable by a value, the series will not be evaluated as
1761-
an expression, but as a 'SeriesData' object:
1762-
>> s = Series[Exp[x^2],{x,0,2}]
1763-
= 1 + x ^ 2 + O[x] ^ 3
1764-
>> s /. x->4
1765-
= 1 + 4 ^ 2 + O[4] ^ 3
1766-
1767-
'Normal' transforms a 'SeriesData' expression into a polynomial:
1768-
>> s // Normal
1769-
= 1 + x ^ 2
1770-
>> (s // Normal) /. x-> 4
1771-
= 17
1772-
>> Clear[s];
1773-
We can also expand over multiple variables
1774-
>> Series[Exp[x-y], {x, 0, 2}, {y, 0, 2}]
1775-
= (1 - y + 1 / 2 y ^ 2 + O[y] ^ 3) + (1 - y + 1 / 2 y ^ 2 + O[y] ^ 3) x + (1 / 2 + (-1 / 2) y + 1 / 4 y ^ 2 + O[y] ^ 3) x ^ 2 + O[x] ^ 3
1755+
For elementary expressions, 'Series' returns the explicit power series as a 'SeriesData' expression:
1756+
>> series = Series[Exp[x^2], {x,0,2}]
1757+
= 1 + x ^ 2 + O[x] ^ 3
1758+
1759+
The expression created is a 'SeriesData' object:
1760+
>> series // FullForm
1761+
= SeriesData[x, 0, {1,0,1}, 0, 3, 1]
1762+
1763+
Replacing $x$ with does a value produces another 'SeriesData' object:
1764+
>> series /. x->4
1765+
= 1 + 4 ^ 2 + O[4] ^ 3
1766+
1767+
'Normal' transforms a 'SeriesData' expression into a polynomial:
1768+
>> series // Normal
1769+
= 1 + x ^ 2
1770+
>> (series // Normal) /. x-> 4
1771+
= 17
1772+
>> Clear[series];
1773+
1774+
We can also expand over multiple variables:
1775+
>> Series[Exp[x-y], {x, 0, 2}, {y, 0, 2}]
1776+
= (1 - y + 1 / 2 y ^ 2 + O[y] ^ 3) + (1 - y + 1 / 2 y ^ 2 + O[y] ^ 3) x + (1 / 2 + (-1 / 2) y + 1 / 4 y ^ 2 + O[y] ^ 3) x ^ 2 + O[x] ^ 3
1777+
1778+
See also <url>
1779+
:'SeriesCoefficient':
1780+
/doc/reference-of-built-in-symbols/integer-and-number-theoretical-functions/calculus/seriescoefficient/</url> and <url>
1781+
:'SeriesData':
1782+
/doc/reference-of-built-in-symbols/integer-and-number-theoretical-functions/calculus/seriesdata/</url>.
17761783
17771784
"""
17781785

@@ -1782,7 +1789,7 @@ class Series(Builtin):
17821789
"sspec": "Series specification `1` is not a list with three elements.",
17831790
}
17841791

1785-
summary_text = "power series and asymptotic expansions"
1792+
summary_text = "compute power series and asymptotic expansions"
17861793

17871794
def eval_series(self, f, x, x0, n, evaluation: Evaluation):
17881795
"""Series[f_, {x_Symbol, x0_, n_Integer}]"""
@@ -1810,13 +1817,24 @@ class SeriesCoefficient(Builtin):
18101817
18111818
<dl>
18121819
<dt>'SeriesCoefficient[$series$, $n$]'
1813-
<dd>Find the $n$th coefficient in the given $series$
1820+
<dd>Find the $n$th coefficient in the given $series$.
1821+
1822+
<dt>'SeriesCoefficient[$f$, {$x$, $x0$, $n$}]'
1823+
<dd>Find the ($x$-$x0$)^n in the expansion of $f$ about the point $x$=$x0$.
18141824
</dl>
18151825
1816-
>> SeriesCoefficient[Series[Exp[Sin[x]], {x, 0, 10}], 8]
1817-
= 31 / 5760
1818-
>> SeriesCoefficient[Exp[-x], {x, 0, 5}]
1819-
= -1 / 120
1826+
First we list 5 terms of a series:
1827+
>> Series[Exp[Sin[x]], {x, 0, 5}]
1828+
= 1 + x + 1 / 2 x ^ 2 + (-1 / 8) x ^ 4 + (-1 / 15) x ^ 5 + O[x] ^ 6
1829+
1830+
Now get the $x$^4 coefficient:
1831+
>> SeriesCoefficient[%, 4]
1832+
= -1 / 8
1833+
1834+
Do the same thing, but without calling 'Series' first:
1835+
>> SeriesCoefficient[Exp[Sin[x]], {x, 0, 4}]
1836+
= -1 / 8
1837+
18201838
>> SeriesCoefficient[2x, {x, 0, 2}]
18211839
= 0
18221840
@@ -1826,14 +1844,19 @@ class SeriesCoefficient(Builtin):
18261844
= 0
18271845
>> SeriesCoefficient[SeriesData[x, c, Table[i^2, {i, 10}], 7, 17, 3], 17/3]
18281846
= Indeterminate
1847+
1848+
See also <url>
1849+
:'Series':
1850+
/doc/reference-of-built-in-symbols/integer-and-number-theoretical-functions/calculus/series/</url> and <url>
1851+
:'SeriesData':
1852+
/doc/reference-of-built-in-symbols/integer-and-number-theoretical-functions/calculus/seriesdata/</url>.
18291853
"""
18301854

18311855
attributes = A_PROTECTED
1832-
summary_text = "power series coefficient"
1833-
18341856
rules = {
18351857
"SeriesCoefficient[f_, {x_Symbol, x0_, n_Integer}]": "SeriesCoefficient[Series[f, {x, x0, n}], n]"
18361858
}
1859+
summary_text = "compute power series coefficient"
18371860

18381861
def eval(self, series: Expression, n: Rational, evaluation: Evaluation):
18391862
"""SeriesCoefficient[series_SeriesData, n_]"""
@@ -1856,25 +1879,48 @@ class SeriesData(Builtin):
18561879
<url>:WMA link:https://reference.wolfram.com/language/ref/SeriesData.html</url>
18571880
18581881
<dl>
1859-
<dt>'SeriesData[...]'
1860-
<dd>Represents a series expansion.
1882+
<dt>'SeriesData[$x$, $x0$, {$a0$, $a1$, ...}, $nmin$, $nmax$, $den$]'
1883+
<dd>produces a power series in the variable $x$ about point $x0$. The \
1884+
$ai$ are the coefficients of the power series. The powers of ($x$-$x0$) that appear \
1885+
are $nmin$/$den$, ($nmin$+1)/$den$, ..., $nmax$/$den$.
18611886
</dl>
18621887
1863-
Sum of two series:
1864-
>> Series[Cosh[x],{x,0,2}] + Series[Sinh[x],{x,0,3}]
1888+
'SeriesData' is the 'Head' of expressions generated by 'Series':
1889+
1890+
>> series = Series[Cosh[x],{x,0,2}]
1891+
= 1 + 1 / 2 x ^ 2 + O[x] ^ 3
1892+
1893+
>> Head[series]
1894+
= SeriesData
1895+
1896+
>> series // FullForm
1897+
= SeriesData[x, 0, {1,0,Rational[1, 2]}, 0, 3, 1]
1898+
1899+
You can apply certain mathematical operations to 'SeriesData' objects to get \
1900+
new 'SeriesData' objects truncated to the appropriate order.
1901+
1902+
>> series + Series[Sinh[x],{x,0,3}]
18651903
= 1 + x + 1 / 2 x ^ 2 + O[x] ^ 3
1904+
18661905
>> Series[f[x],{x,0,2}] * g[w]
18671906
= f[0] g[w] + g[w] f'[0] x + g[w] f''[0] / 2 x ^ 2 + O[x] ^ 3
1868-
The product of two series on the same neighbourhood of the same variable are multiplied
1907+
1908+
The product of two series on the same neighborhood of the same variable are multiplied:
18691909
>> Series[Exp[-a x],{x,0,2}] * Series[Exp[-b x],{x,0,2}]
18701910
= 1 + (-a - b) x + (a ^ 2 / 2 + a b + b ^ 2 / 2) x ^ 2 + O[x] ^ 3
18711911
>> D[Series[Exp[-a x],{x,0,2}],a]
18721912
= -x + a x ^ 2 + O[x] ^ 3
1913+
1914+
See also <url>
1915+
:'Series':
1916+
/doc/reference-of-built-in-symbols/integer-and-number-theoretical-functions/calculus/series/</url> and <url>
1917+
:'SeriesCoefficient':
1918+
/doc/reference-of-built-in-symbols/integer-and-number-theoretical-functions/calculus/seriescoefficient/</url>.
18731919
"""
18741920

18751921
# TODO: Implement sum, product and composition of series
18761922

1877-
summary_text = "power series of a variable about a point"
1923+
summary_text = "compute power series of a variable about a point"
18781924

18791925
def eval_reduce(
18801926
self, x, x0, data, nummin: Integer, nummax: Integer, den, evaluation: Evaluation

mathics/builtin/numbers/linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class LeastSquares(Builtin):
366366
"underdetermined": "Solving for underdetermined system not implemented.",
367367
"matrix": "Argument `1` at position `2` is not a non-empty rectangular matrix.",
368368
}
369-
summary_text = "least square solver for linear problems"
369+
summary_text = "compute least squares of linear problems"
370370

371371
def eval(self, m, b, evaluation: Evaluation):
372372
"LeastSquares[m_, b_]"

mathics/builtin/numbers/numbertheory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,6 @@ class SquaresR(Builtin):
11091109
"""
11101110

11111111
attributes = A_LISTABLE | A_PROTECTED | A_READ_PROTECTED
1112-
summary_text = "function to compute the sum of squares"
11131112

11141113
rules = {
11151114
"SquaresR[d_Integer, 0]": "1",
@@ -1118,3 +1117,4 @@ class SquaresR(Builtin):
11181117
"SquaresR[6, n_Integer?Positive]": "4 Total[#^2 * (4 * KroneckerSymbol[-4, n/#] - KroneckerSymbol[-4, #]) & /@ Divisors[n]]",
11191118
"SquaresR[8, n_Integer?Positive]": "16 Total[(-1)^(n + #) #^3 & /@ Divisors[n]]",
11201119
}
1120+
summary_text = "compute the sum of squares"

0 commit comments

Comments
 (0)