This is an unintentional detour for our little course. I didn’t plan to investigate the factorial function in so much detail, but it came about quite by accident (or stupidity) as we’ll see in later articles. In any case, it is very interesting.

### The Factorial Function

Those of a certain age might well remember the introduction of the electronic scientific calculator into school mathematics lessons. All I remember was trying to get a hold of one with working batteries and an intact keyboard. Anyhow, if you would have looked closely at the keyboard you might have seen a button with this symbol written on it:

\[n!\]

…a \(n\) followed by an exclamation mark, which calculates the factorial of \(n\). In the world of combinatorics this is one of the most useful functions.

It’s very easy to understand but can be quite complex to calculate, as we’ll see. Mathematically it can written like this:

\[n! = {\prod _{i=1}^n \; i}\]

…where \(n\) is a positive integer, then if \(n=4\):

\[4! = {\prod _{i=1}^4 \; i} \; = \; (1*2*3*4) = 24\]

The factorials of \(1!,…,5!\), look like this:

\begin{array},

1! = (1) = 1 \\

2! = (1*2) = 2 \\

3! = (1*2*3) = 6 \\

4! = (1*2*3*4) = 24 \\

5! = (1*2*3*4*5) = 120

\end{array}

Some of the more astute puffins will have noticed that in the above formula \(i\) starts at one, \(i=1\). What if \(i\) equals zero?

The short answer is \(0!=1\). The long answer is that it’s the *empty product*, or the result of a multiplication with no factors. For these articles it’s easier to just accept that the answer is one.

### Calculation Of Factorials With Real Numbers

A moments thought reveals a quite impressive problem when it comes to solving the factorial function – how do I calculate the factorial of a real number or a fraction?

Three factorial is simply \(3*2*1=6\), and four factorial is \(4*3*2*1=24\). What is the factorial that’s half way between three and four, namely three and a half or 3.5? We know it’s somewhere between 6 and 24. Perhaps it’s the number 15, which is exactly half way between 6 and 24? No, and to see why we need to look at some graphs:

For a start, the graph on the left is as bent as a politician. It’s very difficult to calculate a *linear interpolation* between any two values. The red line shows you what \(y=x!\) would look like if the result was linear. Unfortunately, it’s not.

Think of a simple number line: 1—2—3—4—5—6. If I ask you what the number between two and four is you can clearly see that it’s three. We can easily calculate what is between any of the numbers as it’s a linear progression.

In fig. 2, below, I’ve plotted a graph of \(y=x\). First, you can see that it’s a nice straight line. Second, it’s perfectly linear. In other words: for every change in \(x\), \(y\) *proportionally* changes by the same amount.

The difference between eight and four, in fig. 2, is four: \(8-4=4\). Then we take that difference and divide it by two: \({4 \over 2}=2\). If we then add two to four or subtract two from eight we get six: \(4+2=6, {\;\;} 8-2=6\), and six *intersects* the line perfectly between four and eight.

We’ve calculated the number half way between four and eight. And we can do this for any pair of numbers along that line.

Therefore, what we’d like to do is make that curvy line, in fig.1, straight while preserving the factorial function. Referring back to fig.1, the graph on the right has *sort of* done just that. You can see that between one and four it closely represents the red line on the left.

The \(ln\) function has calculated the *natural logarithm* of \(x!\), and by doing so has *straightened* out the curve. It’s not perfect, but it’s better than nothing! We can use this to approximate what \(3.5!\) is, as it’s made the calculation a lot simpler.

First, calculate the difference between two factorials and divide that value by two. In our case we want to know the value half way between three and four. We’ll call it \(d\) for difference:

\[d={(ln(4!)-ln(3!)) \over 2}\]

…next we add \(ln(3!)\) to this value, to move us half way along the graph’s line between 3 and 4, the green dot in fig.1:

\[n=d+ln(3!)\]

Lastly, we need to re-bend the curve! To do this we use the \(\text{exp}()\) function:

\[3.5! \approx \text{exp}(n) = 12 {\;\;\;} \text{Where exp(n)=e}^n\]

…the actual answer is 11.6, but 12 is not bad. We could have subtracted \(d\) from \(ln(4!)\) and ended up with the same result: \(n=ln(4!)-d, \; \text{exp}(n)=12\).

If you draw a horizontal line from 12 on the \(y\) axis until it touches the curve and then draw a vertical line down, you’ll see that it intersects approximately 3.5 on the \(x\) axis. As shown in fig.1.

A problem with this solution (other than the accuracy) is that it doesn’t work for numbers less than one, as can be seen in fig.1. You can see the little curve between zero and one which renders the calculation meaningless.

If you fire-up your desktop calculator (assuming it has a scientific mode), or go to Wolfram Alpha and type in \(3.5!\) the answer you’ll get back will be about 11.632. In the next part we’ll use some *slightly* more complex mathematics to get closer to this value.

Thinking caps at the ready…

© Doc Mike Finnley 2019