Linear algebra formalism
Aspects of tuning theory are often described in the language of linear algebra.
Monzos and vectors
Vals and covectors
Mappings and matrices
Matrix operations
Dot product
The dot product is a way to combine two vectors to get out a single number. Say we want to take the dot product of the vectors [math]\displaystyle{ \begin{pmatrix}12\\19\\28\end{pmatrix} }[/math] and [math]\displaystyle{ \begin{pmatrix}-2\\0\\1\end{pmatrix} }[/math]. To do so, follow these steps:
- Write the vectors separated by a dot to denote the dot product: [math]\displaystyle{
\begin{pmatrix}
12\\
19\\
28\\
\end{pmatrix}
\cdot
\begin{pmatrix}
-2\\
0\\
1
\end{pmatrix}
}[/math]
- This may also be notated [math]\displaystyle{ \langle 12, 19, 28 \vert -2, 0, 1\rangle }[/math]; from this derives the notation for vals and monzos.
- Multiply the corresponding elements, and add the results together: [math]\displaystyle{ \left(12\cdot-2\right)+\left(19\cdot0\right)+\left(28\cdot1\right) = -24 + 0 + 28 = 4 }[/math]
Multiply matrix by vector
We write the "application" of a matrix like so:
[math]\displaystyle{ \begin{bmatrix} 1 & 0 & -4\\ 0 & 1 & 4 \end{bmatrix} \begin{bmatrix} -2\\ 0\\ 1 \end{bmatrix} }[/math]
where the second object is the vector.
To write the first element of our output, we take the dot product of the first row of our matrix with our vector: [math]\displaystyle{ \begin{pmatrix} 1\\ 0\\ -4\\ \end{pmatrix} \cdot \begin{pmatrix} -2\\ 0\\ 1 \end{pmatrix} = \left(1\cdot-2\right)+\left(0\cdot0\right)+\left(-4\cdot1\right) = -2 + 0 + -4 = -6 }[/math]
We do the same thing for the second element of our output, computing [math]\displaystyle{ \begin{pmatrix} 0\\ 1\\ 4\\ \end{pmatrix} \cdot \begin{pmatrix} -2\\ 0\\ 1 \end{pmatrix} = 4 }[/math].
Thus, our output is [math]\displaystyle{ \begin{bmatrix} -6\\ 4\\ \end{bmatrix} }[/math] .
Multiply matrix by matrix
A matrix can act on another matrix, as well. In this case, the matrix on the right can simply be treated as several vectors next to each other.
[math]\displaystyle{ \begin{bmatrix} 1 & 0 & -4\\ 0 & 1 & 4 \end{bmatrix} \begin{bmatrix} 1 & -1 & -2\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix} = \begin{bmatrix} 1 & -1 & -6\\ 0 & 1 & 4 \end{bmatrix} }[/math]
Multiply row vector by matrix
This is to taking the dot product as matrix*matrix multiplication is to matrix*vector multiplication. You take the dot product of the row vector with each successive column of the matrix, and write the result as another row vector. Any matrix*vector operation can be rewritten in this format by swapping rows and columns; the reason these are distinguished is because it is conventional to represent certain things as column vectors and different things as row vectors (i.e. monzos and vals); in this case, vectors represented as rows are called "covectors".
Determinant
Practical usage
Let's say we want to determine the tuning of 6/5 in quarter-comma meantone.
Stage 1: JI to temperament
[math]\displaystyle{ \begin{bmatrix} 1 & 0 & -4\\ 0 & 1 & 4 \end{bmatrix} }[/math]
This matrix I've been using as an example is actually a "function" that converts a 5-limit interval in monzo format (with the entries corresponding to powers of 2, 3, and 5) into a corresponding meantone interval in an analogous format (with the entries representing powers of meantone's tempered 2 and 3) called "tempered monzos" or "tmonzos".
So, let's take the monzo for 6/5, [1 1 -1⟩, and apply this matrix to it: [math]\displaystyle{ \begin{bmatrix} 1 & 0 & -4\\ 0 & 1 & 4 \end{bmatrix} \begin{bmatrix} 1\\ 1\\ -1 \end{bmatrix} = \begin{bmatrix} 5\\ -3 \end{bmatrix} }[/math].
The result is the meantone tmonzo representing a tempered 6/5.
Stage 2: Temperament to tuning
Now, we have the tmonzo. We'll be introducing something called a tval, which gives us a specific tuning of our temperament the same way a regular val gives us a specific tuning of just intonation. The quarter-comma meantone tval for this meantone mapping is ⟨1200 ~1896.5784] in cents. This is where the dot product comes in: [math]\displaystyle{ \langle 1200, ~1896.5784 \vert 5, -3\rangle }[/math].
Computing this dot product yields ~310.265, which is exactly the size of the QCM minor third in cents!