// Numbas version: exam_results_page_options {"name": "Solution curves and Vector fields 3: $dy/dx=x^3-y^3$", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["a"], "rulesets": {}, "variables": {"a": {"description": "

Just a filler - not used. Need a variable to publish.

", "name": "a", "group": "Ungrouped variables", "templateType": "anything", "definition": "1"}}, "extensions": ["jsxgraph"], "functions": {"testfield": {"type": "html", "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 x*x*x-y*y*y;}\n var str = \"x*x*x-y*y*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[0]; 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', [[0],[0]], {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; iUsing Jsxgraph to draw the vector field for a differential equation of the form $\\frac{dy}{dx}=f(x,y)=x^3-y^3$, 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)$.

", "licence": "Creative Commons Attribution 4.0 International"}, "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

{testfield()}

\n

", "name": "Solution curves and Vector fields 3: $dy/dx=x^3-y^3$", "parts": [{"type": "information", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "scripts": {}, "variableReplacements": [], "prompt": "

Vector field for the differential equation \\[\\frac{dy}{dx}=f(x,y)=x^3-y^3\\]

\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. 

", "marks": 0}], "tags": [], "advice": "

Move the point $(x_0,y_0)$ to see the solutions through that point.

", "preamble": {"css": "", "js": ""}, "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/"}]}