We are given the {first_given} and the {second_given}.

\nWe can use Pythagoras' theorem to work out the {missing}.

\nPythagoras' theorem states that

\n\\[ a^2 + b^2 = c^2 \\text{,} \\]

\nwhere $a$ is the opposite side, $b$ is the adjacent side, and $c$ is the hypotenuse.

\nSubstituting the values into this equation, we have

\n\\[ \\var{opposite}^2 + \\var{adjacent}^2 = c^2 \\]\\[ \\var{opposite}^2 + b^2 = \\var{hypotenuse}^2 \\]\\[ a^2 + \\var{adjacent}^2 = \\var{hypotenuse}^2 \\]

\nSo the {missing} is

\n\\[ \\simplify[noleadingminus,unitfactor]{ sqrt({signs[second_given]}*{sides[first_given]}^2 + {sides[second_given]}^2)} = \\sqrt{\\var{sides[missing]^2}} = \\var{sides[missing]}\\text{m} \\]

", "functions": {}, "parts": [{"scripts": {}, "showFeedbackIcon": true, "gaps": [{"allowFractions": false, "maxValue": "sides[missing]", "marks": 1, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "mustBeReducedPC": 0, "correctAnswerFraction": false, "minValue": "sides[missing]", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "showFeedbackIcon": true, "correctAnswerStyle": "plain"}], "prompt": "What is the length of the {missing}?

\n[[0]]m

", "variableReplacementStrategy": "originalfirst", "marks": 0, "type": "gapfill", "showCorrectAnswer": true, "variableReplacements": []}], "rulesets": {}, "variables": {"signs": {"group": "Ungrouped variables", "templateType": "anything", "name": "signs", "description": "Signs of each of the components in the equation $a^2 + b^2 - c^2 = 0$. Used in the working-out in the advice.

\nIn the equation $\\text{missing} = \\sqrt{ \\pm \\text{first}^2 \\pm \\text{second}^2}$, note that:

\n- \n
- when the hypotenuse is missing, both sides in the square root are positive: $\\sqrt{ \\text{first}^2 + \\text{second}^2} = \\sqrt{a^2+b^2}$ \n
- when either of the other sides is missing, it's $\\sqrt{- \\text{first}^2 + \\text{second}^2} = \\sqrt{-(a \\text{ or } b)^2 + c^2}$. \n

So, only the first side in the square root changes sign depending on the missing side.

", "definition": "[\"opposite side\": 1, \"adjacent side\": 1, \"hypotenuse\": -1]"}, "sides": {"group": "Ungrouped variables", "templateType": "anything", "name": "sides", "description": "A dictionary giving the lengths of the sides. Used in the statement and to set the correct answer.

", "definition": "[\"opposite side\":opposite,\"adjacent side\":adjacent,\"hypotenuse\":hypotenuse]"}, "adjacent": {"group": "Ungrouped variables", "templateType": "anything", "name": "adjacent", "description": "The length of the adjacent side. The sides will always form a Pythagorean triple.

", "definition": "(opposite^2-1)/2"}, "first_given": {"group": "Ungrouped variables", "templateType": "anything", "name": "first_given", "description": "The name of the first side given to the student.

", "definition": "if(missing=\"opposite side\",\"adjacent side\",\"opposite side\")"}, "second_given": {"group": "Ungrouped variables", "templateType": "anything", "name": "second_given", "description": "The name of the second side given to the student.

", "definition": "if(missing=\"hypotenuse\",\"adjacent side\",\"hypotenuse\")"}, "hypotenuse": {"group": "Ungrouped variables", "templateType": "anything", "name": "hypotenuse", "description": "The length of the hypotenuse.

", "definition": "adjacent+1"}, "missing": {"group": "Ungrouped variables", "templateType": "anything", "name": "missing", "description": "The name of the side which the student has to work out.

", "definition": "random(keys(sides))"}, "opposite": {"group": "Ungrouped variables", "templateType": "anything", "name": "opposite", "description": "The length of the opposite side.

", "definition": "random(3..13#2)"}}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/", "name": "Christian Lawson-Perfect"}], "tags": [], "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Some clever variable-substitution trickery to randomly pick two sides of a right-angled triangle to give to a student, and ask for the other.

\nThe sides are set up so they're always Pythagorean triples, and the opposite side is always odd.

\nAs ever, most of the tricky stuff is in the advice.

\nBecause this was created quickly to show how to set up the randomisation, there's no diagram. It would benefit greatly from a diagram.

"}, "type": "question", "statement": "You are told that a triangle has {first_given} side {sides[first_given]}m, and {second_given} side {sides[second_given]}m.

", "variable_groups": [], "preamble": {"js": "", "css": ""}}]}], "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/", "name": "Christian Lawson-Perfect"}]}