// Numbas version: finer_feedback_settings {"name": "Population growth with plot", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Population growth with plot", "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-NonCommercial 4.0 International"}, "statement": "", "advice": "

We have \\(P_0=\\var{P_0}\\)  and \\(P=\\var{pop}\\) at \\(t = \\var{t}\\) years, hence:

\n

\\begin{align}\\var{pop}&=\\var{P_0}\\left(1-e^{-\\var{t}k}\\right)\\\\\\frac{\\var{pop}}{\\var{P_0}}&=\\left(1-e^{-\\var{t}k}\\right)\\\\e^{-\\var{t}k}&=1-\\frac{\\var{pop}}{\\var{P_0}}\\quad\\text{taking natural logs of both sides we have}\\\\-\\var{t}k&=\\ln\\left( 1-\\frac{\\var{pop}}{\\var{P_0}}\\right)\\\\k&=-\\frac{\\ln\\left({1-\\frac{\\var{pop}}{\\var{P_0}}}\\right)}{\\var{t}}\\\\k&\\approx\\var{k} \\end{align}

\n

Hence the  formula for population as a function of time is \\(P(t)=\\var{P_0}\\left(1-e^{-\\var{k}t}\\right)\\)

\n

The graph of the population vs time function will be:

\n

{sol_graph}

