// Numbas version: finer_feedback_settings {"name": "Matrix Multiplication", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Matrix Multiplication", "tags": [], "metadata": {"description": "

Multiplication of two matrices.

", "licence": "Creative Commons Attribution-NonCommercial 4.0 International"}, "statement": "

Matrix Multiplication

\n

Given two matrices:

\n

$$
\\boldsymbol{A}=\\begin{pmatrix} \\var{a11}&\\var{a12}&\\var{a13}\\\\ \\var{a21}&\\var{a22}&\\var{a23}\\\\ \\end{pmatrix} ,\\boldsymbol{B}=\\begin{pmatrix} \\var{b11}&\\var{b12}\\\\ \\var{b21}&\\var{b22}\\\\ \\var{b31}&\\var{b32}\\\\\\end{pmatrix}
$$

\n

Calculate the following matrix multiplications.

\n

", "advice": "

Remember multiplication of matrices is carried out by multiplying the rows of the first matrix by the columns of the second matrix

\n

a)

\n

$$
\\begin{aligned}
\\boldsymbol{A}\\boldsymbol{B} &= \\begin{pmatrix} \\var{a11}&\\var{a12}&\\var{a13}\\\\ \\var{a21}&\\var{a22}&\\var{a23} \\end{pmatrix}\\begin{pmatrix} \\var{b11}&\\var{b12}\\\\ \\var{b21}&\\var{b22} \\\\ \\var{b31}&\\var{b32}\\end{pmatrix} \\\\
&= \\begin{pmatrix}\\var{a11}\\times\\var{b11}+\\var{a12}\\times\\var{b21}+\\var{a13}\\times\\var{b31}&\\var{a11}\\times\\var{b12}+\\var{a12}\\times\\var{b22}+\\var{a13}\\times\\var{b32} \\\\ \\var{a21}\\times\\var{b11}+\\var{a22}\\times\\var{b21}+\\var{a23}\\times\\var{b31}&\\var{a21}\\times\\var{b12}+\\var{a22}\\times\\var{b22}+\\var{a23}\\times\\var{b32}\\end{pmatrix} \\\\
&=\\begin{pmatrix}\\simplify{{a11}*{b11}+{a12}*{b21}+{a13}*{b31}}&\\simplify{{a11}*{b12}+{a12}*{b22}+{a13}*{b32}}\\\\ \\simplify{{a21}*{b11}+{a22}*{b21}+{a23}*{b31}}&\\simplify{{a21}*{b12}+{a22}*{b22}+{a23}*{b32}}\\end{pmatrix}
\\end{aligned}
$$

\n

b)

\n

To evaluate \\(\\boldsymbol{B}\\boldsymbol{A}\\) we swap their positions and this time multiply the rows of \\(\\boldsymbol{B}\\) by the columns of \\(\\boldsymbol{A}\\)

\n

$$
\\begin{aligned}
\\boldsymbol{B}\\boldsymbol{A} &=
\\begin{pmatrix} \\var{b11}&\\var{b12}\\\\ \\var{b21}&\\var{b22} \\\\ \\var{b31}&\\var{b32}\\end{pmatrix}
\\begin{pmatrix} \\var{a11}&\\var{a12}&\\var{a13}\\\\ \\var{a21}&\\var{a22}&\\var{a23} \\end{pmatrix} \\\\
&=
\\begin{pmatrix}
\\var{b11} \\times \\var{a11} + \\var{b12} \\times \\var{a21} & \\var{b11} \\times \\var{a12} + \\var{b12} \\times \\var{a22} & \\var{b11} \\times \\var{a13} + \\var{b12} \\times \\var{a23} \\\\
\\var{b21} \\times \\var{a11} + \\var{b22} \\times \\var{a21} & \\var{b21} \\times \\var{a12} + \\var{b22} \\times \\var{a22} & \\var{b21} \\times \\var{a13} + \\var{b22} \\times \\var{a23} \\\\
\\var{b31} \\times \\var{a11} + \\var{b32} \\times \\var{a21} & \\var{b31} \\times \\var{a12} + \\var{b32} \\times \\var{a22} & \\var{b31} \\times \\var{a13} + \\var{b32} \\times \\var{a23} \\\\
\\end{pmatrix} \\\\
&=
\\begin{pmatrix}
\\simplify{{b11}*{a11}+{b12}*{a21}} & \\simplify{{b11} *{a12} + {b12} *{a22}} & \\simplify{{b11}*{a13} + {b12}*{a23}} \\\\
\\simplify{{b21}*{a11}+{b22}*{a21}} & \\simplify{{b21}*{a12} + {b22}*{a22}} & \\simplify{{b21}*{a13} + {b22}*{a23}} \\\\
\\simplify{{b31}*{a11}+{b32}*{a21}} & \\simplify{{b31}*{a12} + {b32}*{a22}} & \\simplify{{b31}*{a13} + {b32}*{a23}} \\\\
\\end{pmatrix} \\\\
\\end{aligned}
$$

", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers"]}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"ba23": {"name": "ba23", "group": "Ungrouped variables", "definition": "{b21}*{a13}+{b22}*{a23}", "description": "", "templateType": "anything", "can_override": false}, "ba33": {"name": "ba33", "group": "Ungrouped variables", "definition": "{b31}*{a13}+{b32}*{a23}", "description": "", "templateType": "anything", "can_override": false}, "a21": {"name": "a21", "group": "Ungrouped variables", "definition": "random(0 .. 10#1)", "description": "", "templateType": "randrange", "can_override": false}, "ba22": {"name": "ba22", "group": "Ungrouped variables", "definition": "{b21}*{a12}+{b22}*{a22}", "description": "", "templateType": "anything", "can_override": false}, "b21": {"name": "b21", "group": "Ungrouped variables", "definition": "random(2 .. 11#1)", "description": "", "templateType": "randrange", "can_override": false}, "a12": {"name": "a12", "group": "Ungrouped variables", "definition": "{a11}-1", "description": "", "templateType": "anything", "can_override": false}, "b32": {"name": "b32", "group": "Ungrouped variables", "definition": "random(0 .. 14#1)", "description": "", "templateType": "randrange", "can_override": false}, "b12": {"name": "b12", "group": "Ungrouped variables", "definition": "random(1 .. 8#1)", "description": "", "templateType": "randrange", "can_override": false}, "ab21": {"name": "ab21", "group": "Ungrouped variables", "definition": "{a21}*{b11}+{a22}*{b21}+{a23}*{b31}", "description": "", "templateType": "anything", "can_override": false}, "b22": {"name": "b22", "group": "Ungrouped variables", "definition": "random(2 .. 11#1)", "description": "", "templateType": "randrange", "can_override": false}, "a13": {"name": "a13", "group": "Ungrouped variables", "definition": "random(4 .. 12#1)", "description": "", "templateType": "randrange", "can_override": false}, "b11": {"name": "b11", "group": "Ungrouped variables", "definition": "random(1 .. 9#1)", "description": "", "templateType": "randrange", "can_override": false}, "ab11": {"name": "ab11", "group": "Ungrouped variables", "definition": "{a11}*{b11}+{a12}*{b21}+{a13}*{b31}", "description": "", "templateType": "anything", "can_override": false}, "ba21": {"name": "ba21", "group": "Ungrouped variables", "definition": "{b21}*{a11}+{b22}*{a21}", "description": "", "templateType": "anything", "can_override": false}, "ba13": {"name": "ba13", "group": "Ungrouped variables", "definition": "{b11}*{a13}+{b12}*{a23}", "description": "", "templateType": "anything", "can_override": false}, "ba31": {"name": "ba31", "group": "Ungrouped variables", "definition": "{b31}*{a11}+{b32}*{a21}", "description": "", "templateType": "anything", "can_override": false}, "k": {"name": "k", "group": "Ungrouped variables", "definition": "random(1 .. 9#1)", "description": "", "templateType": "randrange", "can_override": false}, "ba32": {"name": "ba32", "group": "Ungrouped variables", "definition": "{b31}*{a12}+{b32}*{a22}", "description": "", "templateType": "anything", "can_override": false}, "a11": {"name": "a11", "group": "Ungrouped variables", "definition": "random(1 .. 10#1)", "description": "", "templateType": "randrange", "can_override": false}, "a22": {"name": "a22", "group": "Ungrouped variables", "definition": "random(1 .. 9#1)", "description": "", "templateType": "randrange", "can_override": false}, "ab22": {"name": "ab22", "group": "Ungrouped variables", "definition": "{a21}*{b12}+{a22}*{b22}+{a23}*{b32}", "description": "", "templateType": "anything", "can_override": false}, "ba12": {"name": "ba12", "group": "Ungrouped variables", "definition": "{b11}*{a12}+{b12}*{a22}", "description": "", "templateType": "anything", "can_override": false}, "ba11": {"name": "ba11", "group": "Ungrouped variables", "definition": "{b11}*{a11}+{b12}*{a21}", "description": "", "templateType": "anything", "can_override": false}, "ab12": {"name": "ab12", "group": "Ungrouped variables", "definition": "{a11}*{b12}+{a12}*{b22}+{a13}*{b32}", "description": "", "templateType": "anything", "can_override": false}, "a23": {"name": "a23", "group": "Ungrouped variables", "definition": "random(10 .. 16#1)", "description": "", "templateType": "randrange", "can_override": false}, "b31": {"name": "b31", "group": "Ungrouped variables", "definition": "random(0 .. 5#1)", "description": "", "templateType": "randrange", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["a11", "a12", "a21", "a22", "k", "a13", "a23", "b11", "b12", "b21", "b22", "b31", "b32", "ab11", "ab12", "ab21", "ab22", "ba11", "ba12", "ba13", "ba21", "ba22", "ba23", "ba31", "ba32", "ba33"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "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": "

Calculate the product $\\boldsymbol{AB}$

\n

First set up the size of the answer matrix (choose the correct number of rows and columns in the boxes) and then input the entries:

\n

$\\boldsymbol{AB} =$ [[0]]

", "gaps": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": "2", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "correctAnswer": "matrix([\n [ab11,ab12],\n [ab21,ab22]\n])", "correctAnswerFractions": false, "numRows": "1", "numColumns": "1", "allowResize": true, "tolerance": 0, "markPerCell": true, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0, "prefilledCells": ""}], "sortAnswers": false}, {"type": "gapfill", "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": "

Calculate the product $\\boldsymbol{BA}$

\n

First set up the size of the answer matrix (choose the correct number of rows and columns in the boxes) and then input the entries:

\n

$\\boldsymbol{BA} =$ [[0]]

", "gaps": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": "4", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "correctAnswer": "matrix([\n [ba11,ba12,ba13],\n [ba21,ba22,ba23],\n [ba31,ba32,ba33]\n])", "correctAnswerFractions": false, "numRows": "1", "numColumns": "1", "allowResize": true, "tolerance": 0, "markPerCell": true, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0, "prefilledCells": ""}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Frank Doheny", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/789/"}, {"name": "Tamsin Smith", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/14108/"}, {"name": "Fraser Buxton", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/24224/"}]}]}], "contributors": [{"name": "Frank Doheny", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/789/"}, {"name": "Tamsin Smith", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/14108/"}, {"name": "Fraser Buxton", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/24224/"}]}