// Numbas version: finer_feedback_settings {"name": "Find a basis for the row space of a matrix", "extensions": ["codewords", "permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"codeword_matrix": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(\n matrix(map(x[0..word_length[j]],x,shown_words[j])),\n j,\n 0..num_parts-1\n)", "name": "codeword_matrix", "description": ""}, "word_length": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(4..6),num_parts)", "name": "word_length", "description": ""}, "generating_set": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(shuffle(allwords(word_length[j],field_size[j]))[0..random(3..4)],j,0..num_parts-1)", "name": "generating_set", "description": ""}, "shown_words": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(shuffle(span[j] except zero(word_length[j],field_size[j]))[0..random(3..4)],j,0..num_parts-1)", "name": "shown_words", "description": ""}, "num_parts": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2", "name": "num_parts", "description": ""}, "field_size": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(2,3,5),num_parts)", "name": "field_size", "description": ""}, "rref": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(reduced_row_echelon_form(x),x,shown_words)", "name": "rref", "description": ""}, "basis": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(rref[j] except zero(word_length[j],field_size[j]),j,0..num_parts-1)", "name": "basis", "description": ""}, "span": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(set_generated_by(x),x,generating_set)", "name": "span", "description": ""}, "rref_matrix": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(\n matrix(map(x[0..word_length[j]],x,rref[j])),\n j,\n 0..num_parts-1\n)", "name": "rref_matrix", "description": ""}}, "ungrouped_variables": ["num_parts", "field_size", "word_length", "generating_set", "span", "shown_words", "codeword_matrix", "rref", "rref_matrix", "basis"], "name": "Find a basis for the row space of a matrix", "functions": {}, "preamble": {"css": "", "js": "question.mark_basis = function(part,field_size,shown_words) {\n with(Numbas.extensions.codewords) {\n // check input is valid and parse as a list of words\n mark_codeword_set(part,field_size,function(words) {\n // answer is valid\n this.answered = true;\n \n // check words given are linearly independent\n if(!linearly_independent(words)) {\n this.setCredit(0,\"The set of vectors you gave is not linearly independent.\");\n return;\n }\n \n // check that all of the shown words are in the set generated by the student's basis\n var span = new Code(set_generated_by(words));\n var not_generated = []\n shown_words.map(function(word) {\n if(!span.contains(word)) {\n not_generated.push(word);\n }\n });\n \n // if any words aren't generated by the basis, no marks\n if(not_generated.length) {\n this.setCredit(0,\"Your basis does not generate every row of the given matrix.\");\n return;\n }\n \n // otherwise, student's basis is correct!\n this.setCredit(1,\"Your answer is correct.\");\n });\n }\n}"}, "parts": [{"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "
$\\var{matrix(map(x[0..word_length[0]],x,shown_words[0]))}$ in $\\mathbb{Z}_{\\var{field_size[0]}}$.
\n[[0]]
", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"answer": "", "displayAnswer": "{join(map(string(x),x,basis[0]),',')}", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "matchMode": "regex", "showFeedbackIcon": true, "scripts": {"mark": {"script": "question.mark_basis(this,variables.field_size[0],variables.shown_words[0]);", "order": "instead"}, "validate": {"script": "return Numbas.extensions.codewords.validate_codeword_set(this);", "order": "instead"}}, "type": "patternmatch", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": "2"}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "$\\var{matrix(map(x[0..word_length[1]],x,shown_words[1]))}$ in $\\mathbb{Z}_{\\var{field_size[1]}}$.
\n[[0]]
", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"answer": "", "displayAnswer": "{join(map(string(x),x,basis[1]),',')}", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "matchMode": "regex", "showFeedbackIcon": true, "scripts": {"mark": {"script": "question.mark_basis(this,variables.field_size[1],variables.shown_words[1]);", "order": "instead"}, "validate": {"script": "return Numbas.extensions.codewords.validate_codeword_set(this);", "order": "instead"}}, "type": "patternmatch", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": "2"}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}], "statement": "Find bases for the row spaces of the following matrices.
\nEnter each answer as a list of vectors separated by commas.
", "tags": [], "rulesets": {}, "extensions": ["codewords", "permutations"], "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Given a matrix in the field $\\mathbb{Z}_n$. By reducing it to row-echelon form (or otherwise), find a basis for the row space of the matrix, as a list of vectors.
"}, "variablesTest": {"condition": "sum(map(\n if(linearly_independent(x),0,1),\n x,\n shown_words\n))>1", "maxRuns": 100}, "advice": "We can find a basis by row-reducing the given matrix to echelon form:
\n\\[ \\var{rref_matrix[0]} \\]
\nTake the non-zero rows of this matrix as a set of basis vectors, i.e. $\\var{latex(join(map(latex(x),x,basis[0]),', '))}$. This is only one of many possible bases for the row space of the given matrix.
\nWe can find a basis by row-reducing the given matrix to echelon form:
\n\\[ \\var{rref_matrix[1]} \\]
\nTake the non-zero rows of this matrix as a set of basis vectors, i.e. $\\var{latex(join(map(latex(x),x,basis[1]),', '))}$. This is only one of many possible bases for the row space of the given matrix.
", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}