// Numbas version: exam_results_page_options {"name": "Free oscillations of a pendulum", "extensions": ["mas-codeassess", "jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Free oscillations of a pendulum", "extensions": ["jsxgraph", "programming"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Christopher Graham", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/73/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

Solving 2nd order differential equation for pendulum, with and without damping.

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

In the absence of air resistance, the equation of motion of a bob, of mass $m$, at the end of a pendulum of length $l$ is

\n

\\[ ml\\frac{\\mathrm{d}^2\\theta}{\\mathrm{d}t^2} = -mg\\sin\\theta\\text{.} \\]

\n

In the small angle approximation, $\\sin\\theta\\approx\\theta$, this reduces to

\n

\\[ \\frac{\\mathrm{d}^2\\theta}{\\mathrm{d}t^2}+\\frac{g}{l}\\theta = 0\\text{.} \\]

", "advice": "

a)

\n

We have a second order constant coefficient differential equation,

\n

\\[ \\frac{\\mathrm{d}^2\\theta}{\\mathrm{d}t^2}+\\frac{g}{l}\\theta = 0 \\text{.} \\]

\n

Setting $\\theta = e^{\\lambda t}$, we obtain the auxiliary equation

\n

\\[ \\lambda^2 + \\frac{g}{l} = 0 \\implies \\lambda = \\pm i\\sqrt{\\frac{g}{l}} \\text{.} \\]

\n

The general solution for an auxiliary equation with complex roots is

\n

\\[ \\theta(t) = A\\sin\\omega t + B\\cos\\omega t \\text{,} \\]

\n

where $\\omega = \\sqrt{\\frac{g}{l}}$ is the angular frequency of the oscillations, also known as the natural frequency: the frequency with which the pendulum oscillates in the absence of external forcing).

\n

Note that

\n

\\[ \\frac{\\mathrm{d}\\theta}{\\mathrm{d}t} = A\\omega\\cos\\omega t - B\\omega\\sin\\omega t \\text{.} \\]

\n

Applying the initial conditions:

\n

\\begin{align}
\\frac{\\mathrm{d}\\theta}{\\mathrm{d}t} (0) = 0 &=A\\omega\\cos(0) - B\\omega\\sin(0) \\text{,}  \\\\
&= A\\omega \\text{,} \\\\
\\therefore A &= 0 \\text{.}
\\end{align}

\n

\\begin{align}
\\theta (0) =\\frac{\\pi}{\\var{theta0_frac}} &=B\\cos(0) \\text{,}  \\\\
\\therefore B &=\\frac{\\pi}{\\var{theta0_frac}} \\text{.}
\\end{align}

\n

Therefore our solution is

\n

\\[ \\theta(t) = \\frac{\\pi}{\\var{theta0_frac}}\\cos\\left(\\sqrt{\\frac{g}{l}}t\\right)\\text{.} \\]

\n

Using the given values for $g$ and $l$,

\n

\\[ \\theta(t) = \\frac{\\pi}{\\var{theta0_frac}}\\cos\\left(\\sqrt{\\frac{\\var{g}}{\\var{l}}}t\\right)\\text{.} \\]

\n

\n

b)

\n

The time period of oscillations is given by

\n

\\[ T = \\frac{2\\pi}{\\omega} = 2\\pi\\sqrt{\\frac{l}{g}} =2\\pi\\sqrt{\\frac{\\var{l}}{\\var{g}}} = \\var{precround(T,2)} \\text{ s.} \\]

\n

c)

\n

Differentiating our solution from part (a), we have

\n

\\[ \\frac{d\\theta}{dt} = -\\frac{\\pi}{\\var{theta0_frac}}\\omega \\sin\\omega t\\text{.} \\]

\n

This is at its maximum when $\\sin \\omega t = -1$, 

\n

\\[ \\left(\\frac{\\mathrm{d}\\theta}{\\mathrm{d}t}\\right)_{\\text{max}} = \\frac{\\pi}{\\var{theta0_frac}}\\omega =\\frac{\\pi}{\\var{theta0_frac}}\\sqrt{\\frac{\\var{g}}{\\var{l}}} = \\var{precround(theta0*sqrt(g/l),2)}\\text{ rad s}^{-1 }\\text{.} \\]

