# Functions Module¶

## Elementary¶

This module implements elementary functions (abs, max, etc.)

### abs¶

Returns the absolute value of the argument.

Examples::
```>>> from sympy.functions import abs
>>> abs(-1)
1
```

### arg¶

Returns the argument (in radians) of a complex number. For a real number, the argument is always 0.

Examples::
```>>> from sympy.functions import arg
>>> from sympy import I, sqrt
>>> arg(2.0)
0
>>> arg(I)
pi/2
>>> arg(sqrt(2) + I*sqrt(2))
pi/4
```

### conjugate¶

Returns the ‘complex conjugate <http://en.wikipedia.org/wiki/Complex_conjugation>’_ of an argument. In mathematics, the complex conjugate of a complex number is given by changing the sign of the imaginary part. Thus, the conjugate of the complex number

a + ib

(where a and b are real numbers) is

a - ib
Examples::
```>>> from sympy.functions import conjugate
>>> from sympy import I
>>> conjugate(2)
2
>>> conjugate(I)
-I
```

### min¶

Returns the minimum of two (comparable) expressions.

Examples::
```>>> from sympy.functions import min_
>>> min_(1,2)
1
>>> from sympy import Symbol
>>> x = Symbol('x')
>>> min_(1,x)
min_(1, x)
```

It is named min and not min to avoid conflicts with built-in function min.

### max¶

Returns the maximum of two (comparable) expressions

It is named max and not max to avoid conflicts with built-in function min.

### re¶

Return the real part of an expression

Examples::
```>>> from sympy.functions import re
>>> from sympy import I
>>> re(2+3*I)
2
```

### sqrt¶

Returns the square root of an expression. It is equivalent to raise to Rational(1,2)

```>>> from sympy.functions import sqrt
>>> from sympy import Rational
>>> sqrt(2) == 2**Rational(1,2)
True
```

### sign¶

Returns the sign of an expression, that is:
-1 if expr is negative

0 if expr is zero 1 if expr is positive

```>>> from sympy.functions import sign
>>> sign(-1)
-1
>>> sign(0)
0
```

## Combinatorial¶

This module implements various combinatorial functions.

### Binomial¶

class sympy.functions.combinatorial.factorials.Binomial

Implementation of the binomial coefficient. It can be defined in two ways depending on its desired interpretation:

C(n,k) = n!/(k!(n-k)!) or C(n, k) = ff(n, k)/k!

First, in a strict combinatorial sense it defines the number of ways we can choose ‘k’ elements from a set of ‘n’ elements. In this case both arguments are nonnegative integers and binomial is computed using an efficient algorithm based on prime factorization.

The other definition is generalization for arbitrary ‘n’, however ‘k’ must also be nonnegative. This case is very useful when evaluating summations.

For the sake of convenience for negative ‘k’ this function will return zero no matter what valued is the other argument.

```>>> from sympy import Symbol, Rational, binomial
>>> n = Symbol('n', integer=True)
```
```>>> binomial(15, 8)
6435
```
```>>> binomial(n, -1)
0
```
```>>> [ binomial(0, i) for i in range(1)]
[1]
>>> [ binomial(1, i) for i in range(2)]
[1, 1]
>>> [ binomial(2, i) for i in range(3)]
[1, 2, 1]
>>> [ binomial(3, i) for i in range(4)]
[1, 3, 3, 1]
>>> [ binomial(4, i) for i in range(5)]
[1, 4, 6, 4, 1]
```
```>>> binomial(Rational(5,4), 3)
-5/128
```
```>>> binomial(n, 3)
n*(1 - n)*(2 - n)/6
```

### Factorial¶

class sympy.functions.combinatorial.factorials.Factorial

Implementation of factorial function over nonnegative integers. For the sake of convenience and simplicity of procedures using this function it is defined for negative integers and returns zero in this case.

The factorial is very important in combinatorics where it gives the number of ways in which ‘n’ objects can be permuted. It also arises in calculus, probability, number theory etc.

There is strict relation of factorial with gamma function. In fact n! = gamma(n+1) for nonnegative integers. Rewrite of this kind is very useful in case of combinatorial simplification.

Computation of the factorial is done using two algorithms. For small arguments naive product is evaluated. However for bigger input algorithm Prime-Swing is used. It is the fastest algorithm known and computes n! via prime factorization of special class of numbers, called here the ‘Swing Numbers’.

