Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

182 lines (172 sloc) 7.414 kB
<!DOCTYPE html>
<html data-require="math kmatrix matrix-input subhints">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Inverse of a 3x3 matrix</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<div data-ensure="DET !== 0">
<var id="DIM">3</var>
<var id="HINT_MAT">
makeMatrix([["a","b","c"],["d","e","f"],["g","h","i"]])
</var>
<var id="MAT">makeMatrix(randRange(0, 2, DIM, DIM))</var>
<var id="DET">matrixDet(MAT)</var>
<var id="MAT_MINORS">matrixMinors(MAT)</var>
<var id="MAT_MINORS_DET">
matrixMap(function(elem) {
return matrixDet(elem);
}, MAT_MINORS)
</var>
<var id="MAT_MINORS_DET_SIGNS">
matrixMap(function(elem, row, col) {
var sign = (row + col) % 2 ? -1 : 1;
return sign * elem;
}, MAT_MINORS_DET)
</var>
<var id="MAT_MINORS_FORMAT">
printSimpleMatrix(matrixMap(function(elem) {
return printSimpleMatrixDet(elem);
},
MAT_MINORS))
</var>
<var id="MAT_ADJ">
matrixTranspose(MAT_MINORS_DET_SIGNS)
</var>
</div>
<var id="SOLN_MAT">matrixInverse(MAT)</var>
<var id="PADDED_SOLN_MAT">matrixPad(SOLN_MAT, 3, 3)</var>
<var id="PRETTY_SOLN_MAT">
printMatrix(function(a) {
var sign = (a &lt; 0) ? "-" : "";
var frac = toFraction(abs(a));
// omit denominator when it's equal to 1
if (frac[1] === 1) {
return sign + frac[0];
}
return sign + "\\frac{" + frac[0] + "}{" + frac[1] + "}";
}, SOLN_MAT)
</var>
<var id="PRETTY_MAT_ID">"\\textbf " + randFromArray("ABCDEF")</var>
</div>
<div class="problems">
<div>
<div class="problem">
<p>
<code><var>PRETTY_MAT_ID</var> = <var>printSimpleMatrix(MAT)</var></code>
</p>
</div>
<p class="question">
What is <code><var>PRETTY_MAT_ID</var>^{-1}</code>?
</p>
<div class="solution" data-type="multiple">
<div class="matrix-row" data-each="PADDED_SOLN_MAT as row">
<span data-each="row as elem">
<span class="sol" data-if="elem !== ''" data-simplify="optional">
<var>elem</var>
</span>
<span class="sol" data-else="" data-type="text">
<var>elem</var>
</span>
</span>
</div>
</div>
<div class="hints">
<div>
<p>The inverse of a matrix is equal to the adjugate of the matrix divided by the determinant of the matrix.</p>
<code>
<var>PRETTY_MAT_ID</var>^{-1} = \frac{1}{det(<var>PRETTY_MAT_ID</var>)}adj(<var>PRETTY_MAT_ID</var>)
</code>
</div>
<div>
<p><b>Step 1: Find the adjugate</b></p>
<p>First, compute the matrix of minors of <code><var>PRETTY_MAT_ID</var></code>.</p>
<code>
<var>MAT_MINORS_FORMAT</var>
= <var>printSimpleMatrix(MAT_MINORS_DET)</var>
</code>
</div>
<div>
<p>Next, multiply the elements of the matrix of minors by the following pattern:
</p>
<code><var>
printSimpleMatrix([["+","-","+"],["-","+","-"],["+","-","+"]])
</var></code>
<p>This gives us what is called the matrix of cofactors:</p>
<code>
<var>printSimpleMatrix(MAT_MINORS_DET_SIGNS)</var>
</code>
</div>
<div>
<p>Next, transpose the matrix of cofactors to get the adjugate.</p>
<code>
adj(<var>PRETTY_MAT_ID</var>) =
<var>printSimpleMatrix(MAT_MINORS_DET_SIGNS)</var>^T =
<var>printSimpleMatrix(MAT_ADJ, KhanUtil.BLUE)</var>
</code>
</div>
<div>
<p><b>Step 2: Find the determinant</b></p>
<p>Compute the determinant of the original matrix. [<a href="#" class="show-subhint" data-subhint="determinant">Show me how</a>]</p>
<div class="subhint" id="determinant">
<p>The determinant of any 3x3 matrix can be computed the following way:</p>
<p>
<code>
<var>printSimpleMatrixDet(HINT_MAT)</var>
= <var>matrix3x3DetHint(HINT_MAT, true)</var>
</code>
</p>
<p>
<code>
= <var>matrix3x3DetHint(HINT_MAT)</var>
</code>
</p>
<p>In this specific case,</p>
<p>
<code>
<var>printSimpleMatrixDet(MAT)</var>
= <var>matrix3x3DetHint(MAT, true)</var>
</code>
</p>
<p>
<code>
= <var>matrix3x3DetHint(MAT)</var>
</code>
</p>
<p>
<code>
= <var>DET</var>
</code>
</p>
</div>
<p>
<code>
det(<var>PRETTY_MAT_ID</var>) =
<var>printSimpleMatrixDet(MAT)</var>=
<var>expr(["color", KhanUtil.RED, DET])</var>
</code>
</p>
</div>
<div>
<p><b>Step 3: Put it all together</b></p>
<p>Now that we have both the determinant and the adjugate, we can compute the inverse.</p>
<code>
<var>PRETTY_MAT_ID</var>^{-1} =
\frac{1}{<var>expr(["color", KhanUtil.RED, DET])</var>}
<var>printSimpleMatrix(MAT_ADJ, KhanUtil.BLUE)</var>
</code>
</div>
<div>
<p>
<code> = <var>PRETTY_SOLN_MAT</var></code>
</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.