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:These systems can be represented as a product of matrices such as the following:
Which can also be represented as:
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.
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:
Where A_j is the original matrix with the j-th row changed with b.
- 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]
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!).
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.