I know that you’re probably interested in machine learning, but did you know that linear algebra is a must to understand many algorithms? To deeply understand and tune them you need to be familiar with what’s under the hood.
In this series of articles on Linear Algebra, I will go through the main concepts so that you understand the fundamentals. To understand these articles you need to be familiar with algebra.
What is a Linear Equation?
A linear equation is simply an equation of the following form:
I chose the coefficients randomly, so they could have been any real or complex numbers.
The following equation is not linear because of the square root:
One of the simplest linear equation that you may recall from high school is:
A linear equation in this context is similar, but can take more than 2 xs.
A System of Linear Equations
Now imagine two linear equations using the same variables. For example:
Here x1 was treated as the independent variable, and x2 as the dependent variable. Here’s the Python code to create this chart:
import matplotlib.pyplot as plt
import pandas as pd
return (4 - 3*x)/5
return (x - 2)/2
myRange = pd.Series(range(-10,10))
plt.title("The 2 equations from x1=-10 to x1=10")
Multiple linear equations who share the same variables is called a System of linear equations.
When having multiple linear equations it’s possible to find some values of xs that make all the equations true. For example, in the example above a solution is [ 0.90909091, 1.27272727]:
import numpy as np
a = np.array([[3,1], [5,-2]])
b = np.array([4,2])
x = np.linalg.solve(a, b)
In this case there is a unique solution, but a System of linear equations can also have no solution, or an infinity of solutions. The set of all solutions is called the Solution Set.
Formally, we call a system with no solution incompatible, and a system with at least one solution compatible.
Writing equations like  and  becomes quickly tedious for bigger systems of linear equations, and so using the matrix notation is beneficial. We can resume the system in  and  like this:
Columns 1 and 2 are the coefficients on the left side of the equations  and , and the last column is the coefficients of the right side.
We can also look at the size of a matrix, which in this case is a 2 by 3 matrix. The first number is always the number of rows, and the second one is the number of columns.
Here’s what you should remember:
- Multiple linear equations sharing the same variables are called a System of linear equations.
- A system of linear equations can have no solution, one solution, of an infinity of solutions.
- The matrix notation is beneficial for larger system of linear equations and also to perform calculations that we will see in future articles.
If you like that article and want more content like this please share it 🙂