// Numbas version: finer_feedback_settings {"name": "Cubics: Summary (Intermediate steps)", "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": "Cubics: Summary (Intermediate steps)", "tags": [], "metadata": {"description": "

Part (a): Given two cubic functions $g(x)$ and $h(x)$ of the form $ax^3+bx^2+cx+d$, give an expression for the function $f(x)$, where $f(x)=g(x)-2h(x)$. 

\n

Part (b): Solve $f(x)=0$.

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

\\[g(x)=\\simplify[all]{{m1*A}x^3+{m2*B}x^2+{m3*C}x+{m4*D}},\\quad h(x)=\\simplify[all]{{n1*A}x^3+{n2*B}x^2+{n3*C}x+{n4*D}}\\]

", "advice": "

a) We are asked to find $f(x)$, where $f(x)=g(x)-2h(x)$.

\n

Therefore,

\n

\\[ \\begin{split} f(x) &\\,= \\simplify[all]{{m1*A}x^3+{m2*B}x^2+{m3*C}x+{m4*D}} - 2 \\left( \\simplify[all]{{n1*A}x^3+{n2*B}x^2+{n3*C}x+{n4*D}} \\right) \\\\ &\\,=\\simplify[all]{{m1*A}x^3+{m2*B}x^2+{m3*C}x+{m4*D}} -\\left(\\simplify[all]{{2*n1*A}x^3+{2*n2*B}x^2+{2*n3*C}x+{2*n4*D}}\\right) \\\\&\\,=\\simplify[all,!collectNumbers,!cancelTerms]{{m1*A}x^3+{m2*B}x^2+{m3*C}x+{m4*D} -{2*n1*A}x^3-{2*n2*B}x^2-{2*n3*C}x-{2*n4*D}}.\\end{split} \\]

\n

Collecting similar terms, we find the expression for $f(x)$:

\n

\\[ f(x) = \\simplify[all]{{m1*A-2*n1*A}x^3+{m2*B-2*n2*B}x^2+{m3*C-2*n3*C}x+{m4*D-2*n4*D}}.\\]

\n

\n

b) We now need to solve $f(x)=0$.

\n

From part (a), we know that 

\n

\\[ f(x) = \\simplify[all]{{m1*A-2*n1*A}x^3+{m2*B-2*n2*B}x^2+{m3*C-2*n3*C}x+{m4*D-2*n4*D}}.\\]

\n

Setting this equal to $0$, we now have a cubic equation in terms of $x$:

\n

\\[ \\simplify[all]{{m1*A-2*n1*A}x^3+{m2*B-2*n2*B}x^2+{m3*C-2*n3*C}x+{m4*D-2*n4*D}} = 0.\\]

\n

To find the solutions of this equation we want to factorise the left-hand side of the equation into its linear factors. 

\n

To find the first of these factors, we can try appropriate values for $x$ to see if they satisfy $f(x)=0$. A sensible approach to this step is to try the positive and negative factors of the constant term in the equation, which is $\\var{{m4*D-2*n4*D}}$ in this case. 

\n

Starting with $\\var{-b1/a1}$, we find that $f(\\var{-b1/a1})=0$, which tells us that $(\\simplify{x-{-b1/a1}})$ is a factor of $f(x)$. (Note: The first number you try will often not be a factor, and this is completely fine. It can be helpful to list the factors first and try each one in order until you find one that works.)

\n

\n

To find the other factors, we can write $f(x)$ as a product of this factor and a quadratic, and then factorise the quadratic to find the remaining linear factors:

\n

\\[ \\begin{split} \\simplify[all]{{m1*A-2*n1*A}x^3+{m2*B-2*n2*B}x^2+{m3*C-2*n3*C}x+{m4*D-2*n4*D}} &\\,= (\\simplify{x-{-b1/a1}})(\\simplify{{a2*a3}x^2+{a2*b3+a3*b2}x+{b2*b3}}) \\\\ &\\,= (\\simplify{x-{-b1/a1}})(\\simplify{{a2}x-{-b2}})(\\simplify{{a3}x-{-b3}}) \\end{split}\\]

\n

Therefore, 

\n

\\[(\\simplify{x-{-b1/a1}})(\\simplify{{a2}x-{-b2}})(\\simplify{{a3}x-{-b3}}) = 0,\\]

\n