\n

d)

\n

With the addition of a damping term, our differential equation becomes

\n

\\[ \\frac{\\mathrm{d}^2\\theta}{\\mathrm{d}t^2}+\\frac{k}{m}\\frac{\\mathrm{d}\\theta}{\\mathrm{d}t}+\\frac{g}{l}\\theta = 0\\text{.} \\]

\n

This is still a constant-coefficient second-order differential equation, however the extra term changes the auxiliary equation. For convenience we can let $\\beta = \\frac{k}{2m}$ (we will later find that this is $\\beta$ as asked for in the question) and $\\omega^2 = \\frac{g}{l}$, as before, to put our auxiliary equation in the form

\n

\\[ \\lambda^2 + 2\\beta \\lambda + \\omega^2 = 0\\text{,} \\]

\n

which has the solutions

\n

\\[ \\begin{align} \\lambda &=-\\frac{2\\beta}{2}\\pm \\frac{\\sqrt{2\\beta^2-4\\omega^2}}{2} \\\\
 &= -\\beta\\pm \\sqrt{\\beta^2-\\omega^2} \\\\
 &= -\\beta\\pm i\\sqrt{\\omega^2-\\beta^2}\\text{.} \\end{align}\\]

\n

Note that the values in our problem have determined that $\\omega >\\beta$. As in part (a), we have an auxiliary equation with complex roots:

\n

\\[\\theta(t) = e^{-\\beta t}\\left[A\\sin\\left(\\sqrt{\\omega^2-\\beta^2}\\; t\\right) + B\\cos\\left(\\sqrt{\\omega^2-\\beta^2}\\; t\\right)\\right]\\text{.} \\]

\n

Using the values and initial conditions from part (a), this becomes

\n

\\[\\theta(t) = \\frac{\\pi}{\\var{theta0_frac}}e^{-\\beta t}\\cos\\left(\\sqrt{\\frac{\\var{g}}{\\var{l}}-\\beta^2}\\; t\\right)\\text{,} \\]

\n

with

\n

\\[ \\beta = \\frac{k}{2m} = \\frac{\\var{k}}{2\\times\\var{m}} = \\var{precround(beta,2)}\\text{.}\\]

\n

e)

\n

The amplitude of the oscillation is at 5% of the initial release angle when

\n

\\[ e^{-\\beta t} = 0.05\\text{.} \\]

\n

The time taken is therefore

\n

\\[ t = -\\frac{\\ln{(0.05)}}{\\beta}=-\\frac{\\ln{(0.05)}}{\\var{precround(beta,2)}} = \\var{precround(damping5,2)}\\text{ s.} \\]

\n

", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"g": {"name": "g", "group": "Ungrouped variables", "definition": "9.81", "description": "

gravitational acceleration (ms^-2)

", "templateType": "number", "can_override": false}, "T": {"name": "T", "group": "Ungrouped variables", "definition": "2*pi*sqrt(l/g)", "description": "

Time period of the undamped oscillations (seconds)

", "templateType": "anything", "can_override": false}, "theta0": {"name": "theta0", "group": "Ungrouped variables", "definition": "pi/theta0_frac", "description": "

Release angle of the pendulum

", "templateType": "anything", "can_override": false}, "m": {"name": "m", "group": "Ungrouped variables", "definition": "random(2..6)", "description": "

mass of the bob (kg)

", "templateType": "anything", "can_override": false}, "theta0_frac": {"name": "theta0_frac", "group": "Ungrouped variables", "definition": "random(3,5,6)", "description": "

Question displays pi/theta0_frac.

", "templateType": "anything", "can_override": false}, "is_under_damped": {"name": "is_under_damped", "group": "damping", "definition": "(g/l)-k/(2*m) > 0", "description": "

Is the system under-damped? (this should be true)

", "templateType": "anything", "can_override": false}, "damping5": {"name": "damping5", "group": "damping", "definition": "-ln(0.05)/beta", "description": "

