Section 1 Matrix Vocabulary Overview
In this section we will take a look at the different components of a matrix and consider the necessary vocabulary to work with matrices both in linear algebra, as well as in machine learning.
Definition 1.1. Matrix.
A matrix is a rectangular array of numbers. (Can also be functions or other mathematical objects) This array is often denoted using parentheses or brackets. In most applications, these reflect the same thing. Here is a general example of how they will look thoughout this module:
Below we will find the first "code box". These boxed will include python code as well as comments. # is used for a comment. When new code is introduced, we will include long-form comments. In later code boxes, we will truncate repeated comments. These boxes are intended to be copied into your IDE and explored at leisure. Note that the code boxes build throughout the module.
Array (matrix) in Python
# Include the numpy module. This is used for working with many different # mathematical objects.We use the alias np for numpy, and it is assigned # by using "as". import numpy as np # This is the syntax to assign the above matrix to A. Each of the # brackets, [] ,is the delimiter for the array. The most outside # set gives us an array. Each inside set will allow us to assign a row. A = np.array([[1,-1, 4], [6, 3, 1], [9, 0 , 3]]) # This line will print the resulting array. print(A)
We should note that the definition does not specify the size of the rectangular array, so we should start with the vocab that will allow us to refer to the size or shape of a matrix.
The horizontal reference in a matrix is called the row and we start counting row at the top row. The vertical reference in a matrix is called the column. The size of a matrix is the number of row "by" the number of columns.
Definition 1.2. Square Matrix.
If the number of rows equals the number of columns, we say that the matrix is square .
Example 1.3.
For the matrix below, 6 is in the second row and the first column.
The above matrix in this example has three rows and four columns. So we would say that this is a "three by four matrix". We should also note that this matrix is not square (since the number of row is not equal to the number of columns).
Next let's establish some foundational syntax for matrices. Consider the following,
There is is a lot to unpack from the above block of mathematical syntax. First note the use of capital \(A \text{.}\) Generally in mathematics we use capital letters to represent matrices.
Now in the above matrix \(A \) we have used subscripts to articulate the row and column that we are in. The subscript looks like it is a two digit number, but it should be thought of as two numbers, just sitting close together. So \(a_{23} \) is in row 2, column 3. Additionally, \(a_{ij} \) would be referred to as the "i'th j'th entry of the matrix".
Now that we have some of the vocabulary established, let's break into some matrix operations. Throughout the rest of the module we will take a look at,
- matrix addition
- matrix multiplication
and we take a look at matrix equations.