### Introduction

This method finds all the solutions of a linear equation system. We define a linear equation system as n sets of equations in the form of:$\sum_{i=1}^{n}a_{ij}x_i=b_j$These systems can be represented as a product of matrices such as the following:

$\begin{bmatrix} 2 & 1 & 3\\ 2 & 6 & 8\\ 6 & 8 & 18 \end{bmatrix} \begin{bmatrix} x_1\\ x_2\\ x_3 \end{bmatrix} = \begin{bmatrix} 1\\ 3\\ 5 \end{bmatrix}$

Which can also be represented as:

$\left\{\begin{matrix} 2x_1+x_2+3x_3=1\\ 2x_1+6x_2+8x_3=3\\ 6x_1+8x_2+18x_3=5 \end{matrix}\right.$

The solutions to this problem are the set of values x1 to xn that satisfy the equations.

An linear equations system is conformed by two parts: a nxn (square) invertible matrix, which contains the coefficients of each equation and a nx1 (column) matrix, which contains the independent terms of each equation.

### Method

Cramer method relies on determinants. A determinant is a numeric value of a matrix, which can be calculed in several ways. More information about determinants, their properties and how to calculate them can be found here.

Cramer’s rule is the following:

$x_j=\frac{|A_j|}{|A|}$

Where A_j is the original matrix with the j-th row changed with b.

### Examples

• A = [7., 2.; -21., -5.], B = [16.; 50.], R = [-25.7; 98.]
• A = [2., -3.; 4., 1.], B = [-2.; 24.], R = [5.; 4.]
• A = [3., -0.1, -0.2; 0.1, 7., -0.3; 0.3, -0.2, 10.], B = [7.85; -19.3; 71.4], R = [3.; -2.5; 7.]
• A = [0.3, 0.52, 1.; 0.5, 1., 1.9; 0.1, 0.3, 0.5], B = [-0.01; 0.67; -0.44], R=[-14.9; -29.5; -19.8]

### Singularities

This method is not an iterative method. Even though it realizes the calculations with iterations, these iterations are defined by the size of the matrix and not by the contents of it. An iterative method realizes unknown iterations, and it stops until it meets an error criteria given. Because of this, an iterative method can diverge. On the other hand, a non-iterative error makes a fixed number of iterations. It can have a terrible complexity, but it is finite. It does not diverge, it does not fail.

Calculating the determinant of a matrix is a really heavy operation. It requires lots of memory and time. Trying to solve big equations systems can become a hard task, since Laplace determinant expansion takes O(n!).

### Conclusions

Cramer method is really easy to understand and to program (given that we have a function to get the determinant of a matrix, since this is not that easy to implement). But, it has its potential only with small systems. Larger systems take larger computational time and space.