// Numbas version: exam_results_page_options {"name": "Functions and Critical Points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International", "description": "

Uses JSXGraph to generate a plot for a cubic, with given critical points, along with three other incorrect graphs with modified properties. JSXGraph code is commented.

"}, "preamble": {"css": "", "js": ""}, "advice": "

a) Critical points of $f(x)$ are found as solutions to $f'(x)=0$. For a cubic function $f(x)$ the differential is quadratic, so you will find two (not necessarily distinct, in general) roots.

\n

b) The nature of a critical point $x_{*}$ of $f(x)$ is determined by the sign of $f''(x_{*})$. If $f''(x_{*})>0$, $x_{*}$ is a minimum; if $f''(x_{*})=0$, $x_{*}$ is a saddle point; if $f''(x_{*})<0$, $x_{*}$ is a maximum.

\n

c) To match the function to a graph, the elements to consider are:

\n
    \n
  1. Roots of the function: $x$ such that $f(x)=0$. This gives the crossings on the $x$-axis;
  2. \n
  3. Critical points: $x$ such that $f'(x)=0$. This gives the turning points on the graph;
  4. \n
  5. Nature of critical points.
  6. \n
\n

d) The gradient of a tangent line at a point $x_{0}$ is simply $f'(x_{0})$. Writing the equation of a line as $y-y_{0}=m(x-x_{0})$, we can see that the equation of the tangent line at $x_{0}$ can be written as $y-f(x_{0})=f'(x_{0})(x-x_{0})$, from which we can find the equation in the form $y=mx+c$. If $m_{t}$ is the gradient of the tangent line, then the gradient of the normal is $m_{n}=-1/m_{t}$, and given that the normal line also passes through the point $(x_{0},f(x_{0}))$, we can find the normal line equation similarly.

\n

e) There are two places where a minimum of a continuous function can occur on a closed interval $[a,b]$: either at an endpoint, giving minimum $f(a)$ or $f(b)$, or at a turning point of the function, provided the turning point is a minimum. So we simply check the value of $f(x)$ at the endpoints $x=a$ and $x=b$, and check $f(x)$ at any critical points (found in (a)), and pick the minimum of those.

", "rulesets": {}, "extensions": ["jsxgraph"], "name": "Functions and Critical Points", "ungrouped_variables": ["crit1", "crit2", "crit1func", "crit2func", "coeff", "const", "whichpoint", "rand", "markingmatrix", "freevbls", "crits", "tanpoint", "mini", "start", "end"], "functions": {"graph": {"type": "html", "definition": "/* Given a function defined by its critical points f'(x)=a(x-c1)(x-c2), this takes the critical points\nand the free variables (the coefficient a and some constant b) and produces a graph containing the axes,\nand roughly centred around the critical points. \nTo call this in a question, we use {graph([{crit1},{crit2}],[{freevbl1,freevbl2})}. See Part c)*/\n// NOTE THAT THIS MUST BE SET TO OUTPUT HTML IN THE FUNCTION DESCRIPTION ABOVE\n\n// Simple boring function to evaluate f(x) at a point.\nfunction funcval(val)\n{\n return freevbls[0]/3 *math.pow(val,3)-freevbls[0]/2 *(crits[0]+crits[1])*val*val+freevbls[0]*crits[0]*crits[1]*val+freevbls[1];\n}\n\n// An artifact of me changing the plot limits a lot and being too lazy to change it everywhere.\nvar dist=2;\n\n// Since JSXGraph takes the region of plotting in the form of a bounding box: (upperleftcoords, bottomrightcoords),\n// this finds the maximum and minimum of the region to be plotted.\nvar uppercritval = Numbas.math.max(funcval(crits[0]),funcval(crits[1]));\nvar lowercritval = Numbas.math.min(funcval(crits[0]),funcval(crits[1]));\nvar leftlim = Numbas.math.max(funcval(crits[0]-dist),funcval(crits[1]+dist));\nvar rightlim = Numbas.math.min(funcval(crits[1]+dist),funcval(crits[0]-dist));\n\n/* JSXGraph code. The first line initialises the plotting region: height and width settings are given\nfor the output, then we define a bounding box. Here I've checked max and min again to ensure that\nthe axes are present in any plot we make. Finally, we can choose to show axes and a grid if wanted. */\nvar grdiv = Numbas.extensions.jsxgraph.makeBoard('200px','200px',{boundingbox:[Numbas.math.min(-0.5,crits[0])-dist,Numbas.math.max(leftlim,Numbas.math.max(0.5,uppercritval))+dist,Numbas.math.max(0.5,crits[1])+dist,Numbas.math.min(rightlim,Numbas.math.min(lowercritval,-0.5))-dist],axis:true,grid:false});\n// The object in JSXGraph is the 'board'. Adding graphs, points etc is equivalent to creating things on the board.\nvar board = grdiv.board;\n/* Creating the function. Relatively straightforward: 'functiongraph' is the JSXGraph name, then we define\na function to plot (using my funcval()), along with a start and endpoint for the plotting. */\nvar graph = board.create('functiongraph',[function(x){return funcval(x);},math.floor(crits[0]-dist)-1,math.floor(crits[1]+dist)+1]);\n// Chucks out the board, with the plot on it!\nreturn grdiv;", "language": "javascript", "parameters": [["crits", "list"], ["freevbls", "list"]]}}, "tags": [], "variablesTest": {"condition": "not (crit1=0 or crit2=0)", "maxRuns": 100}, "variable_groups": [], "variables": {"crits": {"name": "crits", "group": "Ungrouped variables", "definition": "[min(crit1,crit2),max(crit1,crit2)]", "description": "

