If you looked at my last post on complex numbers, the example I used was 1-dimensional, there was only one variable of interest. However, if you include time, the problem is 2-dimensional and we can plot the result on a 2-dimensional coordinate system. But our world is 3-dimensional (4 if you include time). In engineering, there are frequently many more than 3 variables needed to solve a problem. To handle these kind of problems, matrices are needed. Matrices come with their own set of algebra rules, but you don’t need to know these to follow this post. Let’s look at some examples.
System of Equations
Perhaps the simplest example that looks intuitively correct is using matrices to solve a set of m linear equations with m unknowns. In year 10, students are taught how to solve a system of 2 equations and 2 unknowns. They learn about two methods to solve these: substitution and elimination. These methods can be used for higher number of unknowns but this quickly becomes unwieldy as the number of unknowns increases.
An engineering example using 3 unknowns comes from my experience as an astronautical engineer. I was tasked to model the output of a mechanical gyroscope. A gyroscope is used to measure rotation about a specific direction (axis). This information is used in an inertial navigation system to determine an object’s orientation and velocity. There are several kinds of gyroscopes: mechanical, laser, semiconductor. The one in your smartphone is a semiconductor one. Mechanical ones are still used in aircraft and spacecraft navigation systems because of their long-term stability. However, their electronic output is not directly proportional to the rotational input, there are errors in the output. In an ideal world, the output, v, will be kÏ = v where Ï is the rotation detected (radians/second), v is the output voltage, and k is the conversion factor needed to convert radians/second to volts. But as our world is not ideal, there are errors in the signal produced by the gyroscope. These errors need to be subtracted from the output before it is sent to the navigation system.
The model I used had many more terms in it, but for purposes of this post, I will simplify it to
\[k_1\omega_1+k_2\omega_2+k_3\omega_3=v\]where k1Ï1 is the desired output in direction 1, and the other two terms are errors introduced from rotations about the other 2 perpendicular directions in 3-dimensional space. For a particular gyroscope, I had to find the k‘s so that the navigation system would know what the actual rotation about direction 1 is.
So the gyroscope was placed on a very accurate test platform where its orientation with respect to the earth’s rotation was accurately known and the platform could also rotate an accurately known amount. So if the gyroscope was subjected to three different orientations/rotations and the output measured at each position, three equations in the 3 k unknowns could be generated. Actually, many more measurements were made. There are errors in the measurements of the outputs and the inputs so I actually used a least squares matrix process (yes, statistics is used in engineering as well) to find the best estimates of the k‘s. But again, for purposes of this post, let’s assume we have perfect knowledge of the inputs and outputs so that only three measurements are needed.
Using different rotation rates about the primary measurement axis and the two perpendicular ones, we generate the following set of equations:
\[3k_1+2k_2+1k_3=2.51\\5k_1-5k_2+7k_3=3.82\\6k_1-6k_2-7k_3=4.43\]where, for example, for the first equation, a rotation of 3 radians/second about the primary axis, 2 radians/second about axis 2, and 1 radian/second about axis 3 generated a voltage of 2.51 volts.
There is a matrix version of this system of equations:
\[\begin{bmatrix}3&2&1\\5&-5&7\\6&-6&-7\end{bmatrix}\begin{bmatrix}k_1\\k_2\\k_3\end{bmatrix}=\begin{bmatrix}2.51\\3.82\\4.43\end{bmatrix}\]Without going into the rules of matrix algebra, I think you can see how each of the objects in the above equations were assembled: the array (matrix) of numbers are the coefficients of the unknowns, listed in the same order as in the system of equations. The vertical matrix next to it (also called a vector as it only has the one column) lists the unknowns, and the matrix on the right side is the numbers on the right side of the system. If we let A be the matrix of coefficients, k be the matrix of unknowns, and b be the matrix of the right side numbers, the matrix equation and its solution is:
\[\textbf{Ak}=\textbf{b}\Longrightarrow\textbf{k}=\textbf{A}^{-1}\textbf{b}\]On a CAS calculator, this is solved very quickly. The answer will be the matrix k and you just pick off the elements for each ki in the same order as in the setup of the matrix equation. Doing this on my CAS, I get the answer :
\[\textbf{k}=\begin{bmatrix}0.8\\0.05\\0.01\end{bmatrix}\]So the output model for this gyro is
\[0.8\omega_1+0.05\omega_2+0.01\omega_3=v\]Given the corrected outputs of the other two gyros, the navigation system knows what the true rotation about axis 1 is.
Rotation matrix
Another “rocket scientist” application of matrices associated with navigation are rotation matrices. Supposed your spacecraft is halfway between earth and the moon and a course correction is needed. In which direction do you burn your rocket engines? If you just point your spacecraft toward the moon and fire, you will miss by a lot. This is because you are not taking your spacecraft’s and the moon’s motion into account. And when I say “motion”, I mean with respect to an inertial (that is static) reference coordinate system, called an inertial reference frame. Depending on the scenario, this could be a system at the centre of the earth or the sun that does not rotate with the earth or sun.
So calculations are made with respect to the inertial frame but the spacecraft’s navigation system only knows its reference frame when it comes to firing the engines. Rotation matrices is how an inertial direction is converted to a spacecraft’s reference frame.
To simplify this a bit, I will limit the coordinate systems to be 2-dimensional, but the concept can easily be extended to 3 dimensions.
Consider the two coordinate systems below:
where the x-y system is the inertial frame and the x’-y’ system is the spacecraft reference frame. Now I know that the origins of these two frames will be physically separated, but it turns out that this does not matter. Only the angle (angles for 3-dimensions) between the two frames matter. I draw them together so you can more easily see the result.
Now suppose that, with respect to the inertial frame which does take into account the motions of the spacecraft and the moon, it is calculated that the direction the engines should fire for the course correction is v as indicated in the diagram. This direction has an x value and a y value which corresponds to where the arrow of v is. The spacecraft has to convert this to its coordinate system and it does it with the following matrix multiplication:
\[\begin{bmatrix}x’\\y’\end{bmatrix}=\begin{bmatrix}\text{cos}(\theta)&\text{sin}(\theta)\\-\text{sin}(\theta)&\text{cos}(\theta)\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}\]The angle ð is known from the various navigation systems that are being used to track the spacecraft, including an inertial navigation system that has gyroscopes that we just modelled. Now the spacecraft knows in what direction it has to fire its engines.
Other uses
In the previous example, the navigation computers needed to have a model of all the forces acting on the spacecraft and the resulting motions, that is its dynamics, in order to calculate the vector v. This model is a matrix differential equation that is constantly being numerically solved. To do this, the computer needs to keep track of the spacecraft’s position in 3-dimensional space (3 variables) as well as the velocity in each of those dimensions (3 more variables). The matrix needed for that model has to have the same number of rows and columns as the number of variables, so that is a 6 Ã 6 matrix (36 elements).
Matrices are used in electronics, optics, quantum mechanics, cryptography, robotics – you get the point.