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:

[1]

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:

[2]

One of the simplest linear equation that you may recall from high school is:

[3]

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:

[4]

[5]

Here x1 was treated as the independent variable, and x2 as the dependent variable. Here’s the Python code to create this chart:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import matplotlib.pyplot as plt import pandas as pd def linearEquation1(x): return (4 - 3*x)/5 def linearEquation2(x): return (x - 2)/2 myRange = pd.Series(range(-10,10)) plt.plot(myRange,linearEquation1(myRange),c='b') plt.plot(myRange,linearEquation2(myRange),c='r') plt.title("The 2 equations from x1=-10 to x1=10") plt.ylabel("x2") plt.xlabel("x1") plt.show() |

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]:

1 2 3 4 |
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**.

## Matrix Notation

Writing equations like [4] and [5] becomes quickly tedious for bigger systems of linear equations, and so using the matrix notation is beneficial. We can resume the system in [4] and [5] like this:

[6]

Columns 1 and 2 are the coefficients on the left side of the equations [4] and [5], 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.

## Conclusion

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 🙂