// Numbas version: exam_results_page_options {"name": "Find a basis for the span of a set of vectors", "extensions": ["codewords", "permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"parts": [{"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "

$\\var{code(shown_words[0])} \\subset \\mathbb{Z}_{\\var{field_size[0]}}^{\\var{word_length[0]}}$

\n

[[0]]

", "unitTests": [], "sortAnswers": false, "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, "showFeedbackIcon": true}, {"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "

$\\var{code(shown_words[1])} \\subset \\mathbb{Z}_{\\var{field_size[1]}}^{\\var{word_length[1]}}$

\n

[[0]]

", "unitTests": [], "sortAnswers": false, "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, "showFeedbackIcon": true}, {"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "

$\\var{code(shown_words[2])} \\subset \\mathbb{Z}_{\\var{field_size[2]}}^{\\var{word_length[2]}}$

\n

[[0]]

", "unitTests": [], "sortAnswers": false, "scripts": {}, "gaps": [{"answer": "", "displayAnswer": "{join(map(string(x),x,basis[2]),',')}", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "matchMode": "regex", "showFeedbackIcon": true, "scripts": {"mark": {"script": "question.mark_basis(this,variables.field_size[2],variables.shown_words[2]);", "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, "showFeedbackIcon": true}], "variables": {"basis": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(rref[j] except zero(word_length[j],field_size[j]),j,0..num_parts-1)", "description": "", "name": "basis"}, "word_length": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(4..6),num_parts)", "description": "", "name": "word_length"}, "shown_words": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(\n shuffle(\n span[j] except zero(word_length[j],field_size[j])\n )[0..random(5..6)],\n j,\n 0..num_parts-1\n)", "description": "", "name": "shown_words"}, "rref_matrix": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(\n matrix(map(x[0..word_length[j]],x,rref[j])),\n j,\n 0..2\n)", "description": "", "name": "rref_matrix"}, "num_parts": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "num_parts"}, "field_size": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(2,3,5),num_parts)", "description": "", "name": "field_size"}, "rref": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(reduced_row_echelon_form(x),x,shown_words)", "description": "", "name": "rref"}, "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)", "description": "", "name": "generating_set"}, "span": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(set_generated_by(x),x,generating_set)", "description": "", "name": "span"}, "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..2\n)", "description": "", "name": "codeword_matrix"}}, "ungrouped_variables": ["num_parts", "field_size", "word_length", "generating_set", "span", "shown_words", "codeword_matrix", "rref", "rref_matrix", "basis"], "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 part.answered = true;\n \n // check words given are linearly independent\n if(!linearly_independent(words)) {\n part.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 part.setCredit(0,\"Your basis does not generate all of the given vectors.\");\n return;\n }\n \n // otherwise, student's basis is correct!\n part.setCredit(1,\"Your answer is correct.\");\n });\n }\n}"}, "name": "Find a basis for the span of a set of vectors", "variable_groups": [], "functions": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

Find bases for the spans of the following sets.

\n

Enter 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 set of vectors, find a basis which generates their span as a subspace of $\\mathbb{Z}_n$.

"}, "advice": "

a)

\n

We can find a basis by forming a matrix whose rows are the given vectors:

\n

\\[ \\var{codeword_matrix[0]} \\]

\n

Row-reduce this matrix to obtain the echelon form

\n

\\[ \\var{rref_matrix[0]} \\]

\n

Take 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 given vectors.

\n

b)

\n

We can find a basis by forming a matrix whose rows are the given vectors:

\n

\\[ \\var{codeword_matrix[1]} \\]

\n

Row-reduce this matrix to obtain the echelon form

\n

\\[ \\var{rref_matrix[1]} \\]

\n

Take 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 given vectors.

\n

c)

\n

We can find a basis by forming a matrix whose rows are the given vectors:

\n

\\[ \\var{codeword_matrix[2]} \\]

\n

Row-reduce this matrix to obtain the echelon form

\n

\\[ \\var{rref_matrix[2]} \\]

\n

Take the non-zero rows of this matrix as a set of basis vectors, i.e. $\\var{latex(join(map(latex(x),x,basis[2]),', '))}$. This is only one of many possible bases for the given vectors.

", "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/"}]}