Skip to content

Commit 47e82c7

Browse files
authored
Go over docs for gamma and no-meaning infix ops (#1394)
Go over docs for `Beta`, `Gamma`, `Product`, and infix operators with no meaning
1 parent 6edcf54 commit 47e82c7

File tree

4 files changed

+48
-44
lines changed

4 files changed

+48
-44
lines changed

mathics/builtin/arithmetic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,14 +713,14 @@ class Product(IterationFunction, SympyFunction):
713713
outermost-to-innermost order.
714714
</dl>
715715
716-
>> Product[k, {k, 1, 10}]
717-
= 3628800
718-
>> 10!
719-
= 3628800
720-
>> Product[x^k, {k, 2, 20, 2}]
721-
= x ^ 110
716+
The product of the first 10 integers is its factorial:
717+
>> Product[k, {k, 1, 10}] == 10!
718+
= True
719+
720+
'Product' can be used symbolically:
722721
>> Product[2 ^ i, {i, 1, n}]
723722
= 2 ^ (n / 2 + n ^ 2 / 2)
723+
724724
>> Product[f[i], {i, 1, 7}]
725725
= f[1] f[2] f[3] f[4] f[5] f[6] f[7]
726726

mathics/builtin/no_meaning/infix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create_class_function(
2929
operator_name=operator_name, operator_string=operator_string
3030
),
3131
"operator": operator_string,
32-
"summary_text": f"""{operator_name} postfix operator "{operator_string}" (no pre-set meaning attached)""",
32+
"summary_text": f"""{operator_name} infix operator "{operator_string}" (no pre-set meaning attached)""",
3333
"formats": {
3434
(
3535
("InputForm", "OutputForm", "StandardForm"),

mathics/builtin/specialfns/gamma.py

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,28 @@
4848

4949

5050
class Beta(MPMathMultiFunction):
51-
"""
52-
<url>
53-
:Euler beta function:
54-
https://en.wikipedia.org/wiki/Beta_function</url> (<url>:SymPy:
55-
https://docs.sympy.org/latest/modules/functions/
51+
r"""
52+
<url>
53+
:Euler beta function:
54+
https://en.wikipedia.org/wiki/Beta_function</url> (<url>:SymPy:
55+
https://docs.sympy.org/latest/modules/functions/
5656
special.html#sympy.functions.special.beta_functions.beta</url>, <url>
57-
:WMA:
58-
https://reference.wolfram.com/language/ref/Beta.html</url>)
59-
60-
<dl>
61-
<dt>'Beta'[$a$, $b$]
62-
<dd>is the Euler's Beta function.
63-
<dt>'Beta'[$z$, $a$, $b$]
64-
<dd>gives the incomplete Beta function.
65-
</dl>
66-
67-
The Beta function satisfies the property
68-
Beta[x, y] = Integrate[t^(x-1)(1-t)^(y-1),{t,0,1}] = Gamma[a] Gamma[b] / Gamma[a + b]
69-
>> Beta[2, 3]
70-
= 1 / 12
71-
>> 12* Beta[1., 2, 3]
72-
= 1.
57+
:WMA:
58+
https://reference.wolfram.com/language/ref/Beta.html</url>)
59+
60+
<dl>
61+
<dt>'Beta'[$a$, $b$]
62+
<dd>is the Euler's Beta function $\mathrm{B}(a, b)$.
63+
<dt>'Beta'[$z$, $a$, $b$]
64+
<dd>gives the incomplete Beta function $\mathrm{B}_z(a, b)$.
65+
</dl>
66+
67+
The Beta function satisfies the property:
68+
$\mathrm{B} = \int_0^t t^{(x-1)(1-t)^(y-1)} = \Gamma(a) \Gamma(b) / \Gamma(a + b)$
69+
>> Beta[2, 3]
70+
= 1 / 12
71+
>> 12* Beta[1., 2, 3]
72+
= 1.
7373
"""
7474

7575
attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED
@@ -272,7 +272,7 @@ def fact2_generic(x):
272272

273273

274274
class Gamma(MPMathMultiFunction):
275-
"""
275+
r"""
276276
<url>:Gamma function:
277277
https://en.wikipedia.org/wiki/Gamma_function</url> (<url>
278278
:SymPy:https://docs.sympy.org/latest/modules/functions
@@ -287,35 +287,39 @@ class Gamma(MPMathMultiFunction):
287287
288288
<dl>
289289
<dt>'Gamma'[$z$]
290-
<dd>is the gamma function on the complex number $z$.
290+
<dd>is the Euler gamma function, $\Gamma(z)$ on the complex number $z$.
291291
292-
<dt>'Gamma'[$z$, $x$]
293-
<dd>is the upper incomplete gamma function.
292+
<dt>'Gamma'[$a$, $z$]
293+
<dd>is the upper incomplete gamma function, $\Gamma(a, z)$.
294294
295-
<dt>'Gamma'[$z$, $x_0$, $x_1$]
296-
<dd>is equivalent to 'Gamma[$z$, $x_0$] - Gamma[$z$, $x_1$]'.
295+
<dt>'Gamma'[$a$, $z_0$, $z_1$]
296+
<dd>is the generalized incomplete gamma function $\Gamma[a, z_0] - \Gamma(a, z_1)$.
297297
</dl>
298298
299-
'Gamma[$z$]' is equivalent to '($z$ - 1)!':
299+
'Gamma[$z$]' is equivalent to $(z - 1)!$:
300300
>> Simplify[Gamma[z] - (z - 1)!]
301301
= 0
302302
303-
Exact arguments:
303+
Examples of using 'Gamma' with exact numeric arguments:
304304
>> Gamma[8]
305305
= 5040
306+
306307
>> Gamma[1/2]
307308
= Sqrt[Pi]
308-
>> Gamma[1, x]
309-
= E ^ (-x)
310-
>> Gamma[0, x]
311-
= ExpIntegralE[1, x]
312309
313-
Numeric arguments:
314310
>> Gamma[123.78]
315311
= 4.21078×10^204
312+
316313
>> Gamma[1. + I]
317314
= 0.498016 - 0.15495 I
318315
316+
Examples of 'Gamma' with symbolic arguments:
317+
318+
>> Gamma[1, x]
319+
= E ^ (-x)
320+
>> Gamma[0, x]
321+
= ExpIntegralE[1, x]
322+
319323
Both 'Gamma' and 'Factorial' functions are continuous:
320324
>> Plot[{Gamma[x], x!}, {x, 0, 4}]
321325
= -Graphics-

mathics/core/builtin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ class NoMeaningInfixOperator(InfixOperator):
12791279
https://reference.wolfram.com/language/ref/{operator_name}.html</url>
12801280
12811281
<dl>
1282-
<dt>'{operator_name}[$x$, $y$, ...]'
1282+
<dt>'{operator_name}['$x$, $y$, ...']'
12831283
<dd>displays $x$ {operator_string} $y$ {operator_string} ...
12841284
</dl>
12851285
@@ -1379,7 +1379,7 @@ class NoMeaningPostfixOperator(PostfixOperator):
13791379
https://reference.wolfram.com/language/ref/{operator_name}.html</url>
13801380
13811381
<dl>
1382-
<dt>'{operator_name}[$x$]'
1382+
<dt>'{operator_name}['$x$']'
13831383
<dd>displays $x$ {operator_string}
13841384
</dl>
13851385
@@ -1421,7 +1421,7 @@ class NoMeaningPrefixOperator(PrefixOperator):
14211421
https://reference.wolfram.com/language/ref/{operator_name}.html</url>
14221422
14231423
<dl>
1424-
<dt>'{operator_name}[$x$]'
1424+
<dt>'{operator_name}['$x$']'
14251425
<dd>displays {operator_string} $x$
14261426
</dl>
14271427

0 commit comments

Comments
 (0)