// Numbas version: finer_feedback_settings {"name": "Hyperbolic differentiation: notice derivatives have order 2 SPARE", "extensions": [], "custom_part_types": [{"source": {"pk": 297, "author": {"name": "Will Roberts", "pk": 32402}, "edit_page": "/part_type/297/edit"}, "name": "Will's copy of Differential Equation", "short_name": "will-s-copy-of-differential-equation", "description": "
For questions on differentiation. Takes the student answer and explicitly checks that it satisfies a given differential equation.
\nWill also check that the general solution has the correct number of linearly independent solutions (for up to a third-order ODE).
", "help_url": "", "input_widget": "jme", "input_options": {"correctAnswer": "settings['sample']", "hint": {"static": true, "value": ""}, "showPreview": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(unexpectedVariables);\napply(sameVars);\napply(hasConstants);\nif(length(constants)=2 or length(constants)=3, apply(notInd), true);\napply(numericallyCorrect)\n\ninterpreted_answer:\nstring(studentAnswer)\n\nequation:\njoin(map(settings['decoeffs'][n]+\"*(\"+d(string(studentAnswer),settings['arg'],length(settings['decoeffs'])-1-n)+\")\",n,0..length(settings['decoeffs'])-1),'+')\n\nagree:\nmap(\n try(\n resultsEqual(eval(parse(equation),vars),eval(settings['RHS'],vars),'RelDiff',0.0001),\n message,\n warn(translate(\"part.jme.answer invalid\",[\"message\":message]));\n fail(translate(\"part.jme.answer invalid\",[\"message\":message]));\n false\n ),\n vars,\n vset\n )\n\nvset:\nrepeat(\n dict(map([x,random(vRange)],x,correctVars or studentVariables)),\n 5\n)\n\ncorrectVars:\nset(settings['arg'])\n\nstudentVariables:\nset(findvars(studentAnswer))\n\nvRange:\n0..1#0\n\nunexpectedVariables:\nif (settings['var'] in list(studentVariables),\n incorrect(\"$\"+settings['var']+\"$ is the function $\"+settings['var']+\"(\"+settings['arg']+\")$; it should not be in the final answer.\"); end(),\n false\n ) \n\nsameVars:\nif (not (settings['arg'] in list(studentVariables)),\n incorrect(\"The argument of the function is $\"+settings['arg']+\"$; your solution does not contain it.\"); end(),\n true\n )\n\nnumFails:\napply(agree);\nlen(filter(not x,x,agree))\n\nnumericallyCorrect:\napply(numFails);\nif(numFails<1,\n correct(translate('part.jme.marking.correct')),\n incorrect()\n ) \n\nhasConstants:\nif(not(length(studentVariables)=length(findvars(settings[\"sample\"]))),\n incorrect(\"Your solution does not have the required number of constants to be a general solution.\"); end(),\n true\n )\n\nconstants:\nfilter(not(x=settings['arg']),x,map(x,x,studentVariables))\n\ntestSet:\nrepeat([settings['arg'],random(vRange)],5)\n\ntestingSets:\nmap(\nmap(\n dict(\n map([constants[m],if(m=n,1,0)],m,0..length(constants)-1)\n +[vars]),\n n,0..length(constants)-1\n),\nvars,testSet)\n\nlinears:\nmap(\nmap(\n map(eval(parse(d(string(studentAnswer),settings['arg'],m)),vars),m,0..length(constants)-1),\n vars,testingSets[x0]),\nx0,0..length(testingSets)-1)\n\nnotInd:\nif(length(constants)=2 or length(constants)=3,\nif(some(map(det(matrix(linears[n]))=0,n,0..length(linears)-1)),\n incorrect(\"Your solutions are not linearly independent.\"); end(),\n false\n),\nfalse\n)", "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": "apply(unexpectedVariables);\napply(sameVars);\napply(hasConstants);\nif(length(constants)=2 or length(constants)=3, apply(notInd), true);\napply(numericallyCorrect)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "string(studentAnswer)"}, {"name": "equation", "description": "The differential equation in the question
", "definition": "join(map(settings['decoeffs'][n]+\"*(\"+d(string(studentAnswer),settings['arg'],length(settings['decoeffs'])-1-n)+\")\",n,0..length(settings['decoeffs'])-1),'+')"}, {"name": "agree", "description": "Do the student's answer and the expected answer agree on each of the sets of variable values?
", "definition": "map(\n try(\n resultsEqual(eval(parse(equation),vars),eval(settings['RHS'],vars),'RelDiff',0.0001),\n message,\n warn(translate(\"part.jme.answer invalid\",[\"message\":message]));\n fail(translate(\"part.jme.answer invalid\",[\"message\":message]));\n false\n ),\n vars,\n vset\n )"}, {"name": "vset", "description": "The set of variable values to test against
", "definition": "repeat(\n dict(map([x,random(vRange)],x,correctVars or studentVariables)),\n 5\n)"}, {"name": "correctVars", "description": "Variables used in the correct answer
", "definition": "set(settings['arg'])"}, {"name": "studentVariables", "description": "Variables used in the student's answer
", "definition": "set(findvars(studentAnswer))"}, {"name": "vRange", "description": "The range to pick variable values from
", "definition": "0..1#0"}, {"name": "unexpectedVariables", "description": "Unexpected variables used in the student's answer
", "definition": "if (settings['var'] in list(studentVariables),\n incorrect(\"$\"+settings['var']+\"$ is the function $\"+settings['var']+\"(\"+settings['arg']+\")$; it should not be in the final answer.\"); end(),\n false\n ) "}, {"name": "sameVars", "description": "Does the student use the same variables as the correct answer?
", "definition": "if (not (settings['arg'] in list(studentVariables)),\n incorrect(\"The argument of the function is $\"+settings['arg']+\"$; your solution does not contain it.\"); end(),\n true\n )"}, {"name": "numFails", "description": "The number of times the student's answer and the expected answer disagree
", "definition": "apply(agree);\nlen(filter(not x,x,agree))"}, {"name": "numericallyCorrect", "description": "Is the student's answer numerically correct?
", "definition": "apply(numFails);\nif(numFails<1,\n correct(translate('part.jme.marking.correct')),\n incorrect()\n ) "}, {"name": "hasConstants", "description": "Checks that the student's solution has the correct number of undetermined constants, by comparing to the sample solution.
", "definition": "if(not(length(studentVariables)=length(findvars(settings[\"sample\"]))),\n incorrect(\"Your solution does not have the required number of constants to be a general solution.\"); end(),\n true\n )"}, {"name": "constants", "description": "Finds the constants in the student's expression.
", "definition": "filter(not(x=settings['arg']),x,map(x,x,studentVariables))"}, {"name": "testSet", "description": "Generates a random set of x values to test independence of solutions over.
", "definition": "repeat([settings['arg'],random(vRange)],5)"}, {"name": "testingSets", "description": "Creates a set of 'linearly independent' solutions, by sequentially setting one constant to one and the others to zero.
", "definition": "map(\nmap(\n dict(\n map([constants[m],if(m=n,1,0)],m,0..length(constants)-1)\n +[vars]),\n n,0..length(constants)-1\n),\nvars,testSet)"}, {"name": "linears", "description": "Evaluates the 'linearly independent' solutions over a pre-determined sample of argument values.
", "definition": "map(\nmap(\n map(eval(parse(d(string(studentAnswer),settings['arg'],m)),vars),m,0..length(constants)-1),\n vars,testingSets[x0]),\nx0,0..length(testingSets)-1)"}, {"name": "notInd", "description": "Checks that the student does have the right number of linearly independent solutions. Fails if any of the determinants are zero: the determinants are the Wronskian W for the 'independent' solutions y1(x)=y(x;1,0,...,0), y2(x)=(x;0,1,...,0),...,yn(x)=(x;0,0,...,1).
\n", "definition": "if(length(constants)=2 or length(constants)=3,\nif(some(map(det(matrix(linears[n]))=0,n,0..length(linears)-1)),\n incorrect(\"Your solutions are not linearly independent.\"); end(),\n false\n),\nfalse\n)"}], "settings": [{"name": "sample", "label": "Sample Solution", "help_url": "", "hint": "A possible solution, to be shown to the student on 'Reveal Answer'.", "input_type": "mathematical_expression", "default_value": "", "subvars": true}, {"name": "decoeffs", "label": "Differential Equation Coefficients", "help_url": "", "hint": "A list of strings corresponding to the (possible function-valued) coefficients of the various terms in the differential equation.Give any valid solution to a second order ODE with general solution Ae^x+Bcosh(x)+Csinh(x)
", "licence": "Creative Commons Attribution-NonCommercial 4.0 International"}, "statement": "", "advice": "The solution to this equation is a function that is itself after twice differentiating. Once such function is $e^x$, since this function differentiates to itself immediately. Two further options are $\\cosh(x)$ and $\\sinh(x)$. Multiplying any of these functions by a constant will preserve the quality that they are equal to their second derivatives, for example
\n$$
\\frac{d^2}{dx^2}7\\cosh(x)=7\\cosh(x)
$$
Hence any of these functions (or any linear combination of them) is a solution to the differential equation $y=\\frac{d^2y}{dx^2}$. That is, the general solution is of the form
\n$$
y=Ae^x+B\\cosh(x)+C\\sinh(x), \\quad A, B, C \\in \\mathbb{R}.
$$
Suggest a valid solution to the following differential equation.
\n$$
y=\\frac{d^2y}{dx^2}
$$