// Numbas version: exam_results_page_options {"name": "Demo exam", "metadata": {"description": "

This is an old demo. For a demonstration of Numbas's current features, please see the newest demo exam.

\n

A few questions which show off various features of Numbas.

", "licence": "Creative Commons Attribution 4.0 International"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": false, "showstudentname": true, "question_groups": [{"name": "Group", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", "", "", "", ""], "questions": [{"name": "Combining algebraic fractions 1 (Video)", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "variables": {"a2": {"definition": "1", "name": "a2", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "a1": {"definition": "1", "name": "a1", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "s1": {"definition": "if(c<0,-1,1)", "name": "s1", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "c": {"definition": "random(-9..9 except [0,-a])", "name": "c", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "nb": {"definition": "if(c<0,'taking away','adding')", "name": "nb", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "a": {"definition": "random(1..9)", "name": "a", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "b": {"definition": "random(-9..9 except 0)", "name": "b", "description": "", "templateType": "anything", "group": "Ungrouped variables"}, "d": {"definition": "random(-9..9 except [0,round(b*a2/a1)])", "name": "d", "description": "", "templateType": "anything", "group": "Ungrouped variables"}}, "statement": "

Add the following two fractions together and express as a single fraction over a common denominator.

", "variablesTest": {"condition": "", "maxRuns": 100}, "rulesets": {"std": ["all", "!collectNumbers", "fractionNumbers", "!noLeadingMinus"]}, "metadata": {"description": "

Express $\\displaystyle \\frac{a}{x + b} \\pm  \\frac{c}{x + d}$ as an algebraic single fraction over a common denominator. 

\n

Contains a video in Show steps.

", "licence": "Creative Commons Attribution 4.0 International"}, "advice": "\n

The formula for {nb} fractions is :

\n

\\[\\simplify[std]{a / b + {s1} * (c / d) = (ad + {s1} * bc) / bd}\\]

\n

and for this exercise we have $\\simplify{b=x+{b}}$, $\\simplify{d=x+{d}}$.
Hence we have:
\\[\\simplify[std]{{a} / ({a1}*x + {b}) + ({c} / ({a2}*x + {d})) = ({a} * ({a2}*x + {d}) + {c} * ({a1}*x + {b})) / (({a1}*x + {b}) * ({a2}*x + {d})) = ({a*a2 + c*a1} * x + {a * d + c * b}) / (({a1}*x + {b}) * ({a2}*x + {d}))}\\]

\n ", "preamble": {"js": "", "css": ""}, "tags": ["algebra", "algebraic fractions", "algebraic manipulation", "chain rule", "combining algebraic fractions", "common denominator"], "functions": {}, "ungrouped_variables": ["a", "c", "b", "d", "nb", "a1", "a2", "s1"], "parts": [{"gaps": [{"variableReplacementStrategy": "originalfirst", "vsetRange": [10, 11], "checkingType": "absdiff", "checkingAccuracy": 1e-05, "showFeedbackIcon": true, "variableReplacements": [], "answer": "({a*a2 + c*a1} * x + {a * d + c * b})/ (({a1}*x + {b}) * ({a2}*x + {d}))", "scripts": {}, "showCorrectAnswer": true, "customMarkingAlgorithm": "", "answerSimplification": "std", "failureRate": 1, "unitTests": [], "extendBaseMarkingAlgorithm": true, "marks": 2, "type": "jme", "showPreview": true, "notallowed": {"strings": [")-", ")+"], "message": "

Input as a single fraction.