", "rulesets": {}, "extensions": ["jsxgraph"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"pop": {"name": "pop", "group": "Ungrouped variables", "definition": "random(0.50*P_0..0.95*P_0 #2000)", "description": "

Population density at time t years

", "templateType": "anything", "can_override": false}, "k": {"name": "k", "group": "Ungrouped variables", "definition": "precround(-ln(1-pop/P_0)/t,3)", "description": "", "templateType": "anything", "can_override": false}, "P_0": {"name": "P_0", "group": "Ungrouped variables", "definition": "random(20000..35000 #5000)", "description": "

maximum population density

", "templateType": "anything", "can_override": false}, "t": {"name": "t", "group": "Ungrouped variables", "definition": "random(5..15)", "description": "

Time (in years) to achieve given population density.

", "templateType": "anything", "can_override": false}, "sol_graph": {"name": "sol_graph", "group": "Ungrouped variables", "definition": "jessiecode(800,500,[-t/10,1.1*P_0,1.1*t,-0.1*P_0],\"\"\"\n line([0,{P_0}],[1,{P_0}])<>;\n text({t/2},{-0.06*P_0},\"Time (years)\");\n text({-t/15},{P_0/2},\"Population\") <>;\n functiongraph('{fn}',0,{1.1*t}) <>;\n \"\"\",\n )", "description": "", "templateType": "anything", "can_override": false}, "fn": {"name": "fn", "group": "Ungrouped variables", "definition": "'{P_0}*(1-exp(-{k}*x))'", "description": "", "templateType": "anything", "can_override": false}, "P_1": {"name": "P_1", "group": "Ungrouped variables", "definition": "random(10000..pop-2000 #2000)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["pop", "k", "P_0", "t", "sol_graph", "fn", "P_1"], "variable_groups": [], "functions": {"graph": {"parameters": [["p", "number"], ["time", "number"]], "type": "html", "language": "javascript", "definition": "// This function creates the board and sets it up, then returns an\n// HTML div tag containing the board.\n \n\n\n// First, make the JSXGraph board.\n// The function provided by the JSXGraph extension wraps the board up in \n// a div tag so that it's easier to embed in the page.\nvar div = Numbas.extensions.jsxgraph.makeBoard('600px','400px',\n{boundingBox: [-1.5,1.1*p,time+1,-2000],\n axis: true,\n showNavigation: false,\n grid: true\n});\n \n// div.board is the object created by JSXGraph, which you use to \n// manipulate elements\nvar board = div.board; \n\n\n\n// create the static line based on the room temperature\nvar line1 = board.create('line',[[0,p],[1,p]],{fixed:true, strokeWidth:1});\nvar xlab = board.create('text',[time/2,-900,\"Time(years)\"]);\nvar ylab = board.create('text',[-1,p/2,\"Population\"], {display: 'internal', rotate: 90});\n\n\n// Now we can do the clever stuff with the student's answer!\n// We'll add a curve to the board which is a plot of a function we provide.\n// That function will parse the student's input and evaluate it.\n\n// The variable `studentExpression` will store the parsed version of\n// the student's expression.\nvar studentExpression;\n\n// This function evaluates the student's expression at a given point `t`.\nfunction makestudentline(t){\n // Create a JME scope with the variable x set to the given value.\n var nscope = new Numbas.jme.Scope([\nNumbas.jme.builtinScope,\n{variables: {t: new Numbas.jme.types.TNum(t)}}\n ]);\n \n // If the student's input has been parsed, evaluate it\n if(studentExpression) {\ntry {\n var val = Numbas.jme.evaluate(studentExpression,nscope).value;\n return val;\n}\ncatch(e) {\n // If there was an error evaluating the student's expression\n // (wrong variables, or some other weirdness)\n // throw an error\n throw(e)\n}\n }\n // Otherwise, if the student's expression hasn't been parsed\n // (they haven't written anything, or they wrote bad syntax)\n // return 0\n else {\nreturn 0;\n }\n}\nvar studentline = board.create('functiongraph', \n [makestudentline,0,time+1],\n {strokeColor:'black', strokeWidth: 3, visible: false}\n );\n\n// This is where some voodoo happens.\n// Because the HTML for the question is inserted into the page after the function eqnline\n// is called, we need to wait until the 'question-html-attached' event is fired\n// to do the interaction with the student input box.\n// So:\n\n// When the question is inserted into the page\nquestion.signals.on('HTMLAttached',function(e) {\n \n // Create a Knockout.js observable\n ko.computed(function(){\n// Get the student's input string from part 0, gap 0.\nvar studentString = question.parts[0].gaps[1].display.studentAnswer();\n\n// Try to parse it as a JME expression\ntry {\n studentExpression = Numbas.jme.compile(studentString,scope);\n \n // If the student didn't write anything, compile returns null\n if(studentExpression === null)\nthrow(new Error('no expression'));\n \n // If everything worked, show the line and update it\n // (this calls makestudentline on a few points)\n studentline.showElement();\n studentline.updateCurve();\n}\ncatch(e) {\n // If something went wrong, hide the curve\n studentExpression = null;\n studentline.hideElement();\n}\n\nboard.update();\n });\n}); \n\nreturn div;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"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": "

The population  \\(P\\) of a new suburb can be shown to grow according to an equation given by \\[P=P_0\\left(1-e^{-kt}\\right) \\] where \\(P_0\\) is the maximum population  for the suburb and \\(t\\) is measured in years. If the maximum population  for a suburb is \\(\\var{P_0}\\) and at time \\(\\var{t}\\) years the population  is \\(\\var{pop}\\), find the value of \\(k\\) accurate to 3 decimal places. Hence give the formula for the population density as a function of time. Show full working in your handwritten working.

\n

\\(k=\\;\\) [[0]] hence

\n

\\(P(t)=\\;\\)[[1]] (note: to enter \\(e^{-kt}\\) type e^(-kt).)

\n

Graph of population growth will be shown below.

\n

{graph(P_0,t)}

\n

Using the above graph or otherwise, estimate the time taken for the population to reach \\(\\var{P_1}\\). (Note: your approximation should be given to the precision readable from the graph)

\n

\\(t\\approx\\)[[2]] years

\n

", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "k", "marks": "0.5", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{k}", "maxValue": "{k}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "jme", "useCustomName": true, "customName": "Formula", "marks": "0.25", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "{P_0}*(1-e^(-{k}t))", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": "10", "vsetRange": [0, "10"], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "valuegenerators": [{"name": "t", "value": ""}]}, {"type": "numberentry", "useCustomName": true, "customName": "time", "marks": "0.25", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "-0.9*ln(1-{P_1/P_0})/{k}", "maxValue": "-1.1*ln(1-{P_1/P_0})/{k}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "-ln(1-{P_1/P_0})/{k}", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Don Shearman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/680/"}, {"name": "Merryn Horrocks", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4052/"}], "resources": []}]}], "contributors": [{"name": "Don Shearman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/680/"}, {"name": "Merryn Horrocks", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4052/"}]}