// Numbas version: finer_feedback_settings {"name": "copy of Matrix times vector", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "copy of Matrix times vector", "tags": ["linear map", "matrix multiplication", "matrix times vector", "matrix transformation"], "metadata": {"description": "

Calculate matrix times vector.

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

Calculate the following:

", "advice": "

To calculate matrix times vector, we calculate this row by row: the first entry of the resulting vector is \"row 1 of the matrix times the vector\". For example

\n

\\[\\begin{pmatrix} a_{11} & a_{12} \\\\ a_{21} & a_{22}\\end{pmatrix} \\begin{pmatrix}x_1\\\\x_2\\end{pmatrix}= \\begin{pmatrix} a_{11}x_1+a_{12}x_2 \\\\ a_{21}x_1+a_{22}x_2\\end{pmatrix}\\]

\n

 \\(\\var{A}\\var{va}=\\var{unresolvedAva}=\\var{A*va}\\)

", "rulesets": {}, "extensions": [], "variables": {"A": {"name": "A", "group": "Ungrouped variables", "definition": "matrix(repeat(repeat(random(-3..3),n),m))", "description": "", "templateType": "anything"}, "va": {"name": "va", "group": "Ungrouped variables", "definition": "vector(repeat(random(-2..2),n))", "description": "", "templateType": "anything"}, "rawunresolvedAva": {"name": "rawunresolvedAva", "group": "Ungrouped variables", "definition": "map(if({A[k][l]<0,'({A[k][l]})','{A[k][l]}')+'\\\\cdot'+if(va[l]<0,'({va[l]})','{va[l]}')+symbols(m,n)[k][l],[k,l],product(0..m-1,0..n-1))", "description": "

collects the terms \\(a_{ij}\\cdot v_j\\) for the matrix times vector multiplication, with plus symbols or new line concatenated ready to put into latex code for the calulcation steps of the matrix.

\n

All the \"if\" things are to put brackets round negative numbers. not using simplify because i prefer \\(\\cdot\\) to \\(\\times\\).

\n

Without the need for brackets, it could just be  map('{A[k][l]}\\\\cdot{va[l]}'+symbols(2,2)[k][l],[k,l],product(0..1,0..1))

\n

The \"symbols\" is a function giving the correct addition or new line symbols for the size of the matrix that is being used.

", "templateType": "anything"}, "unresolvedAva": {"name": "unresolvedAva", "group": "Ungrouped variables", "definition": "latex('\\\\begin{pmatrix}'+ concatstrings(rawunresolvedAva) +'\\\\end{'+'pmatrix}')", "description": "

for the solution, the calculation steps written out unresolved.

", "templateType": "anything"}, "m": {"name": "m", "group": "Ungrouped variables", "definition": "random(2..4)", "description": "", "templateType": "anything"}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "random(2..4)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["A", "va", "rawunresolvedAva", "unresolvedAva", "m", "n"], "variable_groups": [], "functions": {"concatstrings": {"parameters": [["input", "list"]], "type": "string", "language": "javascript", "definition": "var output = '';\nvar i;\nfor (i = 0; i < input.length; i++) {\n output += input[i];\n} \nreturn output;"}, "symbols": {"parameters": [["m", "number"], ["n", "number"]], "type": "list", "language": "jme", "definition": "repeat(repeat('+',n-1)+['\\\\\\\\'],m-1)+[repeat('+',n-1)+['']]"}}, "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": "

\\(\\var{A}\\var{va}= \\) [[0]]

", "gaps": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "correctAnswer": "A*va", "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": "Julia Goedecke", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5121/"}]}]}], "contributors": [{"name": "Julia Goedecke", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5121/"}]}