// Numbas version: finer_feedback_settings {"name": "Anna's copy of Maria's copy of Mario's copy of Interactive Newton-Raphson method", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "statement": "
Consider the following equation.
\n\\[\\simplify[std]{e^({m}x)+{b}x-{a}=0}\\]
\nFind the approximate solution in the range $0 \\le x \\le 1$ by using the Newton-Raphson method.
\nThe following diagram demonstrates the method.
\n$x_0$ is the starting value, you can slide it along the x-axis to see the effect of changing it.
\n\n{test(m,b,a,maxy)}
\n\n\n", "variablesTest": {"maxRuns": 100, "condition": ""}, "name": "Anna's copy of Maria's copy of Mario's copy of Interactive Newton-Raphson method", "preamble": {"js": "", "css": ""}, "extensions": ["jsxgraph"], "functions": {"fun": {"definition": "((m*c-1)*e^(m*c)+a)/(m*e^(m*c)+b)", "language": "jme", "type": "number", "parameters": [["m", "number"], ["b", "number"], ["a", "number"], ["c", "number"]]}, "test": {"definition": "var div = Numbas.extensions.jsxgraph.makeBoard('600px','400px', {boundingbox:[0,maxy,3,-30], axis:false});\n var brd=div.board;\n // Initial function term\n var term = function(x) { return Math.exp(m*x)+b*x-a; };\n var graph = function(x) { return term(x); };\n // Recursion depth\n var steps = 4;\n // Start value\n var s = 2;\n \n //for (i = 0; i < steps; i++) {\n //document.write('a)
\nRecall that the Newton-Raphson method is defined by:
\\[x_{n+1}=x_n-\\frac{g(x_n)}{g'(x_n)}\\]
where we would like to find the root of the equation $g(x)=0$
In this question we have:
\\[\\simplify[std]{g(x) = Exp({m} * x) + {b} * x + { -a}} \\Rightarrow \\simplify[std]{g'(x) = {m}*Exp({m} * x) + {b}}\\]
Substituting these expressions into the formula we have:
\\[x_{n+1} =\\simplify[std]{ x_n -((Exp({m} * x_n) + {b} * x_n + { -a}) / ({m} * Exp({m} * x_n) + {b}))}\\]
which can be rearranged to give:
\\[x_{n + 1} = \\simplify[std]{(({m} * x_n -1) * Exp({m} * x_n) + {a}) / ({m} * Exp({m} * x_n) + {b})}\\]
(In your answers you would input $x$ rather than $x_n$.)
\nIn the following let $\\displaystyle f(x)=\\simplify[std]{ (({m} * x -1) * Exp({m} * x ) + {a}) / ({m} * Exp({m} * x ) + {b})}$
\nb)
\nIf $x_0=2$ then $x_1$ is simply given by:
\\[\\simplify[std]{x_1 = (({2*m} -1) * Exp({2*m}) + {a}) / ({m} * Exp({2*m}) + {b})}\\]
which to 4 decimal places is: $\\;\\;x_1= \\var{ans}$
\nWe find on running the iteration that the first six values are:
\n\\[\\begin{align}x_1&=f(x_0)=f(2)&=\\var{results[1]}\\\\x_2&=f(x_1)=f(\\var{results[1]})&=\\var{results[2]}\\\\x_3&=f(x_2)=f(\\var{results[2]})&=\\var{results[3]}\\\\x_4&=f(x_3)=f(\\var{results[3]})&=\\var{results[4]}\\\\x_5&=f(x_4)=f(\\var{results[4]})&=\\var{results[5]}\\\\x_6&=f(x_5)=f(\\var{results[5]})&=\\var{results[6]}\\end{align}\\]
\nSo the solution to the equation to four decimal places for $0 \\le x \\le 1$ is $x=\\var{precround(ans1,4)}$
\nHere we see the graph of $\\simplify{e^({m}*x)+{b}*x-{a}}$ and the first four successive approximations to the root:
\n{test(m,b,a,maxy)}
\n\nNote that you can slide the first approximation $x_0$ along the x-axis to see the effect of changing the starting value.
", "metadata": {"description": "Write down the Newton-Raphson formula for finding a numerical solution to the equation $e^{mx}+bx-a=0$. If $x_0=1$ find $x_1$.
\nIncluded in the Advice of this question are:
\n6 iterations of the method.
\nGraph of the NR process using jsxgraph. Also user interaction allowing change of starting value and its effect on the process.
", "licence": "Creative Commons Attribution 4.0 International"}, "ungrouped_variables": ["a", "maxy", "ans1", "m", "results", "b", "tol", "ans", "tans", ""], "variables": {"": {"templateType": "anything", "name": "", "description": "", "group": "Ungrouped variables", "definition": ""}, "m": {"templateType": "anything", "name": "m", "description": "", "group": "Ungrouped variables", "definition": "random(1.5..2#0.1)"}, "b": {"templateType": "anything", "name": "b", "description": "", "group": "Ungrouped variables", "definition": "random((a+1)..9)"}, "tans": {"templateType": "anything", "name": "tans", "description": "", "group": "Ungrouped variables", "definition": "((2*m-1)*exp(2*m)+a)/(m*exp(2*m)+b)"}, "results": {"templateType": "anything", "name": "results", "description": "", "group": "Ungrouped variables", "definition": "nr(m,b,a,2,10,[])"}, "ans1": {"templateType": "anything", "name": "ans1", "description": "", "group": "Ungrouped variables", "definition": "precround(results[6],4)"}, "maxy": {"templateType": "anything", "name": "maxy", "description": "", "group": "Ungrouped variables", "definition": "ceil(e^(2*m)+2*b-a)+5"}, "a": {"templateType": "anything", "name": "a", "description": "", "group": "Ungrouped variables", "definition": "random(8..15)"}, "ans": {"templateType": "anything", "name": "ans", "description": "", "group": "Ungrouped variables", "definition": "precround(tans,4)"}, "tol": {"templateType": "anything", "name": "tol", "description": "", "group": "Ungrouped variables", "definition": "0"}}, "rulesets": {"std": ["all", "!collectNumbers", "!noLeadingMinus"]}, "variable_groups": [], "parts": [{"scripts": {}, "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "stepsPenalty": 0, "sortAnswers": false, "useCustomName": false, "prompt": "\nThis equation has a root in the range $0 \\lt x \\lt 1$.
\nUsing the Newton-Raphson formula, if $x_n$ is the $n$th estimate for this root, show that the next estimate can be written in the form \\[x_{n+1}= \\frac{p(x_n)}{g'(x_n)}\\]
Enter $p(x_n)$ and $g'(x_n)$ in the boxes below.
Please note that if you enter a function of the form $xe^{ax}$, then you must input it as $x*e^{ax}$.
\n$p(x_n)=\\;\\;$[[0]] In your answer use $x$ instead of $x_n$.
\n$g'(x_n)=\\;\\;$[[1]] In your answer use $x$ instead of $x_n$.
\nIf you have forgotten the Newton-Raphson formula you can click on Steps to see it. You will not lose any marks in doing so.
\n ", "gaps": [{"customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "extendBaseMarkingAlgorithm": true, "checkingAccuracy": 0.0001, "showPreview": true, "failureRate": 1, "checkingType": "absdiff", "vsetRange": [1, 1.5], "unitTests": [], "answer": "(((({m} * x) -1) * Exp(({m} * x))) + {a})", "variableReplacements": [], "valuegenerators": [{"name": "x", "value": ""}], "answerSimplification": "std", "showCorrectAnswer": true, "type": "jme", "scripts": {}, "marks": 1, "showFeedbackIcon": true, "useCustomName": false, "checkVariableNames": false, "customName": ""}, {"customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "extendBaseMarkingAlgorithm": true, "checkingAccuracy": 0.001, "showPreview": true, "failureRate": 1, "checkingType": "absdiff", "vsetRange": [0, 1], "unitTests": [], "answer": "(({m} * Exp(({m} * x))) + {b})", "variableReplacements": [], "valuegenerators": [{"name": "x", "value": ""}], "answerSimplification": "std", "showCorrectAnswer": true, "type": "jme", "scripts": {}, "marks": 1, "showFeedbackIcon": true, "useCustomName": false, "checkVariableNames": false, "customName": ""}], "unitTests": [], "marks": 0, "variableReplacements": [], "steps": [{"customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "vsetRangePoints": 5, "extendBaseMarkingAlgorithm": true, "checkingAccuracy": 0.001, "showPreview": true, "failureRate": 1, "checkingType": "absdiff", "vsetRange": [0, 1], "unitTests": [], "answer": "", "variableReplacements": [], "valuegenerators": [], "checkVariableNames": false, "type": "jme", "scripts": {}, "marks": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "useCustomName": false, "prompt": "Recall that the Newton-Raphson method is defined by:
\\[x_{n+1}=x_n-\\frac{g(x_n)}{g'(x_n)}\\]
where we would like to find the root of the equation $g(x)=0$
If $x_0=2\\;\\;\\;$what is $x_1$ correct to $4$ decimal places?
\n$x_1=\\;\\;$ [[0]]
\nEnter your answer to 4 decimal places.
", "unitTests": [], "marks": 0, "variableReplacements": [], "customName": "", "showCorrectAnswer": true, "type": "gapfill"}, {"customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "showCellAnswerState": true, "unitTests": [], "matrix": [0, 0, 0], "variableReplacements": [], "minMarks": 0, "showCorrectAnswer": true, "type": "1_n_2", "displayType": "radiogroup", "scripts": {}, "distractors": ["", "", ""], "marks": 0, "choices": ["Choice 1Which graph represent the following equation:
\n\\[\\simplify[std]{e^({m}x)+{b}x-{a}=0}\\]
", "customName": "", "shuffleChoices": false, "displayColumns": 0}, {"customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "showCellAnswerState": true, "unitTests": [], "matrix": [0, 0, 0], "variableReplacements": [], "minMarks": 0, "showCorrectAnswer": true, "type": "1_n_2", "displayType": "radiogroup", "scripts": {}, "distractors": ["", "", ""], "marks": 0, "choices": ["Choice 1Which graph represent the following equation:
\n\\[\\simplify[std]{e^({m}x)+{b}x-{a}=0}\\]
", "customName": "", "shuffleChoices": false, "displayColumns": 0}], "type": "question", "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"name": "Anna Strzelecka", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2945/"}, {"name": "Mario Stevanovski", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2979/"}, {"name": "Maria Aneiros", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3388/"}]}]}], "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"name": "Anna Strzelecka", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2945/"}, {"name": "Mario Stevanovski", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2979/"}, {"name": "Maria Aneiros", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3388/"}]}