// Numbas version: exam_results_page_options {"name": "Solution curves and Vector fields 1 : dy/dx=sin(x-y)", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Using Jsxgraph to draw the vector field for a differential equation of the form $\\frac{dy}{dx}=f(x,y)=\\sin(x-y)$, and also by moving the point $(x_0,y_0)$ you can see the solution curves going through that point.

\n

If you want to modify $f(x,y)$ simply change the definition of  $f(x,y)$ and that of the variable  str in the user defined function testfield in Extensions and scripts. You have to use javascript notation for functions and powers in the definition of $f(x,y)$.

"}, "variables": {"a": {"definition": "1", "templateType": "anything", "name": "a", "description": "

Filler variable  - not used.

", "group": "Ungrouped variables"}}, "extensions": ["jsxgraph"], "functions": {"testfield": {"definition": "\n var div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[-5,5,5,-5],grid:true,axis:true});\n function f(x,y){return Math.sin(x-y);}\n var str = \"Math.sin(x-y)\";\n var board = div.board;\n for(var i=-10;i<10;i++){\n for(var j=-10;j<10;j++){\n //board.create('point',[i/2,j/2],{size:2,name:'',face:'+'});\n var len=4;\n // the length of a segment is 1/4\n var d=1/(len*(Math.pow(1+Math.pow(f(i/2,j/2),2),0.5)));\n board.create('segment',[[i/2,j/2],[i/2+d,d*f(i/2,j/2)+j/2]]);}\n }\n //var N = board.create('slider',[[-4,4],[4,4],[-5,2.5,5]], {name:'N'});\n var P = board.create('point',[0,0], {name:'(x_0,y_0)'});\n \n function doIt() {\n var txt = JXG.GeonextParser.geonext2JS(str);\n f = new Function(\"x\", \"yy\", \"var y = yy; var z = \" + txt + \"; return [z]\");\n board.update();\n }\n \n function ode() {\n return JXG.Math.Numerics.rungeKutta('heun', [P.Y()], [P.X(), 5], 200, f);\n }\n function ode1() {\n return JXG.Math.Numerics.rungeKutta('heun', [P.Y()], [P.X(), -5], 200, f);\n } \n var g = board.create('curve', [,], {strokeColor:'red', strokeWidth:2});\n g.updateDataArray = function() {\n var data = ode();\n var data1= ode1();\n var h = (5-P.X())/200;\n var h1 = (5+P.X())/200;\n this.dataX = [];\n this.dataY = [];\n for(var i=0; i{testfield()}

\n

", "variable_groups": [], "name": "Solution curves and Vector fields 1 : dy/dx=sin(x-y)", "advice": "

If you want to see the solution curve through a particular point then drag the point labeled $(x_0,y_0)$ to it.

\n

", "variablesTest": {"maxRuns": 100, "condition": ""}, "tags": ["differential equations", "Differential equations", "vector field"], "parts": [{"variableReplacements": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "marks": 0, "variableReplacementStrategy": "originalfirst", "scripts": {}, "prompt": "

Vector field for the differential equation \$\\frac{dy}{dx}=f(x,y)=\\sin(x-y)\$

\n

You change the function $f(x,y)$ by modifying the function $f(x,y)$ in the testfield function defined in Extensions and scripts.

\n

You have to use Javascript notation for powers and standard functions when you define $f(x,y)$ in testfield.

\n

If you want to see the solution curve through a particular point then drag the point labeled $(x_0,y_0)$ to it.

", "type": "information"}], "rulesets": {}, "ungrouped_variables": ["a"], "preamble": {"js": "", "css": ""}, "type": "question", "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}]}]}], "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}]}