// Numbas version: exam_results_page_options {"name": "14: Matrices - Basic Operations", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"rulesets": {}, "variablesTest": {"maxRuns": "100", "condition": "det(a) <> 0 and det(b) <> 0 and a[0][1] <> a[1][0]"}, "ungrouped_variables": ["a", "b", "c", "d"], "functions": {"inverse": {"type": "matrix", "language": "jme", "definition": "matrix([mat[1][1],-mat[0][1]],[-mat[1][0],mat[0][0]])/det(mat)", "parameters": [["mat", "matrix"]]}}, "metadata": {"licence": "All rights reserved", "description": "
Perform basic operations with 2x2 matrices - addition, subtraction, multiplication by scalar, matrix multiplication, determinant, transpose
"}, "statement": "The following questions use the matrices below.
\n$A = \\left( \\begin{array}{cc}\\var{a[0][0]} & \\var{a[0][1]}\\\\\\var{a[1][0]} & \\var{a[1][1]}\\end{array} \\right)$, $B =\\left( \\begin{array}{cc}\\var{b[0][0]} & \\var{b[0][1]}\\\\\\var{b[1][0]} & \\var{b[1][1]}\\end{array} \\right)$, $C =\\left( \\begin{array}{cc}\\var{c[0][0]} & \\var{c[0][1]}\\\\\\var{c[1][0]} & \\var{c[1][1]}\\end{array} \\right)$, $D = \\left( \\begin{array}{cc}\\var{d[0][0]} & \\var{d[0][1]}\\\\\\var{d[1][0]} & \\var{d[1][1]}\\end{array} \\right)$
\n\nMake sure to read through the explanation in the advice section at the bottom of the page after revealing the answers if you have any difficulties with these questions.
", "advice": "An n x m matrix has n rows and m columns.
\na) Matrix addition is the 'slotwise' addition of each element in the two matrices, i.e. every element which is in the same location in the matrix is added together. It requires that both matrices are of the same size. For example,
\n$\\left( \\begin{array}{ccc}3 & 2 & 2\\\\4 & 2& 0\\\\1 & 0 & 1\\end{array} \\right) + \\left( \\begin{array}{ccc}2 & 1 & 0\\\\7 & -3& 7\\\\-2 & 4 & 1\\end{array} \\right) = \\left( \\begin{array}{ccc}3 + 2& 2 +1& 2+0\\\\4+7 & 2-3& 0+7\\\\1-2 & 0+4 & 1+1\\end{array} \\right)=\\left( \\begin{array}{ccc}5 & 3 & 2\\\\11 & -1& 7\\\\-1 & 4 & 2\\end{array} \\right)$.
\nThis is a commutative operation (order doesn't matter).
\nScalar multiplication of a matrix is achieved by multiplying each element in the matrix by the scalar indivudually. For example,
\n$3\\times\\left( \\begin{array}{cc}1 & -1\\\\3 & 0\\end{array} \\right) =\\left( \\begin{array}{cc}3 & -3 \\\\12 &0\\end{array} \\right)$
\n
This is again a commutative operation (order doesn't matter), since it boils down to slotwise multiplication, and multiplication of two numbers is a commutative operation.
b) Matrix multiplication is not quite as simple. It is a non-commutative operation, so the order matters. We can only multiply two matrices if the number of columns in the first matrix is the same as the number of rows in the second matrix. The dimension of the resulting matrix will be (no. rows in first matrix) x (no. columns in second matrix). For example, if we have a 2x4 matrix, $A$, and a 4x3 matrix, $B$, then $AB$ has dimension 2x3, i.e. 2 rows and 3 columns.
\nThe process of matrix multiplication is as follows:
\nHere is an example of matrix multiplication of a 2x3 matrix and a 3x2 matrix. The resulting matrix is 2x2 as explained above.
\n$\\left( \\begin{array}{ccc}2 & 4 & 3\\\\1 & -1 & 2\\end{array}\\right) \\times \\left(\\begin{array}{cc}1 & 4\\\\-2 & 0\\\\3 & -1\\end{array}\\right) = \\left(\\begin{array}{cc}3 & 5\\\\9 & 2\\end{array}\\right)$
\nHere is an expanded form of the element in the second row and first column of the answer matrix: $9 = (1\\times1) + (-1\\times-2) + (2\\times3) = 1 + 2 + 6$. The first number in each bracket is taken from the second row of the first matrix, going left to right, and the second number is taken from the first column of the second matrix, going top to bottom. Check that you understand this process by finding the expanded form of the other 3 elements of the 2x2 answer matrix.
\nIt is obvious that for two non-square matrices that we are allowed to multiply together, the operation of matrix multiplication is non-commutative, since the dimension of the answer matrix will be different in each case. For two square matrices of the same dimension, in general, $AB \\neq BA$, so it is non-commutative. However, sometimes we find matrices which do commute. For example, the identity matrix, $I_n$, which is an nxn square matrix consisting of zeros with ones along the diagonal from top left to bottom right, commutes with all other matrices. Always assume that we cannot switch around the order of matrix multiplication unless we know for certain that we have two matrices which commute with each other, e.g. any nxn matrix and the nxn identity matrix, $I_n$, or an (invertible) matrix and its inverse.
\nc) We usually label the elements in a matrix with lowercase letters. For example, we write a general 2x2 matrix, $M$, as $M = \\left(\\begin{array}{cc}a&b\\\\c&d\\end{array}\\right)$. The determinant of a 2x2 matrix, $M$, denoted $det(M)$ or $\\begin{vmatrix}M\\end{vmatrix}$, is $det(M) = ad - bc$. For example,
\n$\\begin{vmatrix}\\left(\\begin{array}{cc}3&5\\\\-2&1\\end{array}\\right)\\end{vmatrix} = 3\\times 1 - (5 \\times -2) = 3 -(-10) = 13$
\nd) To transpose a matrix we switch its rows and columns. For example,
\n$\\left(\\begin{array}{ccc}a & b & c\\\\d& e & f\\end{array}\\right)^\\textbf{T} = \\left(\\begin{array}{cc}a &d\\\\b&e\\\\c&f\\end{array}\\right)$
\nWe can see that the first row becomes the first column and so on. We could also think of this as the first column becoming the first row and so on.
\n\nWe can only find the inverse of a square matrix which has a non-zero determinant. For a 2x2 matrix, we use this formula to calculate the inverse of a matrix:
\n$M^{-1} = \\left(\\begin{array}{cc}a & b\\\\c&d\\end{array}\\right)^{-1} = \\dfrac{1}{\\begin{vmatrix}M\\end{vmatrix}}\\left(\\begin{array}{cc}d & -b\\\\-c & a\\end{array}\\right)$
\nYou might wish to check that this is correct by multiplying $M$ and $M^{-1}$ both ways around to check that you get the 2x2 identity matrix, $I_2$.
\n", "preamble": {"css": "", "js": ""}, "parts": [{"type": "gapfill", "scripts": {}, "gaps": [{"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "a+b", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "a-b", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "c+d", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "scalarCoeff[0]*a", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "scalarCoeff[1]*a + scalarCoeff[2]*b", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "scalarCoeff[3]*d", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "prompt": "Find the following using matrix addition/subtraction and scalar multiplication:
\ni) $A + B = $ [[0]]
\nii) $A - B = $ [[1]]
\niii) $C + D =$ [[2]]
\niv) $\\simplify{{scalarCoeff[0]}A}=$ [[3]]
\nv) $\\simplify{{scalarCoeff[1]}A + {scalarCoeff[2]}B} =$ [[4]]
\nvi) $\\simplify{{scalarCoeff[3]}D} = $ [[5]]
\n", "variableReplacements": [], "marks": 0}, {"type": "gapfill", "scripts": {}, "gaps": [{"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "a*b", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "b*c", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "c*d", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "d*c", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "prompt": "$A = \\left( \\begin{array}{cc}\\var{a[0][0]} & \\var{a[0][1]}\\\\\\var{a[1][0]} & \\var{a[1][1]}\\end{array} \\right)$, $B =\\left( \\begin{array}{cc}\\var{b[0][0]} & \\var{b[0][1]}\\\\\\var{b[1][0]} & \\var{b[1][1]}\\end{array} \\right)$, $C =\\left( \\begin{array}{cc}\\var{c[0][0]} & \\var{c[0][1]}\\\\\\var{c[1][0]} & \\var{c[1][1]}\\end{array} \\right)$, $D = \\left( \\begin{array}{cc}\\var{d[0][0]} & \\var{d[0][1]}\\\\\\var{d[1][0]} & \\var{d[1][1]}\\end{array} \\right)$
\nFind the following using matrix multiplication:
\ni) $AB =$ [[0]]
\nii $BC =$ [[1]]
\niii) $CD =$ [[2]]
\niv) $DC =$ [[3]]
", "variableReplacements": [], "marks": 0}, {"type": "gapfill", "scripts": {}, "gaps": [{"type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": false, "maxValue": "det(a)", "allowFractions": false, "variableReplacementStrategy": "originalfirst", "minValue": "det(a)", "scripts": {}, "showPrecisionHint": false, "variableReplacements": [], "marks": 1}, {"type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": false, "maxValue": "det(b)", "allowFractions": false, "variableReplacementStrategy": "originalfirst", "minValue": "det(b)", "scripts": {}, "showPrecisionHint": false, "variableReplacements": [], "marks": 1}, {"type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": false, "maxValue": "det(c)", "allowFractions": false, "variableReplacementStrategy": "originalfirst", "minValue": "det(c)", "scripts": {}, "showPrecisionHint": false, "variableReplacements": [], "marks": 1}, {"type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": false, "maxValue": "det(d)", "allowFractions": false, "variableReplacementStrategy": "originalfirst", "minValue": "det(d)", "scripts": {}, "showPrecisionHint": false, "variableReplacements": [], "marks": 1}], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "prompt": "$A = \\left( \\begin{array}{cc}\\var{a[0][0]} & \\var{a[0][1]}\\\\\\var{a[1][0]} & \\var{a[1][1]}\\end{array} \\right)$, $B =\\left( \\begin{array}{cc}\\var{b[0][0]} & \\var{b[0][1]}\\\\\\var{b[1][0]} & \\var{b[1][1]}\\end{array} \\right)$, $C =\\left( \\begin{array}{cc}\\var{c[0][0]} & \\var{c[0][1]}\\\\\\var{c[1][0]} & \\var{c[1][1]}\\end{array} \\right)$, $D = \\left( \\begin{array}{cc}\\var{d[0][0]} & \\var{d[0][1]}\\\\\\var{d[1][0]} & \\var{d[1][1]}\\end{array} \\right)$
\n$\\begin{vmatrix}M\\end{vmatrix}$ is another way of writing $det(M)$.
\nFind the following determinants:
\ni) $\\begin{vmatrix}A\\end{vmatrix} = $ [[0]]
\nii) $\\begin{vmatrix}B\\end{vmatrix} = $ [[1]]
\n\niii) $\\begin{vmatrix}C\\end{vmatrix} = $ [[2]]
\n\niv) $\\begin{vmatrix}D\\end{vmatrix} = $ [[3]]
\n", "variableReplacements": [], "marks": 0}, {"type": "gapfill", "scripts": {}, "gaps": [{"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "transpose(a)", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}, {"numColumns": "2", "allowResize": false, "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": true, "precisionPartialCredit": 0, "numRows": "2", "type": "matrix", "correctAnswerFractions": false, "marks": 1, "tolerance": 0, "precisionType": "dp", "scripts": {}, "markPerCell": false, "strictPrecision": false, "correctAnswer": "inverse(a)", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "precision": "3"}, {"numColumns": "2", "allowResize": false, "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": true, "precisionPartialCredit": 0, "numRows": "2", "type": "matrix", "correctAnswerFractions": false, "marks": 1, "tolerance": 0, "precisionType": "dp", "scripts": {}, "markPerCell": false, "strictPrecision": false, "correctAnswer": "inverse(b)", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "precision": "3"}, {"numColumns": "2", "allowResize": false, "allowFractions": false, "numRows": "2", "marks": 1, "tolerance": 0, "type": "matrix", "scripts": {}, "markPerCell": false, "correctAnswer": "matrix([1,0],[0,1])", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFractions": false}], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "prompt": "$A = \\left( \\begin{array}{cc}\\var{a[0][0]} & \\var{a[0][1]}\\\\\\var{a[1][0]} & \\var{a[1][1]}\\end{array} \\right)$, $B =\\left( \\begin{array}{cc}\\var{b[0][0]} & \\var{b[0][1]}\\\\\\var{b[1][0]} & \\var{b[1][1]}\\end{array} \\right)$, $C =\\left( \\begin{array}{cc}\\var{c[0][0]} & \\var{c[0][1]}\\\\\\var{c[1][0]} & \\var{c[1][1]}\\end{array} \\right)$, $D = \\left( \\begin{array}{cc}\\var{d[0][0]} & \\var{d[0][1]}\\\\\\var{d[1][0]} & \\var{d[1][1]}\\end{array} \\right)$
\n$A^\\textbf{T}$ is the transpose of $A$ and $A^{-1}$ is the inverse of $A$.
\nFind the following: (give your answers to 3 decimal places where applicable)
\ni) $A^\\textbf{T} =$ [[0]]
\nii) $A^{-1} =$ [[1]]
\niii) $B^{-1} =$ [[2]]
\niv) $A\\space A^{-1}$ [[3]]
", "variableReplacements": [], "marks": 0}], "variables": {"d": {"group": "Ungrouped variables", "name": "d", "definition": "matrix(repeat(repeat(random(-5..5),2),2))", "templateType": "anything", "description": ""}, "b": {"group": "Ungrouped variables", "name": "b", "definition": "matrix(repeat(repeat(random(-5..5),2),2))", "templateType": "anything", "description": ""}, "scalarCoeff": {"group": "Part a)", "name": "scalarCoeff", "definition": "repeat(random(-5..5 except 0..1),4)", "templateType": "anything", "description": ""}, "a": {"group": "Ungrouped variables", "name": "a", "definition": "matrix(repeat(repeat(random(-5..5),2),2))", "templateType": "anything", "description": ""}, "c": {"group": "Ungrouped variables", "name": "c", "definition": "matrix(repeat(repeat(random(-5..5),2),2))", "templateType": "anything", "description": ""}}, "extensions": [], "tags": [], "name": "14: Matrices - Basic Operations", "type": "question", "variable_groups": [{"name": "Part a)", "variables": ["scalarCoeff"]}], "showQuestionGroupNames": false, "question_groups": [{"pickingStrategy": "all-ordered", "name": "", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "John Hodkinson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/921/"}]}]}], "contributors": [{"name": "John Hodkinson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/921/"}]}