", "showStrings": false, "partialCredit": 0}, "checkVariableNames": false, "expectedVariableNames": [], "vsetRangePoints": 5}], "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "scripts": {}, "showCorrectAnswer": true, "customMarkingAlgorithm": "", "unitTests": [], "extendBaseMarkingAlgorithm": true, "marks": 0, "steps": [{"variableReplacementStrategy": "originalfirst", "unitTests": [], "extendBaseMarkingAlgorithm": true, "marks": 0, "showFeedbackIcon": true, "customMarkingAlgorithm": "", "prompt": "

The formula for {nb} fractions is:

\n

\\[\\simplify[std]{a / b + {s1} * (c / d) = (ad + {s1} * bc) / bd}\\]

\n

and for this exercise we have $\\simplify{b=x+{b}}$, $\\simplify{d=x+{d}}$.

\n

Note that in your answer you do not need to expand the denominator.

\n

The following video goes through an example similar to this one.

\n

", "type": "information", "scripts": {}, "showCorrectAnswer": true, "variableReplacements": []}], "type": "gapfill", "stepsPenalty": 1, "prompt": "

Express

\n

\\[\\simplify{{a} / ({a1}x + {b}) + ({c} / ({a2}x + {d}))}\\]

\n

as a single fraction.

\n

Enter the fraction here: [[0]]

\n

Input your answer in the form $\\displaystyle \\frac{(ax+b)}{((cx+d)(ex+f))}$ with no other brackets than those shown.

\n

Click on Show steps if you need help. You will lose one mark if you do so.

"}], "variable_groups": [], "type": "question"}, {"name": "Graph of a quadratic function", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": ["JSXgraph", "jsxgraph", "Jsxgraph", "plot", "quadratic"], "metadata": {"description": "

Compute a table of values for a quadratic function. A JSXgraph plot shows the curve going through the entered values.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

You are given the quadratic formula

\n

$y=\\simplify[std]{{a}x^2+{c}}$

", "advice": "", "rulesets": {"std": ["all", "fractionNumbers"]}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"a": {"name": "a", "group": "Ungrouped variables", "definition": "random(-2,-1,-0.5,0.5,1,2)", "description": "", "templateType": "anything", "can_override": false}, "c": {"name": "c", "group": "Ungrouped variables", "definition": "random(-4..4 except 0)", "description": "", "templateType": "anything", "can_override": false}, "ys": {"name": "ys", "group": "Ungrouped variables", "definition": "map(a*x^2+c,x,-3..3)", "description": "

The $y$-coordinates of the points to plot.

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["a", "c", "ys"], "variable_groups": [], "functions": {}, "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n var a = scope.variables.a.value;\n var c = scope.variables.c.value;\n var maxy = Math.max(Math.abs(a*9+c),Math.abs(c));\n \n var div = Numbas.extensions.jsxgraph.makeBoard('250px','400px',{boundingBox:[-5,maxy+3,5,-maxy-3],grid:true});\n $(question.display.html).find('#dragpoint').append(div);\n \n var board = div.board;\n \n //shorthand to evaluate a mathematical expression to a number\n function evaluate(expression) {\n try {\n var val = Numbas.jme.evaluate(expression,question.scope);\n return Numbas.jme.unwrapValue(val);\n }\n catch(e) {\n // if there's an error, return no number\n return NaN;\n }\n }\n \n // set up points array\n var num_points = 7;\n var points = [];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n var point = points[i] = board.create(\n 'glider',\n [i-(num_points-1)/2,0,line],\n {\n name:'',\n size:2,\n snapSizeY: 0.1, // the point will snap to y-coordinates which are multiples of 0.1\n snapToGrid: true\n }\n );\n \n // the contents of the input box for this point\n var studentAnswer = question.parts[1].gaps[i].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n y = evaluate(studentAnswer());\n if(!(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var y = Numbas.math.niceNumber(point.Y());\n studentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;iThe graph of this formula is:

", "minMarks": 0, "maxMarks": 1, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["

An upwards-opening parabola

", "

A downwards-opening parabola

"], "matrix": ["if(a>0,1,0)", "if(a>0,0,1)"], "distractors": ["", ""]}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Fill in the table of values for $y=\\simplify[std]{{a}x^2+{c}}$:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$x$$-3$$-2$$-1$$0$$1$$2$$3$
$y$[[0]][[1]][[2]][[3]][[4]][[5]][[6]]
\n
", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "$x=-3$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "ys[0]", "maxValue": "ys[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "$x=-2$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "ys[1]", "maxValue": "ys[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "$x=-1$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "ys[2]", "maxValue": "ys[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "$x=0$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "ys[3]", "maxValue": "ys[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "$x=1$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "ys[4]", "maxValue": "ys[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "$x=2$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "ys[5]", "maxValue": "ys[5]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "$x=3$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "ys[6]", "maxValue": "ys[6]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "matrix", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Give the coordinates of the turning point of the parabola.

", "correctAnswer": "matrix([0,c])", "correctAnswerFractions": false, "numRows": 1, "numColumns": "2", "allowResize": false, "tolerance": 0, "markPerCell": false, "allowFractions": true, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Quadratic regression", "extensions": ["stats", "jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}], "functions": {"regfun": {"definition": "\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',\n{boundingBox:[-15,maxy,maxx,-400],\n axis:false,\n showNavigation:false,\n grid:false,\n });\n\n var board = div.board; \nvar xaxis = board.create('line',[[0,0],[1,0]], { strokeColor: 'black', fixed: true,name:\"Advertising spend\",withLabel:false});\nvar xticks = board.create('ticks',[xaxis,10],{\n drawLabels: true,\n label: {offset: [-4, -10]},\n minorTicks: 0\n});\n\n// create the y-axis\nvar yaxis = board.create('line',[[0,0],[0,1]], { strokeColor: 'black', fixed: true,name:\"Revenue\",withLabel:false });\nvar yticks = board.create('ticks',[yaxis,500],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0\n});\nfor (j=0;ja) We have  $\\displaystyle a = \\frac{SPXY}{SSX}$ where:

\n

$\\displaystyle SPXY=\\sum xy - \\frac{(\\sum x)\\times (\\sum y)}{\\var{n}}=\\var{sxy}-\\frac{\\var{t[0]}\\times \\var{t[1]}}{\\var{n}}=\\var{spxy}$

\n

$\\displaystyle SSX=\\sum x^2 - \\frac{(\\sum x)^2}{\\var{n}}=\\var{ssq[0]}- \\frac{\\var{t[0]}^2}{\\var{n}}=\\var{ss[0]}$

\n

Hence $\\displaystyle a=\\frac{\\var{spxy}}{\\var{ss[0]}}=\\var{spxy/ss[0]}$.

\n

\n

Then $\\displaystyle b = \\frac{1}{\\var{n}}\\left[\\sum y-a \\sum x\\right]=\\frac{1}{\\var{n}}\\left[\\var{t[1]}-\\var{atrue}\\times\\var{t[0]}\\right]=\\var{btrue}$

\n

", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"stepsPenalty": 0, "prompt": "

{regfun(r1,r2,max(r1)+30,max(r2)+30,rsquared,sumr,n,1)}

\n

First  we perform a linear regression $y=ax+b$ to find the equation of the line fitted as shown in the above diagram. 

\n

You have to calculate the coefficients $a,\\;b$

\n

If you input your line (before submitting) it will be drawn on the above graph to see how it compares with the fitted line. 

\n

Note carefully that the line drawn only gives a rough guide to the fitted line and you should always calculate $a$ and $b$ to ensure you obtain the required result.

\n

Input your line in the form $y=ax+b$ for values of $a$ and $b$ accurate to 3 decimal places,

\n

$y=\\;$[[0]].    

\n

Click on Show steps if you want more information on calculating $a$ and $b$. You will not lose any marks by doing so.

\n

\n

 

", "marks": 0, "gaps": [{"expectedvariablenames": [], "checkingaccuracy": 0.001, "vsetrange": [0, 1], "showpreview": true, "vsetrangepoints": 5, "showCorrectAnswer": true, "answersimplification": "all,!noLeadingMinus", "scripts": {}, "answer": "{a}*x+{b}", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "type": "jme"}], "showCorrectAnswer": true, "scripts": {}, "steps": [{"type": "information", "showCorrectAnswer": true, "scripts": {}, "prompt": "

To find $a$ and $b$ you first find  $\\displaystyle a = \\frac{SPXY}{SSX}$ where:

\n

$\\displaystyle SPXY=\\sum xy - \\frac{(\\sum x)\\times (\\sum y)}{\\var{n}}$

\n

$\\displaystyle SSX=\\sum x^2 - \\frac{(\\sum x)^2}{\\var{n}}$

\n

Then $\\displaystyle b = \\frac{1}{\\var{n}}\\left[\\sum y-a \\sum x\\right]$

\n

Note that it is advisable to do all your calculations to at least 5 decimal places in order to ensure that $a$ and $b$ are accurate to 3 decimal places at the end of the calulations. This means that when you calculate $b$ using $a$ then $a$ should be accurate to at least 5 decimal places.

\n

\n

 

", "marks": 0}], "type": "gapfill"}, {"type": "information", "showCorrectAnswer": true, "scripts": {}, "prompt": "

Next we fit the data by using quadratic regression, that is we look for a function of the form $y=ax^2+bx+c$ for constants $a,\\;b\\;c$ which best fit the data.

\n

You are not expected to find this quadratic and we display it below.

\n

Note the SSE is displayed, which is a measure of how well the quadratic regression fits the data. Compare this with the SSE for the linear regression, also displayed.

\n

{regfun(r1,r2,max(r1)+30,max(r2)+30,rsquared,sumr,n,2)}

\n

You can increase the degree of the polynomial fitting the data by moving the slider and the measure of how well it fits is given by the updated SSE. But note that it doesn't make much sense in doing this if there are only marginal gains in fitting the polynomial as measured by the SSE. The rule is that you should always go for the simplest model!

", "marks": 0}], "statement": "

It is believed that there is a quadratic relationship between the amount a company spends on advertising ( $X$, in thousands of pounds) and their revenue ( $Y$, also in thousands of pounds).

\n

To investigate, $X$ and $Y$ were collected for a randomly selected number $\\var{n}$ of companies in the U.K. 

\n

\n

\n

\n

\n

\n

\n

\n

Your first task is to find the equation of the linear regression fitted as shown as the black line. You are given the information below in order to complete the task.

\n\n\n\n\n\n\n\n\n\n\n\n
$X$$\\sum x=\\;\\var{t[0]}$$\\sum x^2=\\;\\var{ssq[0]}$
$Y$$\\sum y=\\;\\var{t[1]}$$\\sum y^2=\\;\\var{ssq[1]}$
\n

Also you are given $\\sum xy = \\var{sxy}$.

\n

\n

", "variable_groups": [], "progress": "ready", "preamble": {"css": "", "js": ""}, "variables": {"ch": {"definition": "random(0..n-1)", "templateType": "anything", "group": "Ungrouped variables", "name": "ch", "description": ""}, "atrue": {"definition": "spxy/ss[0]", "templateType": "anything", "group": "Ungrouped variables", "name": "atrue", "description": ""}, "b1": {"definition": "random(2..5#0.1)", "templateType": "anything", "group": "Ungrouped variables", "name": "b1", "description": ""}, "sxy": {"definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "templateType": "anything", "group": "Ungrouped variables", "name": "sxy", "description": ""}, "res": {"definition": "map(precround(r2[x]-(b+a*r1[x]),2),x,0..n-1)", "templateType": "anything", "group": "Ungrouped variables", "name": "res", "description": ""}, "spxy": {"definition": "sxy-t[0]*t[1]/n", "templateType": "anything", "group": "Ungrouped variables", "name": "spxy", "description": ""}, "ls": {"definition": "precround(b+a*sc,2)", "templateType": "anything", "group": "Ungrouped variables", "name": "ls", "description": ""}, "tol": {"definition": 0.001, "templateType": "anything", "group": "Ungrouped variables", "name": "tol", "description": ""}, "a": {"definition": "precround(atrue,3)", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "btrue": {"definition": "1/n*(t[1]-spxy/ss[0]*t[0])", "templateType": "anything", "group": "Ungrouped variables", "name": "btrue", "description": ""}, "ssq": {"definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "templateType": "anything", "group": "Ungrouped variables", "name": "ssq", "description": ""}, "sumr": {"definition": "round(sum(map(res[x]^2,x,0..n-1)))", "templateType": "anything", "group": "Ungrouped variables", "name": "sumr", "description": ""}, "a1": {"definition": "random(2..5#0.5)", "templateType": "anything", "group": "Ungrouped variables", "name": "a1", "description": ""}, "c1": {"definition": "random(0.1..1#0.1)", "templateType": "anything", "group": "Ungrouped variables", "name": "c1", "description": ""}, "tsqovern": {"definition": "[t[0]^2/n,t[1]^2/n]", "templateType": "anything", "group": "Ungrouped variables", "name": "tsqovern", "description": ""}, "b": {"definition": "precround(btrue,3)", "templateType": "anything", "group": "Ungrouped variables", "name": "b", "description": ""}, "obj": {"definition": "['A','B','C','D','E','F','G','H']", "templateType": "anything", "group": "Ungrouped variables", "name": "obj", "description": ""}, "r1": {"definition": "repeat(round(normalsample(50,10)),n)", "templateType": "anything", "group": "Ungrouped variables", "name": "r1", "description": ""}, "r2": {"definition": "map(round((a1+b1*x+c1*x^2+normalsample(0,20))),x,r1)", "templateType": "anything", "group": "Ungrouped variables", "name": "r2", "description": ""}, "ss": {"definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "templateType": "anything", "group": "Ungrouped variables", "name": "ss", "description": ""}, "n": {"definition": "random(20..35)", "templateType": "anything", "group": "Ungrouped variables", "name": "n", "description": ""}, "t": {"definition": "[sum(r1),sum(r2)]", "templateType": "anything", "group": "Ungrouped variables", "name": "t", "description": ""}, "sc": {"definition": "r1[ch]", "templateType": "anything", "group": "Ungrouped variables", "name": "sc", "description": ""}, "rsquared": {"definition": "precround(spxy^2/(ss[0]*ss[1]),3)", "templateType": "anything", "group": "Ungrouped variables", "name": "rsquared", "description": ""}}, "metadata": {"notes": "

10/02/2014:

\n

Created. Based on the Numbas question JSXGraph line of best fit plot 5

\n

14/02/2014:

\n

Improved display and modified so that $20 \\le n \\le 35$. Also sharpened up the error term to be N(0,20) rather than N(0,100) (see variable r2)  so that the quadratic regression would clearly be best.

", "description": "

The data is fitted by linear and quadratic regression.  First, find a linear regression equation for the $n$ data points, $20 \\le n \\le 35$.

\n

They then are shown that the quadratic regression is often a better fit as measured by SSE. Also users can experiment with fitting polynomials of higher degree.

\n

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Integrate an expression", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "functions": {}, "ungrouped_variables": ["a", "b"], "tags": ["demo"], "preamble": {"css": "", "js": "//*************\n// differentiation\nvar jme = Numbas.jme;\nvar TNum = Numbas.jme.types.TNum;\n\nvar functionDerivatives = {\n 'cos': '-sin(x)',\n 'sin': 'cos(x)'\n};\nvar generalFunctionDerivative = jme.compile(\"f'(x)\");\nfor(var name in functionDerivatives) {\n functionDerivatives[name] = jme.compile(functionDerivatives[name]);\n}\nvar chainRule = jme.compile(\"x'*f'\")\n var opDerivatives = {\n '+': \"u'+v'\",\n '+u': \"+u'\",\n '-u': \"-u'\",\n '-': \"u'-v'\",\n '*': \"u'*v+u*v'\",\n \"/\": \"(v*u'-v'*u)/(v^2)\"\n }\n var powerRule = jme.compile(\"v*u'*u^(v-1)\");\nvar exponentialRule = jme.compile(\"ln(u)*v'*u^v\");\nfor(var name in opDerivatives) {\n opDerivatives[name] = jme.compile(opDerivatives[name]);\n}\n\nvar differentiate = jme.differentiate = function(tree,x) {\n var tok = tree.tok;\n \n switch(tok.type) {\n case 'number':\n return {tok: new TNum(0)};\n break;\n case 'name':\n return {tok: new TNum(tok.name==x ? 1 : 0)};\n case 'op':\n var l = differentiate(tree.args[0],x,1);\n if(tree.args.length>1)\n var r = differentiate(tree.args[1],x,1);\n var scope = {variables: {\"u\": tree.args[0], \"u'\": l, \"v\": tree.args[1], \"v'\": r}};\n if(tok.name=='^') {\n if(tree.args[1].tok.type=='number' || (tree.args[1].tok.type=='op' && tree.args[1].tok.name=='-u' && tree.args[1].args[0].tok.type=='number')) {\t// f(x)^n\n return jme.substituteTree(powerRule,scope);\n }\n else if(tree.args[0].tok.type=='number' || (tree.args[0].tok.type=='op' && tree.args[0].tok.name=='-u' && tree.args[0].args[0].tok.type=='number')) {\t// n^x\n return jme.substituteTree(exponentialRule,scope);\n }\n else {\n throw(new Numbas.Error('jme.differentiate.hard exponential'));\n }\n }\n return jme.substituteTree(opDerivatives[tok.name],scope);\n case 'function':\n var df = jme.substituteTree(tok.name in functionDerivatives ? functionDerivatives[tok.name] : generalFunctionDerivative,{variables:{x:tree.args[0], \"f'\": tok.name+\"'\"}});\n var dx = differentiate(tree.args[0],x);\n return jme.substituteTree(chainRule,{variables: {\"f'\": df, \"x'\": dx}});\n }\n}\n // end of differentiation code\n // ***************************\n \n question.signals.on('HTMLAttached',function() {\n var gap = question.parts[0].gaps[0];\n var omark = gap.mark;\n var add_constant_rule = new Numbas.jme.display.Rule('x+y',[]);\n gap.mark = function() {\n var integral = gap.studentAnswer;\n var tree;\n var derivative;\n var derivative_tree;\n try {\n tree = Numbas.jme.compile(integral);\n derivative_tree = differentiate(tree,'x');\n derivative = Numbas.jme.display.treeToJME(derivative_tree);\n derivative = Numbas.jme.display.simplifyExpression(derivative,'all',Numbas.jme.builtinScope);\n }\n catch(e) {\n derivative = '';\n }\n // set the \"student's answer\" to the derivative\n this.studentAnswer = derivative;\n \n // mark the JME part\n omark.apply(this);\n \n // set the student's answer back to what they typed\n this.studentAnswer = integral;\n \n this.markingFeedback = [];\n \n if(this.credit==1) { // derivative matches\n this.markingComment('Your answer is correct. Well done!');\n \n // check there's a constant of integration\n if(Numbas.jme.findvars(tree).length!=2) {\n this.multCredit(0.5,'You need to add a constant of integration, but otherwise this is correct.');\n }\n }\n else {\n var derivativeTeX = Numbas.jme.display.exprToLaTeX(derivative,[],Numbas.jme.builtinScope);\n this.markingComment('The derivative of your answer should be equal to the expression you were asked to integrate, i.e.: \\\\[ \\\\simplify{cos({a}x) + e^(x/{b})} \\\\] The derivative of your function is \\\\['+derivativeTeX+'\\\\]');\n }\n }\n });"}, "advice": "", "rulesets": {}, "parts": [{"prompt": "

This part is marked by calculating the derivative of your answer and comparing it to the original expression.

\n

$\\displaystyle{\\int \\simplify{cos({a}x) + e^(x/{b})} \\,\\mathrm{d}x = }$ [[0]]

", "marks": 0, "gaps": [{"expectedvariablenames": [], "checkingaccuracy": 0.001, "vsetrange": [0, 1], "showpreview": true, "vsetrangepoints": 5, "showCorrectAnswer": true, "scripts": {}, "answer": "cos({a}x)+e^(x/{b})", "marks": 2, "checkvariablenames": false, "checkingtype": "absdiff", "type": "jme"}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}], "statement": "", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "type": "question", "variables": {"a": {"definition": "random(1..10)", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "b": {"definition": "random(-10..10 except 0)", "templateType": "anything", "group": "Ungrouped variables", "name": "b", "description": ""}}, "metadata": {"notes": "", "description": "

Demo question: do some sneaky symbolic differentiation to check that the student's answer is the integral of the expression they're given.

\n

Needs an advice section before it can be used.

", "licence": "Creative Commons Attribution 4.0 International"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Dynamical system 6:Centre.", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}], "functions": {}, "ungrouped_variables": ["xr", "yr", "v", "f"], "tags": ["centres", "differential equations", "Differential equations", "dynamical system", "feedback", "fixed points", "interactive", "Jsxgraph", "jsxgraph", "navigation change", "phase space", "stable", "systems of differential equations", "unstable"], "preamble": {"css": "", "js": "var pc;\nvar brd;\nvar P1;\nvar brd1;\nvar g1;\nvar g2;\nvar fin;\nvar m;\nvar adv;\nfunction updateBoards(a,b,c,d) {\n function f(x,yy) {\n var y1 = yy[0];\n var y2 = yy[1];\n var z1 = a*y1+b*y2;\n var z2 = c*y1+d*y2;\n return [z1,z2];\n }\n \n function ode() {\n //solution curve data array produced in the interval between 0 and 10, 200 steps\n return JXG.Math.Numerics.rungeKutta('heun', [P1.Y(),P1.X()], [0, 10], 500, f);\n }\n function ode1() {\n //solution curve data array produced in the interval between 0 and -10, 200 steps\n return JXG.Math.Numerics.rungeKutta('heun', [P1.Y(),P1.X()], [0, -10], 500, f);\n }\n \n pc.updateDataArray = function() {\n var data = ode();\n var l=data.length;\n var data1=ode1();\n var l1=data1.length;\n this.dataX = [];\n this.dataY = [];\n for(var i=0; i0){\n ty='Unstable spiral.';\n } \n else if(ans1<0){\n ty='Stable spiral.';\n }\n else {\n ty='Centre.';\n }\n }\n else {\n if(det<0){\n ty='Saddle.';\n }\n else if ((det>0)&&(ans1>0)){\n ty='Unstable node.';\n } \n else {\n ty='Stable node.';\n }\n }\n }\n else {ty=''};\n //if either the input has not been completed or the correct answer has been input - no message.\n if(fin){adv='You have not entered all the numerical values into the matrix';}\n if(fin||((ans1==0)&&(ans2==0))){ m='';}\n //all entries have been input and an incorrect diagonal value has been input or gives the wrong eigenvalue.\n else if(ans1!=0){m='You did not enter the correct value for the diagonal.';}\n else {m='You have the wrong eigenvalue.';}\n \n var html = $(question.display.html);\n html.find('#type').text(ty);\n //This is displayed in the question as an aid to the user.\n html.find('#mess').text(m);\n \n /*values for hidden gapfills which are marked*/\n question.parts[0].gaps[3].display.studentAnswer(ans1); \n question.parts[0].gaps[4].display.studentAnswer(ans2);\n \n updateBoards(a,b,c,d);\n });\n});\n"}, "advice": "

Given the system of differential equations:

\n

\\[\\begin{align}\\dot{x}&=\\simplify[std]{a*x+b*y},\\\\\\dot{y}&=\\simplify[std]{c*x+d*y}.\\end{align}\\]

\n

It can be written in the form $\\dot{\\boldsymbol{x}}=\\mathsf{A}\\boldsymbol{x}$, where $\\boldsymbol{x}=\\pmatrix{x,y}^\\mathsf{T}$ and 

\n

\\[\\mathsf{A}=\\pmatrix{a& b\\\\c & d}\\]

\n

In this case, with $a=\\var{f}$  we want to enter values for $b,\\;c,\\;d$ such that the system gives a centre.

\n

For this to happen we need the eigenvalues of $A$ to be purely imaginary and you are given that they are $\\simplify{{v}*i}$ and $\\simplify{{-v}*i}$.

\n

The characteristic polynomial for $A$ is given by 

\n

\\[\\det\\left(\\mathsf{A}-\\lambda\\mathsf{I}\\right)=0,\\]

\n

i.e.  $(a-\\lambda)(d-\\lambda)-bc=0$.  This leads to $\\lambda^2-(a+d)\\lambda+(ad-bc)=0$.

\n

So in order to get purely imaginary eigenvalues $\\pm \\var{abs(v)*i}$ we need :

\n

1. $a+d=0 \\Rightarrow d=\\var{-f}$ as $a=\\var{f}$.

\n

2. $ad-bc=\\var{v^2} \\Rightarrow bc=-\\var{v^2}-\\var{f^2}$.

\n

Hence if you set $d=\\var{-f}$ and you  choose values of  $b,\\;c$ such that $bc=-\\var{f^2+v^2}$, this will give the required system of differential equations with phase space a centre and the required eigenvalues.

", "rulesets": {"std": ["all", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"stepsPenalty": 0, "prompt": "

The system can be written in the form $\\dot{\\boldsymbol{x}}=\\mathsf{A}\\boldsymbol{x}$, where $\\boldsymbol{x}=\\pmatrix{x,y}^\\mathsf{T}$.

\n

Input the components of the matrix $\\mathsf{A}$ in order to obtain a centre where the eigenvalues of $A$ are $\\simplify{{v}*i}$ and $\\simplify{{-v}*i}$.

\n

You are given that $a=\\var{f}$.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\mathsf{A}=\\Bigg($$\\var{f}$[[0]]$\\Bigg)$
[[1]][[2]]
\n

\n

\n

Once you have input appropriate values into the matrix, the diagram below shows the plot of $(x(t),y(t))$.

\n

At $t=0$ we have initally $x=-5,\\;\\;y=5$. Moving the point gives phase diagrams for the following initial values at $t=0$:

\n

$x=\\;$       $y=\\;$

\n

\n

\n
\n

\n\n

\n

You can click on Steps to see the solutions for $x(t),\\;y(t)$ after you have input values into the matrix.

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "steps": [{"prompt": "

Graph of $x(t),\\;y(t)$

\n
\n

\n

$x(t)$ is in black, $y(t)$ in blue.

\n

You can use the navigation bar to zoom in and out of the graph.

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "information"}], "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "0", "minValue": "0", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "0", "minValue": "0", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 2, "type": "numberentry", "showPrecisionHint": false}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "statement": "

Consider the following two-dimensional dynamical system . You have to find values for $a,\\;b\\;c,\\;d$ such that the system's phase space is a centre.

\n

\\[\\begin{align}\\dot{x}&=\\simplify[std]{a*x+b*y},\\\\\\dot{y}&=\\simplify[std]{c*x+d*y}.\\end{align}\\]

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"xr": {"definition": "50", "templateType": "anything", "group": "Ungrouped variables", "name": "xr", "description": ""}, "yr": {"definition": "50", "templateType": "anything", "group": "Ungrouped variables", "name": "yr", "description": ""}, "f": {"definition": "random(-9..9 except[0,1,-1])", "templateType": "anything", "group": "Ungrouped variables", "name": "f", "description": ""}, "v": {"definition": "random(1..5)", "templateType": "anything", "group": "Ungrouped variables", "name": "v", "description": ""}}, "metadata": {"notes": "

\n

01/04/2014:

\n

Created.

\n

02/02/2014:

\n

Graphs of  x(t), y(t) included.

\n

04/08/2014

\n

Changed showNavigation to false and commented out line re using Jsxgraph navigation in the Part as this does not work at present - need to upload new version of jsxgraph?

", "description": "

Asking users to input coefficients of a system of diff equations so that the phase space is a centre. All systems input by the user are graphed together with immediate feedback. Also included in the Steps are the graphs of the solutions for $x(t),\\; y(t);\\; x(0)=-5,\\;y(0)=5.$

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}]}], "navigation": {"allowregen": true, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": false, "showresultspage": "never", "navigatemode": "sequence", "onleave": {"action": "none", "message": ""}, "preventleave": false, "startpassword": ""}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"showactualmark": true, "showtotalmark": true, "showanswerstate": true, "allowrevealanswer": true, "advicethreshold": 0, "intro": "", "reviewshowscore": true, "reviewshowfeedback": true, "reviewshowexpectedanswer": true, "reviewshowadvice": true, "feedbackmessages": []}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "extensions": ["jsxgraph", "stats"], "custom_part_types": [], "resources": []}