// Numbas version: finer_feedback_settings {"name": "Adding matrices of different sizes", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Adding matrices of different sizes", "tags": [], "metadata": {"description": "
Adding matrices of random size: two to four rows and two to four columns. Advice (i.e. solution) has conditional visibility to show only the correct size.
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "", "advice": "We can add any two matrices which have the same size. To add the matrices, we add each entry separately: entry 1,1 of the first matrix plus entry 1,1 of the second matrix goes into entry 1,1 of the sum, and so on.
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}}\\\\\\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}\\end{pmatrix}=\\var{matrixC}\\]
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}} &\\simplify[]{{matrixA[0][2]}+{matrixB[0][2]}} \\\\\\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}&\\simplify[]{{matrixA[1][2]}+{matrixB[1][2]}}\\end{pmatrix}=\\var{matrixC}\\]
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}} &\\simplify[]{{matrixA[0][2]}+{matrixB[0][2]}} &\\simplify[]{{matrixA[0][3]}+{matrixB[0][3]}}\\\\\\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}&\\simplify[]{{matrixA[1][2]}+{matrixB[1][2]}} &\\simplify[]{{matrixA[1][3]}+{matrixB[1][3]}}\\end{pmatrix}=\\var{matrixC}\\]
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}} \\\\\\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}\\\\\\simplify[]{{matrixA[2][0]}+{matrixB[2][0]}} & \\simplify[]{{matrixA[2][1]}+{matrixB[2][1]}}\\end{pmatrix}=\\var{matrixC}\\]
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}} &\\simplify[]{{matrixA[0][2]}+{matrixB[0][2]}} \\\\\\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}&\\simplify[]{{matrixA[1][2]}+{matrixB[1][2]}} \\\\\\simplify[]{{matrixA[2][0]}+{matrixB[2][0]}} & \\simplify[]{{matrixA[2][1]}+{matrixB[2][1]}}&\\simplify[]{{matrixA[2][2]}+{matrixB[2][2]}} \\end{pmatrix}=\\var{matrixC}\\]
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}} &\\simplify[]{{matrixA[0][2]}+{matrixB[0][2]}} &\\simplify[]{{matrixA[0][3]}+{matrixB[0][3]}}\\\\\\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}&\\simplify[]{{matrixA[1][2]}+{matrixB[1][2]}} &\\simplify[]{{matrixA[1][3]}+{matrixB[1][3]}}\\\\\\simplify[]{{matrixA[2][0]}+{matrixB[2][0]}} & \\simplify[]{{matrixA[2][1]}+{matrixB[2][1]}}&\\simplify[]{{matrixA[2][2]}+{matrixB[2][2]}} &\\simplify[]{{matrixA[2][3]}+{matrixB[2][3]}}\\end{pmatrix}=\\var{matrixC}\\]
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}} \\\\ \\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}\\\\\\simplify[]{{matrixA[2][0]}+{matrixB[2][0]}} & \\simplify[]{{matrixA[2][1]}+{matrixB[2][1]}}\\\\\\simplify[]{{matrixA[3][0]}+{matrixB[3][0]}} & \\simplify[]{{matrixA[3][1]}+{matrixB[3][1]}}\\end{pmatrix}=\\var{matrixC}\\]
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}} &\\simplify[]{{matrixA[0][2]}+{matrixB[0][2]}} \\\\\\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}&\\simplify[]{{matrixA[1][2]}+{matrixB[1][2]}} \\\\\\simplify[]{{matrixA[2][0]}+{matrixB[2][0]}} & \\simplify[]{{matrixA[2][1]}+{matrixB[2][1]}}&\\simplify[]{{matrixA[2][2]}+{matrixB[2][2]}} \\\\\\simplify[]{{matrixA[3][0]}+{matrixB[3][0]}} & \\simplify[]{{matrixA[3][1]}+{matrixB[3][1]}}&\\simplify[]{{matrixA[3][2]}+{matrixB[3][2]}} \\end{pmatrix}=\\var{matrixC}\\]
\n\\[\\var{matrixA}+\\var{matrixB}= \\begin{pmatrix} \\simplify[]{{matrixA[0][0]}+{matrixB[0][0]}}&\\simplify[]{{matrixA[0][1]}+{matrixB[0][1]}} &\\simplify[]{{matrixA[0][2]}+{matrixB[0][2]}} &\\simplify[]{{matrixA[0][3]}+{matrixB[0][3]}}\\\\\\simplify[]{{matrixA[1][0]}+{matrixB[1][0]}} & \\simplify[]{{matrixA[1][1]}+{matrixB[1][1]}}&\\simplify[]{{matrixA[1][2]}+{matrixB[1][2]}} &\\simplify[]{{matrixA[1][3]}+{matrixB[1][3]}}\\\\\\simplify[]{{matrixA[2][0]}+{matrixB[2][0]}} & \\simplify[]{{matrixA[2][1]}+{matrixB[2][1]}}&\\simplify[]{{matrixA[2][2]}+{matrixB[2][2]}} &\\simplify[]{{matrixA[2][3]}+{matrixB[2][3]}}\\\\\\simplify[]{{matrixA[3][0]}+{matrixB[3][0]}} & \\simplify[]{{matrixA[3][1]}+{matrixB[3][1]}}&\\simplify[]{{matrixA[3][2]}+{matrixB[3][2]}} &\\simplify[]{{matrixA[3][3]}+{matrixB[3][3]}}\\end{pmatrix}=\\var{matrixC}\\]
", "rulesets": {}, "extensions": [], "variables": {"matrixC": {"name": "matrixC", "group": "Ungrouped variables", "definition": "matrixA+matrixB", "description": "Matrix C, the sum of matrices A and B.
", "templateType": "anything"}, "rows": {"name": "rows", "group": "Ungrouped variables", "definition": "random(2..4)", "description": "Number of rows in the matrices
", "templateType": "anything"}, "columns": {"name": "columns", "group": "Ungrouped variables", "definition": "random(2..4)", "description": "number of columns of the matrices
", "templateType": "anything"}, "matrixA": {"name": "matrixA", "group": "Ungrouped variables", "definition": "matrix(repeat(repeat(random(-5..5),columns),rows))", "description": "randomly generated matrix of random size.
", "templateType": "anything"}, "matrixB": {"name": "matrixB", "group": "Ungrouped variables", "definition": "matrix(repeat(repeat(random(-5..5),columns),rows))", "description": "randomly generated matrix of same size as matrixA
", "templateType": "anything"}, "matrixAentryproduct": {"name": "matrixAentryproduct", "group": "Ungrouped variables", "definition": "all(map(is_zero(vector((list(matrixA)[n]))),n,0..rows-1))", "description": "checks if all enries of matrix A are zero
", "templateType": "anything"}, "matrixBentryproduct": {"name": "matrixBentryproduct", "group": "Ungrouped variables", "definition": "all(map(is_zero(vector((list(matrixB)[n]))),n,0..rows-1))", "description": "checks if all enries of matrix B are zero
", "templateType": "anything"}, "entries": {"name": "entries", "group": "Ungrouped variables", "definition": "rows*columns", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "not matrixAentryproduct and not matrixBentryproduct", "maxRuns": 100}, "ungrouped_variables": ["matrixC", "rows", "columns", "matrixA", "matrixB", "matrixAentryproduct", "matrixBentryproduct", "entries"], "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 \\(\\var{matrixA} + \\var{matrixB}=\\) [[0]].
\n", "gaps": [{"type": "matrix", "useCustomName": true, "customName": "Gap 0", "marks": "5", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "correctAnswer": "matrixC", "correctAnswerFractions": false, "numRows": "1", "numColumns": "1", "allowResize": true, "tolerance": 0, "markPerCell": true, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Tatiana Tyukina", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/341/"}, {"name": "Julia Goedecke", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5121/"}]}]}], "contributors": [{"name": "Tatiana Tyukina", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/341/"}, {"name": "Julia Goedecke", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5121/"}]}