// Numbas version: exam_results_page_options {"name": "Completing the square and finding roots of a quadratic equation", "extensions": [], "custom_part_types": [{"source": {"pk": 3, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/3/edit"}, "name": "Give a numerical input for an expression", "short_name": "give-a-numerical-input-for-an-expression", "description": "

The student gives a point $x$ at which to evaluate a given function $f$. The answer is correct if $f(x)$ is the expected value.

", "help_url": "", "input_widget": "number", "input_options": {"correctAnswer": "settings[\"correctAnswer\"]", "hint": {"static": true, "value": ""}, "allowedNotationStyles": {"static": true, "value": ["plain", "en", "si-en"]}, "allowFractions": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\nif(equal,\n correct()\n,\n incorrect(settings[\"student_value_description\"]+\" $\"+student_value+\"$.\")\n)\n\ninterpreted_answer:\nstudentAnswer\n\nstudent_value:\neval(settings[\"expression\"],[\"x\":studentAnswer])\n\nequal:\nwithintolerance(student_value,settings[\"expected_value\"],0.00001)", "marking_notes": [{"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "if(equal,\n correct()\n,\n incorrect(settings[\"student_value_description\"]+\" $\"+student_value+\"$.\")\n)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "studentAnswer"}, {"name": "student_value", "description": "", "definition": "eval(settings[\"expression\"],[\"x\":studentAnswer])"}, {"name": "equal", "description": "", "definition": "withintolerance(student_value,settings[\"expected_value\"],0.00001)"}], "settings": [{"name": "expected_value", "label": "Expected value", "help_url": "", "hint": "The value that the function should take at the given point.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The value that the student should write.", "input_type": "string", "default_value": "", "subvars": true}, {"name": "student_value_description", "label": "Description of the student's value", "help_url": "", "hint": "", "input_type": "string", "default_value": "The value at your point is", "subvars": true}, {"name": "expression", "label": "Function to evaluate", "help_url": "", "hint": "The function that will be applied to the student's number.
The student's number will be substituted for $x$ in this expression.", "input_type": "mathematical_expression", "default_value": "", "subvars": true}], "public_availability": "always", "published": true, "extensions": []}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "rulesets": {}, "statement": "

Writing $ax^2+bx+c$ as a square plus another term is called \"completing the square\". We can use this technique to solve quadratic equations.

", "name": "Completing the square and finding roots of a quadratic equation", "parts": [{"useCustomName": false, "prompt": "

Write the following expression in the form $a(x+b)^2-c$.

\n

$\\simplify {{med}x^2+{sml}x+{big}} = $ [[0]]

", "sortAnswers": false, "marks": 0, "showFeedbackIcon": true, "adaptiveMarkingPenalty": 0, "variableReplacements": [], "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "customName": "", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "unitTests": [], "gaps": [{"musthave": {"strings": [")^2"], "partialCredit": 0, "showStrings": false, "message": "

It doesn't look like you've completed the square.

"}, "answer": "{bits[2]}*(x+{bits[0]})^2-{bits[1]^2}", "scripts": {}, "adaptiveMarkingPenalty": 0, "type": "jme", "showCorrectAnswer": true, "valuegenerators": [{"value": "", "name": "x"}], "unitTests": [], "vsetRangePoints": 5, "useCustomName": false, "notallowed": {"strings": ["x^2"], "partialCredit": 0, "showStrings": false, "message": "

It doesn't look like you've completed the square.

"}, "showPreview": true, "marks": 1, "failureRate": 1, "checkVariableNames": false, "showFeedbackIcon": true, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "checkingType": "absdiff", "customName": "", "checkingAccuracy": 0.001, "vsetRange": [0, 1], "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": ""}], "variableReplacementStrategy": "originalfirst"}, {"useCustomName": false, "prompt": "

Now solve the quadratic equation

\n

\\[ \\simplify {{med}x^2+{sml}x+{big}} = 0\\text{.} \\]

\n

$x_1=$ [[0]]

\n

or

\n

$x_2=$ [[1]]

", "sortAnswers": true, "marks": 0, "showFeedbackIcon": true, "adaptiveMarkingPenalty": 0, "variableReplacements": [], "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "customName": "", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "unitTests": [], "gaps": [{"minValue": "{-bits[0]-bits[1]/sqrt(bits[2])}", "scripts": {}, "adaptiveMarkingPenalty": 0, "type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": false, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "unitTests": [], "useCustomName": false, "allowFractions": true, "marks": 1, "showFractionHint": true, "showFeedbackIcon": true, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "maxValue": "{-bits[0]-bits[1]/sqrt(bits[2])}", "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst"}, {"minValue": "{-bits[0]+bits[1]/sqrt(bits[2])}", "scripts": {}, "adaptiveMarkingPenalty": 0, "type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": false, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "unitTests": [], "useCustomName": false, "allowFractions": true, "marks": 1, "showFractionHint": true, "showFeedbackIcon": true, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "customMarkingAlgorithm": "", "correctAnswerStyle": "plain", "maxValue": "{-bits[0]+bits[1]/sqrt(bits[2])}", "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst"}], "variableReplacementStrategy": "originalfirst"}, {"useCustomName": false, "sortAnswers": false, "marks": 0, "showFeedbackIcon": true, "adaptiveMarkingPenalty": 0, "variableReplacements": [], "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "customName": "", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "unitTests": [], "gaps": [{"useCustomName": false, "settings": {"expected_value": "", "expression": "", "correctAnswer": "", "student_value_description": "The value at your point is"}, "marks": 1, "showFeedbackIcon": true, "adaptiveMarkingPenalty": 0, "variableReplacements": [], "scripts": {}, "extendBaseMarkingAlgorithm": true, "type": "give-a-numerical-input-for-an-expression", "customName": "", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "unitTests": [], "variableReplacementStrategy": "originalfirst"}], "variableReplacementStrategy": "originalfirst"}], "variablesTest": {"condition": "", "maxRuns": 100}, "functions": {}, "preamble": {"js": "", "css": ""}, "variables": {"sml": {"definition": "2*bits[0]*bits[2]", "description": "

The coefficient of $x$ in the expanded quadratic.

", "templateType": "anything", "name": "sml", "group": "Ungrouped variables"}, "med": {"definition": "bits[2]", "description": "

The coeffient of $x^2$

", "templateType": "anything", "name": "med", "group": "Ungrouped variables"}, "bits": {"definition": "sort(shuffle(1..9)[0..3])", "description": "

After completing the square, the expression will have the form $\\mathrm{bits}[2](x + \\mathrm{bits}[0])^2 - \\mathrm{bits}[1]^2$.

", "templateType": "anything", "name": "bits", "group": "Ungrouped variables"}, "big": {"definition": "bits[2]*(bits[0])^2-bits[1]^2", "description": "

The constant term in the expanded quadratic.

", "templateType": "anything", "name": "big", "group": "Ungrouped variables"}}, "metadata": {"description": "

Solve a quadratic equation by completing the square. The roots are not pretty!

", "licence": "Creative Commons Attribution 4.0 International"}, "extensions": [], "ungrouped_variables": ["big", "sml", "bits", "med"], "advice": "

Completing the square works by noticing that

\n

\\[ (x+a)^2 = x^2 + 2ax + a^2 \\]

\n

So when we see an expression of the form $x^2 + 2ax$, we can rewrite it as $(x+a)^2-a^2$.

\n

a)

\n

Rewrite $x^2+\\var{sml}x$ as $\\simplify[basic]{ (x+{sml/2})^2 - {sml/2}^2}$.

\n

\\begin{align}
\\simplify[basic]{x^2+{sml}x+{big}} &= \\simplify[basic]{(x+{sml/2})^2-{(sml/2)}^2+{big}} \\\\
&= \\simplify[basic]{(x+{sml/2})^2+{-(sml/2)^2+big}} \\text{.}
\\end{align}

\n

b)

\n

We showed above that

\n

\\[ \\simplify[basic]{x^2+{sml}x+{big}} = 0 \\]

\n

is equivalent to

\n

\\[ \\simplify[basic]{(x+{bits[0]})^2-{bits[1]^2}} = 0 \\text{.} \\]

\n

We can then rearrange this equation to solve for $x$.

\n

\\begin{align}
\\simplify{(x+{bits[0]})^2-{(bits[1])^2} } &= 0 \\\\
(x+\\var{bits[0]})^2 &= \\var{bits[1]^2} \\\\
x+\\var{bits[0]} &= \\pm \\var{bits[1]} \\\\
x &= -\\var{bits[0]} \\pm \\var{bits[1]} \\\\[2em]

x_1 &= \\var{-bits[0]-bits[1]} \\text{,}\\\\
x_2 &= \\var{-bits[0]+bits[1]} \\text{.}
\\end{align}

", "variable_groups": [], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Maria Pickett", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3492/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Maria Pickett", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3492/"}]}