I have forgotten

COST (GBP)
1.40
3.96
0

# fixed permutation

Calculates the number of permutations of \e n objects with \e m fixed.
Controller: CodeCogs

C++
Excel

## Fixed Permutation

 intfixed_permutation( int n int m )
A permutation of n objects with m fixed is a permutation in which exactly m of the objects retain their original positions. In more formal terms, consider the following permutation

$\sigma&space;=&space;\left(&space;\begin{array}{cccc}&space;1&space;&&space;2&space;&&space;\ldots&space;&&space;n&space;\cr&space;\sigma(1)&space;&&space;\sigma(2)&space;&&space;\ldots&space;&&space;\sigma(n)&space;\end{array}&space;\right)$

then $\inline&space;&space;\sigma$ has exactly m fixed objects if

$\mathrm{card}&space;\{&space;i&space;\,|\,\sigma(i)&space;=&space;i,&space;\quad&space;i&space;=&space;\overline{1,&space;n}&space;\}&space;=&space;m$

If $\inline&space;&space;m&space;=&space;0$, the permutation is a derangement, while if $\inline&space;&space;m&space;=&space;n$, the permutation is the identity.

The number of permutations of n objects with m fixed is given by

$F(n,&space;m)&space;=&space;(n!&space;/&space;m!)&space;\cdot&space;(1&space;-&space;1/1!&space;+&space;1/2!&space;+&space;\cdots&space;+&space;(-1)^{n-m}/(n-m)!)$

or

$F(n,&space;m)&space;=&space;\left(&space;\begin{array}{c}&space;n&space;\cr&space;m&space;\end{array}&space;\right)&space;\cdot&space;D_{n&space;-&space;m}$

where $\inline&space;&space;D_{n&space;-&space;m}$ is the number of derangements of $\inline&space;&space;n&space;-&space;m$ objects.

This function calculates the value of $\inline&space;&space;F(n,&space;m)$ based on the above formula.

## References:

SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html

### Example 1

#include <iostream>
int main()
{
std::cout << "The number of permutations of 10 elements with 5 fixed is: ";
std::cout << Maths::Combinatorics::Sequences::fixed_permutation(10, 5) << std::endl;
return 0;
}

### Output

The number of permutations of 10 elements with 5 fixed is: 11088

### Parameters

 n the size of the permutation m the number of fixed objects

### Returns

the number of permutations of n items with m fixed

### Authors

Lucian Bentea (August 2005)
##### Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.