ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Linear Algebra Fundamentals for Machine Learning
Chapter 1: Why Linear Algebra Matters in Machine Learning
Representing Data with Vectors and Matrices
Linear Algebra in Machine Learning Algorithms
Core Concepts Overview
Setting Up Your Python Environment
Quiz for Chapter 1
Chapter 2: Getting Started with NumPy for Numerical Computing
Introduction to NumPy Arrays
Creating NumPy Arrays
Array Indexing and Slicing
Basic Array Operations
Array Attributes and Shape Manipulation
Hands-on: NumPy Array Creation and Manipulation
Quiz for Chapter 2
Chapter 3: Working with Vectors
What is a Vector?
Vector Notation
Vectors in Python using NumPy
Vector Addition and Subtraction
Scalar Multiplication
Vector Norms: Measuring Length
The Dot Product
Hands-on: Vector Operations with NumPy
Quiz for Chapter 3
Chapter 4: Working with Matrices
What is a Matrix?
Matrix Notation and Dimensions
Matrices in Python using NumPy
Types of Matrices: Square, Identity, Zero
Diagonal and Triangular Matrices
Hands-on: Matrix Creation with NumPy
Quiz for Chapter 4
Chapter 5: Essential Matrix Operations
Matrix Addition and Subtraction
Scalar Multiplication
Matrix Transpose
Matrix Multiplication: The Dot Product
Properties of Matrix Multiplication
Hands-on: Matrix Operations with NumPy
Quiz for Chapter 5
Chapter 6: Systems of Linear Equations and Matrix Inverses
Representing Linear Equations with Matrices
The Concept of a Solution
The Identity Matrix Revisited
The Matrix Inverse
Conditions for Invertibility
Solving Ax = b using the Inverse
Calculating Inverses with NumPy
Solving Linear Systems with NumPy
Hands-on: Solving Systems with NumPy
Quiz for Chapter 6

This course has been archived: A newer version with updated syllabus and improved content is now available.

Matrix Notation and Dimensions

Matrices are ordered tables of numbers. To work with these mathematical structures effectively, a standard method is needed to describe their size and refer to their individual components. This involves understanding matrix dimensions and element notation.

Understanding Dimensions: Rows and Columns

The size, or dimensions, of a matrix are defined by the number of rows and the number of columns it contains. We typically say a matrix with mmm rows and nnn columns is an m×nm \times nm×n matrix (read as "m by n"). The number of rows always comes first.

For example, this matrix AAA:

A=[5126−3014]A = \begin{bmatrix} 5 & 12 & 6 \\ -3 & 0 & 14 \end{bmatrix}A=[5−3​120​614​]

Matrix AAA has 2 rows and 3 columns, so it is a 2×32 \times 32×3 matrix.

It's important to remember this order: rows first, then columns. A 3×23 \times 23×2 matrix would look different, having 3 rows and 2 columns:

B=[123456]B = \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix}B=​135​246​​

Here, BBB is a 3×23 \times 23×2 matrix.

Matrices AAA and BBB have different dimensions. AAA is 2×32 \times 32×3, while BBB is 3×23 \times 23×2.

Referring to Matrix Elements

We often need to refer to a specific number, or element, within a matrix. We do this using indices, typically represented by subscripts. If we have a matrix AAA, the element in the iii-th row and jjj-th column is denoted as AijA_{ij}Aij​ or aija_{ij}aij​. Again, the row index (iii) comes first, followed by the column index (jjj).

Let's use matrix AAA from before:

A=[5126−3014]A = \begin{bmatrix} 5 & 12 & 6 \\ -3 & 0 & 14 \end{bmatrix}A=[5−3​120​614​]

Here's how we refer to its elements:

  • The element in the 1st row and 1st column is A11=5A_{11} = 5A11​=5.
  • The element in the 1st row and 3rd column is A13=6A_{13} = 6A13​=6.
  • The element in the 2nd row and 1st column is A21=−3A_{21} = -3A21​=−3.
  • The element in the 2nd row and 2nd column is A22=0A_{22} = 0A22​=0.

Notation AijA_{ij}Aij​ specifies the element at row iii and column jjj.

Indexing: Math vs. Programming

In mathematics and textbooks, indices usually start from 1 (1-based indexing). So, the top-left element is A11A_{11}A11​. However, in many programming languages, including Python and its library NumPy, indexing starts from 0 (0-based indexing).

  • Mathematical Notation: AijA_{ij}Aij​, where iii starts at 1 and jjj starts at 1.
  • NumPy/Python Notation: A[i, j], where i starts at 0 and j starts at 0.

So, the mathematical element A11A_{11}A11​ corresponds to A[0, 0] in NumPy. Similarly, A23A_{23}A23​ corresponds to A[1, 2]. We will primarily use the mathematical notation (AijA_{ij}Aij​) when discussing concepts, but it's essential to remember the 0-based indexing when we start implementing these ideas in Python with NumPy in the hands-on sections.

Summary of Notation

  • Matrices are usually denoted by uppercase letters (e.g., A,B,XA, B, XA,B,X).
  • Elements within a matrix are denoted by the corresponding lowercase letter with subscripts indicating the row and column (e.g., aij,bij,xija_{ij}, b_{ij}, x_{ij}aij​,bij​,xij​) or using the uppercase letter with subscripts (AijA_{ij}Aij​).
  • The dimensions are written as rows ×\times× columns (e.g., m×nm \times nm×n).

Understanding these conventions allows us to precisely communicate about matrices and their components, which is fundamental as we move towards performing operations with them. When we work with NumPy, we'll see how its array structures directly map to these mathematical concepts, using 0-based indexing for practical access.

  • Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares, Stephen Boyd, Lieven Vandenberghe, 2018 (Cambridge University Press) DOI: 10.1017/9781108583664 - A comprehensive text on linear algebra for engineers and scientists, clearly explaining matrix notation and dimensions with practical examples.
  • Introduction to Linear Algebra, Gilbert Strang, 2016 (Wellesley-Cambridge Press) - A standard textbook for linear algebra, providing a rigorous yet accessible introduction to matrix definitions, dimensions, and element indexing.
  • Linear Algebra Review and Background, Andrew Ng, 2022 Stanford University CS229 Lecture Notes - A concise review of essential linear algebra concepts, including matrix definitions and indexing, serving as a prerequisite for machine learning.
  • NumPy indexing, NumPy Developers, 2023 (NumPy Project) - Official documentation detailing 0-based indexing for NumPy arrays, which represent matrices in Python, and contrasts with mathematical 1-based indexing.

© 2026 ApX Machine Learning