```>>> from sympy import Symbol, factorial
>>> n = Symbol('n', integer=True)
```
```>>> factorial(-2)
0
```
```>>> factorial(0)
1
```
```>>> factorial(7)
5040
```
```>>> factorial(n)
n!
```
```>>> factorial(2*n)
(2*n)!
```

### FallingFactorial¶

class sympy.functions.combinatorial.factorials.FallingFactorial

Falling factorial (related to rising factorial) is a double valued function arising in concrete mathematics, hypergeometric functions and series expansions. It is defined by

ff(x, k) = x * (x-1) * ... * (x - k+1)

where ‘x’ can be arbitrary expression and ‘k’ is an integer. For more information check “Concrete mathematics” by Graham, pp. 66 or visit http://mathworld.wolfram.com/FallingFactorial.html page.

```>>> from sympy import ff
>>> from sympy.abc import x
```
```>>> ff(x, 0)
1
```
```>>> ff(5, 5)
120
```
```>>> ff(x, 5) == x*(x-1)*(x-2)*(x-3)*(x-4)
True
```

### MultiFactorial¶

class sympy.functions.combinatorial.factorials.MultiFactorial

### RisingFactorial¶

class sympy.functions.combinatorial.factorials.RisingFactorial

Rising factorial (also called Pochhammer symbol) is a double valued function arising in concrete mathematics, hypergeometric functions and series expansions. It is defined by

rf(x, k) = x * (x+1) * ... * (x + k-1)

where ‘x’ can be arbitrary expression and ‘k’ is an integer. For more information check “Concrete mathematics” by Graham, pp. 66 or visit http://mathworld.wolfram.com/RisingFactorial.html page.

```>>> from sympy import rf
>>> from sympy.abc import x
```
```>>> rf(x, 0)
1
```
```>>> rf(1, 5)
120
```
```>>> rf(x, 5) == x*(1 + x)*(2 + x)*(3 + x)*(4 + x)
True
```

## Special¶

### DiracDelta¶

class sympy.functions.special.delta_functions.DiracDelta

DiracDelta function, and the derivatives. DiracDelta function has the following properties: 1) diff(Heaviside(x),x) = DiracDelta(x) 2) integrate(DiracDelta(x-a)*f(x),(x,-oo,oo)) = f(a)

integrate(DiracDelta(x-a)*f(x),(x,a-e,a+e)) = f(a)
1. DiracDelta(x) = 0, for all x != 0
2. DiracDelta(g(x)) = Sum_i(DiracDelta(x-xi)/abs(g’(xi))) Where xis are the roots of g

Derivatives of k order of DiracDelta have the following property: 5) DiracDelta(x,k) = 0, for all x!=0

### Heaviside¶

class sympy.functions.special.delta_functions.Heaviside

Heaviside Piecewise function. Heaviside function has the following properties: 1) diff(Heaviside(x),x) = DiracDelta(x)

( 0, if x<0
1. Heaviside(x) = < [*] 1/2 if x==0

( 1, if x>0

[*]Regarding to the value at 0, Mathematica adopt the value H(0)=1, and Maple H(0)=undefined

I think is better to have H(0)=1/2, due to the following: integrate(DiracDelta(x),x) = Heaviside(x) integrate(DiracDelta(x),(x,-oo,oo)) = 1

and since DiracDelta is a symmetric function, integrate(DiracDelta(x),(x,0,oo)) should be 1/2 in fact, that is what maple returns.

If we take Heaviside(0)=1/2, we would have integrate(DiracDelta(x),(x,0,oo)) = Heaviside(oo)-Heaviside(0)=1-1/2= 1/2 and integrate(DiracDelta(x),(x,-oo,0)) = Heaviside(0)-Heaviside(-oo)=1/2-0= 1/2

If we consider, instead Heaviside(0)=1, we would have integrate(DiracDelta(x),(x,0,oo)) = Heaviside(oo)-Heaviside(0) = 0 and integrate(DiracDelta(x),(x,-oo,0)) = Heaviside(0)-Heaviside(-oo) = 1

### gamma¶

class sympy.functions.special.gamma_functions.gamma

### loggamma¶

class sympy.functions.special.gamma_functions.loggamma

### polygamma¶

class sympy.functions.special.gamma_functions.polygamma

### uppergamma¶

class sympy.functions.special.gamma_functions.uppergamma
Upper incomplete gamma function