// 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": [{"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.

", "tags": [], "functions": {"graph": {"parameters": [["crits", "list"], ["freevbls", "list"]], "language": "javascript", "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;"}}, "name": "Functions and Critical Points", "ungrouped_variables": ["crit1", "crit2", "crit1func", "crit2func", "coeff", "const", "whichpoint", "rand", "markingmatrix", "freevbls", "crits", "tanpoint", "mini", "start", "end"], "variables": {"mini": {"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", "group": "Ungrouped variables", "name": "mini", "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])"}, "whichpoint": {"description": "

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

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

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

", "templateType": "anything", "group": "Ungrouped variables", "name": "tanpoint", "definition": "random(-2..2 except [crit1,crit2])"}, "markingmatrix": {"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", "group": "Ungrouped variables", "name": "markingmatrix", "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]))]"}, "crit1": {"description": "

A turning point of the function f(x).

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

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

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

See in whichpoint.

", "templateType": "anything", "group": "Ungrouped variables", "name": "rand", "definition": "random([0,1])"}, "crit2func": {"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", "group": "Ungrouped variables", "name": "crit2func", "definition": "coeff*crit2^3/3-coeff*(crit1+crit2)/2 * crit2^2+coeff*crit1*crit2^2+const"}, "crit1func": {"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", "group": "Ungrouped variables", "name": "crit1func", "definition": "coeff*crit1^3/3-coeff*(crit1+crit2)/2 * crit1^2+coeff*crit1^2*crit2+const"}, "freevbls": {"description": "

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

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

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

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

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

", "templateType": "anything", "group": "Ungrouped variables", "name": "crits", "definition": "[min(crit1,crit2),max(crit1,crit2)]"}, "start": {"description": "

Lower bound of the interval in (e).

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

A turning point of the function f(x).

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

Upper bound of the interval in (e).

", "templateType": "anything", "group": "Ungrouped variables", "name": "end", "definition": "random([0,1] except start)"}}, "variablesTest": {"condition": "not (crit1=0 or crit2=0)", "maxRuns": 100}, "parts": [{"extendBaseMarkingAlgorithm": true, "scripts": {}, "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]]

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

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

", "showCellAnswerState": true, "maxMarks": 0, "variableReplacementStrategy": "originalfirst", "minMarks": 0, "displayColumns": 0, "shuffleChoices": false, "choices": ["

A maximum?

", "

A minimum?

", "

An inflexion point?

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

Select the graph that represents the function.

", "maxMarks": 0, "variableReplacementStrategy": "originalfirst", "minMarks": 0, "shuffleChoices": true, "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}])}

"], "unitTests": [], "type": "1_n_2", "showCorrectAnswer": true, "marks": 0, "customMarkingAlgorithm": ""}, {"extendBaseMarkingAlgorithm": true, "scripts": {}, "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]]

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

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

", "answer": "{mini}", "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "vsetRange": [0, 1], "showPreview": true, "showCorrectAnswer": true, "marks": 1, "vsetRangePoints": 5}], "extensions": ["jsxgraph"], "statement": "

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

", "preamble": {"css": "", "js": ""}, "rulesets": {}, "metadata": {"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.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "variable_groups": [], "contributors": [{"name": "Andrew Iskauskas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/724/"}]}]}], "contributors": [{"name": "Andrew Iskauskas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/724/"}]}