# Subfactorial

Subfactorial[n]

gives the number of permutations of n objects that leave no object fixed.

# Details • Mathematical function, suitable for both symbolic and numerical manipulation.
• For noninteger n, the numerical value of Subfactorial[n] is given by Gamma[n+1,-1]/E.
• Subfactorial can be evaluated to arbitrary numerical precision.
• A permutation in which no object appears in its natural place is called a derangement.
• Subfactorial automatically threads over lists.
• Subfactorial gives 1.
• Subfactorial can be used with CenteredInterval objects. »

# Examples

open allclose all

## Basic Examples(5)

Evaluate numerically:

Plot the sequence:

Plot over a subset of the complexes:

Series expansion at the origin:

Series expansion at Infinity:

## Scope(24)

### Numerical Evaluation(5)

Evaluate numerically:

Evaluate to high precision:

The precision of the output tracks the precision of the input:

Complex number input:

Evaluate efficiently at high precision:

Subfactorial can be used with CenteredInterval objects:

### Specific Values(5)

Values of Subfactorial at fixed points:

Value at zero:

Evaluate symbolically:

Limiting values at infinity:

Find a value of for which the real part of Subfactorial[x] is equal to 5:

### Visualization(2)

Plot the absolute value of Subfactorial:

Plot the real part of Subfactorial[x+ y]:

Plot the imaginary part of Subfactorial[x+ y]:

### Function Properties(7)

Real domain of Subfactorial:

Complex domain:

Subfactorial is not an analytic function on :

In fact, it is singular and discontinuous everywhere on the reals:

However, it is analytic in the complex plane:

The absolute value of Subfactorial is not injective:

The absolute value of Subfactorial is not surjective:

Subfactorial is neither non-negative nor non-positive:

Subfactorial is neither convex nor concave:

### Differentiation(2)

First derivative with respect to :

Higher derivatives with respect to :

Plot the higher derivatives with respect to :

### Series Expansions(3)

Find the Taylor expansion using Series:

Plots of the first three approximations around :

Find the series expansion at Infinity:

Taylor expansion at a generic point:

## Applications(1)

There are 9 derangements of a set of 4 objects:

Here are all permutations of the set {1,2,3,4}:

Delete all permutations where an object is fixed:

Check that there are only 9 derangements:

## Properties & Relations(5)

Subfactorial[n] is given by :

Recurrence relations satisfied by Subfactorial:

Subfactorial can be represented as a DifferenceRoot:

FindSequenceFunction can recognize the Subfactorial sequence:

The exponential generating function for Subfactorial:

## Neat Examples(1)

The only number equal to the sum of subfactorials of its digits: