Blog

Engineering Topics – Complex Numbers

The world moves and so do many things that occur naturally or are made by humans. Because of this, when engineers or scientists want to mathematically model a system or process, they frequently need to identify not only the variables of interest (like position), but the rate of change of these variables (like velocity). These mathematical models are equations that relate the variables and their rates of change. Equations like this are called differential equations and how to solve these equations is usually introduced to students after they have studied calculus. And solutions to these equations frequently have complex numbers in them.

What is a complex number? A complex number is defined using the definition of the imaginary unit, i:

\[i=\sqrt{-1}\]

This may look like a crime against mathematics as through much of our maths education, we were told that you cannot take the square root of a negative number. This is reinforced by trying to take the square root of a negative number on many calculators resulting in an error. But it turned out that this invention had some usefulness in maths.

Numbers like bi where b is a real number are called imaginary numbers. If you add a real number a to this, a + bi, you get a complex number, where a is the real part and b is the imaginary part. There is a lot of theory surrounding complex numbers, but I will only cover what is necessary for this post.

Complex numbers satisfy many of the properties you are familiar with using real numbers including the rules involving exponents. So using a complex number as an exponent to the natural base e (a number, like πœ‹, which is frequently used in engineering), the expression can be split into two parts:

\[e^{a+bi}=e^ae^{bi}\]

You are familiar with ea, but what do we do with ebi? This is actually a complex number as well and can be put into a standard form using Euler’s formula:

\[e^{bi}=\text{cos}\,b+i\,\text{sin}\,b\]

In textbooks, the right side of the above equation is abbreviated as cis b. So

\[e^{a+bi}=e^a(\text{cos}\,b+i\,\text{sin}\,b)=e^a\,\text{cis}\,b\]

So what can imaginary numbers tell us about the real world? Well, the “useless” things you were taught about quadratic equations, are about to become useful.

The Damped Harmonic Oscillator

There are many things that oscillate, but not forever: electronic circuits, your car when it hits a bump, aircraft when they hit an air pocket. A simple example is a mass on a spring with a damper attached:

Modified image from https://commons.wikimedia.org/

There’s a lot of physics happening here. But all you need to know is that there are 3 main forces affecting the motion of the mass. These forces are created by: gravity (which creates an acceleration downward), spring (proportional to the position of the mass), and damper (proportional to the velocity of the mass). What is the position of the mass at any time t?

Using Newton’s second law, F = ma, the following differential equation can be generated. A differential equation is an equation that relates a variable (in this case, the position x) with its rates of change (in this case velocity and acceleration):

\[m\ddot{x}+b\dot{x}+kx=0\]

where x is the position of the mass relative to a reference point, b is the damping coefficient (how strong is the damper), k is the spring constant (how strong is the spring), x with one dot above it is the rate of change of x with respect to time (commonly known as velocity), and x with two dots is the rate of change of velocity with respect to time (commonly known as acceleration).

Solving differential equations is a whole university course, but for this type of equation, the solution will be of the form:

\[x(t)=Ae^{πœ†t}\]

where A is the initial position of the mass at t = 0. So the problem reduces down to finding πœ†. It turns out that πœ† is the solution to the corresponding algebraic equation (called the characteristic equation):

\[m\lambda^2+b\lambda+k=0\]

So yes, here is an example where you use the quadratic skills you learned. Using the quadratic formula:

\[\lambda=\frac{-b\pm\sqrt{b^2-4mk}}{2m}\]

The discriminant b2 – 4mk, dictates the type of solutions for πœ†. In this post, I am interested in the case where b2 – 4mk < 0, the under damped case which is graphically shown in the animation above.

With a little bit of algebra and using the definition of i to factor out the βˆ’1 inside the square root (and what remains in the square root is positive):

\[\lambda=\frac{-b\pm\sqrt{(-1)(4mk-b^2)}}{2m}=\frac{-b}{2m}\pm i\sqrt{\frac{k}{m}-\frac{b^2}{4m^2}}\]

If we let

\[\alpha=\frac{b}{2m}\text{  and  }\omega=\sqrt{\frac{k}{m}-\frac{b^2}{4m^2}}\]

then πœ† = -⍺ Β± Ο‰i. So the solution is

\[x(t)=Ae^{(-\alpha\pm \omega i)t}=Ae^{-\alpha t}e^{(\pm\omega ti)}=Ae^{-\alpha t}(\text{cos}(\pm \omega t)+i\,\text{sin}(\pm\omega t))\]

Now it looks like we still have an imaginary part in the answer. We need a real solution that fits the real world. As I said before, solving differential equations is a separate subject usually studied at uni. In that subject, you would learn about the superposition principle where any linear combination of two separate solutions of a differential equation will also be a solution. Notice that we do in fact, have two solutions above: one using the + and the other using the βˆ’. Using relationships that exist for circular (trig) functions for sine and cosine, we can add these two solutions together and the imaginary part will cancel out, leaving only a real solution:

\[x(t)=Ae^{-\alpha t}\text{cos}(\omega t)\]

As t grows, the cosine part of the solution just bounces up and down between Β±A. But the exponent of e gets more negative as t grows making eβˆ’βΊt smaller, starting at 1 when t = 0. This generates the following curve:

Notice how the exponential part of the solution is an envelope that the cosine curve must fit into.

Instead of a mass hanging on a spring, the differential equation we started out with could represent your car’s suspension system which has springs and shock absorbers (dampers). Notice that we can change the parameters, the strengths of the springs and shock absorbers, to change the way a car handles bumps. The response in the graph above may be too loose and we may want to change the parameters to make the car settle down more quickly. This is engineering.

Engineering Topics – Vectors

As an ex-engineer, I know that almost all of the math skills I have learned in school have been used in my career. However, students generally do not appreciate this when, for example, they are factoring a quadratic. It becomes easier to demonstrate the usefulness of math to students when they are being taught skills that have a direct application. So I thought I would present a few topics in maths with some applications in engineering. The first of these topics is vectors.

A vector is an object with a magnitude and a direction. If you are travelling at 60 km/hr, that number is just a magnitude. But if you are travelling north at 60 km/hr, that has a directions as well and can be represented as a vector.

There are a lot of new math skills associated with vectors, but I will only cover what is necessary to present this application of vectors.

Vector Addition

Vectors can be added algebraically but I will just be talking about how to add vectors graphically.

Here is a typical vector:

It’s magnitude can be its physical length or a labelled quantity like 60 km/hr or 100 N (newtons) of force. Its direction though, needs a reference. This will usually be a coordinate system like the Cartesian coordinate system:

This vector represents a velocity of 60 km/hr in the direction 30Β° from the positive x-axis. Now this direction is completely dependent on the coordinate system used. We could have made the x-axis line up with the vector itself. But once established, questions regarding the vector will be answered with respect to the coordinate system used.

A vector can be the sum of two or more vectors. There are many variations to this but the scenario applicable to this post is where the vector is the sum of two vectors that are perpendicular to each other. Given the coordinate system we have used, the vector V can be broken up into two components, Vx and Vy. That is, V = Vx + Vy. Graphically, this looks like:

Now we already know the direction with respect to this coordinate system of each of the component vectors Vx and Vy, but what are their magnitudes?

Looking at the above figure, you can see that the vector V splits the rectangle formed by the x and y axes and the dotted lines into two similar right triangles. If the length of the hypotenuse of these triangles is 60, then

\[\left|{\boldsymbol{V_x}}\right|=60\text{ cos}(30Β°)=51.96 \text{ km/hr}\]

where |vector| is notation to represent the magnitude of a vector. Similarly, you can see that

\[ \left|{\boldsymbol{V_y}}\right|=60\text{ sin}(30Β°)=30 \text{ km/hr}\]

If you were given the perpendicular vector components, you can use the Pythagorean theorem to find the magnitude. Let’s use the components found above to see if they give back the original vector:

\[\left|{\boldsymbol{V}}\right|=\sqrt{\boldsymbol{V_x}^2+\boldsymbol{V_y}^2}=\sqrt{51.96^2+30^2}\approx60\text{ km/hr}\]

This is approximately 60 because the 51.96 number used is a two decimal place approximation to the actual irrational number.

So here is a practical application of this:

A cable supports a beam at an angle of 29.745Β°. A weight at the end of the beam provides a force of 500 N. Assume that the weight of the beam is negligible. What is the tension (force) seen by the cable?

