# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
256 lines (233 sloc) 11.3 KB
 Inverse of a 2x2 matrix
["A", "B", "C", "D", "E", "F"] rand(6) "\\textbf " + LETTERS[MAT_ID]
2 makeMatrix(randRange(-10, 10, DIM, DIM)) matrixDet(MAT)
randRangeWeighted(-6, 6, 1, 0.3) * randRangeWeighted(-6, 6, 1, 0.3) randRangeWeighted(-6, 6, 1, 0.3) * randRangeWeighted(-6, 6, 1, 0.3) (function() { if (B2 * C2 === 0) { return KhanUtil.shuffle([0, KhanUtil.randRangeNonZero(-6, 6)]); } else { var factor = KhanUtil.shuffle(KhanUtil.getFactors(Math.abs(B2 * C2)))[0]; var a = KhanUtil.randRangeNonZero(-1, 1) * B2 * C2 / factor; var d = B2 * C2 / a; return [a, d]; } })()
makeMatrix([[A2, B2], [C2, D2]]) matrixDet(MAT_2) makeMatrix([["a","b"],["c","d"]]) makeMatrix([["d","-b"],["-c","a"]]) matrixInverse(MAT) matrixPad(SOLN_MAT, 3, 3) printMatrix(function(a) { var frac = toFraction(a); return fractionReduce(frac[0], frac[1], true); }, SOLN_MAT)

PRETTY_MAT_ID = printSimpleMatrix(MAT)

What is PRETTY_MAT_ID^{-1}?

elem elem

Find the determinant:

For any 2 \times 2 matrix printSimpleMatrix(HINT_MAT), the determinant is matrix2x2DetHint(HINT_MAT).

det(PRETTY_MAT_ID) = matrix2x2DetHint(MAT) = \red{DET}

Now that we have both the determinant and the adjugate, we can compute the inverse.

= PRETTY_SOLN_MAT

PRETTY_MAT_ID = printSimpleMatrix(MAT_2)

What is PRETTY_MAT_ID^{-1}?

Find the determinant:

For any 2 \times 2 matrix printSimpleMatrix(HINT_MAT), the determinant is matrix2x2DetHint(HINT_MAT).

det(PRETTY_MAT_ID) = matrix2x2DetHint(MAT_2) = \red{DET_2}

Since \frac{1}{0} is undefined, PRETTY_MAT_ID^{-1} does not exist.

(LETTERS.length + MAT_ID + randRangeNonZero(-1, 1)) % LETTERS.length "\\textbf " + LETTERS[MAT_ID_2] rand(2)

PRETTY_MAT_ID = printSimpleMatrix(MAT)

PRETTY_MAT_ID_2 = printSimpleMatrix(MAT_2)

PRETTY_MAT_ID_2 = printSimpleMatrix(MAT_2)

PRETTY_MAT_ID = printSimpleMatrix(MAT)

Which matrix is invertible? What is its inverse?

Matrix LETTERS[MAT_ID] is invertible.
Its inverse is:
elem elem

A matrix is invertible if its determinant is non-zero.

The determinant of a 2 \times 2 matrix printSimpleMatrix(HINT_MAT), is matrix2x2DetHint(HINT_MAT).

det(PRETTY_MAT_ID) = matrix2x2DetHint(MAT) = \red{DET}

det(PRETTY_MAT_ID_2) = matrix2x2DetHint(MAT_2) = \red{DET_2}

det(PRETTY_MAT_ID_2) = matrix2x2DetHint(MAT_2) = \red{DET_2}

det(PRETTY_MAT_ID) = matrix2x2DetHint(MAT) = \red{DET}

Therefore, only matrix PRETTY_MAT_ID is invertible.