Cramer’s rule : In linear algebra, Cramer’s rule is an explicit formula for the solution of a system of linear equations with as many equations as unknown variables. It expresses the solution in terms of the determinants of the coefficient matrix and of matrices obtained from it by replacing one column by the column vector of right-hand-sides of the equations. Cramer’s rule is computationally inefficient for systems of more than two or three equations.
Suppose we have to solve these equations:
a1x + b1y + c1z = d1
a2x + b2y + c2z = d2
a3x + b3y + c3z = d3
Following the Cramer’s Rule, first find the determinant values of all four matrices.
There are 2 cases:
Case I : When D ≠ 0 In this case we have,
x = D1/D
y = D2/D
z = D3/D
Hence unique value of x, y, z will be obtained.
Case II : When D = 0
(a) When at least one of D1, D2 and D3 is non zero: Then no solution is possible and hence system of equations will be inconsistent.
(b) When D = 0 and D1 = D2 = D3 = 0: Then the system of equations will be consistent and it will have infinitely many solutions.
Consider the following system of linear equations.
[2x – y + 3z = 9], [x + y + z = 6], [x – y + z = 2]
[x = D1/D = 1], [y = D2/D = 2], [z = D3/D = 3]
Below is the implementation.
Output: D is : -2.000000 D1 is : -2.000000 D2 is : -4.000000 D3 is : -6.000000 Value of x is : 1.000000 Value of y is : 2.000000 Value of z is : 3.000000
- Linear Diophantine Equations
- Data Science | Solving Linear Equations
- Gaussian Elimination to Solve Linear Equations
- Data Science - Solving Linear Equations
- Find n-variables from n sum equations with one missing
- Find number of solutions of a linear equation of n variables
- Find the values of X and Y in the Given Equations
- Program for Simpson's 1/3 Rule
- Pair of integers (a, b) which satisfy the given equations
- Number of solutions to Modular Equations
- Program to implement Simpson's 3/8 rule
- Find n positive integers that satisfy the given equations
- Find 'N' number of solutions with the given inequality equations
- Find the repeating and the missing number using two equations
- Trapezoidal Rule for Approximate Value of Definite Integral
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.