Time taken for amplitude to reduce to 5% of original.

", "templateType": "anything", "can_override": false}, "l": {"name": "l", "group": "Ungrouped variables", "definition": "random(3..6)", "description": "

length of the pendulum rod (m)

", "templateType": "anything", "can_override": false}, "damping0p01": {"name": "damping0p01", "group": "damping", "definition": "abs(log(0.0001))/beta", "description": "

Time taken for amplitude to reduce to 0.001% of original.

", "templateType": "anything", "can_override": false}, "beta": {"name": "beta", "group": "damping", "definition": "k/(2*m)", "description": "

decay rate

", "templateType": "anything", "can_override": false}, "k": {"name": "k", "group": "damping", "definition": "random(2..5)", "description": "

friction coefficient (kgs-1)

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["g", "l", "m", "T", "theta0_frac", "theta0"], "variable_groups": [{"name": "damping", "variables": ["k", "beta", "damping5", "damping0p01", "is_under_damped"]}], "functions": {"jsx_pendulum": {"parameters": [], "type": "html", "language": "javascript", "definition": "// Get Numbas variables\nvar g = question.unwrappedVariables.g; // grav acc.\nvar l = question.unwrappedVariables.l; // length of rod\nvar m = question.unwrappedVariables.m; // mass of bob\nvar theta0 = question.unwrappedVariables.theta0; // initial angle\n\n// Set up board\nvar div = Numbas.extensions.jsxgraph.makeBoard('600px','250px',\n {\n boundingBox:[-5, 0.2, 9, -6],\n axis:false,\n showNavigation:false,\n grid:false\n }\n);\n\nvar board = div.board; \n\nboard.options = JXG.merge(board.options,{\n elements: {\n fixed: true\n },\n point: {\n showInfobox: false\n },\n text: {\n highlightStrokeOpacity: 1\n }\n});\n\n\n// Pendulum 1: exact solution \nvar p3 = board.create('point', [0.02, 0], {visible:false, size: 3});\nvar c2 = board.create('circle', [p3, [0.02,5]], {visible:false, name: 'circle', size: 3});\nvar pp4 = board.create('glider', [0.02,5, c2], {visible: true, name: '', size: 8, color: 'red', highlightFillColor: 'red', strokeWidth: 0, highlightStrokeWidth: 0});\n\n\n// Pendulum 2: student solution\nvar p1 = board.create('point', [0, 0], {visible:false, size: 3});\nvar c1 = board.create('circle', [p1, [0,5]], {visible:false, name: 'circle', size: 3});\nvar pp2 = board.create('glider', [0,5, c1], {visible: true, name: '', size: 8, color: '#91bcd8', highlightFillColor: '#91bcd8', strokeWidth: 0, highlightStrokeWidth: 0});\n\n// Decor\nvar line1 = board.create('line', [[-2,0],[2,0]],{color: 'grey', highlightStrokeColor: 'grey',straightFirst:false, straightLast:false, strokeWidth: 10});\nvar line2 = board.create('line', [[0.02,0],[0.02,-5]],{color: 'grey', highlightStrokeColor: 'grey',straightFirst:false, straightLast:false, strokeWidth: 1, dash:1});\n\n// Pendulum rods\nvar line3 = board.create('line', [p3, pp4], {visible:true, straightFirst: false,straightLast: false, color: 'red', highlightStrokeColor: 'red', strokeWidth: 3});\nvar line4 = board.create('line', [p1, pp2], {visible:true, straightFirst: false,straightLast: false, color: '#91bcd8', highlightStrokeColor: '#91bcd8', strokeWidth: 3});\n\n// Info panel \nvar tt2 = board.create('text',[5,-0.3,''],{color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar tt3 = board.create('text',[5.5,-1.5,''],{color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar tt4 = board.create('text',[5.5,-2,''],{color: '#444', highlightStrokeColor: '#444', fontSize: 13});\nvar tt5 = board.create('text',[5.5,-3.5,''],{visible: false, color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar tt6 = board.create('text',[5.5,-4,''],{visible: false, color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar tt7 = board.create('text',[5.5,-1,'Correct solution'],{color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar tt8 = board.create('text',[5.5,-3,'Your solution'],{color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar tt9 = board.create('text',[5.5,-4,'Enter an answer below to preview your solution.'],{color: '#AAA', highlightStrokeColor: '#aaa', fontSize: 14});\n\n// Shaded background\nvar sq = board.create('polygon',[[4.5,-5],[9,-5],[9,0.2],[4.5,0.2]], {color: '#DDD', highlightFillColor: '#ddd', vertices: {visible: false},borders: {strokeWidth: 3,lineCap: 'round',visible: false}});\n\n// Pendulum icons\nvar p5 = board.create('point', [5, -1.5], {color: '#91bcd8', highlightFillColor: '#91bcd8', highlightStrokeWidth:0, strokeWidth: 0, size: 8, name: ''});\nvar p6 = board.create('point', [5, -3.5], {color: 'red', highlightFillColor: 'red', size: 8, highlightStrokeWidth:0, strokeWidth: 0, name: ''});\nvar l5 = board.create('line', [p5, [p5.X(),p5.Y()+0.5]], {straightFirst: false,straightLast: false, color: '#91bcd8', highlightStrokeColor: '#91bcd8', strokeWidth: 3});\nvar l6 = board.create('line', [p6, [p6.X(),p6.Y()+0.5]], {straightFirst: false,straightLast: false, color: 'red', highlightStrokeColor: 'red', strokeWidth: 3});\n\n// Start button\nvar button1 = board.create('button', [-4.9,-1, '► Restart', function() {\n startAnimation(theta0);\n board.update();\n}], {fontSize: 16});\n\nvar isInDragMode = false;\n\n// Get the student's function (t is the independant variable)\nvar tree;\nvar nscope = new Numbas.jme.Scope([Numbas.jme.builtinScope]);\nfunction userf(t){\n if(tree) {\n try {\n var val = nscope.evaluate(tree, {t:t});\n if(val.type!=='number') {\n throw(new Error(\"not a number\"));\n }\n return val.value;\n }\n catch(e) {\n return 0;\n }\n } else {\n return 0;\n }\n}\n\n\n// The animation\nfunction startAnimation(start_pos) {\n // Run animations \n var duration = 0.5 * 1e5; \n\n // Path of the correct solution\n pp2.moveAlong(function() {\n return function(t) {\n if (t >= duration) {\n // Restart the animation\n startAnimation(start_pos);\n }\n t = t/1000;\n var angle1 = start_pos*Math.cos(Math.sqrt(g/l) * t);\n var angled1 = -Math.sqrt(g/l)*start_pos*Math.sin(Math.sqrt(g/l) * t);\n var angle2 = -Math.PI/2+angle1;\n tt2._setUpdateText('t = '+t.toFixed(0)+'s');\n tt3._setUpdateText('θ = '+angle1.toFixed(1)+'rad');\n tt4._setUpdateText('dθ/dt = '+angled1.toFixed(1)+'rads-1');\n return [p1.X()+l*Math.cos(angle2),p1.Y()+l*Math.sin(angle2)];\n }; \n }());\n\n // Path of the student's solution\n pp4.moveAlong(function() { \n return function(t) {\n if (t >= duration) {\n // Restart the animation\n startAnimation(start_pos);\n }\n t = t/1000;\n var utheta = userf(t);\n angle1=-Math.PI/2+utheta;\n angled1=(utheta-userf(t-0.001))/0.001;\n tt5._setUpdateText('θ = '+utheta.toFixed(1)+'rad');\n tt6._setUpdateText('dθ/dt = '+angled1.toFixed(1)+'rads-1'); \n return [p3.X()+l*Math.cos(angle1),p3.Y()+l*Math.sin(angle1)];\n }; \n }());\n}\n\n//pick up the student answer\nquestion.signals.on('HTMLAttached',function(e) {\n startAnimation(theta0); \n ko.computed(function(){\n var expr = question.getPart('p0g0').display.studentAnswer();\n try {\n tree = Numbas.jme.compile(expr,scope);\n }\n catch(e) {\n tree = null;\n }\n\n if(tree){\n startAnimation(theta0);\n tt5.setAttribute({visible: true});\n tt6.setAttribute({visible: true});\n tt9.setAttribute({visible: false});\n board.update();\n } else {\n tt9.setAttribute({visible: true});\n tt5.setAttribute({visible: false});\n tt6.setAttribute({visible: false});\n }\n\n });\n}); \n\n\nreturn div;\n\n"}, "jsx_pendulum2": {"parameters": [], "type": "html", "language": "javascript", "definition": "// Get Numbas variables\nvar g = question.unwrappedVariables.g; // grav acc.\nvar l = question.unwrappedVariables.l; // length of rod\nvar m = question.unwrappedVariables.m; // mass of bob\nvar theta0 = question.unwrappedVariables.theta0; // initial angle\nvar k = question.unwrappedVariables.k; // friction coefficient\nvar damping0p01 = question.unwrappedVariables.damping0p01;\n\n// Set up board\nvar div = Numbas.extensions.jsxgraph.makeBoard('600px','250px',\n {\n boundingBox:[-5, 0.2, 9, -6],\n axis:false,\n showNavigation:false,\n grid:false\n }\n);\n\nvar board2 = div.board; \n\nboard2.options = JXG.merge(board2.options,{\n elements: {\n fixed: true\n },\n point: {\n showInfobox: false\n },\n text: {\n highlightStrokeOpacity: 1\n }\n});\n\n// Pendulum 1: exact solution \nvar p3 = board2.create('point', [0.02, 0], {visible:false, size: 3});\nvar c2 = board2.create('circle', [p3, [0.02,5]], {visible:false, name: 'circle', size: 3});\nvar p4 = board2.create('glider', [0.02,5, c2], {visible: true, name: '', size: 8, color: 'red', highlightFillColor: 'red', strokeWidth: 0, highlightStrokeWidth: 0});\n\n\n// Pendulum 2: student solution\nvar p1 = board2.create('point', [0, 0], {visible:false, size: 3});\nvar c1 = board2.create('circle', [p1, [0,5]], {visible:false, name: 'circle', size: 3});\nvar p2 = board2.create('glider', [0,5, c1], {visible: true, name: '', size: 8, color: '#91bcd8', highlightFillColor: '#91bcd8', strokeWidth: 0, highlightStrokeWidth: 0});\n\n// Decor\nvar l1 = board2.create('line', [[-2,0],[2,0]],{color: 'grey', highlightStrokeColor: 'grey',straightFirst:false, straightLast:false, strokeWidth: 10});\nvar l2 = board2.create('line', [[0.02,0],[0.02,-5]],{color: 'grey', highlightStrokeColor: 'grey',straightFirst:false, straightLast:false, strokeWidth: 1, dash:1});\n//t1 = board2.create('text',[4,-2,\"Enter a solution for θ(t) in the box below to preview your solution\"],{color: 'grey', fontSize: 16});\n\n// Pendulum rods\nvar l3 = board2.create('line', [p3, p4], {visible:true, straightFirst: false,straightLast: false, color: 'red', highlightStrokeColor: 'red', strokeWidth: 3});\nvar l4 = board2.create('line', [p1, p2], {visible:true, straightFirst: false,straightLast: false, color: '#91bcd8', highlightStrokeColor: '#91bcd8', strokeWidth: 3});\n\n// Info panel \nvar t2 = board2.create('text',[5,-0.3,''],{color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar t3 = board2.create('text',[5.5,-1.5,''],{color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar t4 = board2.create('text',[5.5,-2,''],{color: '#444', highlightStrokeColor: '#444', fontSize: 13});\nvar t5 = board2.create('text',[5.5,-3.5,''],{visible: false, color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar t6 = board2.create('text',[5.5,-4,''],{visible: false, color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar t7 = board2.create('text',[5.5,-1,'Correct solution'],{color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar t8 = board2.create('text',[5.5,-3,'Your solution'],{color: '#444', highlightStrokeColor: '#444', fontSize: 14});\nvar t9 = board2.create('text',[5.5,-4,'Enter an answer below to preview your solution.'],{color: '#AAA', highlightStrokeColor: '#AAA', fontSize: 14});\n\n// Shaded background\nvar sq = board2.create('polygon',[[4.5,-5],[9,-5],[9,0.2],[4.5,0.2]], {color: '#DDD', highlightFillColor: '#DDD', vertices: {visible: false},borders: {strokeWidth: 3,lineCap: 'round',visible: false}});\n\n// Pendulum icons\nvar p5 = board2.create('point', [5, -1.5], {color: '#91bcd8', highlightFillColor: '#91bcd8', size: 8, name: '', strokeWidth: 0, highlightStrokeWidth: 0});\nvar p6 = board2.create('point', [5, -3.5], {color: 'red', highlightFillColor: 'red', size: 8, name: '', strokeWidth: 0, highlightStrokeWidth: 0});\nvar l5 = board2.create('line', [p5, [p5.X(),p5.Y()+0.5]], {straightFirst: false,straightLast: false, color: '#91bcd8', highlightStrokeColor: '#91bcd8', strokeWidth: 3});\nvar l6 = board2.create('line', [p6, [p6.X(),p6.Y()+0.5]], {straightFirst: false,straightLast: false, color: 'red', highlightStrokeColor: 'red', strokeWidth: 3});\n\n// Start button\nbutton1 = board2.create('button', [-4.9,-1, '► Restart', function() {\n startAnimation2(theta0);\n board2.update();\n }], {fontSize: 16, fixed: true}),\n\n\nisInDragMode = false;\n\n// the student's beta\nvar student_beta = null;\n\n// The animation\nfunction startAnimation2(start_pos) {\n\n var duration = 1e5; \n\n // Path of the correct solution\n p2.moveAlong(function() {\n return function(t) {\n if (t >= duration) {\n // Restart the animation\n startAnimation2(start_pos);\n }\n t = t/1000;\n var beta = k/(2*m);\n // Calculate theta \n var angle1= start_pos*Math.exp(-beta*t)*Math.cos(Math.sqrt((g/l)-beta) * t);\n var angle2=-Math.PI/2+angle1;\n t2._setUpdateText('t = '+t.toFixed(0)+'s');\n t3._setUpdateText('θ = '+angle1.toFixed(1)+'rad');\n\n if(t>0.01){\n // Fudge dtheta/dt\n var anglelast = start_pos*Math.exp(-beta*(t-0.01))*Math.cos(Math.sqrt((g/l)-beta) * (t-0.01) );\n var anglediff = (angle1-anglelast)/0.01; \n t4._setUpdateText('dθ/dt = '+anglediff.toFixed(1)+'rads-1');\n }\n return [p1.X()+l*Math.cos(angle2),p1.Y()+l*Math.sin(angle2)];\n }; \n }()\n );\n\n // Path of the student's solution\n p4.moveAlong(function() { \n return function(t) {\n if (t >= duration) {\n // Restart the animation\n startAnimation2(start_pos); \n }\n t = t/1000;\n try {\n if(student_beta===null) {\n throw(new Error(\"beta is not set\"));\n }\n var beta = student_beta || 0;\n var angle1 = start_pos*Math.exp(-beta*t)*Math.cos(Math.sqrt((g/l)-beta) * t);\n var angle2 = -Math.PI/2+angle1;\n\n if(isNaN(angle1) || isNaN(angle2)) {\n throw(new Error(\"angle NaN\"));\n }\n t5._setUpdateText('θ = '+angle1.toFixed(1)+'rad');\n\n if(t>0.01){\n // Fudge dtheta/dt\n anglelast= start_pos*Math.exp(-beta*(t-0.01))*Math.cos(Math.sqrt((g/l)-beta) * (t-0.01) );\n anglediff = (angle1-anglelast)/0.01; \n t6._setUpdateText('dθ/dt = '+anglediff.toFixed(1)+'rads-1');\n } \n\n return [p3.X()+l*Math.cos(angle2),p3.Y()+l*Math.sin(angle2)];\n } catch(e) {\n t5._setUpdateText('θ is not a real number!');\n t6._setUpdateText('');\n return [p3.X(),p3.Y()-l];\n }\n }; \n }());\n\n\n}\n\n// Start the animation with initial condition\nstartAnimation2(theta0);\n\n//pick up the student answer\nquestion.signals.on('HTMLAttached',function(e) {\n var part = question.getPart('p3g0');\n ko.computed(function(){\n var expr = part.display.studentAnswer();\n try {\n student_beta = Numbas.util.parseNumber(expr,part.settings.allowFractions,part.settings.allowFractions);\n if(isNaN(student_beta)) {\n throw(new Error(\"Not a number\"));\n }\n }\n catch(e) {\n student_beta = null;\n }\n console.log(student_beta);\n\n if(student_beta!==null){\n startAnimation2(theta0);\n t5.setAttribute({visible: true});\n t6.setAttribute({visible: true});\n t9.setAttribute({visible: false});\n board2.update();\n } else {\n t5.setAttribute({visible: false});\n t6.setAttribute({visible: false});\n t9.setAttribute({visible: true});\n board2.update();\n }\n\n });\n}); \n\n\nreturn div;\n\n"}}, "preamble": {"js": "", "css": ".JXGtext button{\n color: black;\n background-color: #a2d1f0;\n border: 1px solid #91bcd8;\n border-radius: 6px;\n}\n\n.JXGtext button:hover{\n background-color: #91bcd8;\n}"}, "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": "

