// Numbas version: exam_results_page_options {"name": "Trapezium Rule", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Trapezium Rule", "tags": [], "metadata": {"description": "Using the trapezium rule with 5 ordinates to approximate $\\int_a^b{1/(x^2+c)}$", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

Use the trapezium rule with {n+1} ordinates ({n} strips)

", "advice": "

The trapezium rule states that $\\int^b_aydx\\approx0.5h[(y_0+y_n)+2(y_1+y_2+...+y_{n-1})]$ where $h=\\frac{b-a}{n}$

\n

In our example $a=\\var{a}, b=\\var{b}$ and $n=\\var{n}$ is the number of strips.

\n

Hence $h=\\frac{\\var{b}-\\var{a}}{\\var{n}}=\\var{h}$

\n

So $\\int^\\var{b}_\\var{a}{\\frac{1}{x^2+\\var{c}}}dx\\approx0.5\\times\\var{h}[(y_0+y_4)+2(y_1+y_2+y_3)]$

\n

Our values of $x_i$ are given by $a+h \\times i=\\var{a}+\\var{h}\\times i$, as we vary $i$ from 0 to $\\var{n}$

\n

Thus we obtain $[x_0,...,x_\\var{n}] = \\var{x}$

\n

Now we can calculate each $y_i$ as $y_i = y(x_i) = {\\frac{1}{x_i^2+\\var{c}}}$

\n

Thus we obtain $[y_0,...,y_\\var{n}] = \\var{y}$

\n

Hence $\\int^\\var{b}_\\var{a}{\\frac{1}{x^2+\\var{c}}}dx\\approx0.5\\times\\var{h}[(\\var{y[0]}+\\var{y[4]})+2(\\var{y[1]}+\\var{y[2]}+\\var{y[3]})] \\approx \\var{answer}$

\n

\n
\n

\n

For comparison, the exact integral $\\int{\\frac{1}{x^2+\\var{c}}}dx$ is given by $\\frac{tan^{-1}(x/ \\sqrt {\\var{c}})}{\\sqrt {\\var{c}}}$. Hence the exact value of $\\int^\\var{b}_\\var{a}{\\frac{1}{x^2+\\var{c}}}dx$ is $\\frac{tan^{-1}(\\var{b}/\\sqrt {\\var{c}})}{\\sqrt {\\var{c}}}-\\frac{tan^{-1}(\\var{a}/\\sqrt {\\var{c}})}{\\sqrt {\\var{c}}} = \\var{precround(exactanswer,5)}$

\n

\n

The trapezium rule approximation to the area under the curve can be seen below. The convexity of the curve explains why in this case the trapezium rule gives an overestimate of the true integral.

\n

\n

{plotf(c,n,a,b)}

", "rulesets": {}, "extensions": ["jsxgraph"], "variables": {"a": {"name": "a", "group": "Ungrouped variables", "definition": "random(1 .. 3#1)", "description": "", "templateType": "randrange"}, "h": {"name": "h", "group": "Ungrouped variables", "definition": "random(0.25,0.5,1)", "description": "", "templateType": "anything"}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "4", "description": "", "templateType": "anything"}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "a+(n)*h", "description": "", "templateType": "anything"}, "c": {"name": "c", "group": "Ungrouped variables", "definition": "random(1,2,3)", "description": "", "templateType": "anything"}, "x": {"name": "x", "group": "Ungrouped variables", "definition": "list(a..b#h)", "description": "", "templateType": "anything"}, "y": {"name": "y", "group": "Ungrouped variables", "definition": "map(precround(1/(z^2+c),5),z,x)", "description": "", "templateType": "anything"}, "answer": {"name": "answer", "group": "Ungrouped variables", "definition": "precround(0.5*h*(y[0]+y[4]+2*(y[1]+y[2]+y[3])),5)", "description": "", "templateType": "anything"}, "exactanswer": {"name": "exactanswer", "group": "Ungrouped variables", "definition": "(arctan(b/sqrt(c))-arctan(a/sqrt(c)))/sqrt(c)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "a<>h", "maxRuns": 100}, "ungrouped_variables": ["a", "h", "n", "b", "c", "x", "y", "answer", "exactanswer"], "variable_groups": [], "functions": {"plotf": {"parameters": [["c", "number"], ["n", "number"], ["a", "number"], ["b", "number"]], "type": "html", "language": "javascript", "definition": "\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px', {axis:true,showNavigation:false, boundingbox:[a-0.5,1/(c+(a-0.5)*(a-0.5)),b+0.5,-0.1/c]});\nvar brd=div.board;\n//The function for which we are estimating the integral. \n//This dispays to the right\nvar f = function(x){ return 1/(x*x+c); };\nvar plot = brd.create('functiongraph',[f,0,b+1]);\nvar os = brd.create('riemannsum',[f,n,'trapezoidal',a, b ], \n{fillColor:'#ffff00', fillOpacity:0.3});\nreturn div;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "3", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Find an approximate value for $\\int_\\var{a}^\\var{b}{\\frac{1}{x^2+\\var{c}}}dx$

", "minValue": "answer", "maxValue": "answer", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "contributors": [{"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}]}]}], "contributors": [{"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}]}