Message Boards Message Boards

0
|
8374 Views
|
9 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Functions for permutations and combinations counting?

Posted 3 years ago

The simple counts. I can make Mathematica do them (using CS notation, P(n,r) and C(n,r)). Is there a reason that these don't exist as simple built-in functions (or can I just not find them)?

POSTED BY: Stefan Baratto
9 Replies
Posted 1 year ago
In[112]:= Pochhammer[3, 2]

Out[112]= 12

But 3P2 = 6, not 12

POSTED BY: Greg Lee

Check the reference page for Pochhammer to see how the arguments get used. In particular, to map to permutations (n,k), one would use Pochhammer[k,n-k+1].

POSTED BY: Daniel Lichtblau
Posted 1 year ago

Thanks, Daniel, I hadn't thought to do that.

But for my own convenience, I will create a user-defined function as suggested by Gianluca.

POSTED BY: Greg Lee

In my humble opinion, permutations (n,k) or nPk may be calculated by Pochhammer[n-k+1, k], not by Pochhammer[k,n-k+1]. For example, 5P2 is 5!/(5-2)! = 5!/3! = 5x4=20. Pochhammer[4,2] gives 20. Pochhammer[2,4] results in 120. I am just learning ropes in Mathematica and my math skills are quite rusty. Please, take my words with a grain of salt. Sang

POSTED BY: Sang Dhong
Posted 2 years ago

That doesn't answer the original question, which is one I have as well. Why aren't these native to Mathematica?

POSTED BY: Doug Shaw

Binomial (which counts combinations) and Pochhammer (which counts permutations) are both Mathematica system functions.

POSTED BY: Daniel Lichtblau
Posted 3 years ago

You might also take a look at Pochhammer and FactorialPower.

POSTED BY: Jim Baldwin

Binomial makes sense. That's what I figured for Perm. Thanks.

POSTED BY: Stefan Baratto

The function C is called Binomial in Mathematica. The function P does not appear to be pre-installed, but you can define it yourself:

P[n_, r_] := n!/(n - r)!
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract