// Numbas version: finer_feedback_settings {"name": "Finding bases for the null space and row space of a matrix", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"column_basis": {"group": "Ungrouped variables", "templateType": "anything", "definition": "set(map(trtestmatrix[x],x,echelonform[1]))", "description": "", "name": "column_basis"}, "maxint": {"group": "Ungrouped variables", "templateType": "anything", "definition": "4", "description": "", "name": "maxint"}, "testmatrix": {"group": "Ungrouped variables", "templateType": "anything", "definition": "matrix(rdmat)*matrix(ech)", "description": "", "name": "testmatrix"}, "deter": {"group": "Ungrouped variables", "templateType": "anything", "definition": "rref(rdmat,0)[3]", "description": "", "name": "deter"}, "record": {"group": "Ungrouped variables", "templateType": "anything", "definition": "rref(list(testmatrix),0)", "description": "", "name": "record"}, "freecols": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(transpose(echmatrix)[nbasis_column[x]-1][0..columns-1],x,0..length(nbasis_column)-1)", "description": "", "name": "freecols"}, "echelonform": {"group": "Ungrouped variables", "templateType": "anything", "definition": "echelon_form_matrix(rows,rank,columns,maxint)", "description": "", "name": "echelonform"}, "nullity": {"group": "Ungrouped variables", "templateType": "anything", "definition": "5-rank", "description": "", "name": "nullity"}, "othercols": {"group": "Ungrouped variables", "templateType": "anything", "definition": "list(set(1,2,3,4,5)-set(echform))", "description": "", "name": "othercols"}, "ech": {"group": "Ungrouped variables", "templateType": "anything", "definition": "echelonform[0]", "description": "", "name": "ech"}, "colmark": {"group": "Ungrouped variables", "templateType": "anything", "definition": "colmar(z,echform)", "description": "", "name": "colmark"}, "rank": {"group": "Ungrouped variables", "templateType": "anything", "definition": "3\n", "description": "", "name": "rank"}, "trtestmatrix": {"group": "Ungrouped variables", "templateType": "anything", "definition": "transpose(testmatrix)", "description": "", "name": "trtestmatrix"}, "columns": {"group": "Ungrouped variables", "templateType": "anything", "definition": "5", "description": "", "name": "columns"}, "echmatrix": {"group": "Ungrouped variables", "templateType": "anything", "definition": "matrix(ech)", "description": "", "name": "echmatrix"}, "sum": {"group": "Ungrouped variables", "templateType": "anything", "definition": "sum(echform)", "description": "", "name": "sum"}, "record_ops_message": {"group": "Ungrouped variables", "templateType": "anything", "definition": "record[1]", "description": "", "name": "record_ops_message"}, "record_ops_matrix": {"group": "Ungrouped variables", "templateType": "anything", "definition": "record[0]", "description": "", "name": "record_ops_matrix"}, "c0": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(fill(echform[x]-1,othercols[0]-1,echmatrix[x][othercols[0]-1]),x,0..2)", "description": "", "name": "c0"}, "rows": {"group": "Ungrouped variables", "templateType": "anything", "definition": "6", "description": "", "name": "rows"}, "coordcol": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(id(5)[nbasis_column[x]-1],x,0..length(nbasis_column)-1)", "description": "", "name": "coordcol"}, "null_basis": {"group": "Ungrouped variables", "templateType": "anything", "definition": "switch(sum=6,[[ec[0][2]*ec[2][3]-ec[0][3],ec[1][2]*ec[2][3]-ec[1][3],-ec[2][3],1,0],\n [ec[0][2]*ec[2][4]-ec[0][4],ec[1][2]*ec[2][4]-ec[1][4],-ec[2][4],0,1]],\n sum=7,[[-ec[0][2],-ec[1][2],1,0,0],[-ec[0][4],-ec[1][4],0,-ec[2][4],1]],\n (sum=8) and(5 in echform),[[-ec[0][2],-ec[1][2],1,0,0],[-ec[0][3],-ec[1][3],0,1,0]],\n sum=8,[[-ec[0][1],1,0,0,0],[-ec[0][4],0,-ec[1][4],-ec[2][4],1]],\n sum=9,[[-ec[0][1],1,0,0,0],[-ec[0][3],0,-ec[1][3],1,0]],\n [[-ec[0][1],1,0,0,0],[-ec[0][2],0,1,0,0]])", "description": "", "name": "null_basis"}, "rref1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "rref1(list(testmatrix))[0]", "description": "", "name": "rref1"}, "chosen": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[true,true,false,true,false]", "description": "", "name": "chosen"}, "steps": {"group": "Ungrouped variables", "templateType": "anything", "definition": "rref(list(testmatrix),0)[2]", "description": "", "name": "steps"}, "c1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(fill(echform[x]-1,othercols[1]-1,echmatrix[x][othercols[1]-1]),x,0..2)", "description": "", "name": "c1"}, "rdmat": {"group": "Ungrouped variables", "templateType": "anything", "definition": "rdmat(rows)", "description": "", "name": "rdmat"}, "echform": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(x+1,x,echelonform[1])", "description": "", "name": "echform"}, "student_cols_matrix": {"group": "Ungrouped variables", "templateType": "anything", "definition": "transpose(matrix(map(transpose(echmatrix)[n],n,filter(chosen[j],j,0..4))))", "description": "", "name": "student_cols_matrix"}, "nbasis_column": {"group": "Ungrouped variables", "templateType": "anything", "definition": "list(set(1,2,3,4,5)-set(echform))", "description": "", "name": "nbasis_column"}, "z": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[0,0,0,0,0]", "description": "", "name": "z"}, "not_chosen_col": {"group": "Ungrouped variables", "templateType": "anything", "definition": "transpose(matrix(map(transpose(echmatrix)[n],n,filter(!chosen[j],j,0..4)))[0])", "description": "", "name": "not_chosen_col"}, "ec": {"group": "Ungrouped variables", "templateType": "anything", "definition": "echmatrix", "description": "", "name": "ec"}}, "ungrouped_variables": ["echelonform", "ech", "echform", "testmatrix", "record", "rref1", "record_ops_matrix", "record_ops_message", "rank", "maxint", "steps", "rdmat", "deter", "nullity", "echmatrix", "trtestmatrix", "nbasis_column", "coordcol", "freecols", "rows", "columns", "column_basis", "sum", "null_basis", "ec", "chosen", "student_cols_matrix", "not_chosen_col", "othercols", "c0", "c1", "colmark", "z"], "rulesets": {}, "name": "Finding bases for the null space and row space of a matrix", "functions": {"solution": {"type": "html", "language": "javascript", "definition": "function st(o){\n return '['+o.toString()+']';\n}\nfunction display_format(mat){\nvar s= st(mat.map(st));\n return '$\\\\simplify[fractionNumbers]{{matrix('+s+')}}$';\n}\nvar table = $('');\nvar n=matrix_list.length;\nvar m='';\nvar mess='';\nfor(var i=0;i');\ntable.append('');\ntable.append(''); \n}\nreturn table;\n", "parameters": [["matrix_list", "list"], ["message_list", "list"]]}, "colmar": {"type": "list", "language": "javascript", "definition": "var ar=z;\nfor (var i=0;i<3;i++) {\n ar[ef[i]-1]=1;\n}\nreturn ar;", "parameters": [["z", "list"], ["ef", "list"]]}, "rref1": {"type": "list", "language": "javascript", "definition": "function finish() {\n for(var i=0;i=ind?temp.push(getRandomInt(1,max)):temp.push(0);\n }\n for(var k=0;k=b,0,c)", "parameters": [["a", "number"], ["b", "number"], ["c", "number"]]}, "rdmat": {"type": "list", "language": "javascript", "definition": "function getRandomInt(min, max) {\nreturn Math.floor(Math.random() * (max - min + 1)) + min;\n};\nvar m=[];\nvar temp;\nfor(var i=0;iRank of $A=\\;$[[0]]