Now before I tackle this, a bit of background. First, the “N” in “500 N” stands for “newtons”. This is the unit of force in the SI system of units. SI is the International System of Units that is usually used in science and engineering. Though your mass may be 80 kg, the force you exert on the earth is 784.8 N. In return, the earth exerts a force of 784.8 N against you in the opposite direction. Second, this problem is a statics problem, that is, nothing is moving. That means that all involved forces (vector quantities that have direction) must add to zero. The force you exert on the earth and the opposite force that the earth exerts on you add to zero, so there is no motion up or down. Third, tension and compression in a structural member is a force that the member exerts on neighbouring objects in response to forces that cause the tension or compression.

Let’s isolate the end of this structure where the force is being applied:

As there is no motion, there must be an opposite but equal force of 500 N:

What is causing this opposite force? It’s the tension in the cable. This tension must be great enough to cause a force of 500 N in the y (up) direction. This 500 N up is the y component of the force from the cable:

Knowing the y component, the opposite side of the right triangle shown, we can use trigonometry to find the hypotenuse, the value of the tension in the cable T:

\[\left|{\boldsymbol{T}}\right|=\frac{500}{\text{sin}(29.745Β°)}=1000.78 \text{ N}\]

I leave it to you to review the definition of the sine of an angle in a right triangle.

Even though this was not asked, the tension in the cable creates a force in the x direction (horizontal direction). Again using trigonometry, the value of this force is 875.00 N. Where is the force that opposes this so that there is no motion? It comes from the compression imposed on the horizontal member:

This is an engineering problem because if you were to design and build this structure, you would have to ensure that the materials used could handle the tension and compression loads with an additional safety factor. Before reading this post, if you just thought that the cable needs to handle 500 N, you would soon be looking for a new job.

Transformations 4

Let’s do a couple of examples using the knowledge from my last 3 posts and show how the order of transformations make a difference.

The image of the equation that follows will be generated by the following transformations:

a. Dilate along y-axis by factor 1/2
b. Reflect along y-axis (across x-axis)
c. Dilate along x-axis by factor 3
d. Translate along x-axis +4 units
e. Translate along y-axis -2 units

\[y=\sqrt{3x-4}\]

In the previous post, I showed that given an equation y = f(x), its image under a general transformation is given by

\[f(x)\Rightarrow af\left[\frac{1}{n}(x-h)\right]+k\]

where
a = dilation\reflection factor along y-axis (from x-axis)
n = dilation\reflection factor along x-axis (from y-axis)
h = translation along x-axis
k = translation along y-axis

This assumes that dilations/reflections are done first. So if

\[f(x)=\sqrt{3x-4}\]

then

\[f(x)\Rightarrow af\left[\frac{1}{n}(x-h)\right]+k=-\frac{1}{2}\sqrt{3\left [ \frac{1}{3}(x-4)\right]-4}-2\]

This can be simplified to

\[y=-\frac{1}{2}\sqrt{ x-8}-2\]

In this form, the pre-image (the equation that this one came from before the transformation) is lost. The question could be asked, what are the transformations required to go from

\[y=-\frac{1}{2}\sqrt{ x-8}-2\Rightarrow y=\sqrt{3x-4}\]

One would expect that if we just do the opposite of the transformations above, we would get the original equation. Let’s see. Let’s do the following:

a. Dilate along y-axis by factor 2
b. Reflect along y-axis (across x-axis)
c. Dilate along x-axis by factor 1/3
d. Translate along x-axis -4 units
e. Translate along y-axis +2 units

These undo the previous transformations. Putting these in our model

\[f(x)\Rightarrow af\left[\frac{1}{n}(x-h)\right]+k\]

We get

\[f(x)\Rightarrow -2f\left[3(x+4)\right]+2=\sqrt{3(x+4)-8}+4+2=\sqrt{3x+4}+6\]

Not exactly what we wanted. What went wrong? Well, the model we used assumes that dilations go first. If we want to undo the previous transformations, not only do we use the values we just used, but they must be applied in reverse order as well: the translations go first then the dilations/reflections. Otherwise the dilations affect the translations before they are applied.

I’ll leave this as an exercise for the reader, but the model for transforming y = f(x) assuming that translations go first is

\[y=af\left( \frac{x}{n}-h \right)+ak\]

So undoing the original transformations in reverse order:

a. Translate along y-axis +2 units
b. Translate along x-axis -4 units
c. Dilate along x-axis by factor 1/3
d. Reflect along y-axis (across x-axis)
e. Dilate along y-axis by factor 2

gives the result

\[f(x)\Rightarrow -\frac{1}{2}f\left(3x+4\right)\Rightarrow-\frac{1}{2}\sqrt{3x+4-8}-2+2\Rightarrow\sqrt{3x-4}\]

which is the original equation.

So the order of transformations steps will change the final result.

I hope this series of posts helps you better understand transformations.

Transformations 3

In my last post, I took a general point (x,y) and through the series of transformations:

A. (x,y)
B. Dilate/reflect by factor a along y-axis
C. Dilate/reflect by factor n along x-axis
D. Translate k units along y-axis
E. Translate h units along x-axis

the point was changed to:

A(xy) β€”-> B(xay) β€”-> C(nxay) β€”-> D(nxay+k) β€”->
E(nx+hay+k).

Now let’s restrict the original point to be one that satisfies the equation y = x2. How does this equation change so that all of its points are transformed correctly?

Think of the transformation process as changing old points to new ones. So the old points, (xy), are changed to the new points (nx+hay+k) = (x‘, y‘), where the apostrophe ‘ is used to distinguish the new x‘s and the new y‘s from the old ones. So under this transformation, x‘ = nx+h and y‘ = ay+k.

Now the equation y = x2 is the equation that the old points satisfy. To find the equation that the new points satisfy, we need to find what the old variables are in terms of the new ones. Solving for the old x and y in the above equations, we get

\[x’=nx+ h\Longrightarrow x = \frac{1}{n}\left(x’-h\right)\]
\[y’=ay+ k\Longrightarrow y = \frac{1}{a}\left(y’-k\right)\]

If we replace the old variables in the equation with the right side of the above equations, then we will get an equation with the new variables, which can be cleaned up with a little algebra:

\[\frac{1}{a}(y’-k)=\left[\frac{1}{n}(x’-h)\right]^2\Longrightarrow y’=a\left[\frac{1}{n}(x’-h)\right]^2+k\]

Now that we have the new equation, we don’t need the ‘ anymore. So the new equation is:

\[y=a\left[\frac{1}{n}(x-h)\right]^2+k\]

Notice that if we were given this new equation and were asked, “what are the transformations that generated this equation from y = x2 ?”, then we can pick off the dilations and the translations. Be aware though, that we must assume that the dilations occurred first. Textbooks will tell you this to keep answers consistent. With this caution, if a = 2, n = 3, h =-5, and k =4, then the new equation would be

\[y=2\left[\frac{1}{3}(x+5)\right]^2+4\]

The graph below shows the effect of these transformations on the original curve:

So given a set of transformations, the steps that I did above for the particular equation y = x2, can be done for any equation.

What if the problem is reversed: given the end result, what is the set of transformations that created the new equation from and original one? Using functional notation, notice that:

\[f(x)={x}^{2}\Longrightarrow af\left[\frac{1}{n}(x-h)\right]+k=2{\left[\frac{1}{3}(x+5)\right]}^{2}+4\]

If you were given this final result, you can pick off the dilations along both axes (These are assumed to be first) and the translations along both axes. If either the a and/or the n were negative, then there would be reflections as well.

Transformations 2

In my last post, I took specific points and transformed them using dilations/reflections and translations. The goal is to transform an equation into a new equation. But before we get there, let’s again look at a single point. But this time, this will be a general point (x, y).

So starting with general point A(x, y), let’s do the same transformation as I did in my last post:

A. (x,y)
B. Dilate by factor 2 along y-axis
C. Dilate by factor 1/3 along x-axis
D. Reflect across x-axis
E. Reflect across y-axis
F. Translate 3 units up
G. Translate 3 units to the left

In this order, the new transformed points become:

A(x, y) —-> B(x, 2y) —-> C(x/3, 2y) —-> D(x/3, -2y) —->
E(-x/3, -2y) —-> F(-x/3, -2y+3) —-> G(-x/3-3, -2y+3)

From my last post, if you use the particular point A(3,1), and use these values in the result above, you get the same point G(-4,1).

This can be generalised more by using letters to represent the dilation factors and the translation amounts:

a = dilation/reflection factor along y axis
n = dilation/reflection factor along x axis
h = translation along x axis
k = translation along y axis

Note that I have combined dilations and reflections. This is because a reflection can be viewed as a negative dilation. If a is negative, then this is a reflection along the y axis (across the x axis) as well as a dilation. If n is negative, then this is a reflection along the x axis (across the y axis) as well as a dilation. This does slightly restrict the flexibility of transformations as we cannot separate the order of a dilation and a reflection, but for most problems, this is not an issue. Also, if h is negative, that is a translation to the left. If k is negative, that is a translation down.

Now I’ll apply this to the same set of transformations as above except that I will combine the dilation and reflection steps:

A. (x,y)
B. Dilate/reflect by factor a along y-axis
C. Dilate/reflect by factor n along x-axis
D. Translate k units along y-axis
E. Translate h units along x-axis

This leads to the new point:

A(x, y) —-> B(x, ay) —-> C(nx, ay) —-> D(nx, ay+k) —->
E(nx+h, ay+k)

If these transformations are reversed:

A. (x,y)
B. Translate h units alongΒ x-axis
C. Translate k units along y-axis
D. Dilate/reflect by factor n alongΒ x-axis
E. Dilate/reflect by factor a alongΒ y-axis

you get the new point:

A(x, y) —-> B(x+h, y) —-> C(x+h, y+k) —-> D[n(x+h), y+k] —->
E[n(x+h), a(y+k)]

This is different and you will generally get a different ending point for a specific point and transformation values.

Some terminology is needed here. We have an original point (x,y) and then under a set of transformations, a new point is created. In our first set of transformations, this new point was (nx+h, ay+k). Point (nx+h, ay+k) is the image of (x,y) under this transformation. Or (x,y) is the pre-image of (nx+h, ay+k).

It may help to think of this as a black box where (x,y) enters and is magically transformed to (nx+h, ay+k). Though we know it is not magic at all but just maths:

As mentioned, the goal here is to transform a set of points, usually defined by an equation, to a new set (new equation). The above mental image (pun intended) will help keep in focus what is being done.

In my next post, I will transform equations and show how that is done.

Transformations 1

From my experience teaching mathematics, I think that the topic most students find the most difficult is circular functions (trigonometry). The next most difficult topic is transformations: transforming a function to another via dilations, reflections, and translations. This is the first of several posts to address this topic.

First, by way of looking at individual points in a Cartesian coordinate system, let’s do some transformations and define some terms.

Consider the following points A, B, C, and D:

The first transformation will be to dilate these points. This means that we will change their distance from the x or y axes by multiplying the appropriate coordinate by a number. This number is called the dilation factor. If we dilate along the x-axis, we will change the x coordinate of each point by multiplying it by the dilation factor. Be aware that this is also called “dilating from the y-axis” because this dilation changes the point’s distance from the y-axis

So let’s dilate these points along the x-axis by a factor of 2. This makes each point twice as far from the y-axis. So point A becomes A1(6,1), B becomes B1(-4,3), C becomes C1(-8,-1), and D becomes D1(2,-2):

Dilation of factor 2 along x-axis

If we had used a factor of 1/2, then the new points would be half the distance from the y-axis than the original points.

If the factor we use is negative, not only is the dilation happening, but the points are also reflected across the y-axis. So if the dilation factor is -2 along the x-axis, the new points are A1(-6,1), B1(4,3), C1(8,-1), and D1(-2,-2):

Dilation and reflection
of factor -2 along x-axis

Another transformation is translation: moving a point left or right or up or down. So if you translate a point 3 units to the right (along the x-axis), then the new points are A1(6,1), B1(1,3), C1(-1,-1), and D1(4,-2):

Translation 3 units to right (+x directions)

Now all of these transformations can be done along the y-axis (from the x-axis) as well. So doing all transformations along the y-axis, I will dilate point A by a factor of 2, reflect point B with no dilation, translate point C up 3 units, and dilate point D by a factor of 1/2. The new points will then be A1(3,2), B1(-2,-3), C1(-4,2), and D1(1,-1):

Transformations along y-axis

The previous example just changed the x or the y coordinate of each point. Let’s look at point A and mix up these transformations. This will also show that the order of the transformations can affect the final result. Consider the following sequence of transformations of point A:

A. (3,1)
B. Dilate by factor 2 along y-axis
C. Dilate by factor 1/3 along x-axis
D. Reflect across x-axis
E. Reflect across y-axis
F. Translate 3 units up
G. Translate 3 units to the left

The following graph shows the sequence of these transformations .The new point’s letter refer to the result of the transformation’s letter above:

Now let’s do the previous steps in reverse:

A. (3,1)
B. Translate 3 units to the left
C. Translate 3 units up
D. Reflect across y-axis
E. Reflect across x-axis
F. Dilate by factor 1/3 along x-axis
G. Dilate by factor 2 along y-axis

We end up at a very different place. Also notice that if a point is on the y-axis, reflections across the y-axis and dilations along the x-axis, have no effect.

I will generalise this for a generic point (x,y) in my next post.

Graphing Circular Functions

The following file is for year 12 students covering trigonometric functions sine and cosine. It presents an orderly method to graph functions of the form:

f(x) = a sin[n(x βˆ’ h)] + k, x₁ ≀ x ≀ xβ‚‚ or f(x) = a cos[n(x βˆ’ h)] + k, x₁ ≀ x ≀ xβ‚‚. It assumes knowledge of trig functions (or circular functions) and how to use the unit circle.

Statistics – Combinations (Selections)

In my last post, I described how you can find all the ways to arrange x things from a group of n things. Here, order matters, and the equation to calculate this is

\[P\left(n,x\right)=\frac{n!}{\left(n-x\right)!}\]

If this looks strange, please read my last post. Now let’s talk about counting things where order does not matter, for example, picking a team of players.

The math term for this is combinations. Let’s introduce this with an example. How may ways can you arrange the letters A, B, and C? From my last post, you know that this is 3! = 6. ABC and CBA are two different arrangements. Now how many ways can you select all 3 letters? Well, there is only one way that can be done. ABC and CBA are the same selection so are only counted once. Notice that for a given n and x, there are fewer selections than arrangements. In this example, there are 3! = 6 times more arrangements than selections.

Now let’s modify this example. Suppose we want to select 3 letters from ABCDE. For any 3 of the letters chosen, there will be 3! times more arrangements than selections, which means that if we use the permutation formula above to answer this question, the answer would be 3! times too large. Generalising this, there are x! times more arrangements than selections for a given n and x. This allows us to modify the formula above by dividing it by x! to get the combinations formula

\[C\left(n,x\right)=nCx=\left(\begin{matrix}n\\x\\\end{matrix}\right)=\frac{n!}{x!\left(n-x\right)!}\]

The left side are some of the different notations used and the right side is the actual formula. As with permutations, you can use a CAS calculator to do this calculation with the nCr function. Selecting 3 letters from 5, there are

\[C\left(5,\ 3\right)=\frac{5!}{3!\left(5-3\right)!}=10\]

ways to do that. This would also answer the questions: how many ways can you select a team of 3 people from 5 people or how many 3-card hands can be dealt from a deck of 5 cards?

Speaking of cards, how many 5-card poker hands can be dealt from a standard deck of 52 cards?

\[C\left(52,\ 5\right)=\frac{52!}{5!\left(52-5\right)!}=2,598,960\]

Now let’s put this in practice. There are many lotto games around based on picking 6 numbers out of 45. Let’s first calculate how many ways you can select 6 numbers out of 45:

\[C\left(45,\ 6\right)=\frac{45!}{6!\left(45-6\right)!}=8,145,060\]

From my post on basic probability, the probability of your lotto ticket with a single set of 6 numbers winning is

\[\text{probabilty of winning}=\frac{1}{8145060}=0.000000123=0.0000123\text{%}\]

Now if you buy a block of 50 numbers, how much does that improve your chances of winning? This is a binomial distribution problem which is beyond the scope of this post, but to calculate that, it uses the probability calculated above to get 0.000614% chance that at least one of the numbers wins. That’s a 1 out of 162,902 chances to win with a 50 pick lotto card. In Australia, there is a 1 in 12,000 chance of being hit by lightning. Just make sure you’re not standing outside when you buy your ticket.

Statistics – Permutations (Arrangements)

I will discuss counting two types of picking a group of items from a large number of items. These two types are called permutations (also called arrangements) and combinations (also called selections).