{jsx_pendulum()}

\n

You are told that $g=\\var{g}\\textrm{ms}^{-2}$ and that the length of the pendulum's rod $l = \\var{l}$ m. 

\n

Solve for $\\theta(t)$ with initial conditions $\\frac{\\mathrm{d}\\theta}{\\mathrm{d}t}(0)=0$,  $\\theta(0)=\\frac{\\pi}{\\var{theta0_frac}}$. 

\n

$\\theta(t) = $ [[0]]

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": "2", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "(pi/{theta0_frac})*cos(sqrt({g}/{l})*t)", "answerSimplification": "all,!fractionnumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": true, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "valuegenerators": [{"name": "t", "value": ""}]}], "sortAnswers": false}, {"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": "

What is the time period of the undamped oscillations?

\n

$T = $ [[0]]s

", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "T", "maxValue": "T", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"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": "

Determine the maximum angular velocity of the bob.

\n

$\\left(\\frac{\\mathrm{d}\\theta}{\\mathrm{d}t}\\right)_{\\text{max}} = $ [[0]] rad s$^{-1}$.

", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{theta0*sqrt(g/l)}", "maxValue": "{theta0*sqrt(g/l)}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"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": "

Introducing a friction coefficient, $k$, that is proportional to the speed of the bob, the equation of motion becomes

\n

\\[ \\frac{\\mathrm{d}^2\\theta}{\\mathrm{d}t^2}+\\frac{k}{m}\\frac{\\mathrm{d}\\theta}{\\mathrm{d}t}+\\frac{g}{l}\\theta = 0\\text{.} \\]

\n

Let $k=\\var{k}\\textrm{kg s}^{-1}$ and $m=\\var{m}$kg. The initial conditions in part (a) yield the solution

\n

\\[\\theta(t) = \\frac{\\pi}{\\var{theta0_frac}}e^{-\\beta t}\\cos\\left(t \\;\\sqrt{\\frac{\\var{g}}{\\var{l}}-\\beta^2}\\right)\\text{.} \\]

\n

Determine the value of $\\beta$.

\n

$\\beta = $ [[0]]

\n

{jsx_pendulum2()}

", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "2", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{k/(2*m)}", "maxValue": "{k/(2*m)}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"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": "

After how long do the amplitude of oscillations decay to 5% of the initial release angle?

\n

[[0]]s

", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{damping5}", "maxValue": "{damping5}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "2", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Christopher Graham", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/73/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}