\n

Nullity of $A=\\;$[[1]]

", "variableReplacements": [], "marks": 0}, {"variableReplacementStrategy": "originalfirst", "scripts": {}, "gaps": [{"displayType": "checkbox", "choices": ["

Row 1

", "

Row 2

", "

Row 3

", "

Row 4

", "

Row 5

", "

Row 6

"], "showCorrectAnswer": true, "matrix": ["0.3", "0.3", "0.4", 0, 0, 0], "distractors": ["", "", "", "", "", ""], "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": false, "warningType": "none", "scripts": {}, "minMarks": 0, "type": "m_n_2", "maxMarks": "1", "displayColumns": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "

Determine a basis of $\\operatorname{row}(A)$ consisting of rows of $R$ by clicking on the appropriate choices of rows of $R$.

\n

[[0]]

", "variableReplacements": [], "marks": 0}, {"displayType": "checkbox", "choices": ["

Column 1

", "

Column 2

", "

Column 3

", "

Column 4

", "

Column 5

"], "variableReplacementStrategy": "originalfirst", "matrix": "colmark", "prompt": "

\n

Click on the choices of columns of $A$ which form a basis for the column space.

\n\n

Note that there are more than one possible choice of columns and if the columns you choose form a basis then this will be marked as correct. If you Reveal the answer you will see one possible such choice.