Combinations are when the order of the picking does not matter. For example, when picking 5 cards from a 52 card deck, the order does not matter: Ace, 2, 3, 4, 5 is the same hand as 5, 4, 3, 2, Ace (assuming the suits are the same). Or another example is how many 5 player teams can be made from 30 people. I will discuss combinations in a subsequent post. This post is about permutations, where the order of things picked does matter.

An example of a permutation problem is how many ways can you arrange 5 guests on a table from a group of 50 people. Here, order matters: Adam, Betty, Charlie, David, Eddie arranged in that order is different from Eddie, David, Charlie, Betty, Adam.

Let’s look at a simple example and extrapolate from that.

From 5 people, how many ways can we seat 3 of them? There are 5 ways to pick the first person. Now there are only 4 people left, so there are 4 ways to pick the next person. Now there are 3 people left so we only have 3 ways to pick the last person. So the number of ways is the 5 ways to pick the first times the 4 ways to pick the second times the 3 ways to pick the last person: 5 Γ— 4 Γ— 3 = 60 ways to arrange 3 people from a group of 5. If you follow this pattern, you can arrange 5 people from a group of 10, 10 Γ— 9 Γ— 8 Γ— 7 Γ— 6 = 30,240 ways.

This can be generalised: how many ways can you arrange x things from n things. Before I show the formula for this, I need to explain new notation.

Using a “!” after a number has a meaning in maths. This is called a factorial. As an example, 5! = 5 Γ— 4 Γ— 3 Γ— 2 Γ— 1 = 120. So a factorial is successively multiplying one less number. Factorials increase quickly. 40! is a number slightly greater than 8 followed by 47 zeroes. Factorials are used in maths formulas frequently and in order to make these consistent, 0! is defined as 1. Doesn’t look right but this must defined this way as we will see.

Looking at the examples above, we have partial factorials: instead of 5 Γ— 4 Γ—3 Γ— 2 Γ— 1, we have 5 Γ— 4 Γ— 3, or instead of 10 Γ— 9 Γ— 8 Γ— 7 Γ— 6 Γ— 5 Γ— 4 Γ— 3 Γ— 2 Γ— 1 we have 10 Γ— 9 Γ— 8 Γ— 7 Γ— 6. Notice that 5! can be thought of as 5 Γ— 3 Γ— 4 Γ— 2! and 10! can be 10 Γ— 9 Γ— 8 Γ— 7 Γ— 6 Γ— 5!. In the first example, the “2” is 5 – 3, that is the number of people minus the number in the arrangement. In the second, the “5” is 10 – 5, that is the number of people minus the number in the arrangement. If we let n be the number of total things and x the number of the things to be arranged, then the formula to compute this in general is:

\[P\left(n,x\right)={^n}P_x=P_x^n=nPx=\frac{n!}{\left(n-x\right)!}\]

The formula is the far right expression, the notations on the left are the common notations used in different places that mean the same thing. So applying this to our two examples:

\[P(5,3)=\frac{5!}{\left(5-3\right)!}=\frac{5\times4\times3\times2!}{2!}=5\times4\times3=60\] \[P\left(10,5\right)=\frac{10!}{\left(10-5\right)!}=\frac{10\times9\times8\times7\times6\times5!}{5!}=10\times9\times8\times7\times6=30,240\]

The 2! and the 5! cancel out in the fractions and we get the result we want. If we wanted to arrange 5 things from a group of 5, we use the definition that 0! = 1:

\[P\left(5,5\right)=\frac{5!}{\left(5-5\right)!}=\frac{5!}{0!}=\frac{5!}{1}=5\times4\times3\times2\times1=120\]

Because of how large factorials grow, if calculating this formula by hand, it is better to first cancel the (nx)! part from the numerator, then calculate the result.

If you are fortunate to own a CAS calculator, using the permutation function nPr gets the same result with less work: nPr(10,5) = 30,240.

Now this does not directly answer questions about picks where order does not matter, like the number of poker hands. That is a combination question and I will talk about that in my next post.

Statistics – Probability of Conditional Events

This is about the probability of an event given some information. What follows assumes you know how to calculate basic probabilities (two posts ago) and the probability of an intersection of events (my last post).

Let’s start with an example. What is the probability of rolling a 6 on the roll of a die? From basic probability, we know that it is the number of ways to roll a 6 (only 1 way) divided by the number of total things that can happen (6). So the probability is 1/6. Now what if the die is rolled and a friend cheats by telling you that the number rolled is odd. Intuitively, you would say that the probability is 0 as 6 is an even number, so the additional information tells you that a 6 is not possible. The probability of a 6 and an odd number is 0 because the number of ways you can roll a 6 and an odd number is 0.

Now if the die is rolled and your friend says that the number rolled is even, what is the probability that a 6 was rolled? Intuitively, knowing that the number is even should increase the chances that a 6 was rolled. We can answer this using the basic probability formula: the number of ways to roll a 6 and an even number divided by the number of even numbers. Knowing that the number is even reduces the number of total things that can happen from 6 to 3. And the number of ways you can roll a 6 and an even number is 1. So the new probability, thanks to your friend, is 1/3.

As always, maths has notation for this. Let A and B be two events. Then the notation for “the probability of event A given (or on condition that) B occurred” is P(A|B). From the examples above, if A is the event of rolling a 6, and B is the event of rolling an odd number or it’s the event of rolling an even number, then the equation to calculate this is

\[P\left(A\middle|B\right)=\frac{n\left(A\cap B\right)}{n\left(B\right)}\]

From my last two posts, remember that n(something) means the number of ways that something can occur, and the symbol ∩ means intersection or “and”.

This equation can be shown to be equivalent to

\[P\left(A\middle|B\right)=\frac{P\left(A\cap B\right)}{P\left(B\right)}\]

where the probabilities are used instead of the numbers. This can be rearranged to give what is called the multiplication rule of probability

\[P\left(A\cap B\right)=P\left(A\middle|B\right)P\left(B\right)\]

So if P(A ∩ B) = 0.3 and P(B) = 0.7, then

\[P\left(A\middle|B\right)=\frac{P\left(A\cap B\right)}{P\left(B\right)}=\frac{0.3}{0.7}=\frac{3}{7}\]

Another example that shows conditional probability and the multiplication rule of probability in action is the following:

There is a bag with 10 marbles in it: 4 red and 6 blue ones. Two marbles are picked from the bag without replacing the first ball picked. “Without replacing” is important because the probability of picking the second ball’s color is affected by the first ball picked. If the first ball was replaced, the probability of the second ball’s color would not depend in the first ball’s color, that is, the two picks would be independent of each other.

So let’s look at some of the probabilities in this experiment. The probability that the first ball is red is P(R₁) =4/10 = 2/5. Now the probability of the second ball picked is dependent on that as there is 1 less red ball and 1 less ball in total. So the probability that the second ball is red is P(Rβ‚‚|R₁) = 3/9 = 1/3 because there are only 3 red balls left out of the 9 balls left. Likewise, P(Bβ‚‚|R₁) =6/9 = 2/3. For simple experiments like this, tree diagrams are often used to get a complete picture of all the possibilities:

The last column of combination probabilities uses the multiplication rule previously stated. Using tree diagrams like this, you can answer many questions about the experiment by adding these probabilities:

  1. What is the probability of picking just one red marble?
\[P\left({B_2\cap R}_1\right)+P\left({R_2\cap B}_1\right)=\frac{4}{15}+\frac{4}{15}=\frac{8}{15}\]

2. What is the probability of picking two marbles of the same color?

\[P\left({R_2\cap R}_1\right)+\ P\left({B_2\cap B}_1\right)=\frac{2}{15}+\frac{1}{3}=\frac{7}{15}\]

3. What is the probability of picking at least one red marble?

\[P\left({R_2\cap R}_1\right)+P\left({B_2\cap R}_1\right)+P\left({R_2\cap B}_1\right)=\frac{2}{15}+\frac{4}{15}+\frac{4}{15}=\frac{10}{15}=\frac{2}{3}\]

Note that since the last column includes all the possible ways this experiment can go, all of these probabilities add up to 1. So to answer question 3, a more efficient way to calculate the answer is to subtract the one possibility excluded from 1:

\[1-P\left({B_2\cap B}_1\right)=1-\frac{1}{3}=\frac{2}{3}\]

Counting the number of ways an event can happen in simple experiments like this is easy to do in your head. But what about questions like “how many poker hands (5 cards) can be made from a standard deck of 52 cards?”. Not so easy. So next time, I will talk about how we can “count” large possibilities like this.