All published worksheets from http://sagenb.org
Image: ubuntu2004
File: /sagenb/sage_install/sage-4.8-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/rings/arith.py
Type: <type ‘function’>
Definition: multinomial(*ks)
Docstring:
Return the multinomial coefficient
INPUT:
- An arbitrary number of integer arguments k_1,\dots,k_n
- A list of integers [k_1,\dots,k_n]
OUTPUT:
Returns the integer:
\binom{k_1 + \cdots + k_n}{k_1, \cdots, k_n} =\frac{\left(\sum_{i=1}^n k_i\right)!}{\prod_{i=1}^n k_i!} = \prod_{i=1}^n \binom{\sum_{j=1}^i k_j}{k_i}EXAMPLES:
sage: multinomial(0, 0, 2, 1, 0, 0) 3 sage: multinomial([0, 0, 2, 1, 0, 0]) 3 sage: multinomial(3, 2) 10 sage: multinomial(2^30, 2, 1) 618970023101454657175683075 sage: multinomial([2^30, 2, 1]) 618970023101454657175683075AUTHORS:
- Gabriel Ebner
File: /sagenb/sage_install/sage-4.8-sage.math.washington.edu-x86_64-Linux/devel/sage/sage/calculus/var.pyx
Type: <type ‘builtin_function_or_method’>
Definition: function(s, *args, **kwds)
Docstring:
Create a formal symbolic function with the name s.
INPUT:
s - a string, either a single variable name, or a space or comma separated list of variable names.
- **kwds - keyword arguments. Either one of the following two
keywords can be used to customize latex representation of symbolic functions:
- latex_name=LaTeX where LaTeX is any valid latex expression. Ex: f = function(‘f’, x, latex_name=”mathcal{F}”) See EXAMPLES for more.
- print_latex_func=my_latex_print where my_latex_print is any callable function that returns a valid latex expression. Ex: f = function(‘f’, x, print_latex_func=my_latex_print) See EXAMPLES for an explicit usage.
Note
The new function is both returned and automatically injected into the global namespace. If you use this function in library code, it is better to use sage.symbolic.function_factory.function, since it won’t touch the global namespace.
EXAMPLES:
We create a formal function called supersin:
sage: f = function('supersin', x) sage: f supersin(x)We can immediately use supersin in symbolic expressions:
sage: y, z, A = var('y z A') sage: supersin(y+z) + A^3 A^3 + supersin(y + z)We can define other functions in terms of supersin:
sage: g(x,y) = supersin(x)^2 + sin(y/2) sage: g (x, y) |--> supersin(x)^2 + sin(1/2*y) sage: g.diff(y) (x, y) |--> 1/2*cos(1/2*y) sage: k = g.diff(x); k (x, y) |--> 2*supersin(x)*D[0](supersin)(x)Custom typesetting of symbolic functions in LaTeX:
(1) Either using latex_name keyword::sage: riemann(x) = function(‘riemann’, x, latex_name=”mathcal{R}”) sage: latex(riemann(x)) mathcal{R}left(xright)
Or passing a custom callable function that returns a latex expression:
sage: mu,nu = var(‘mu,nu’) sage: def my_latex_print(self, *args): return “psi_{%s}”%(‘, ‘.join(map(latex, args))) sage: psi(mu,nu) = function(‘psi’, mu, nu, print_latex_func=my_latex_print) sage: latex(psi(mu,nu)) psi_{mu, nu}
In Sage 4.0, you must now use the substitute_function() method to replace functions:
sage: k.substitute_function(supersin, sin) 2*sin(x)*cos(x)