// Numbas version: exam_results_page_options {"name": "Functions: floor and roof", "extensions": [], "custom_part_types": [], "resources": [["question-resources/Floor_function.svg.png", "/srv/numbas/media/question-resources/Floor_function.svg.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Functions: floor and roof", "metadata": {"licence": "Creative Commons Attribution-ShareAlike 4.0 International", "description": "

Introduces students to the floor and ceiling functions

"}, "tags": [], "parts": [{"failureRate": 1, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "showCorrectAnswer": true, "answer": "{floor(x1)}", "marks": 1, "checkingAccuracy": 0.001, "type": "jme", "showPreview": true, "extendBaseMarkingAlgorithm": true, "unitTests": [], "vsetRangePoints": 5, "vsetRange": [0, 1], "scripts": {"mark": {"order": "instead", "script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar x1 = unwrap(variables.x1);\n\n// compute its derivative\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n if (Math.floor(x1) == ans) {\n this.setCredit(1,\"Correct. This is the floor of \$\" + x1 + \"\$.\");\n }\n else if (Math.ceil(x1) == ans) { \n this.setCredit(0,\"Close. This is the ceiling of \$\" + x1 + \"\$.\");\n }\n else if (ans % 1 != 0) {\n this.setCredit(0,\"Your answer should be an integer.\"); \n }\n else {\n this.setCredit(0,\"Incorrect.\"); \n }\n}\ncatch(e) {\n this.markingComment(e);\n}"}}, "showFeedbackIcon": true, "checkVariableNames": false, "expectedVariableNames": [], "prompt": "

\$\\lfloor \\var{x1}\\rfloor\$

", "customMarkingAlgorithm": ""}, {"failureRate": 1, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "showCorrectAnswer": true, "answer": "{ceil(x1)}", "marks": 1, "checkingAccuracy": 0.001, "type": "jme", "showPreview": true, "extendBaseMarkingAlgorithm": true, "unitTests": [], "vsetRangePoints": 5, "vsetRange": [0, 1], "scripts": {"mark": {"order": "instead", "script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar x1 = unwrap(variables.x1);\n\n// compute its derivative\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n if (Math.floor(x1) == ans) {\n this.setCredit(0,\"Close. This is the floor of \$\" + x1 + \"\$.\");\n }\n else if (Math.ceil(x1) == ans) { \n this.setCredit(1,\"Correct. This is the ceiling of \$\" + x1 + \"\$.\");\n }\n else if (ans % 1 != 0) {\n this.setCredit(0,\"Your answer should be an integer.\"); \n }\n else {\n this.setCredit(0,\"Incorrect.\"); \n }\n}\ncatch(e) {\n this.markingComment(e);\n}"}}, "showFeedbackIcon": true, "checkVariableNames": false, "expectedVariableNames": [], "prompt": "

\$\\lceil \\var{x1}\\rceil\$

", "customMarkingAlgorithm": ""}, {"failureRate": 1, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "variableReplacements": [{"variable": "", "part": "p1", "must_go_first": false}], "showCorrectAnswer": true, "answer": "{floor(-x1)}", "marks": 1, "checkingAccuracy": 0.001, "type": "jme", "showPreview": true, "extendBaseMarkingAlgorithm": true, "unitTests": [], "vsetRangePoints": 5, "vsetRange": [0, 1], "scripts": {"mark": {"order": "instead", "script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar x1 = -1*unwrap(variables.x1);\n\n// compute its derivative\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n if (Math.floor(x1) == ans) {\n this.setCredit(1,\"Correct. This is the floor of \$\" + x1 + \"\$.\");\n }\n else if (Math.ceil(x1) == ans) { \n this.setCredit(0,\"Close. This is the ceiling of \$\" + x1 + \"\$.\");\n }\n else if (ans % 1 != 0) {\n this.setCredit(0,\"Your answer should be an integer.\"); \n }\n else {\n this.setCredit(0,\"Incorrect.\"); \n }\n}\ncatch(e) {\n this.markingComment(e);\n}"}}, "showFeedbackIcon": true, "checkVariableNames": false, "expectedVariableNames": [], "prompt": "

\$\\lfloor - \\var{x1}\\rfloor\$

", "customMarkingAlgorithm": ""}, {"failureRate": 1, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "showCorrectAnswer": true, "answer": "{ceil(-x1)}", "marks": 1, "checkingAccuracy": 0.001, "type": "jme", "showPreview": true, "extendBaseMarkingAlgorithm": true, "unitTests": [], "vsetRangePoints": 5, "vsetRange": [0, 1], "scripts": {"mark": {"order": "instead", "script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar x1 = -1*unwrap(variables.x1);\n\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer);\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n if (Math.floor(x1) == ans) {\n this.setCredit(0,\"Close. This is the floor of \$\" + x1 + \"\$.\");\n }\n else if (Math.ceil(x1) == ans) { \n this.setCredit(1,\"Correct. This is the ceiling of \$\" + x1 + \"\$.\");\n }\n else if (ans % 1 != 0) {\n this.setCredit(0,\"Your answer should be an integer.\"); \n }\n else {\n this.setCredit(0,\"Incorrect.\"); \n }\n}\ncatch(e) {\n this.markingComment(e);\n}"}}, "showFeedbackIcon": true, "checkVariableNames": false, "expectedVariableNames": [], "prompt": "

\$\\lceil -\\var{x1}\\rceil\$

", "customMarkingAlgorithm": ""}], "functions": {}, "advice": "

Normally, when you round a number you round up to the nearest integer. For example \$3.51\$ gets rounded up to \$4\$, but \$3.49\$ gets rounded down to \$3\$.

\n

The floor and ceiling functions are two different ways of rounding a number.

\n
\n
• The floor function always rounds down: \$\\lfloor 3.51\\rfloor = 3\$.
• \n
• In contrast the ceiling function always rounds up: \$\\lceil 3.49 \\rceil = 4\$.
• \n
", "ungrouped_variables": ["x1"], "statement": "

The floor of \$x\$ is defined to be the largest integer smaller than \$x\$. Similarly the ceiling of \$x\$ is defined to be the smallest integer bigger than \$x\$. We use the notation \$\\lfloor x\\rfloor\$ for the floor and \$\\lceil x\\rceil\$ for the ceiling. Evaluate the following:

\n

", "variables": {"x1": {"templateType": "anything", "name": "x1", "definition": "random(1..9)+random(1..9)/10", "description": "", "group": "Ungrouped variables"}}, "rulesets": {}, "preamble": {"css": "", "js": ""}, "variable_groups": [], "extensions": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "type": "question", "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}]}