// Numbas version: exam_results_page_options {"name": "Quadratics: Solving a Quadratic Equation", "extensions": [], "custom_part_types": [{"source": {"pk": 2, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/2/edit"}, "name": "List of numbers", "short_name": "list-of-numbers", "description": "

The answer is a comma-separated list of numbers.

\n

The list is marked correct if each number occurs the same number of times as in the expected answer, and no extra numbers are present.

\n

You can optionally treat the answer as a set, so the number of occurrences doesn't matter, only whether each number is included or not.

", "help_url": "", "input_widget": "string", "input_options": {"correctAnswer": "join(\n if(settings[\"correctAnswerFractions\"],\n map(let([a,b],rational_approximation(x), string(a/b)),x,settings[\"correctAnswer\"])\n ,\n settings[\"correctAnswer\"]\n ),\n settings[\"separator\"] + \" \"\n)", "hint": {"static": false, "value": "if(settings[\"show_input_hint\"],\n \"Enter a list of numbers separated by {settings['separator']}.\",\n \"\"\n)"}, "allowEmpty": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "bits:\nlet(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)\n\nexpected_numbers:\nlet(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)\n\nvalid_numbers:\nif(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )\n\nis_sorted:\nassert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )\n\nincluded:\nmap(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentThe separate items in the student's answer

", "definition": "let(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)"}, {"name": "expected_numbers", "description": "", "definition": "let(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)"}, {"name": "valid_numbers", "description": "

Is every number in the student's list valid?

", "definition": "if(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )"}, {"name": "is_sorted", "description": "

Are the student's answers in ascending order?

", "definition": "assert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )"}, {"name": "included", "description": "

Is each number in the expected answer present in the student's list the correct number of times?

", "definition": "map(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentHas every number been included the right number of times?

", "definition": "all(included)"}, {"name": "no_extras", "description": "

True if the student's list doesn't contain any numbers that aren't in the expected answer.

", "definition": "if(all(map(x in expected_numbers, x, interpreted_answer)),\n true\n ,\n incorrect(\"Your answer contains \"+extra_numbers[0]+\" but should not.\");\n false\n )"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "if(lower(studentAnswer) in [\"empty\",\"\u2205\"],[],\n map(\n if(settings[\"allowFractions\"],parsenumber_or_fraction(x,notationStyles), parsenumber(x,notationStyles))\n ,x\n ,bits\n )\n)"}, {"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "if(studentanswer=\"\",fail(\"You have not entered an answer\"),false);\napply(valid_numbers);\napply(included);\napply(no_extras);\ncorrectif(all_included and no_extras)"}, {"name": "notationStyles", "description": "", "definition": "[\"en\"]"}, {"name": "isSet", "description": "

Should the answer be considered as a set, so the number of times an element occurs doesn't matter?

", "definition": "settings[\"isSet\"]"}, {"name": "extra_numbers", "description": "

Numbers included in the student's answer that are not in the expected list.

", "definition": "filter(not (x in expected_numbers),x,interpreted_answer)"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The list of numbers that the student should enter. The order does not matter.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "allowFractions", "label": "Allow the student to enter fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "correctAnswerFractions", "label": "Display the correct answers as fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "isSet", "label": "Is the answer a set?", "help_url": "", "hint": "If ticked, the number of times an element occurs doesn't matter, only whether it's included at all.", "input_type": "checkbox", "default_value": false}, {"name": "show_input_hint", "label": "Show the input hint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": true}, {"name": "separator", "label": "Separator", "help_url": "", "hint": "The substring that should separate items in the student's list", "input_type": "string", "default_value": ",", "subvars": false}], "public_availability": "always", "published": true, "extensions": []}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Quadratics: Solving a Quadratic Equation", "tags": [], "metadata": {"description": "

Solving a quadratic equation of the form $ax^2+bx+c=0$.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "

Solve the following quadratic equation:

\n

{question}

\n

", "advice": "

For a quadratic equation of the form \\[ ax^2+bx+c = 0,\\] we can use the quadratic formula to find solutions for $x$: \\[ x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}.\\]

\n

{advice}

\n

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"a": {"name": "a", "group": "Ungrouped variables", "definition": "random(1..2)", "description": "", "templateType": "anything", "can_override": false}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "random(-5..5 except [0,a])", "description": "", "templateType": "anything", "can_override": false}, "c": {"name": "c", "group": "Ungrouped variables", "definition": "random(-10..10 except [0,a,b])", "description": "", "templateType": "anything", "can_override": false}, "solx1": {"name": "solx1", "group": "Ungrouped variables", "definition": "if(f=1,(-b+sqrt(b^2-4*a*c))/(2*a),(-b1+sqrt(b1^2-4*a1*c1))/(2*a1))", "description": "", "templateType": "anything", "can_override": false}, "solx2": {"name": "solx2", "group": "Ungrouped variables", "definition": "if(f=1,(-b-sqrt(b^2-4*a*c))/(2*a),(-b1-sqrt(b1^2-4*a1*c1))/(2*a1))", "description": "", "templateType": "anything", "can_override": false}, "sol1": {"name": "sol1", "group": "Ungrouped variables", "definition": "precround(solx1,3)", "description": "", "templateType": "anything", "can_override": false}, "sol2": {"name": "sol2", "group": "Ungrouped variables", "definition": "precround(solx2,3)", "description": "", "templateType": "anything", "can_override": false}, "question": {"name": "question", "group": "Ungrouped variables", "definition": "if(f=1,'{q1}','{q2}')", "description": "", "templateType": "anything", "can_override": false}, "f": {"name": "f", "group": "Ungrouped variables", "definition": "random(1,2)", "description": "", "templateType": "anything", "can_override": false}, "q1": {"name": "q1", "group": "Ungrouped variables", "definition": "\"

\\\\[ \\\\simplify{{a}x^2+{b}x+{c}=0}\\\\]

\"", "description": "", "templateType": "long string", "can_override": false}, "q2": {"name": "q2", "group": "Ungrouped variables", "definition": "\"

\\\\[ \\\\simplify{{m*n}x^2+{m*q+n*p}x+{p*q}=0}\\\\]

\"", "description": "", "templateType": "long string", "can_override": false}, "m": {"name": "m", "group": "Ungrouped variables", "definition": "random(1,2)", "description": "", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "random(1..2 except m)", "description": "", "templateType": "anything", "can_override": false}, "p": {"name": "p", "group": "Ungrouped variables", "definition": "random(-5..6 except 0)", "description": "", "templateType": "anything", "can_override": false}, "q": {"name": "q", "group": "Ungrouped variables", "definition": "random(-5..6 except[0,p])", "description": "", "templateType": "anything", "can_override": false}, "advice": {"name": "advice", "group": "Ungrouped variables", "definition": "if(f=2,'{solfac}','{solquad}')", "description": "", "templateType": "anything", "can_override": false}, "solfac": {"name": "solfac", "group": "Ungrouped variables", "definition": "\"

Note: In this case it is also possible to use factorisation to find solutions for $x$:

\\n

\\\\[ \\\\simplify{{m*n}x^2+{m*q+n*p}x+{p*q} = ({m}x+{p})({n}x+{q})}.\\\\]

\\n

However, we will give a worked solution using the quadratic formula, as this method holds for all quadratic equations of the form $ax^2+bx+c=0$.

\\n

For the equation \\\\[\\\\simplify{{a1}x^2+{b1}x+{c1}=0}, \\\\]

\\n

the values of the coefficients are \\\\[a=\\\\var{a1}, \\\\quad b=\\\\var{b1}, \\\\quad c=\\\\var{c1}.\\\\]

\\n

Substituting these values into the quadratic formula:

\\n

\\\\[ \\\\begin{split} x &= \\\\frac{\\\\simplify{-{b1}} \\\\pm \\\\sqrt{(\\\\var{b1})^2 - (4 \\\\times \\\\var{a1} \\\\times \\\\var{c1})}}{2 \\\\times \\\\var{a1}} \\\\\\\\\\\\\\\\&= \\\\frac{\\\\simplify{-{b1}} \\\\pm \\\\simplify[!collectNumbers]{sqrt({b1^2}-{4*a1*c1})}}{\\\\var{2*a1}} \\\\\\\\\\\\\\\\&= \\\\frac{\\\\simplify{-{b1}} \\\\pm \\\\simplify[!collectNumbers]{sqrt({b1^2-4*a1*c1})}}{\\\\var{2*a1}} \\\\\\\\\\\\\\\\&= \\\\frac{\\\\simplify{-{b1}} \\\\pm \\\\simplify{sqrt({b1^2-4*a1*c1})}}{\\\\var{2*a1}}. \\\\end{split} \\\\]

\\n

Note the $\\\\pm$ symbol in the quadratic formula. This means that there are $2$ solutions for $x$: one using $+$ and one using $-$. 

\\n

Therefore,

\\n

\\\\[ \\\\begin{split} x_1 &\\\\,= \\\\frac{\\\\simplify{-{b1}} + \\\\simplify{sqrt({b1^2-4*a1*c1})}}{\\\\var{2*a1}} \\\\qquad \\\\text{and} \\\\qquad  x_2 &\\\\,= \\\\frac{\\\\simplify{-{b1}} - \\\\simplify{sqrt({b1^2-4*a1*c1})}}{\\\\var{2*a1}}\\\\\\\\\\\\\\\\ &\\\\,= \\\\var{sol1},\\\\quad &\\\\,=\\\\var{sol2}. \\\\end{split}\\\\]

\"", "description": "", "templateType": "long string", "can_override": false}, "solquad": {"name": "solquad", "group": "Ungrouped variables", "definition": "\"

For the equation \\\\[\\\\simplify{{a}x^2+{b}x+{c}=0}, \\\\]

\\n

the values of the coefficients are \\\\[a=\\\\var{a}, \\\\quad b=\\\\var{b}, \\\\quad c=\\\\var{c}.\\\\]

\\n

Substituting these values into the quadratic formula:

\\n

\\\\[ \\\\begin{split} x &= \\\\frac{\\\\simplify{-{b}} \\\\pm \\\\sqrt{(\\\\var{b})^2 - (4 \\\\times \\\\var{a} \\\\times \\\\var{c})}}{2 \\\\times \\\\var{a}} \\\\\\\\\\\\\\\\&= \\\\frac{\\\\simplify{-{b}} \\\\pm \\\\simplify[!collectNumbers]{sqrt({b^2}-{4*a*c})}}{\\\\var{2a}} \\\\\\\\\\\\\\\\&= \\\\frac{\\\\simplify{-{b}} \\\\pm \\\\simplify[!collectNumbers]{sqrt({b^2-4*a*c})}}{\\\\var{2a}} \\\\\\\\\\\\\\\\&= \\\\frac{\\\\simplify{-{b}} \\\\pm \\\\simplify{sqrt({b^2-4*a*c})}}{\\\\var{2a}}. \\\\end{split} \\\\]

\\n

Note the $\\\\pm$ symbol in the quadratic formula. This means that there are $2$ solutions for $x$: one using $+$ and one using $-$. 

\\n

Therefore,

\\n

\\\\[ \\\\begin{split} x_1 &\\\\,= \\\\frac{\\\\simplify{-{b}} + \\\\simplify{sqrt({b^2-4*a*c})}}{\\\\var{2a}} \\\\qquad \\\\text{and} \\\\qquad  x_2 &\\\\,= \\\\frac{\\\\simplify{-{b}} - \\\\simplify{sqrt({b^2-4*a*c})}}{\\\\var{2a}}\\\\\\\\\\\\\\\\ &\\\\,= \\\\var{sol1},\\\\quad &\\\\,=\\\\var{sol2}. \\\\end{split}\\\\]

\"", "description": "", "templateType": "long string", "can_override": false}, "a1": {"name": "a1", "group": "Ungrouped variables", "definition": "m*n", "description": "", "templateType": "anything", "can_override": false}, "b1": {"name": "b1", "group": "Ungrouped variables", "definition": "m*q+n*p", "description": "", "templateType": "anything", "can_override": false}, "c1": {"name": "c1", "group": "Ungrouped variables", "definition": "p*q", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "b^2-4a*c >0", "maxRuns": 100}, "ungrouped_variables": ["a", "b", "c", "a1", "m", "b1", "n", "c1", "p", "q", "solx1", "solx2", "sol1", "sol2", "question", "f", "q1", "q2", "advice", "solfac", "solquad"], "variable_groups": [], "functions": {}, "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": "

$x=$[[0]] 

\n

Give your answers to 3 decimal places where necessary.

", "gaps": [{"type": "list-of-numbers", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correctAnswer": "[{sol1},{sol2}]", "allowFractions": false, "correctAnswerFractions": false, "isSet": false, "show_input_hint": true, "separator": ","}}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Ruth Hand", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3228/"}, {"name": "Ben McGovern", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4872/"}]}]}], "contributors": [{"name": "Ruth Hand", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3228/"}, {"name": "Ben McGovern", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4872/"}]}