// Numbas version: exam_results_page_options {"name": "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": "Numbas demo: Motion under gravity", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Customised for the Numbas demo exam

\n

Motion 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.

"}, "extensions": ["jsxgraph"], "preamble": {"js": "", "css": ""}, "statement": "

A Numbas question can include interactive graphics, such as this plot of the trajectory given by the student's answer.

\n

See this question in the public editor

\n

A 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$).

\n

The ball is projected upwards with a speed $\\var{v}\\;m/s$.

", "variable_groups": [], "functions": {"graphsolution": {"type": "html", "parameters": [], "language": "javascript", "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 "}, "advicegraph": {"type": "html", "parameters": [], "language": "javascript", "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;"}}, "variables": {"g": {"name": "g", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "9.81"}, "t": {"name": "t", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "V/g"}, "t1": {"name": "t1", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "precround(t,2)"}, "mh": {"name": "mh", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "precround(V^2/(2*g),2)"}, "v": {"name": "v", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "random(50..100)"}}, "tags": [], "parts": [{"variableReplacements": [], "gaps": [{"checkingAccuracy": 0.001, "variableReplacements": [], "vsetRangePoints": 5, "vsetRange": [0, 1], "valuegenerators": [{"name": "g", "value": ""}, {"name": "t", "value": ""}], "type": "jme", "useCustomName": false, "failureRate": 1, "checkingType": "absdiff", "checkVariableNames": true, "unitTests": [], "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "customMarkingAlgorithm": "", "showPreview": true, "answer": "{v}t-1/2g*t^2", "showCorrectAnswer": true, "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": 1}], "type": "gapfill", "useCustomName": false, "prompt": "

{graphsolution()}

\n

Input the vertical distance $z$ as a  function of $t$.

\n

Note that at $t=0$ we have $z=0$ and that $\\displaystyle \\frac{dz}{dt}=\\var{v}m/s$.

\n

Input gravitational acceleration as $g$.

\n

$z=$ [[0]]

\n

Your formula is plotted in the graph above. The vertical axis represents $z$ and the horizontal axis represents $t$.

\n

Note that the blue line indicates that:

\n
    \n
  1. Your solution should go through $(0,0)$;
  2. \n
  3. Your solution should have this line as the tangent to the curve at $(0,0)$, because $\\displaystyle \\frac{\\mathrm{d}z}{\\mathrm{d}t}=\\var{v}\\; m/s$.
  4. \n
", "unitTests": [], "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "sortAnswers": false, "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": 0}, {"variableReplacements": [], "gaps": [{"variableReplacements": [], "minValue": "t1", "useCustomName": false, "maxValue": "t1", "showCorrectAnswer": true, "correctAnswerFraction": false, "mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "unitTests": [], "precisionType": "dp", "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": 1, "precisionPartialCredit": 0, "type": "numberentry", "precision": "2", "mustBeReduced": false, "showPrecisionHint": false, "correctAnswerStyle": "plain", "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "allowFractions": false, "precisionMessage": "You have not given your answer to the correct precision.", "customMarkingAlgorithm": "", "strictPrecision": false}, {"variableReplacements": [], "minValue": "mh", "useCustomName": false, "maxValue": "mh", "showCorrectAnswer": true, "correctAnswerFraction": false, "mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "unitTests": [], "precisionType": "dp", "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": 1, "precisionPartialCredit": 0, "type": "numberentry", "precision": "2", "mustBeReduced": false, "showPrecisionHint": false, "correctAnswerStyle": "plain", "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "allowFractions": false, "precisionMessage": "You have not given your answer to the correct precision.", "customMarkingAlgorithm": "", "strictPrecision": false}], "type": "gapfill", "useCustomName": false, "prompt": "

Time taken to reach maximum height = [[0]] $s$ (accurate to $2$ decimal places)

\n

Maximum height = [[1]] $m$ (accurate to $2$ decimal places)

", "unitTests": [], "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "sortAnswers": false, "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

a)

\n

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}$.

\n

But $A=\\var{v}$ as the velocity is $\\var{V}\\;m/s$ at $t=0$.

\n

So the velocity is

\n

\\begin{align} \\frac{\\mathrm{d}z}{\\mathrm{d}t} &= \\var{v}-gt & (1) \\end{align}

\n

Integrating again gives

\n

\\[ z = \\var{v}t-\\frac{g}{2}t^2+B \\]

\n

and $B=0$ as $z=0$ at $t=0$.

\n

Hence the distance travelled upwards is given by

\n

\\begin{align} z &= \\var{v}t-\\frac{g}{2}t^2 & (2) \\end{align}

\n

{advicegraph()}

\n

b)

\n

The 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}

\n

(to $2$ decimal places)

\n

This is at the point $A$ in the graph above.

\n

c)

\n

The 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}

\n

(to $2$ decimal places)

\n

This is at the point $B$ in the graph above.

", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "ungrouped_variables": ["t", "v", "mh", "g", "t1"], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}