### The Maxima on-line user's manual

Algebra Calculator

#### Factorial

Function: factorial (<x>) Represents the factorial function. Maxima treats `factorial (<x>)` the same as `<x>!`. See `!`.

-- Operator: ! The factorial operator.

For any complex number `x`, except for negative integers, `x!` is defined as `gamma(x+1)`.

For an integer `x`, `x!` simplifies to the product of the integers from 1 to `x` inclusive. `0!` simplifies to 1. For a real or complex number in float or bigfloat precision `x`, `x!` simplifies to the value of `gamma (x+1)`. For `x` equal to `n/2` where `n` is an odd integer, `x!` simplifies to a rational factor times `sqrt`

``     (%pi)` (since `gamma (1/2)` is equal to `sqrt (%pi)`).`

The option variables `factlim` and `gammalim` control the numerical evaluation of factorials for integer and rational arguments. The functions `minfactorial` and `factcomb` simplifies expressions containing factorials. See `factlim`, `gammalim`, `minfactorial` and `factcomb`.

The functions `gamma`, `bffac`, and `cbffac` are varieties of the gamma function. `bffac` and `cbffac` are called internally by `gamma` to evaluate the gamma function for real and complex numbers in bigfloat precision.

`makegamma` substitutes `gamma` for factorials and related functions.

Maxima knows the derivative of the factorial function and the limits for specific values like negative integers.

The option variable `factorial_expand` controls the simplification of expressions like `(n+x)!`, where `n` is an integer.

See also `binomial`.

The factorial of an integer is simplified to an exact number unless the operand is greater than `factlim`. The factorial for real and complex numbers is evaluated in float or bigfloat precision.

```          (%i1) factlim:10;
(%o1)                                 10
(%i2) [0!, (7/2)!, 8!, 20!];
105 sqrt(%pi)
(%o2)                   [1, -------------, 40320, 20!]
16
(%i3) [4.77!, (1.0+%i)!];
(%o3)    [81.44668037931197,
.3430658398165454 %i + .6529654964201665]
(%i4) [2.86b0!, (1.0b0+%i)!];
(%o4) [5.046635586910012b0,
3.430658398165454b-1 %i + 6.529654964201667b-1]```

The factorial of a known constant, or general expression is not simplified. Even so it may be possible to simplify the factorial after evaluating the operand.

```          (%i1) [(%i + 1)!, %pi!, %e!, (cos(1) + sin(1))!];
(%o1)      [(%i + 1)!, %pi!, %e!, (sin(1) + cos(1))!]
(%i2) ev (%, numer, %enumer);
(%o2) [.3430658398165454 %i + .6529654964201665,
7.188082728976031,
4.260820476357003, 1.227580202486819]```

Factorials are simplified, not evaluated. Thus `x!` may be replaced even in a quoted expression.

```          (%i1) ([0!, (7/2)!, 4.77!, 8!, 20!]);
105 sqrt(%pi)
(%o1) [1, -------------, 81.44668037931199, 40320,
16
2432902008176640000]```

Maxima knows the derivative of the factorial function.

```          (%i1) diff(x!,x);
(%o1)                           x! psi (x + 1)
0```

The option variable `factorial_expand` controls expansion and simplification of expressions with the factorial function.

```          (%i1) (n+1)!/n!,factorial_expand:true;
(%o1)                                n + 1```

There are also some inexact matches for `factorial`. Try `?? factorial` to see them.

```(%o1)                                true
(%i2) ```

### Related Examples

##### factorial-plot2d-sin-sum

s:sum((-1)^n*x^(2*n+1...

plot2d(s-sin(x),[x,10...

Calculate

##### factorial-nusum

nusum((factorial(2*n)...

Calculate

##### factorial-log-plot2d-sqrt

plot2d([log(x)^2, x/l...

plot2d([x^2, 3^log(x)...

plot2d([2^(3*x), 2^(2...

Calculate

##### factorial

factorial(1.2342);

Calculate

##### factorial-inf-sum

sum(1/factorial(n), n...

Calculate

##### factorial-log-plot2d

plot2d([log(factorial...

Calculate

##### factorial-sqrt

a:sqrt(factorial(7)+1);

a;

Calculate

##### factorial-linsolve-sum

a:sum((-1)^(i+j) /(fa...

b:sum((-1)^(i+j) /(fa...

linsolve([a,b],[i,g]);

Calculate

##### factorial-plot2d-sin-sum

f(x):=sin(x);

g(n,x):=sum((-1)^n*x^...

plot2d([g(1,x),g(2,x)...

Calculate

##### factorial-plot2d-sin-sum

s:sum((-1)^n*x^(2*n+1...

plot2d([s,sin(x)],[x,...

Calculate