// Numbas version: finer_feedback_settings {"name": "Alan's copy of Numbas demo: Motion under gravity", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Alan's copy of Numbas demo: Motion under gravity", "variables": {"t1": {"definition": "precround(t,2)", "description": "", "name": "t1", "group": "Ungrouped variables", "templateType": "anything"}, "g": {"definition": "9.81", "description": "", "name": "g", "group": "Ungrouped variables", "templateType": "anything"}, "v": {"definition": "random(50..100)", "description": "", "name": "v", "group": "Ungrouped variables", "templateType": "anything"}, "t": {"definition": "V/g", "description": "", "name": "t", "group": "Ungrouped variables", "templateType": "anything"}, "mh": {"definition": "precround(V^2/(2*g),2)", "description": "", "name": "mh", "group": "Ungrouped variables", "templateType": "anything"}}, "variable_groups": [], "advice": "
Integrating $\\displaystyle{\\frac{\\mathrm{d}^2z}{\\mathrm{d}t^2}=-g}$ once gives the velocity $\\displaystyle{\\frac{\\mathrm{d}z}{\\mathrm{d}t}=-gt+A}$.
\nBut $A=\\var{v}$ as the velocity is $\\var{V}\\;m/s$ at $t=0$.
\nSo the velocity is
\n\\begin{align} \\frac{\\mathrm{d}z}{\\mathrm{d}t} &= \\var{v}-gt & (1) \\end{align}
\nIntegrating again gives
\n\\[ z = \\var{v}t-\\frac{g}{2}t^2+B \\]
\nand $B=0$ as $z=0$ at $t=0$.
\nHence the distance travelled upwards is given by
\n\\begin{align} z &= \\var{v}t-\\frac{g}{2}t^2 & (2) \\end{align}
\n{advicegraph()}
\nThe time $t_{\\text{max}}$ taken to reach maximum height is the time satisfying $\\displaystyle{\\frac{dz}{dt}=0}$
\n$t_{\\text{max}}$ is given from equation $(1)$ by
\n\\begin{align}
\\var{v} - gt_{\\text{max}} &= 0 \\\\
gt_{\\text{max}} &= \\var{v} \\\\
t_{\\text{max}} &= \\frac{\\var{v}}{g} \\\\[0.5em]
&= \\frac{\\var{v}}{9.81} \\\\[0.5em]
&= \\var{t1}
\\end{align}
(to $2$ decimal places)
\nThis is at the point $A$ in the graph above.
\nThe maximum height $z_{\\text{max}}$ is given from equation $(2)$ by substituting in the value $t_{\\text{max}}= \\var{v}/g$, giving
\n\\begin{align}
z_{\\text{max}} &= \\var{v} \\times \\frac{\\var{v}}{g} - \\frac{g}{2}\\left(\\frac{\\var{v}}{g}\\right)^2 \\\\
&= \\frac{\\var{v}^2}{g}-\\frac{g\\var{v}^2}{2g^2} \\\\
&= \\frac{\\var{v}^2}{2g} \\\\
&= \\var{mh}\\;m
\\end{align}
(to $2$ decimal places)
\nThis is at the point $B$ in the graph above.
", "ungrouped_variables": ["t", "v", "mh", "g", "t1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "statement": "A Numbas question can include interactive graphics, such as this plot of the trajectory given by the student's answer.
\nSee this question in the public editor
\nA ball is thrown upwards, and moves according to the equation $\\displaystyle{\\frac{d^2z}{dt^2}=-g}$
(where $z(t)$ is distance in metres measured upwards from the ground and the constant acceleration of gravity, $g$ , is given as $9.81\\;m/s^2$).
The ball is projected upwards with a speed $\\var{v}\\;m/s$.
", "metadata": {"description": "Customised for the Numbas demo exam
\nMotion under gravity. Object is projected vertically with initial velocity $V\\;m/s$. Find time to maximum height and the maximum height. Now includes an interactive plot.
", "licence": "Creative Commons Attribution 4.0 International"}, "functions": {"advicegraph": {"type": "html", "definition": "var v = Numbas.jme.unwrapValue(scope.variables.v);\nvar mh = Numbas.jme.unwrapValue(scope.variables.mh);\nvar t = Numbas.jme.unwrapValue(scope.variables.t1);\nvar g = Numbas.jme.unwrapValue(scope.variables.g);\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',\n {boundingBox:[-3,mh+50,2*t+2,-50],\n axis:false,\n showNavigation:false,\n grid:false});\nvar brd = div.board; \n var xas = brd.create('line',[[0,0],[1,0]], { strokeColor: 'black',fixed:true});\n var xticks = brd.create('ticks',[xas,1],{\ndrawLabels: true,\nlabel: {offset: [-4, -10]},\nminorTicks: 0\n });\n var yas = brd.create('line',[[0,0],[0,1]], { strokeColor: 'black',fixed:true});\n var yticks = brd.create('ticks',[yas,50],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0\n }); \nfunction traj(x){return v*x-g*Math.pow(x,2)/2;}\nvar p=brd.create('point',[0,0],{fixed:true,name:'',size:1});\n//var q=brd.create('line',[[0,0],[1,v]],{fixed:true,name:'',dash:2});\nvar r=brd.create('point',[t,0],{fixed:true,name:'A',size:1});\nvar s=brd.create('point',[t,mh],{fixed:true,name:'B',size:1});\nvar maxh=brd.create(\"segment\",[[0,mh],[t,mh]],{dash:1,strokeColor:'green'});\nvar gr=brd.create(\"functiongraph\",[traj,0,2*t],{strokeColor:'blue',strokeWidth:2});\nvar halft=brd.create(\"segment\",[[t,0],[t,traj(t)]],{dash:1,strokeColor:'green'});\nreturn div;", "parameters": [], "language": "javascript"}, "graphsolution": {"type": "html", "definition": "var v = Numbas.jme.unwrapValue(scope.variables.v);\nvar mh = Numbas.jme.unwrapValue(scope.variables.mh);\nvar t = Numbas.jme.unwrapValue(scope.variables.t1);\nvar g = Numbas.jme.unwrapValue(scope.variables.g);\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',\n {boundingBox:[-3,mh+10,2*t+2,-50],\n axis:false,\n showNavigation:false,\n grid:false});\nvar brd = div.board; \n var xas = brd.create('line',[[0,0],[1,0]], { strokeColor: 'black',fixed:true});\n var xticks = brd.create('ticks',[xas,1],{\ndrawLabels: true,\nlabel: {offset: [-4, -10]},\nminorTicks: 0\n });\n var yas = brd.create('line',[[0,0],[0,1]], { strokeColor: 'black',fixed:true});\n var yticks = brd.create('ticks',[yas,50],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0\n }); \nvar p=brd.create('point',[0,0],{fixed:true,name:'',size:1});\nvar q=brd.create('line',[[0,0],[1,v]],{fixed:true,name:'',dash:2});\nvar tree;\n//x is the variable in the equation to be input\n var nscope = new Numbas.jme.Scope([scope,{variables:{t:new Numbas.jme.types.TNum(0)}}]);\n//create a functiongraph from the student input\nfunction userf(t){\nif(tree) {\n try {\nnscope.variables.t.value = t;\n//the user input is evaluated at x=t\n var val = Numbas.jme.evaluate(tree,nscope).value;\n return val;\n }\n catch(e) {\nreturn 0;\n }\n}\nelse\n return 0;\n}\nvar curve=brd.create('functiongraph',[userf,0,2*t],{strokeColor:'red',strokeWidth:2});\n\n //pick up the student answer and is parsed\n question.signals.on('HTMLAttached',function(e) {\nko.computed(function(){\nvar expr = question.parts[0].gaps[0].display.studentAnswer();\ntry {\n tree = Numbas.jme.compile(expr,scope);\n}\ncatch(e) {\n tree = null;\n}\ncurve.updateCurve();\n\nbrd.update();\n});\n }); \n\nreturn div;\n ", "parameters": [], "language": "javascript"}}, "preamble": {"css": "", "js": ""}, "tags": [], "extensions": ["jsxgraph"], "variablesTest": {"maxRuns": 100, "condition": ""}, "parts": [{"scripts": {}, "prompt": "{graphsolution()}
\nInput the vertical distance $z$ as a function of $t$.
\nNote that at $t=0$ we have $z=0$ and that $\\displaystyle \\frac{dz}{dt}=\\var{v}m/s$.
\nInput gravitational acceleration as $g$.
\n$z=$ [[0]]
\nYour formula is plotted in the graph above. The vertical axis represents $z$ and the horizontal axis represents $t$.
\nNote that the blue line indicates that:
\nTime taken to reach maximum height = [[0]] $s$ (accurate to $2$ decimal places)
\nMaximum height = [[1]] $m$ (accurate to $2$ decimal places)
", "customMarkingAlgorithm": "", "unitTests": [], "gaps": [{"mustBeReducedPC": 0, "minValue": "t1", "showPrecisionHint": false, "adaptiveMarkingPenalty": 0, "customName": "", "correctAnswerFraction": false, "scripts": {}, "unitTests": [], "allowFractions": false, "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "customMarkingAlgorithm": "", "precision": "2", "maxValue": "t1", "showCorrectAnswer": true, "marks": 1, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "type": "numberentry", "correctAnswerStyle": "plain", "extendBaseMarkingAlgorithm": true, "precisionPartialCredit": 0, "useCustomName": false, "showFeedbackIcon": true, "strictPrecision": false, "variableReplacements": [], "precisionType": "dp"}, {"mustBeReducedPC": 0, "minValue": "mh", "showPrecisionHint": false, "adaptiveMarkingPenalty": 0, "customName": "", "correctAnswerFraction": false, "scripts": {}, "unitTests": [], "allowFractions": false, "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "customMarkingAlgorithm": "", "precision": "2", "maxValue": "mh", "showCorrectAnswer": true, "marks": 1, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "type": "numberentry", "correctAnswerStyle": "plain", "extendBaseMarkingAlgorithm": true, "precisionPartialCredit": 0, "useCustomName": false, "showFeedbackIcon": true, "strictPrecision": false, "variableReplacements": [], "precisionType": "dp"}], "marks": 0, "adaptiveMarkingPenalty": 0, "customName": "", "type": "gapfill", "showCorrectAnswer": true, "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "useCustomName": false, "showFeedbackIcon": true, "variableReplacements": [], "sortAnswers": false}], "type": "question", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Alan Levine", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4070/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Alan Levine", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4070/"}]}