and the solutions for $x$ are \\[ x_1=\\simplify[fractionNumbers]{{sol1}}\\,,x_2=\\simplify[fractionNumbers]{{sol2}}\\,,x_3=\\simplify[fractionNumbers]{{sol3}}\\,.\\]

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"a1": {"name": "a1", "group": "Ungrouped variables", "definition": "random(1..3)", "description": "", "templateType": "anything", "can_override": false}, "a2": {"name": "a2", "group": "Ungrouped variables", "definition": "random(1..3)", "description": "", "templateType": "anything", "can_override": false}, "a3": {"name": "a3", "group": "Ungrouped variables", "definition": "random(1..3)", "description": "", "templateType": "anything", "can_override": false}, "A": {"name": "A", "group": "Ungrouped variables", "definition": "a1*a2*a3", "description": "", "templateType": "anything", "can_override": false}, "b1": {"name": "b1", "group": "Ungrouped variables", "definition": "random(-5..5 except 0)", "description": "", "templateType": "anything", "can_override": false}, "b2": {"name": "b2", "group": "Ungrouped variables", "definition": "random(-5..5 except [0,b1])", "description": "", "templateType": "anything", "can_override": false}, "b3": {"name": "b3", "group": "Ungrouped variables", "definition": "random(-5..5 except[0,b2,b1])", "description": "", "templateType": "anything", "can_override": false}, "B": {"name": "B", "group": "Ungrouped variables", "definition": "a1*a2*b3+a1*b2*a3+b1*a2*a3", "description": "", "templateType": "anything", "can_override": false}, "C": {"name": "C", "group": "Ungrouped variables", "definition": "a1*b2*b3+b1*a2*b3+b1*b2*a3", "description": "", "templateType": "anything", "can_override": false}, "D": {"name": "D", "group": "Ungrouped variables", "definition": "b1*b2*b3", "description": "", "templateType": "anything", "can_override": false}, "m1": {"name": "m1", "group": "Ungrouped variables", "definition": "random(3..7 #2)", "description": "", "templateType": "anything", "can_override": false}, "m2": {"name": "m2", "group": "Ungrouped variables", "definition": "random(-3..3 #2)", "description": "", "templateType": "anything", "can_override": false}, "m3": {"name": "m3", "group": "Ungrouped variables", "definition": "random(-3..3 #2)", "description": "", "templateType": "anything", "can_override": false}, "m4": {"name": "m4", "group": "Ungrouped variables", "definition": "random(-3..3 #2)", "description": "", "templateType": "anything", "can_override": false}, "n1": {"name": "n1", "group": "Ungrouped variables", "definition": "(m1-1)/2", "description": "", "templateType": "anything", "can_override": false}, "n2": {"name": "n2", "group": "Ungrouped variables", "definition": "(m2-1)/2", "description": "", "templateType": "anything", "can_override": false}, "n3": {"name": "n3", "group": "Ungrouped variables", "definition": "(m3-1)/2", "description": "", "templateType": "anything", "can_override": false}, "n4": {"name": "n4", "group": "Ungrouped variables", "definition": "(m4-1)/2", "description": "", "templateType": "anything", "can_override": false}, "sol1": {"name": "sol1", "group": "Ungrouped variables", "definition": "-b1/a1", "description": "", "templateType": "anything", "can_override": false}, "sol2": {"name": "sol2", "group": "Ungrouped variables", "definition": "-b2/a2", "description": "", "templateType": "anything", "can_override": false}, "sol3": {"name": "sol3", "group": "Ungrouped variables", "definition": "-b3/a3", "description": "", "templateType": "anything", "can_override": false}, "sol1dp": {"name": "sol1dp", "group": "Ungrouped variables", "definition": "precround(sol1,2)", "description": "", "templateType": "anything", "can_override": false}, "sol2dp": {"name": "sol2dp", "group": "Ungrouped variables", "definition": "precround(sol2,2)", "description": "", "templateType": "anything", "can_override": false}, "sol3dp": {"name": "sol3dp", "group": "Ungrouped variables", "definition": "precround(sol3,2)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "-b1/a1=round(-b1/a1)", "maxRuns": 100}, "ungrouped_variables": ["a1", "a2", "a3", "b1", "b2", "b3", "A", "B", "C", "D", "m1", "m2", "m3", "m4", "n1", "n2", "n3", "n4", "sol1", "sol2", "sol3", "sol1dp", "sol2dp", "sol3dp"], "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": "

If $f(x)=g(x)-2h(x)$, calculate $f(x)$.

\n

$f(x)\\,=$ [[0]]

", "gaps": [{"type": "jme", "useCustomName": true, "customName": "Gap 0", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "{A}x^3+{B}x^2+{C}x+{D}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "valuegenerators": [{"name": "x", "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": "

Solve $f(x)=0$.

\n

\n

$x=$[[0]]

\n

(You can give your answers as fractions or to 2 decimal places where necessary)

\n

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