// Numbas version: finer_feedback_settings {"name": "Kernel and image of matrix transformation", "extensions": ["linear-algebra", "linalg2"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Kernel and image of matrix transformation", "tags": ["image", "kernel", "Linear algebra", "Linear Algebra", "linear algebra", "matrix transformation"], "metadata": {"description": "
Student finds a basis for kernel and image of a matrix transformation. Any basis can be entered; there is a custom marking algorithm which checks if it is a correct basis.
\nThere are options to adjust this question fairly easily, for example to get different variants for practice and for a test, by changing the options in the \"pivot columns\" in the variables. You should be careful to think about and test your pivot options, as some are easier or harder than others, and some don't work very well.
", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "Let \\(T_A\\colon {\\mathbb{R}^{\\var{colnum}} \\to \\mathbb{R}^{\\var{rownum}}}\\) with \\( A = \\var{D} \\). Find
\nKernel and nullity
The kernel of \\(T_A\\) is the set of all vectors which gets mapped to zero: \\(\\operatorname{Ker}(T_A)=\\left\\{v \\middle| Av=0\\right\\}\\). In this case, the kernel of \\(T_A\\) is the same as the nullspace of \\(A\\). So we solve the linear system \\(Av=0\\).
\nThe matrix \\(\\var{D}\\) has reduced row echelon form \\(\\var[fractionNumbers]{Dech}\\). So we see that there are no stuff columns, so the nullspace is \\(0\\) So we see that there is are \\(\\var{length(stuffcols)}\\) stuff columns, and a basis of the kernel is given by \\(\\var[fractionNumbers]{transpose(kernelbasismatrix)[0]}\\), \\(\\var[fractionNumbers]{transpose(kernelbasismatrix)[1]}\\), \\(\\var[fractionNumbers]{transpose(kernelbasismatrix)[2]}\\).
\nAny correct basis will be accepted above.
\nThe nullity of \\(T_A\\) is the dimension of the kernel, so we see that it is \\(n(T_A)=\\var{nullityD}\\).
\nImage and rank
The image of \\(T_A\\) is the set of all vectors which are reached: \\(\\operatorname{Im}(T_A)=\\left\\{w\\middle| \\exists v \\text{ s.t. } Av=w\\right\\}\\). The image of the matrix transformation \\(T_A\\) is the same as the column space of matrix \\(A\\). We can find a basis for the column space by taking the columns in \\(A\\) which turn into pivot columns in the RREF of \\(A\\). We see from the above RREF that this is columns \\(\\var{pivots[0]}\\), \\(\\var{pivots[1]}\\), \\(\\var{pivots[2]}\\). (Why? See lecture notes, \"how to find a basis for a column space\".)
\nTherefore the rank of \\(T_A\\), the dimension of the image, is \\(r(T_A)=\\var{rankD}\\). So actually \\(\\operatorname{Im}(A)= \\mathbb{R}^{\\var{rownum}}\\), so any basis of \\(\\mathbb{R}^{\\var{rownum}}\\) is correct here, such as the standard basis.
\nSo a basis for the image is given by \\(\\var{transpose(image)[0]}\\), \\(\\var{transpose(image)[1]}\\), \\(\\var{transpose(image)[2]}\\).
\nWe see that the image is not all of the codomain \\(\\mathbb{R}^{\\var{rownum}}\\).
\nAny correct basis will be accepted above.
\nRank-Nullity Theorem
\nWe can check that rank + nullity = dimension of domain, i.e. \\(r(T_A)+n(T_A)=\\dim(\\mathbb{R}^{\\var{colnum}})\\): \\(\\var{rankD}+\\var{nullityD}=\\var{colnum}\\).
", "rulesets": {}, "extensions": ["linalg2", "linear-algebra"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"pivots3": {"name": "pivots3", "group": "Ungrouped variables", "definition": "random([[1,2,3],[1,3],[2,3],[2]])", "description": "", "templateType": "anything", "can_override": false}, "Aech": {"name": "Aech", "group": "Ungrouped variables", "definition": "matrix(le_random_red_echelon([4,4],pivots4,le_from_to(-2,2)))", "description": "", "templateType": "anything", "can_override": false}, "A": {"name": "A", "group": "Ungrouped variables", "definition": "matrix(le_row_shuffle(Aech))", "description": "", "templateType": "anything", "can_override": false}, "pivots4": {"name": "pivots4", "group": "Ungrouped variables", "definition": "random([[1,2,3],[1,2,4],[2,3,4],[1,4],[2,3]])", "description": "", "templateType": "anything", "can_override": false}, "Bech": {"name": "Bech", "group": "Ungrouped variables", "definition": "matrix(le_random_red_echelon([3,4],pivots4,le_from_to(-2,2)))", "description": "", "templateType": "anything", "can_override": false}, "Cech": {"name": "Cech", "group": "Ungrouped variables", "definition": "matrix(le_random_red_echelon([4,3],pivots3,le_from_to(-2,2)))", "description": "", "templateType": "anything", "can_override": false}, "B": {"name": "B", "group": "Ungrouped variables", "definition": "matrix(le_row_shuffle(Bech))", "description": "", "templateType": "anything", "can_override": false}, "C": {"name": "C", "group": "Ungrouped variables", "definition": "matrix(le_row_shuffle(Cech))", "description": "", "templateType": "anything", "can_override": false}, "D": {"name": "D", "group": "Ungrouped variables", "definition": "random(A,B,C)", "description": "", "templateType": "anything", "can_override": false}, "colnum": {"name": "colnum", "group": "Ungrouped variables", "definition": "numcolumns(D)", "description": "", "templateType": "anything", "can_override": false}, "rankD": {"name": "rankD", "group": "Ungrouped variables", "definition": "rank(matrix(D))", "description": "", "templateType": "anything", "can_override": false}, "kernel_sized_zero_matrix": {"name": "kernel_sized_zero_matrix", "group": "Ungrouped variables", "definition": "if(rankD = colnum,matrix(le_zero_matrix(colnum,1)),matrix(le_zero_matrix(colnum,colnum-rank(D))))", "description": "", "templateType": "anything", "can_override": false}, "rownum": {"name": "rownum", "group": "Ungrouped variables", "definition": "numrows(D)", "description": "", "templateType": "anything", "can_override": false}, "Dech": {"name": "Dech", "group": "Ungrouped variables", "definition": "switch(D=A,Aech,D=B,Bech,Cech)", "description": "", "templateType": "anything", "can_override": false}, "pivots": {"name": "pivots", "group": "Ungrouped variables", "definition": "if(D=C,pivots3,pivots4)", "description": "", "templateType": "anything", "can_override": false}, "stuffcols": {"name": "stuffcols", "group": "Ungrouped variables", "definition": "1..colnum except pivots", "description": "", "templateType": "anything", "can_override": false}, "kernelbasismatrix": {"name": "kernelbasismatrix", "group": "Ungrouped variables", "definition": "transpose(matrix(le_kernel(Dech)))", "description": "transpose(matrix(map(map(-Dech[l][k-1],l,0..(k-2))+[1]+repeat(0,colnum-k),k,stuffcols)))
\ntranspose(matrix(map(map(-Dech[l][k-1],l,0..(k-2) except stuffcols)+[1]+repeat(0,colnum-k),k,stuffcols)))
\n", "templateType": "anything", "can_override": false}, "kernel": {"name": "kernel", "group": "Ungrouped variables", "definition": "if(length(stuffcols)=0,vector(repeat(0,colnum)),kernelbasismatrix)", "description": "", "templateType": "anything", "can_override": false}, "test": {"name": "test", "group": "Ungrouped variables", "definition": "D * kernel", "description": "", "templateType": "anything", "can_override": false}, "image": {"name": "image", "group": "Ungrouped variables", "definition": "if(rankD=rownum, id(rownum),\ntranspose(matrix(map(transpose(D)[k-1],k,pivots))))", "description": "", "templateType": "anything", "can_override": false}, "imagecheckmatrix": {"name": "imagecheckmatrix", "group": "Ungrouped variables", "definition": "if(rankD=rownum,\n matrix(repeat(0,rownum)),\n matrix(le_kernel(matrix(le_red_echelon(transpose(image)))))\n )", "description": "", "templateType": "anything", "can_override": false}, "nullityD": {"name": "nullityD", "group": "Ungrouped variables", "definition": "length(stuffcols)", "description": "", "templateType": "anything", "can_override": false}, "imagecheck": {"name": "imagecheck", "group": "Ungrouped variables", "definition": "imagecheckmatrix * image", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["pivots3", "Aech", "A", "pivots4", "Bech", "Cech", "B", "C", "D", "colnum", "rankD", "kernel_sized_zero_matrix", "rownum", "Dech", "pivots", "stuffcols", "nullityD", "kernelbasismatrix", "kernel", "test", "image", "imagecheckmatrix", "imagecheck"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ".matrix-input .left-bracket, .matrix-input .right-bracket {\n display: none !important;\n}"}, "parts": [{"type": "gapfill", "useCustomName": true, "customName": "Kernel", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Enter the basis for the kernel of \\(T_A\\) as the columns of a matrix. E.g. if there is only one basis vector, select \"1 column\" and enter the vector. If there are two basis vectors, select \"2 columns\" and enter the first basis vector in the first column and the second basis vector in the second column, etc. This way you can determine how many basis vectors there are.
\nIf the kernel is \\(0\\), then just enter a zero vector of the correct size.
\nA basis of the kernel of \\(T_A\\) is:
\n[[0]]
", "gaps": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "wrong_size (Does the student's answer have the wrong dimensions?):\n assert(rows=correct_rows and cols=correct_cols,\n incorrect();\n assert(rows=correct_rows, feedback(\"You have the wrong number of rows.\"));\n assert(rank(studentMatrix)=cols,feedback(\"Your column vectors are linearly dependent.\"));\n end()\n )\n\nlinear_independent:\n rank(studentMatrix) = colnum - rank(D)\n or\n (colnum - rank(D) = 0 and studentMatrix = kernel_sized_zero_matrix)\n\ncolumns_in_kernel:\n if(rows=correct_rows,\n D * studentMatrix = le_zero_matrix(rownum,numcolumns(studentMatrix)),\n false)\n\n\nfurther_feedback:\n assert(linear_independent,feedback(\"The vectors you have entered are not linearly independent.\"));\n assert(columns_in_kernel,feedback(\"The vectors you entered are not all in the kernel.\"))\n\nmark:\n apply(any_empty);\n apply(any_invalid);\n assert(settings[\"precisionType\"]=\"none\" and not settings[\"allowFractions\"], apply(all_same_precision));\n apply(wrong_size);\n correctif(linear_independent and columns_in_kernel);\n apply(further_feedback)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "correctAnswer": "kernel", "correctAnswerFractions": false, "numRows": 1, "numColumns": 1, "allowResize": true, "tolerance": 0, "markPerCell": false, "allowFractions": true, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": true, "customName": "Image", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Enter the basis for the image of \\(T_A\\) as the columns of a matrix. E.g. if there is only one basis vector, select \"1 column\" and enter the vector. If there are two basis vectors, select \"2 columns\" and enter the first basis vector in the first column and the second basis vector in the second column, etc. This way you can determine how many basis vectors there are.
\nIf the image is \\(0\\), then just enter a zero vector of the correct size.
\nA basis of the image of \\(T_A\\) is:
\n[[0]]
", "gaps": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "wrong_size (Does the student's answer have the wrong dimensions?):\n assert(rows=correct_rows and cols=correct_cols,\n incorrect();\n assert(rows=correct_rows, feedback(\"You have the wrong number of rows.\"));\n assert(rank(studentMatrix)=cols,feedback(\"Your column vectors are linearly dependent.\"));\n end()\n )\n\nlinear_independent (Checks rank; note that if there are too many columns, it does not even get to this):\n rank(studentMatrix) =rank(D)\n\n\nspans_image:\n if(rows=correct_rows,\n precround(imagecheckmatrix * studentMatrix,12) = le_zero_matrix(numrows(imagecheckmatrix),cols),\n false)\n\nfurther_feedback:\n assert(linear_independent,feedback(\"The vectors you have entered are not linearly independent.\"));\n assert(spans_image,feedback(\"The vectors you entered do not span the image.\"))\n\nmark:\n apply(any_empty);\n apply(any_invalid);\n assert(settings[\"precisionType\"]=\"none\" and not settings[\"allowFractions\"], apply(all_same_precision));\n apply(wrong_size);\n correctif(linear_independent and spans_image);\n apply(further_feedback)", "extendBaseMarkingAlgorithm": true, "unitTests": [{"variables": [{"name": "pivots3", "value": "[ 2 ]"}, {"name": "Aech", "value": "matrix([0,1,0,-1],[0,0,1,-2],[0,0,0,0],[0,0,0,0])"}, {"name": "A", "value": "matrix([0,-2,3,-4],[0,-1,5,-9],[0,2,-5,8],[0,0,-11,22])"}, {"name": "pivots4", "value": "[ 2, 3 ]"}, {"name": "Bech", "value": "matrix([0,1,0,0],[0,0,1,0],[0,0,0,0])"}, {"name": "Cech", "value": "matrix([0,1,-2],[0,0,0],[0,0,0],[0,0,0])"}, {"name": "B", "value": "matrix([0,17,8,0],[0,-11,-5,0],[0,2,0,0])"}, {"name": "C", "value": "matrix([0,8,-16],[0,-8,16],[0,11,-22],[0,19,-38])"}, {"name": "D", "value": "matrix([0,8,-16],[0,-8,16],[0,11,-22],[0,19,-38])"}, {"name": "colnum", "value": "3"}, {"name": "rankD", "value": "1"}, {"name": "kernel_sized_zero_matrix", "value": "matrix([0,0],[0,0],[0,0])"}, {"name": "rownum", "value": "4"}, {"name": "Dech", "value": "matrix([0,1,-2],[0,0,0],[0,0,0],[0,0,0])"}, {"name": "pivots", "value": "[ 2 ]"}, {"name": "stuffcols", "value": "[ 1, 3 ]"}, {"name": "nullityD", "value": "2"}, {"name": "kernelbasismatrix", "value": "matrix([1,0],[0,2],[0,1])"}, {"name": "kernel", "value": "matrix([1,0],[0,2],[0,1])"}, {"name": "test", "value": "matrix([0,0],[0,0],[0,0],[0,0])"}, {"name": "image", "value": "matrix([8],[-8],[11],[19])"}, {"name": "imagecheckmatrix", "value": "matrix([1,1,0,0],[-1.375,0,1,0],[-2.375,0,0,1])"}], "answer": {"valid": true, "value": [["8"], ["-8"], ["11"], ["19"]]}, "notes": [{"name": "spans_image", "expected": {"value": "true", "messages": [], "warnings": [], "error": "", "valid": true, "credit": 0}}, {"name": "mark", "expected": {"value": "nothing", "messages": ["Your answer is correct.\n\nYou were awarded 1 mark."], "warnings": [], "error": "", "valid": true, "credit": 1}}]}], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "correctAnswer": "image", "correctAnswerFractions": false, "numRows": 1, "numColumns": 1, "allowResize": true, "tolerance": 0, "markPerCell": false, "allowFractions": true, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": true, "customName": "Rank and nullity", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "The rank and nullity of \\(T_A\\) are:
\n\\(r(T_A)= \\) [[0]]
\n\\(n(T_A)= \\) [[1]]
\nCheck for yourself if they satisfy the Rank-Nullity Theorem.
", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "rank", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "alternatives": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "alternativeFeedbackMessage": "Check whether you have entered the rank and nullity the wrong way round.
", "useAlternativeFeedback": false, "minValue": "nullityD", "maxValue": "nullityD", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "minValue": "rankD", "maxValue": "rankD", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "nullity", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "alternatives": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "alternativeFeedbackMessage": "Check if you have entered the rank and nullity the wrong way round.
", "useAlternativeFeedback": false, "minValue": "rankD", "maxValue": "rankD", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "minValue": "nullityD", "maxValue": "nullityD", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "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/"}, {"name": "Peter Guthmann", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/8909/"}]}]}], "contributors": [{"name": "Julia Goedecke", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5121/"}, {"name": "Peter Guthmann", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/8909/"}]}