\n

", "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": false, "warningType": "none", "scripts": {"mark": {"script": "var trm=variables.trtestmatrix;\nvar echform=variables.echform;\nvar rank=variables.rank;\nvar trm=Numbas.util.copyarray(trm,true);\nthis.answered=true;\n\n\nvar tm=[];\nvar selected=[];\nvar not_selected=[];\nvar numTicks = 0;\nfor( var i=0;i<5;i++) {\n if(this.ticks[i][0]) {\n numTicks += 1;\n tm.push(trm[i]);\n selected.push(i+1);\n }\n else {not_selected.push(i+1);}\n}\n\nvar rank1 = question.functions.ref(tm);\nvar diff = false;\nvar explain = this.question.display.html.find('#explain');\nvar note = '';\nvar mess = '';\nfor(var i=0;i<3;i++) { \n if(echform[i]!=selected[i]) {\n diff=true;\n }\n}\nif(diff) {\n mess='You have chosen correctly, but the easiest choice to make is those columns which have pivots, in this case columns '+echform[0]+', '+echform[1]+', '+echform[2]+'. ';\n}\nif(numTicksrank) {\n this.setCredit(0, 'You have included too many columns, the rank is less than '+numTicks+'.');\n} else if(rank1==rank) {\n if(diff) {\n mess='You have chosen correctly, but the easiest choice to make is those columns which have pivots, in this case columns '+echform[0]+', '+echform[1]+', '+echform[2]+'. ';\n } else { \n mess='';\n }\n this.setCredit(1,mess);\n if(diff){ \n note='Click on the Show feedback button for more information on your choices.';\n } else {\n note='';\n }\n explain.text(note);\n} else {\n this.setCredit(0,'These columns are not linearly independent.');\n}\n\n\nthis.validation.numTicks = numTicks;", "order": "instead"}}, "minMarks": 0, "type": "m_n_2", "maxMarks": "1", "displayColumns": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0}, {"variableReplacementStrategy": "originalfirst", "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "minValue": "c0[0]", "showCorrectAnswer": true, "variableReplacements": [], "marks": "0.5", "maxValue": "c0[0]"}, {"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "minValue": "c0[1]", "showCorrectAnswer": true, "variableReplacements": [], "marks": "0.5", "maxValue": "c0[1]"}, {"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "minValue": "c0[2]", "showCorrectAnswer": true, "variableReplacements": [], "marks": "0.5", "maxValue": "c0[2]"}, {"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "minValue": "c1[0]", "showCorrectAnswer": true, "variableReplacements": [], "marks": "0.5", "maxValue": "c1[0]"}, {"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "minValue": "c1[1]", "showCorrectAnswer": true, "variableReplacements": [], "marks": "0.5", "maxValue": "c1[1]"}, {"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "minValue": "c1[2]", "showCorrectAnswer": true, "variableReplacements": [], "marks": "0.5", "maxValue": "c1[2]"}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "

Express the following columns in terms of the columns $c_\\var{echform[0]}$, $c_\\var{echform[1]}$, $c_\\var{echform[2]}$

\n

$c_{\\var{othercols[0]}}$=[[0]]$c_\\var{echform[0]}$+[[1]]$c_{\\var{echform[1]}}$+[[2]]$c_{\\var{echform[2]}}$

\n

$c_{\\var{othercols[1]}}$=[[3]]$c_\\var{echform[0]}$+[[4]]$c_{\\var{echform[1]}}$+[[5]]$c_{\\var{echform[2]}}$

", "variableReplacements": [], "marks": 0}, {"showCorrectAnswer": true, "markPerCell": false, "allowFractions": false, "correctAnswer": "transpose(matrix(null_basis))", "allowResize": true, "prompt": "

Determine a basis for $\\operatorname{Null}(A)$.

\n

Enter the basis elements as the columns of a matrix:

\n

Note that any such basis will be marked as correct. If you Reveal the answer you will see one possible such basis.

\n

", "correctAnswerFractions": false, "numRows": "5", "scripts": {"mark": {"script": "var nullity=variables.nullity;\nvar columns=variables.columns;\nvar rows=variables.rows;\nvar testmatrix=variables.testmatrix;\nvar ans=this.studentAnswer;\nvar ans_rows=this.studentAnswerRows;\nthis.answered=true;\n\nif(ans_rows!=columns){\n this.setCredit(0,'These vectors are not of the correct dimension.')\n return;\n}\nvar ans_cols=this.studentAnswerColumns;\nif(ans_cols!=nullity){\n this.setCredit(0,'Not the correct number of vectors.')\n return;\n}\nvar dim_null_space_ans=question.functions.ref(ans);\nif(dim_null_space_ans!=nullity){\n this.setCredit(0, 'These vectors are not linearly independent.');\n return;\n}\nfunction check_in_kernel(m1,m2) {\n var d = 0;\n for(var i=0;i0\nand\nmax(map(testing(record[0][x]),x,0..length(record[0])-1))=0", "maxRuns": "200"}, "statement": "

The row-reduced echelon form $R$ of the following matrix $A$

\n

$A=\\var{testmatrix}$ is given by $R=\\var{echmatrix}$.

\n

", "tags": ["bases", "basis", "column space", "dimension", "echelon form", "linear algebra", "linear independence", "linearly dependent", "matrices", "matrix type", "null space", "nullity", "rank", "row operations", "row reduced", "row space", "row-reduced"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": "question.functions={};\nquestion.functions.ref=function(m){\n \n m = util.copyarray(m,true);\n \n function finish() {\n\n return rank;\n }\n\n\n\n var lead = 0;\n var rank = 0;\n var echelon=[];\n var rows = m.length;\n for(var i=0;iFix rank to be 3.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Given a matrix in row reduced form use this to find bases for the null, column and row spaces of the matrix.

"}, "advice": "

a) The following shows how $A$ is reduced to row-echelon form.

\n

\n

{solution(record_ops_matrix,record_ops_message)}

\n

The rank of A is the number of columns of R with pivots, i.e. 3.

\n

The nullity of A is the number of columns of R without pivots, i.e. 2.

\n

b) Given the row-echelon form we see that the first three rows of $R$ form a basis for the row space of $A$.

\n

c) One basis for the column-space of $A$ is given by the original columns which in the row-reduced echelon form have a pivot.

