Overview:
This part is a linear algebra refresher. There are different operations you need to understand for ML. Actually, you don’t really need to know that if you know what you’re doing in the code. However, a basic understanding can’t do any harm at this point.
Because this article has become quite long, I decided to split it into three articles. The first part of the refresher covers simple vector operations. The second part is about vector vector multiplication, matrix vector multiplication and matrix matrix multiplication. The third part is about special matrices.
Linear algebra refresher – Part 1/3
The first part covers simple vector operations.
Simple vector operations
Scalar vector product
The scalar vector product, also known as scalar multiplication, is a fundamental operation in linear algebra. It involves multiplying a scalar (a single number) by each component of a vector.
To perform a scalar vector product, you simply multiply the scalar by each element of the vector separately. For example, if we have a scalar c and a vector v, the scalar vector product is denoted as c * v and is calculated as:
c * v = (c * v₁, c * v₂, c * v₃, ..., c * vₙ)
where v₁, v₂, ... vₙ are the individual components of the vector v.

This operation is useful in various mathematical and computational applications. It can be used to scale vectors, change their direction, or perform transformations in vector spaces. Additionally, scalar vector products play a significant role in linear combinations, linear transformations, and eigenvector calculations.
Understanding the scalar vector product is essential for grasping more advanced concepts in linear algebra and machine learning. It’s a fundamental building block that forms the basis for more complex mathematical operations and algorithms.
Implementation in Python
import numpy as np
u = np.array([2, 4, 5, 6])
2 * u
# Output: array([4, 8, 10, 12])
Vector vector addition
Vector vector addition is another important operation in linear algebra. It involves adding two vectors together to obtain a new vector.
To perform vector vector addition, you simply add corresponding components of the vectors. For example, if we have two vectors u and v, the vector vector addition is denoted as u + v and is calculated as:
u + v = (u₁ + v₁, u₂ + v₂, u₃ + v₃, …, uₙ + vₙ)
where u₁, u₂, ... uₙ and v₁, v₂, ... vₙ are the individual components of the vectors u and v respectively.

Vector vector addition is a fundamental operation in various mathematical and computational applications. It can be used to combine the effects of multiple vectors, calculate displacement or velocity, and solve systems of linear equations.
Understanding vector vector addition is crucial for working with vector spaces, linear transformations, and solving problems in machine learning. It provides a basis for more complex operations and algorithms that involve manipulating vectors.
By comprehending both the scalar vector product and vector vector addition, you will have a solid foundation in linear algebra, enabling you to tackle more advanced topics in machine learning with confidence. These operations serve as the building blocks for many mathematical concepts and computational techniques used in the field.
Remember, even though a deep understanding of linear algebra may not be required for implementing machine learning algorithms directly, having a basic understanding can greatly enhance your ability to interpret and optimize these algorithms for better performance and results.
Implementation in Python
import numpy as np
u = np.array([2, 4, 5, 6])
v = np.array([1, 0, 0, 2])
u + v
# Output: array([3, 4, 5, 8])