// Numbas version: exam_results_page_options {"name": "Functions: definition of a function", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Functions: definition of a function", "statement": "

For two sets $A,B$ the Cartesian product is

\n

$A \\times B = \\left\\{(a,b) | a \\in A, b \\in B\\right\\}.$

\n

A function $f$ from $A$ to $B$, written $f : A \\mapsto B$, is a subset of $A\\times B$ subject to the condition that for all $a\\in A$ there is exactly one $b\\in B$ such that $(a,b) \\in f$.

\n

In other words, for every $a$ the function must determine a unique output $b$. Since $a$ determines $b$ we usually indicate this with the function notation $f(a) = b$.

\n

For example, consider the sets $A = \\left\\{\\var{a0},\\var{a1},\\var{b1},\\var{a2}\\right\\}$ and $B=\\left\\{\\var{b0},\\var{b1},\\var{b2}\\right\\}$ and $f : A \\mapsto B$ defined by

\n

$f = \\left\\{ (\\var{a0},\\var{b0}),(\\var{a1},\\var{b1}),(\\var{a2},\\var{b0}),(\\var{a0},\\var{b1})\\right\\}$.

\n

", "extensions": [], "ungrouped_variables": ["a0", "a1", "a2", "b0", "b1", "b2"], "metadata": {"licence": "Creative Commons Attribution-ShareAlike 4.0 International", "description": "

Intorduces students to the definition of a function $f:A\\mapsto B$ as a subset of the Cartesian product $A\\times B$.

"}, "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "rulesets": {}, "functions": {}, "preamble": {"css": "", "js": ""}, "advice": "

This question exhibits the different ways to show that $f$ is not a function.

\n
\n

Part a introduces the notion of a function as a subset of the Cartesian product, and is designed to get you used to the syntax.

\n

For part b, there are two values of $\\var{b0},\\var{b1} \\in B$ which are equal to $f(\\var{a0})$. This means that $f(\\var{a0})$ is not uniquely determined, and so $f$ can not be a function.

\n

For part c, we see that $\\var{b1} \\in A$ but there is no function value for $f(\\var{b1})$. This means that $f(a)$ is not uniquely determined for every $a \\in A$ and so $f$ can not be a function.

", "tags": [], "parts": [{"variableReplacementStrategy": "originalfirst", "minMarks": 0, "type": "m_n_2", "variableReplacements": [], "warningType": "none", "scripts": {}, "minAnswers": 0, "maxMarks": 0, "showCellAnswerState": true, "useCustomName": false, "extendBaseMarkingAlgorithm": true, "customName": "", "shuffleChoices": true, "matrix": ["1", "-1", "1", "-1", "1", "-1"], "showFeedbackIcon": true, "displayType": "checkbox", "showCorrectAnswer": true, "prompt": "

Which of the following are true?

", "marks": 0, "displayColumns": 0, "unitTests": [], "maxAnswers": 0, "customMarkingAlgorithm": "", "distractors": ["", "According to the relation $(\\var{a0}, \\var{b0}) \\in f$, but you answered $(\\var{b0}, \\var{a0})$ which is not in $f$.", "", "According to the relation $f(\\var{a2})=\\var{b0}$, but you answered $f(\\var{b0}) = \\var{a2}$.", "", "You chose $f(\\var{a2}) = \\var{b1}$ but $(\\var{a2}, \\var{b1}) \\notin f$."], "choices": ["

$(\\var{a0}, \\var{b0}) \\in f$

", "

$(\\var{b0}, \\var{a0}) \\in f$

", "

$f(\\var{a2}) = \\var{b0}$

", "

$f(\\var{b0}) = \\var{a2}$

", "

$(\\var{a1}, \\var{b1}) \\in f$

", "

$f(\\var{a2}) = \\var{b1}$

"]}, {"variableReplacementStrategy": "originalfirst", "minMarks": 0, "type": "m_n_2", "variableReplacements": [], "warningType": "none", "scripts": {}, "minAnswers": 0, "maxMarks": 0, "showCellAnswerState": true, "useCustomName": false, "extendBaseMarkingAlgorithm": true, "customName": "", "shuffleChoices": true, "matrix": ["0.5", "0.5", "-0.5", "-0.5", "-0.5"], "showFeedbackIcon": true, "displayType": "checkbox", "showCorrectAnswer": true, "prompt": "

For $f$ to be a function there must be exactly one $b$ value for every $a$ value such that $f(a) = b$. This means that there are two ways that $f$ can fail to be a function: either there are too many possible values of $b$, or too few.

\n

In this example $f$ is not a function because there is more than one value of $b$ such that $f(\\var{a0}) = b$. These are

", "marks": 0, "displayColumns": 0, "unitTests": [], "maxAnswers": 0, "customMarkingAlgorithm": "", "distractors": ["", "", "", "", ""], "choices": ["

$\\var{b0}$

", "

$\\var{b1}$

", "

$\\var{a0}$

", "

$\\var{a1}$

", "

$\\var{a2}$

"]}, {"variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "checkVariableNames": false, "failureRate": 1, "type": "jme", "variableReplacements": [], "scripts": {"mark": {"script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar a0 = unwrap(variables.a0);\nvar a1 = unwrap(variables.a1);\nvar a2 = unwrap(variables.a2);\n\nvar b0 = unwrap(variables.b0);\nvar b1 = unwrap(variables.b1);\nvar b2 = unwrap(variables.b2);\n\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n switch (ans) {\n case a0:\n this.setCredit(0,\"$f(\" + a0 + \")$ is defined to be $\" + b0 + \"$ and $\" + b1 + \"$.\");\n break;\n case a1:\n this.setCredit(0,\"$f(\" + a1 + \")$ is defined to be $\" + b1 + \"$.\");\n break;\n case a2:\n this.setCredit(0,\"$f(\" + a2 + \")$ is defined to be $\" + b0 + \"$.\");\n break;\n case b1: \n this.setCredit(1,\"You correctly identified that $f(\" + b1 + \")$ is undefined.\");\n break;\n default:\n this.setCredit(0,\"Your answer $\" + ans + \"$ is not an element of the domain $A$.\");\n break;\n }\n}\ncatch(e) {\n this.markingComment(e);\n}", "order": "instead"}}, "useCustomName": false, "extendBaseMarkingAlgorithm": true, "customName": "", "vsetRange": [0, 1], "showFeedbackIcon": true, "showCorrectAnswer": true, "prompt": "

Here is a different reason why $f$ is not a function -  becase there is one value of $a\\in A$ such that $f(a)$ is not defined. This is

", "marks": "1", "showPreview": true, "valuegenerators": [], "unitTests": [], "checkingAccuracy": 0.001, "customMarkingAlgorithm": "", "answer": "{b1}", "checkingType": "absdiff"}], "variables": {"a0": {"name": "a0", "group": "Ungrouped variables", "definition": "random(0..9)", "templateType": "anything", "description": ""}, "b2": {"name": "b2", "group": "Ungrouped variables", "definition": "random(0..9 except [a0,a1,a2,b0,b1])", "templateType": "anything", "description": ""}, "b0": {"name": "b0", "group": "Ungrouped variables", "definition": "random(0..9 except [a0,a1,a2])", "templateType": "anything", "description": ""}, "a1": {"name": "a1", "group": "Ungrouped variables", "definition": "random(0..9 except a0)", "templateType": "anything", "description": ""}, "a2": {"name": "a2", "group": "Ungrouped variables", "definition": "random(0..9 except [a0,a1])", "templateType": "anything", "description": ""}, "b1": {"name": "b1", "group": "Ungrouped variables", "definition": "random(0..9 except [a0,a1,a2,b0])", "templateType": "anything", "description": ""}}, "type": "question", "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}