Opening the book…
Let \(Ax=b\) be a system of \(n\) linear equations in \(n\) variables such that \(|A| \neq 0\). The system has a unique solution given by:
\[x_1 = \frac{|A_1|}{|A|}, x_2 = \frac{|A_2|}{|A|}, \ldots, x_n = \frac{|A_n|}{|A|} \nonumber \]
where \(A_i\) is the matrix obtained by replacing column \(i\) of \(A\) with \(b\). The following function generates \(A_i\) by replacing the \(i\)th column of \(A\) with \(b\):
Create a new function called cramersRule, which takes \(A\) and \(b\) and returns \(x\) using the Cramer’s rule.
Note: Use numpy and NOT mydet to find the required determinants. mydet is too slow.
Test your cramersRule function on the following system of linear equations:
\[ x_1 + 2x_2 = 3 \nonumber \]
\[3x_1 + x_2 = -1 \nonumber \]
Verify the above answer by using the np.linalg.solve function:
Test your cramersRule function on the following system of linear equations and verify the answer by using the np.linalg.solve function:
\[ x_1 + 2x_2 +x_3 = 9 \nonumber \]
\[ x_1 + 3x_2 - x_3 = 4 \nonumber \]
\[ x_1 + 4x_2 - x_3 = 7 \nonumber \]
Cramer’s rule is a \(O(n!)\) algorithm and the Gauss-Jordan (or Gaussian) elimination is \(O(n^3)\). What advantages does Cramer’s rule have over elimination?
This page titled 18.3: Using Cramer’s rule to solve Ax=b was last modified on Sat, 17 Sep 2022 15:14:32 GMT and is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform.
The book could not be loaded just now.