\n

For example, $\\{c_i:i \\in \\var{set(echform)}\\}$

\n

$\\var{column_basis}$

\n

There are other bases which you could have chosen and would also have been marked as correct.

\n

d) If you look at the columns $c_{\\var{othercols[0]}}$ and $c_{\\var{othercols[1]}}$ we can simply read off these columns as combinations of the other columns by looking at the numbers above the pivot element in each of the columns $c_{\\var{othercols[0]}}$ and $c_{\\var{othercols[1]}}$.

\n

e) Basis for the null-space.

\n

The dimension of the null-space is $2$ and so we should have $2$ vectors in the basis.

\n

The null space is given by $\\operatorname{Null}(A)=\\operatorname{Null}(R)= $  \\[\\left\\{(x_1,x_2,x_3,x_4,x_5):\\simplify{{ec}*vector(x_1,x_2,x_3,x_4,x_5)=vector(0,0,0,0,0,0)}\\right\\}\\]

\n

This gives three equations:

\n

\\begin{align}\\simplify{{ec[0][0]}x_1+{ec[0][1]}x_2+{ec[0][2]}x_3+{ec[0][3]}x_4+{ec[0][4]}x_5}&=0\\\\\\simplify{{ec[1][0]}x_1+{ec[1][1]}x_2+{ec[1][2]}x_3+{ec[1][3]}x_4+{ec[1][4]}x_5}&=0\\\\\\simplify{{ec[2][0]}x_1+{ec[2][1]}x_2+{ec[2][2]}x_3+{ec[2][3]}x_4+{ec[2][4]}x_5}&=0 \\end{align}