As in freevbls, but provides the critical points as a list.

", "templateType": "anything"}, "crit1": {"name": "crit1", "group": "Ungrouped variables", "definition": "random(-3..3#0.5)", "description": "

A turning point of the function f(x).

", "templateType": "anything"}, "whichpoint": {"name": "whichpoint", "group": "Ungrouped variables", "definition": "[latex('x_{1}'),latex('x_{2}')]", "description": "

This (with rand below) picks a random critical point that the student should use in part (b).

", "templateType": "anything"}, "rand": {"name": "rand", "group": "Ungrouped variables", "definition": "random([0,1])", "description": "

See in whichpoint.

", "templateType": "anything"}, "crit2": {"name": "crit2", "group": "Ungrouped variables", "definition": "random(-3..3#0.5)", "description": "

A turning point of the function f(x).

", "templateType": "anything"}, "const": {"name": "const", "group": "Ungrouped variables", "definition": "random(-10..10)", "description": "

The constant part of $f'(x)$.

", "templateType": "anything"}, "tanpoint": {"name": "tanpoint", "group": "Ungrouped variables", "definition": "random(-2..2 except [crit1,crit2])", "description": "

A point from which the tangent and normal lines in part (d) should be calculated.

", "templateType": "anything"}, "coeff": {"name": "coeff", "group": "Ungrouped variables", "definition": "random(-6..6 except 0)", "description": "

The coefficient of $x$ in $f'(x)$.

", "templateType": "anything"}, "crit1func": {"name": "crit1func", "group": "Ungrouped variables", "definition": "coeff*crit1^3/3-coeff*(crit1+crit2)/2 * crit1^2+coeff*crit1^2*crit2+const", "description": "

The function value at the first critical point.

\n

This is defined here for ease of notation in finding the minimum of the function.

", "templateType": "anything"}, "crit2func": {"name": "crit2func", "group": "Ungrouped variables", "definition": "coeff*crit2^3/3-coeff*(crit1+crit2)/2 * crit2^2+coeff*crit1*crit2^2+const", "description": "

The function value at the second critical point.

\n

This is defined here for ease of notation in finding the minimum of the function.

", "templateType": "anything"}, "end": {"name": "end", "group": "Ungrouped variables", "definition": "random([0,1] except start)", "description": "

Upper bound of the interval in (e).

", "templateType": "anything"}, "mini": {"name": "mini", "group": "Ungrouped variables", "definition": "min([if(crit1>=start and crit1<=end and markingmatrix[0][1]=1,crit1func,infinity),if(crit2>=start and crit2<=end and markingmatrix[1][1]=1,crit2func,infinity),coeff*end^3/3-coeff*(crit1+crit2)*end^2/2+coeff*crit1*crit2*end+const,coeff*start^3/3-coeff*(crit1+crit2)*start^2/2+coeff*crit1*crit2*start+const])", "description": "

Works out the minimum of the function for (e). Takes the minimum of the f(start), f(end), and f(crit1), f(crit2). f(crit1), f(crit2) is only included if crit1, crit2 respectively lie in the interval; else they are assigned the value $\\infty$ (so as to be excluded as a possible minimum).

", "templateType": "anything"}, "freevbls": {"name": "freevbls", "group": "Ungrouped variables", "definition": "[coeff,const]", "description": "

A list of free variables to be passed to the custom JavaScript graph generator.

", "templateType": "anything"}, "markingmatrix": {"name": "markingmatrix", "group": "Ungrouped variables", "definition": "[if(2*coeff*crits[0]-coeff*(crit1+crit2)<0,[1,-1,-1],if(2*coeff*crits[0]-coeff*(crit1+crit2)>0,[-1,1,-1],[-1,-1,1])),if(2*coeff*crits[1]-coeff*(crit1+crit2)<0,[1,-1,-1],if(2*coeff*crits[1]-coeff*(crit1+crit2)>0,[-1,1,-1],[-1,-1,1]))]", "description": "

A marking matrix for part (b). The first entry gives a marking matrix for if $x_{1}$ was selected by rand and whichpoint; similarly for the second entry.

", "templateType": "anything"}, "start": {"name": "start", "group": "Ungrouped variables", "definition": "random([-1,0])", "description": "

Lower bound of the interval in (e).

", "templateType": "anything"}}, "statement": "

Consider the function $y=\\simplify[all,fractionNumbers]{{coeff/3}*x^3-{coeff*(crit1+crit2)/2} *x^2+{coeff*crit1*crit2}*x+{const}}$.

", "parts": [{"customName": "", "type": "gapfill", "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "gaps": [{"customName": "", "type": "jme", "customMarkingAlgorithm": "", "vsetRangePoints": 5, "checkingAccuracy": 0.001, "variableReplacementStrategy": "originalfirst", "marks": 1, "showFeedbackIcon": true, "valuegenerators": [], "failureRate": 1, "answer": "min({crit1},{crit2})", "checkVariableNames": false, "scripts": {}, "useCustomName": false, "showPreview": true, "checkingType": "absdiff", "vsetRange": [0, 1], "showCorrectAnswer": true, "unitTests": [], "variableReplacements": [], "extendBaseMarkingAlgorithm": true}, {"customName": "", "type": "jme", "customMarkingAlgorithm": "", "vsetRangePoints": 5, "checkingAccuracy": 0.001, "variableReplacementStrategy": "originalfirst", "marks": 1, "showFeedbackIcon": true, "valuegenerators": [], "failureRate": 1, "answer": "max({crit1},{crit2})", "checkVariableNames": false, "scripts": {}, "useCustomName": false, "showPreview": true, "checkingType": "absdiff", "vsetRange": [0, 1], "showCorrectAnswer": true, "unitTests": [], "variableReplacements": [], "extendBaseMarkingAlgorithm": true}], "sortAnswers": false, "prompt": "

Find the values of $x$ at the turning points of the function, where $x_{1}\\le x_{2}$.

\n

Point 1: $x_{1}=$[[0]]

\n

Point 2: $x_{2}=$[[1]]

", "scripts": {}, "useCustomName": false, "showCorrectAnswer": true, "unitTests": [], "variableReplacements": [], "extendBaseMarkingAlgorithm": true}, {"customName": "", "type": "1_n_2", "customMarkingAlgorithm": "", "maxMarks": 0, "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "displayColumns": 0, "minMarks": 0, "matrix": "markingmatrix[rand]", "choices": ["

A maximum?

", "

A minimum?

", "

An inflexion point?

"], "prompt": "

Is the turning point $\\var{whichpoint[rand]}$:

", "shuffleChoices": false, "scripts": {}, "useCustomName": false, "displayType": "radiogroup", "showCorrectAnswer": true, "showCellAnswerState": true, "unitTests": [], "variableReplacements": [], "extendBaseMarkingAlgorithm": true}, {"customName": "", "type": "1_n_2", "maxMarks": 0, "showFeedbackIcon": true, "displayType": "radiogroup", "showCorrectAnswer": true, "showCellAnswerState": true, "matrix": ["1", 0, 0, 0], "distractors": ["", "", "", ""], "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "

Select the graph that represents the function.

", "displayColumns": 0, "minMarks": 0, "choices": ["

{graph({crits},{freevbls})}

", "

{graph([{min(-crit1,2*crit2)},{max(-crit1,2*crit2)}],{freevbls})}

", "

{graph({crits},[{-coeff},{const}])}

", "

{graph([{min(-crit1,crit2)},{max(-crit1,crit2)}],[{-coeff},{const}])}

"], "shuffleChoices": true, "scripts": {}, "useCustomName": false, "unitTests": [], "variableReplacements": [], "extendBaseMarkingAlgorithm": true}, {"customName": "", "type": "gapfill", "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "gaps": [{"customName": "", "type": "jme", "customMarkingAlgorithm": "", "vsetRangePoints": 5, "checkingAccuracy": 0.001, "variableReplacementStrategy": "originalfirst", "marks": "2", "showFeedbackIcon": true, "valuegenerators": [{"name": "x", "value": ""}], "failureRate": 1, "answer": "{coeff*(tanpoint-crit1)*(tanpoint-crit2)}(x-{tanpoint})+{coeff*tanpoint*tanpoint*tanpoint/3-coeff*(crit1+crit2)*tanpoint*tanpoint/2+coeff*crit1*crit2*tanpoint+const}", "checkVariableNames": false, "scripts": {}, "useCustomName": false, "showPreview": true, "checkingType": "absdiff", "vsetRange": [0, 1], "showCorrectAnswer": true, "unitTests": [], "variableReplacements": [], "extendBaseMarkingAlgorithm": true}, {"customName": "", "type": "jme", "customMarkingAlgorithm": "", "vsetRangePoints": 5, "checkingAccuracy": 0.001, "variableReplacementStrategy": "originalfirst", "marks": 1, "showFeedbackIcon": true, "valuegenerators": [{"name": "x", "value": ""}], "failureRate": 1, "answer": "-1/{coeff*(tanpoint-crit1)*(tanpoint-crit2)}(x-{tanpoint})+{coeff*tanpoint*tanpoint*tanpoint/3-coeff*(crit1+crit2)*tanpoint*tanpoint/2+coeff*crit1*crit2*tanpoint+const}", "checkVariableNames": false, "scripts": {}, "useCustomName": false, "showPreview": true, "checkingType": "absdiff", "vsetRange": [0, 1], "showCorrectAnswer": true, "unitTests": [], "variableReplacements": [], "extendBaseMarkingAlgorithm": true}], "sortAnswers": false, "prompt": "

Find the equations of the tangent line and normal line at $x=\\var{tanpoint}$. Give your answer in the form $y=mx+c$, where $m$ and $c$ are to be determined.

\n

Tangent line: $y=$[[0]]

\n

Normal line: $y=$[[1]]

", "scripts": {}, "useCustomName": false, "showCorrectAnswer": true, "unitTests": [], "variableReplacements": [], "extendBaseMarkingAlgorithm": true}, {"customName": "", "type": "jme", "vsetRangePoints": 5, "answer": "{mini}", "showFeedbackIcon": true, "valuegenerators": [], "failureRate": 1, "checkingType": "absdiff", "checkVariableNames": false, "showCorrectAnswer": true, "useCustomName": false, "customMarkingAlgorithm": "", "checkingAccuracy": 0.001, "marks": 1, "prompt": "

Find the minimum of the function on $[\\var{start},\\var{end}]$.

", "variableReplacementStrategy": "originalfirst", "scripts": {}, "extendBaseMarkingAlgorithm": true, "showPreview": true, "unitTests": [], "variableReplacements": [], "vsetRange": [0, 1]}], "contributors": [{"name": "Andrew Iskauskas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/724/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}]}], "contributors": [{"name": "Andrew Iskauskas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/724/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}