Calculating $\pi$ Factorial

One of the things I like most about mathematics is its ability to generalize results to realms that one might not have previously thought of before. Historically, this is what happened with rational numbers, negative numbers, irrational numbers, complex numbers, and so on.

Most of you have probably heard of the factorial operation before, but here it is again explicitly. Essentially, if you have a natural number $n$, then it’s factorial is denoted as $n!$ and is defined as $n! = n(n-1)(n-2) \ldots (2)(1)$. That’s an easy enough definition. Start with your number, and just multiply it by all of the numbers that came before it (until you get to one). We also have the base cases of $1!=0!=1$.

The factorial is what is known as a recurrence relation. Instead of getting an explicit formula for how to calculate each term, you get what the $n^{th}$ term is in relation to the next term below it (for this specific case). Let’s do an example with $5!$. If we look at our definition above, we get $5! = 5 \cdot 4!$, since the rest of the multiplication is “hidden” within $4!$. As such, we don’t get a number for $5!$ until we figure out what $4!$ is, which we can only do if we find out what $3!$ is, and so on. Therefore, the factorial is really a recipe, and the only time we get a real answer is when we hit $1!$, which we set to $1$.

That’s great, but it doesn’t look very helpful for calculating $\pi!$. After all, $\pi$ is definitely not in the naturals, so we can’t make use of the definition above. However, let’s keep in mind the kind of relation that the factorial gives us. It tells us that $n! = n \cdot (n-1)!$. Let’s see if we can get something else to work like that.

Somewhat completely out of the blue, let’s take a look at the following function:

\begin{equation} \Gamma(a) = \int_0^\infty x^{a-1}e^{-x} dx, \,\,\,\,\, a \gt 0. \end{equation}

This function is called the Gamma function, and it’s used in probability distributions (which is where I came across it). Now, this might seem like a really weird function to throw at you. How in the world does this relate to anything about factorials? Well, let’s start by trying to calculate the value of $\Gamma(a+1)$.

\begin{equation} \Gamma(a+1) = \int_0^\infty x^{a+1-1}e^{-x} dx = \int_0^\infty x^{a}e^{-x} dx \end{equation}

Then, we can integrate by parts using $u=x^a$ and $dv = e^{-x}dx$ to get:

\begin{equation} \left[-x^a e^{-x} \right]_0^{\infty} +a \int_0^\infty x^{a-1}e^{-x} dx. \end{equation}

The first term evaluates to zero at both boundaries (which can be seen by taking the limit as $x \rightarrow \infty$). Therefore, we are only left with the second term. However, look at the form of the integrand. It’s simply $\Gamma(a)$. As such, we conclude with the following relation:

\begin{equation} \Gamma(a+1) = a \Gamma(a). \end{equation}

This is really neat, because it’s another recurrence relation that gives us an answer in terms of the previous (lower) one. We can also look at the result of $\Gamma(1)$, and confirm that is indeed equal to one. In fact, this means that we get the following result: $\Gamma(a) = (a-1)!$. It’s a recurrence relation exactly like the factorial, but formulated in a totally different way. The one important difference though is that the value of $a$ is not limited to natural numbers. Now, we simply need $a \gt 0$, which means we can easily calculate $\pi!$. This corresponds to a value of $a = \pi + 1$. Inserting this into the integral definition and evaluating the integral numerically gives a result of:

\begin{equation} \pi! = \Gamma(\pi + 1) = \int_0^\infty x^{\pi}e^{-x} dx \approx 7.18808. \end{equation}

How do we interpret this result? I don’t know! But roughly, I can say that it’s a bit more than $3! = 6$, so at least something is on the right track. However, calculating the result of $\pi!$ in particular isn’t of too much importance. It’s simply a neat extension of how one can think of factorials.


One thing I do want to note is that, just because we have a recurrence relation with this Gamma function, this doesn’t mean we technically have the same thing as a factorial if $a$ is not a natural number. Really, we then just have a recurrence relation. However, it’s still an interesting connection that’s worth sharing. Sometimes, seeing operations and concepts you were only used to seeing in one setting suddenly operating in another scenario can broaden one’s perspective on mathematics.

Easy Examples Miss the Point

I’ve been thinking recently about what it takes to make a concept “stick” in a student’s mind. When first looking at a topic, it’s tempting to show a student easy examples that get them familiar with the mechanics, before moving on to more difficult problems. However, when this new concept is a new way to see an old idea, it can be difficult to sell the concept to the students if the old idea seems to be just as effective as the new one. After all, why should the student have to learn a new method if the old one still works?

This is the topic that Dan Meyer talks about in his presentation on the needs of students. His main point is that mathematics education is too much like a collection of solutions, and not enough of giving students “headaches” in which mathematics can help. Throughout the talk, he gives several examples in which the audience is asked to solve an easy problem, and then to solve a similar but much more demanding problem which creates the “need” for new mathematical tools. In particular, I was struck by the example at around the 35:00 mark in which he asked two people from the audience to describe the location of a chosen point in a sea of other points. Crucially, there were many points, so it wasn’t a trivial matter to describe with words where the point one chose was located. The first person struggled with this, but when it was the other person’s turn, the dots were underlayed with a Cartesian grid. You can hear the audience at that moment laugh at how easy everything becomes. I highly encourage watching the whole thing, but if you don’t want to spend the full fifty or so minutes, watch that one part.

Related to Mr. Meyer’s point is the idea of showing easy examples. I’m reminded of the fact that many students are given easy examples only. You’ve seen this before in the fact that assignments have “nice numbers” as answers, and that nothing is too difficult. This is good to start, but it can often lull students into not really grasping why certain methods are used versus others. If there are five ways to answer the question, why does a student have to do it in a specific way? If this method really is important, I think one needs to create problems that show-off the merits of a particular method. As Mr. Meyer says, give the students a headache and show them a particular method as the aspirin. Don’t just give them easy example problems to work through when trying to motivate them on a new technique or concept. Skipping this step means students won’t have buy-in on the idea, and will simply wonder why they have to learn this esoteric method.

Now, I’m not saying that easy examples aren’t useful. They can help during the beginning of practice, where students are motivated by the concept, yet still need to work on getting the technique. Then, it makes sense to give easier examples. This can also help students check their work, since they can compare the new method to their old method. However, once the technique is mastered, don’t give them problems which are so easy that a different (and more familiar) method can be used. Make sure that students see the need for this new technique. There’s a reason it’s there.

Minimization (The Rope Cutting Problem)

If you’re in secondary school, chances are you’ve had to discuss a bunch of properties of functions. These include finding the maxima and minima, the roots (zeros), the intervals where the function is positive or negative, the intervals where the function is increasing or decreasing, and the domain of the function. While having to slog through page after page of this, you might be tempted to ask, “Why do I have to learn about this? Not only is it boring, it’s completely useless!”

Trust me, I hear you. The problem is that, through doing countless exercises of the same flavour, you gain proficiency, but you don’t learn why you should have this piece of information. To remedy this, let me give you a problem where knowing the properties of a function are quite useful. I came across this problem while watching some videos by the great mathematics teach Eddy Woo, and I think if you’ve been wanting something a bit more than what you’ve done in your classes, this will be interesting to you. I’ll state the problem, and then I’ll explain the solution. As such, if you want to try the problem beforehand (which I recommend!), stop reading after I state the problem.

Problem: Imagine you have a one metre rope. Your task is to decide where to cut the rope in order for the two pieces of rope to make a square and a circle. Where should the cut be made in order to minimize the combined area of the two shapes?


Solution:

Begin by choosing a variable to represent the problem. For the square, we have the potential variable $s$, which is the side length of the square. For the circle, we have the natural variable $r$, which represents the radius of the circle. Either variable will work, but only one is needed, since we can express one variable in terms of the other. For this solution, $r$ will be used.

We want to minimize the total area of both shapes, so we need a function that gives us the area. Since we know what the area of a circle is in terms of $r$, and what the area of a square is in terms of $s$, we get the following area function:

Obviously, this has two variables in it, $r$ and $s$. However, as we mentioned above, we can express one variable in terms of the other. This is because the variables $r$ and $s$ can’t be anything. They are constrained by the fact that the rope given in the problem is only one metre long. In other words, the length of the rope has to be the sum of the perimeters of the two shapes, since that’s exactly what the rope will be used to create. Therefore, we get the desired constraint.

Now that we have the variable $s$ expressed in terms of $r$, we substitute this into Equation (1).

The question now becomes, “Where is this a minimum?” To answer this, you might wonder if there is a minimum, but after a moment’s reflection you should recognize that Equation (3) is the equation of a parabola with a positive coefficient for the $r^2$ term, meaning the parabola makes a “U” shape and so does have a minimum. To find the minimum, we will use two different strategies.

The Calculus Way

If you know a bit of calculus, you might be tempted to take the derivative and set it equal to zero (since a parabola only have one point where the derivative is zero). Doing so gives the following.

This gives us the radius at which the total area is a minimum. Therefore, if we want to know where to cut the rope, we want to know the circumference of the circle (since that will indicate where the cut should appear). This means the we need to cut the rope at $2\pi r_{min} = \frac{2\pi}{8+2\pi} = \frac{\pi}{4+\pi}$, which is approximately 44% of the rope.

Completing the Square

The second way to solve this problem once we have Equation (3) is to complete the square. Doing so will transform Equation (3) into the “standard form” of a quadratic equation, which looks like $f(x) = a(x-h)^2 + k$. From there, we know that a quadratic equation has a minimum or maximum at it’s vertex, which is given by $(h,k)$. Therefore, all we need to do is find the coordinate $h$, and we’ve got our minimum. To do this, we will just label the coefficients of Equation (3) as $a$, $b$, and $c$, so we get the following:

To complete the square, we first have to factor the $a$ from both the $r^2$ and $r$ terms, giving:

Now, we simpy write what is in parentheses as a perfect square, and subtract off the extra part. This gives:

Cleaning up these terms brings us to the standard form:

If we recall what our coefficients were, we see that $a = \frac{16\pi + 4\pi^2}{16}$ and $b = \frac{-4\pi}{16}$. From Equation (8) above, we know that our coordinate $h$ is $-b/2a$ (remember that the standard form of the equation has $-h$ in it), so we get:

Once again, if we want to find the spot to cut the rope, we need to multiply this result by $2\pi$ (to get the circumference of the circle). Doing so gives us once again $\frac{\pi}{4+\pi}$, which is about 44% of the rope.


Hopefully, you were able to solve the problem. I really like this problem because you need to come up with your own variables and you need to know how to find the minimum of a function, which are things you might practice a lot, but never really use in a problem. As such, I wanted to give you a taste of what these function properties can actually help us with.

Happy problem solving.

Machines and Processes

When you first learned about algebra, chances are you learned about something called a function, typically one that looks like this: This is nothing more than the equation of a straight line. You probably also learned how this could be represented as a graph (which is why you know it’s a straight line). This was simple enough, and you soon learned how to deal with different kinds of functions. These include quadratics (parabolas), exponentials, rationals, and a host of other functions. You learned what these looked like when graphed, and how to find various properties of these functions. This includes finding the roots of the equation (when $f(x)=0$), finding the domain and range, and characteristics of when the graph is increasing or decreasing.

To find some of these properties, you actually had to interact with the function. That meant working through the algebra and manipulating some equations. Depending on how comfortable you were in mathematics, this could be easy or difficult. However, assuming you got past this stage and still understood what was happening, you then got to more exotic functions, such as logarithmic or trigonometric functions. These have the form $f(x) = \log(x)$ and $f(x) = \sin(x)$, and aren’t your usual functions. This is where you start seeing students making the mistake of dividing by $\sin$ or $\log$.

Why does this happen? From my experience, it’s due to the sense that everything in mathematics is linear. To illustrate this, let’s look at an easy example. Suppose we have the equation $\log(x+1) = 2$. You might be tempted to say that this is the same as $\log(x) + \log(1) = 2$, but this would be incorrect! What we actually have to do is convert the equation into exponential form, giving us $10^2 = x+1$. The answer itself isn’t really important. What’s important is that the logarithm isn’t linear, and so you can’t simple distribute it onto the term $(x+1)$.

From what I can gather, the reason this happens is that $\log(x+1)$ is very similar in notation to $4(x+1)$. We know that the latter is equivalent to $4x+4$, which we get by multiplying each term inside the parentheses by $4$. As such, it isn’t so surprising when students think that the same should apply to these new things called logarithms. The same is true for the expression $\sin(x+1)$ and $(x+1)^2$. We feel like it’s completely natural to write $\sin(x)+\sin(1)$ and $(x^2+1^2)$, but this is incorrect.

Instead, what we should think of the expressions like $\sin(x)$ and $\log(x)$ as functions or machines. When you insert a number $x$ into them, the machine runs, and spits out a number back. The crucial part is that the machine is highly dependent on the initial number you put in. Said differently: if I put $(2+5)$ into $\sin(x)$, or if I do $\sin(2)+\sin(5)$, I get to very different answers. For comparison, the former gives approximately $0.065699$, and the latter gives $0.909297-0.958924=-0.049627$. Obviously, these two numbers aren’t the same. Also, for those who have studied trigonometric functions, you know that $\sin(x)$ varies from $-1$ to $1$, which means that $\sin(x+y)$ must also vary from $-1$ to $1$, while $\sin(x)+\sin(y)$ could vary from $-2$ to $2$, which means these two expressions can’t be the same.

This is also true for logarithms, and many other mathematical functions you may encounter. The difficult at this point is to deal with this while working with algebraic equations. You can’t simply add, subtract, multiply, and divide your way to a solution. You have to know what functions you’re dealing with, and how to work with them.

Last example: consider the function $f(x) = 4\sin(x^2-2) +1$. This function has a lot going on, but the way I think about it is that you have a function within a function within a function. To make this explicit, label $g(x) = \sin(x)$, and $h(x) = x^2-2$. Remember that the variable $x$ in both of these equations is just a placeholder. You can stick anything there. If we think back to our analogy of a machine, think of $x$ as where you input your value into the machine. Now, if we write $f(x)$ in terms pf $g(x)$ and $h(x)$, we get the following: This equation may look a bit busy, but that’s the point! I want you to really see where $x$ is located. It’s nestled into the “deepest” function, $h(x)$. What I want you also see is that instead of writing $g(x)$, I wrote $g(h(x))$. This means that instead of sticking $x$ into the input of $g(x)$, I stuck $h(x)$ instead! There is nothing wrong with this, and it actually has a fancy name. It’s called a composition of functions. Think of it like a machine within a machine. The output of the first machine is connected to the input of the first machine, so that when you give the first machine an initial value, it passes through both machines. As such, you can’t exactly “split up” the machine into two different parts and expect to get the same answer as doing both together. It depends on the nature of the machine.


Hopefully, this gives a bit of intuition into the idea of more complex functions such as the logarithmic or trigonometric functions. They don’t distribute linearly, and so you can’t apply your usual rules of algebra to them. Additionally, it’s important to remember that expressions like $\log$ and $\sin$ by themselves have no meaning. They aren’t numbers. Typing these into your calculator and pressing the “=” buttom gives an error, and rightly so! Remember, they are like machines or processes, so asking what the output of a machine is without any input doesn’t make sense.

By keeping in mind the analogy of functions as machines, you should have a better conceptual understanding of why logarithms and trigonometric functions don’t simply distribute, and this will translate to understanding how to manipulate them without mistakes.