\n

The free columns (without a pivot element) are $c_{\\var{nbasis_column[0]}},c_{\\var{nbasis_column[1]}}$

\n

We obtain $2$ vectors which are linearly independent by:

\n

1) Setting: $x_{\\var{nbasis_column[0]}}=1,x_{\\var{nbasis_column[1]}}=0$ gives $\\var{rowvector(null_basis[0])}$ as a basis element for the null-space.

\n

2) Setting: $x_{\\var{nbasis_column[0]}}=0,x_{\\var{nbasis_column[1]}}=1$ gives $\\var{rowvector(null_basis[1])}$ as another basis element for the null-space.

\n

Hence $\\{\\var{rowvector(null_basis[0])},\\var{rowvector(null_basis[1])}\\}$

\n

is a basis for the null-space.

\n

Note that this is just one possible basis, and if you input another correct basis for the null-space then it will be marked as correct.

\n

Alternatively.

\n

Note that on using the equations above, the variables $x_{\\var{echform[0]}},\\;x_{\\var{echform[1]}}$ and  $x_{\\var{echform[2]}}$ can be expressed in terms of the variables  $x_{\\var{nbasis_column[0]}},x_{\\var{nbasis_column[1]}}$.

\n

If we do so we find that:

\n

$ (x_1,x_2,x_3,x_4,x_5) \\in \\operatorname{Null}(A) \\iff$ \\[(x_1,x_2,x_3,x_4,x_5)= x_{\\var{nbasis_column[0]}}\\var{rowvector(null_basis[0])}+x_{\\var{nbasis_column[1]}}\\var{rowvector(null_basis[1])}.\\]

\n

As $ x_{\\var{nbasis_column[0]}},\\;x_{\\var{nbasis_column[1]}}$ can take any values we see that the vectors

\n

$\\{\\var{rowvector(null_basis[0])},\\var{rowvector(null_basis[1])}\\}$ form a basis as they span  $\\operatorname{Null}(A)$ and there are $2$ vectors which agrees with the nullity.

\n

\n

", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}
'+mess+'
'+m+'