// Numbas version: finer_feedback_settings {"name": "Inverting a 3x3 Matrix", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Inverting a 3x3 Matrix", "tags": [], "metadata": {"description": "
Semi-worked example of inverting a 3x3 matrix using cofactor, adjoint and determinant.
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "There are a number of ways to find the inverse of a 3x3 matrix. This worked exercise will cover the adjoint method.
\n\nTo find the inverse of a matrix using the adjoint method we use the following steps:
\nConsider matrix $A$ below:
\n$A=\\var{ma}$
", "advice": "", "rulesets": {}, "extensions": [], "variables": {"ma": {"name": "ma", "group": "Ungrouped variables", "definition": "matrixRandomInvertable(matrixrandom(3,3))", "description": "", "templateType": "anything"}, "det_ma": {"name": "det_ma", "group": "Ungrouped variables", "definition": "det(ma)", "description": "", "templateType": "anything"}, "cofm": {"name": "cofm", "group": "Ungrouped variables", "definition": "cof(ma)", "description": "", "templateType": "anything"}, "cofn": {"name": "cofn", "group": "Ungrouped variables", "definition": "matrix(\n [cofm[0][0],-cofm[0][1],cofm[0][1]],\n [-cofm[1][0],cofm[1][1],-cofm[1][1]],\n [cofm[2][0],-cofm[2][1],cofm[2][1]]\n)", "description": "cofactor elements before sign rule applied
", "templateType": "anything"}}, "variablesTest": {"condition": "det_ma<>0", "maxRuns": 100}, "ungrouped_variables": ["ma", "det_ma", "cofm", "cofn"], "variable_groups": [], "functions": {"matrixrandom": {"parameters": [["rows", "integer"], ["columns", "integer"]], "type": "matrix", "language": "jme", "definition": "matrix(repeat(repeat(random(0..9)*(random(1,1,1,-1)),columns),rows))"}, "matrixRandomInvertable": {"parameters": [["ma", "matrix"]], "type": "matrix", "language": "jme", "definition": "if(det(ma)<>0,ma,\n matrixRandomInvertable(\n matrix(repeat(repeat(random(0..9)*(random(1,1,1,-1)),numcolumns(ma)),numrows(ma)))\n )\n)"}, "cof": {"parameters": [["m", "matrix"]], "type": "matrix", "language": "jme", "definition": "matrix([\n [m[1][1]*m[2][2]-m[2][1]*m[1][2], -(m[1][0]*m[2][2]-m[2][0]*m[1][2]), m[1][0]*m[2][1]-m[2][0]*m[1][1]],\n [-(m[0][1]*m[2][2]-m[2][1]*m[0][2]), m[0][0]*m[2][2]-m[2][0]*m[0][2], -(m[0][0]*m[2][1]-m[2][0]*m[0][1])],\n [m[0][1]*m[1][2]-m[1][1]*m[0][2], -(m[0][0]*m[1][2]-m[1][0]*m[0][2]), m[0][0]*m[1][1]-m[1][0]*m[0][1]]\n])"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": true, "customName": "Step 1: Determinant", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "First we calculate the determinant of matrix $A$.
", "stepsPenalty": 0, "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "To find the determinant of a 3x3 matrix, we find the sum of the products of the leading diagonals, and subract the sum of the products of the non-leading diagonals. For example, if we had the following matrix:
\n$\\begin{pmatrix}
a & b & c \\\\
d & e & f \\\\
g & h & i \\\\
\\end{pmatrix}$ the deteminat would be calculate as: $(aei + bfg + cdh) - (ceg + bdi + afh)$
Second, we calculate the nine cofactors of matrix $A$:
\n$A _{11}$ cofactor in position 1,1 is [[0]]
\n$A_{12}$ cofactor in position 1,2 is [[1]]
\n$A_{13}$ cofactor in position 1,3 is [[2]]
\n$A_{21}$ cofactor in position 2,1 is [[3]]
\n$A_{22}$ cofactor in position 2,2 is [[4]]
\n$A_{23}$ cofactor in position 2,3 is [[5]]
\n$A_{31}$ cofactor in position 3,1 is [[6]]
\n$A_{32}$ cofactor in position 3,2 is [[7]]
\n$A_{33}$ cofactor in position 3,3 is [[8]]
", "stepsPenalty": 0, "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "We know that the cofactor matrix will be a 3x3 matrix as $A$ is a 3x3 matrix. Therefore we will be calculating 9 individual cofactors. To calculate the cofactors we eliminate the elements in the row and column containing the element. We then calculate the determinant from the remaining elements.
\n\nConsdier the matrix $B = \\begin{pmatrix}
a & b & c \\\\
d & e & f \\\\
g & h & i \\\\
\\end{pmatrix}$
To calculate the first cofactor element $B_{11}$ we eleminate $a$, $b$ and $c$, and $a$ (again), $d$ and $g$. This leaves us with the matrix $\\begin{pmatrix}e & f\\\\ h & i \\end{pmatrix}$. We find the determinant of this matrix. Therefore:
\n$B_{11} = (e \\times i) - (f \\times h)$
$B_{12} = (d \\times i) - (f \\times g)$
$B_{13} = (d \\times h) - (e \\times g)$
and so on...
\n\n$A = \\simplify{{ma}}$
"}, {"type": "numberentry", "useCustomName": true, "customName": "First element", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "So $A_{11} = (\\var{ma[1][1]}\\times\\var{ma[2][2]}) - (\\var{ma[1][2]}\\times\\var{ma[2][1]}) = $?
", "minValue": "cofm[0][0]", "maxValue": "cofm[0][0]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Second element", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "So $A_{12} = (\\var{ma[1][0]}\\times\\var{ma[2][2]}) - (\\var{ma[1][2]}\\times\\var{ma[2][0]}) = $?
", "minValue": "cofm[0][1]", "maxValue": "cofm[0][1]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Third element", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "So $A_{13} = (\\var{ma[1][0]}\\times\\var{ma[2][1]}) - (\\var{ma[1][1]}\\times\\var{ma[2][0]}) = $?
", "minValue": "cofm[0][2]", "maxValue": "cofm[0][2]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "And so on...
"}], "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "cofm[0][0]", "maxValue": "cofm[0][0]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-cofm[0][1]", "maxValue": "-cofm[0][1]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "cofm[0][2]", "maxValue": "cofm[0][2]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-cofm[1][0]", "maxValue": "-cofm[1][0]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "cofm[1][1]", "maxValue": "cofm[1][1]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-cofm[1][2]", "maxValue": "-cofm[1][2]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "cofm[2][0]", "maxValue": "cofm[2][0]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-cofm[2][1]", "maxValue": "-cofm[2][1]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "cofm[2][2]", "maxValue": "cofm[2][2]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "matrix", "useCustomName": true, "customName": "Step 2b: Cofactor matrix", "marks": "5", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Next, place the cofactor elements in a matrix and apply the signs rule to find the cofactor matrix.
", "stepsPenalty": 0, "steps": [{"type": "matrix", "useCustomName": true, "customName": "Place elements", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Place the cofactor elelments into a matrix, such that $\\begin{pmatrix}
a_{11} & a_{12} & a_{13} \\\\
a_{21} & a_{22} & a_{33} \\\\
a_{31} & a_{32} & a_{33}
\\end{pmatrix}$
Next, apply the signs rule: Some signs will stay the same(s), and some signs need to be changed(c) using the following pattern: $\\begin{pmatrix}
s & c & s \\\\
c & s & c \\\\
s & c & s
\\end{pmatrix}$.
(Essentially, change every other element)
", "correctAnswer": "cofm", "correctAnswerFractions": false, "numRows": "3", "numColumns": "3", "allowResize": false, "tolerance": 0, "markPerCell": false, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}], "correctAnswer": "cofm", "correctAnswerFractions": false, "numRows": "3", "numColumns": "3", "allowResize": false, "tolerance": 0, "markPerCell": true, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}, {"type": "matrix", "useCustomName": true, "customName": "Step 3: Adjoint matrix", "marks": "1", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Now, transpose the cofactor matrix to find the adjoint matrix.
", "stepsPenalty": 0, "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "To find the adjoint matrix, all we have to do is transpose the cofactor matrix. To find the transpose of a matrix, the rows in the matrix become the columns in the new, tranposed matrix.
\nIf we had the matrix $\\begin{pmatrix}
a & b & c \\\\
d & e & f \\\\
g & h & i \\\\
\\end{pmatrix}$, the transposed matrix would be $\\begin{pmatrix}
a & d & g \\\\
b & e & h \\\\
c & f & i \\\\
\\end{pmatrix}$
Lastly, we perform a scalar multiplication of $\\dfrac{1}{\\text{determinant}} \\times \\text{adjoint matrix}$
\n\n(Enter answers as fractions.)
", "stepsPenalty": 0, "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "This is the same as dividing every element by the determinant.
"}], "correctAnswer": "transpose(cofm)/det(ma)", "correctAnswerFractions": true, "numRows": "3", "numColumns": "3", "allowResize": false, "tolerance": 0, "markPerCell": false, "allowFractions": true, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Mark Patterson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5064/"}]}]}], "contributors": [{"name": "Mark Patterson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5064/"}]}