Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mathics/builtin/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,14 +713,14 @@ class Product(IterationFunction, SympyFunction):
outermost-to-innermost order.
</dl>

>> Product[k, {k, 1, 10}]
= 3628800
>> 10!
= 3628800
>> Product[x^k, {k, 2, 20, 2}]
= x ^ 110
The product of the first 10 integers is its factorial:
>> Product[k, {k, 1, 10}] == 10!
= True

'Product' can be used symbolically:
>> Product[2 ^ i, {i, 1, n}]
= 2 ^ (n / 2 + n ^ 2 / 2)

>> Product[f[i], {i, 1, 7}]
= f[1] f[2] f[3] f[4] f[5] f[6] f[7]

Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/no_meaning/infix.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create_class_function(
operator_name=operator_name, operator_string=operator_string
),
"operator": operator_string,
"summary_text": f"""{operator_name} postfix operator "{operator_string}" (no pre-set meaning attached)""",
"summary_text": f"""{operator_name} infix operator "{operator_string}" (no pre-set meaning attached)""",
"formats": {
(
("InputForm", "OutputForm", "StandardForm"),
Expand Down
72 changes: 38 additions & 34 deletions mathics/builtin/specialfns/gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,28 @@


class Beta(MPMathMultiFunction):
"""
<url>
:Euler beta function:
https://en.wikipedia.org/wiki/Beta_function</url> (<url>:SymPy:
https://docs.sympy.org/latest/modules/functions/
r"""
<url>
:Euler beta function:
https://en.wikipedia.org/wiki/Beta_function</url> (<url>:SymPy:
https://docs.sympy.org/latest/modules/functions/
special.html#sympy.functions.special.beta_functions.beta</url>, <url>
:WMA:
https://reference.wolfram.com/language/ref/Beta.html</url>)

<dl>
<dt>'Beta'[$a$, $b$]
<dd>is the Euler's Beta function.
<dt>'Beta'[$z$, $a$, $b$]
<dd>gives the incomplete Beta function.
</dl>

The Beta function satisfies the property
Beta[x, y] = Integrate[t^(x-1)(1-t)^(y-1),{t,0,1}] = Gamma[a] Gamma[b] / Gamma[a + b]
>> Beta[2, 3]
= 1 / 12
>> 12* Beta[1., 2, 3]
= 1.
:WMA:
https://reference.wolfram.com/language/ref/Beta.html</url>)

<dl>
<dt>'Beta'[$a$, $b$]
<dd>is the Euler's Beta function $\mathrm{B}(a, b)$.
<dt>'Beta'[$z$, $a$, $b$]
<dd>gives the incomplete Beta function $\mathrm{B}_z(a, b)$.
</dl>

The Beta function satisfies the property:
$\mathrm{B} = \int_0^t t^{(x-1)(1-t)^(y-1)} = \Gamma(a) \Gamma(b) / \Gamma(a + b)$
>> Beta[2, 3]
= 1 / 12
>> 12* Beta[1., 2, 3]
= 1.
"""

attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED
Expand Down Expand Up @@ -272,7 +272,7 @@ def fact2_generic(x):


class Gamma(MPMathMultiFunction):
"""
r"""
<url>:Gamma function:
https://en.wikipedia.org/wiki/Gamma_function</url> (<url>
:SymPy:https://docs.sympy.org/latest/modules/functions
Expand All @@ -287,35 +287,39 @@ class Gamma(MPMathMultiFunction):

<dl>
<dt>'Gamma'[$z$]
<dd>is the gamma function on the complex number $z$.
<dd>is the Euler gamma function, $\Gamma(z)$ on the complex number $z$.

<dt>'Gamma'[$z$, $x$]
<dd>is the upper incomplete gamma function.
<dt>'Gamma'[$a$, $z$]
<dd>is the upper incomplete gamma function, $\Gamma(a, z)$.

<dt>'Gamma'[$z$, $x_0$, $x_1$]
<dd>is equivalent to 'Gamma[$z$, $x_0$] - Gamma[$z$, $x_1$]'.
<dt>'Gamma'[$a$, $z_0$, $z_1$]
<dd>is the generalized incomplete gamma function $\Gamma[a, z_0] - \Gamma(a, z_1)$.
</dl>

'Gamma[$z$]' is equivalent to '($z$ - 1)!':
'Gamma[$z$]' is equivalent to $(z - 1)!$:
>> Simplify[Gamma[z] - (z - 1)!]
= 0

Exact arguments:
Examples of using 'Gamma' with exact numeric arguments:
>> Gamma[8]
= 5040

>> Gamma[1/2]
= Sqrt[Pi]
>> Gamma[1, x]
= E ^ (-x)
>> Gamma[0, x]
= ExpIntegralE[1, x]

Numeric arguments:
>> Gamma[123.78]
= 4.21078×10^204

>> Gamma[1. + I]
= 0.498016 - 0.15495 I

Examples of 'Gamma' with symbolic arguments:

>> Gamma[1, x]
= E ^ (-x)
>> Gamma[0, x]
= ExpIntegralE[1, x]

Both 'Gamma' and 'Factorial' functions are continuous:
>> Plot[{Gamma[x], x!}, {x, 0, 4}]
= -Graphics-
Expand Down
6 changes: 3 additions & 3 deletions mathics/core/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ class NoMeaningInfixOperator(InfixOperator):
https://reference.wolfram.com/language/ref/{operator_name}.html</url>

<dl>
<dt>'{operator_name}[$x$, $y$, ...]'
<dt>'{operator_name}['$x$, $y$, ...']'
<dd>displays $x$ {operator_string} $y$ {operator_string} ...
</dl>

Expand Down Expand Up @@ -1379,7 +1379,7 @@ class NoMeaningPostfixOperator(PostfixOperator):
https://reference.wolfram.com/language/ref/{operator_name}.html</url>

<dl>
<dt>'{operator_name}[$x$]'
<dt>'{operator_name}['$x$']'
<dd>displays $x$ {operator_string}
</dl>

Expand Down Expand Up @@ -1421,7 +1421,7 @@ class NoMeaningPrefixOperator(PrefixOperator):
https://reference.wolfram.com/language/ref/{operator_name}.html</url>

<dl>
<dt>'{operator_name}[$x$]'
<dt>'{operator_name}['$x$']'
<dd>displays {operator_string} $x$
</dl>

Expand Down