Course Content

Mathematics for Data Analysis and Modeling

## Mathematics for Data Analysis and Modeling

# System of Linear Equations

**A system of linear equations (SLE)** is a set of equations where each equation is a linear combination of variables. The goal is to find a solution that satisfies all the equations simultaneously.

## Example

Let's look at the example of a system of linear equations:

We have 3 unknown variables `x`

, `y`

and `z`

and have 3 equations that include all of these variables.

## Solving the system

How can we solve the system? Firstly, let's rewrite it in a matrix form:

Expressing the system of linear equations in matrix form provides us with a straightforward approach for solving the system utilizing the inverse matrix:

To use this approach we have to be sure that matrix A can be inversed:**The square matrix A can be inversed if and only if its determinant is nonzero**.

## Example 1

We have found the solution using the inverted matrix.

## Example 2

The code above produces an error - the matrix is **singular (has zero determinant)** so we can't solve the system of equations.

The explanation for this is quite simple: the matrix rows are **linearly dependent** (the third row is the sum of the first two). As a result, **the third equation doesn't provide any additional information**, and we are left with a system of 3 variables but only 2 unique equations. As a result such a system either have no solutions or there are lots of solutions.

Everything was clear?