Differential equations: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
var P = brd.create('point',[0,0], {name:'x_0'}); | var P = brd.create('point',[0,0], {name:'x_0'}); | ||
var f = function(t,x) { | var f = function(t,x) { | ||
return 3*x; | return [3*x[0]]; | ||
}; | }; | ||
function ode() { | function ode() { | ||
var data = JXG.Math.Numerics.rungeKutta(JXG.Math.Numerics.predefinedButcher.Heun, [1], [0, 2], 20, f); | |||
} | |||
var data = JXG.Math.Numerics.rungeKutta(JXG.Math.Numerics.predefinedButcher. | |||
} | |||
var g = brd.createElement('curve', [[0],[0]], {strokeColor:'red', strokeWidth:'2px'}); | var g = brd.createElement('curve', [[0],[0]], {strokeColor:'red', strokeWidth:'2px'}); | ||
g.updateDataArray = function() { | g.updateDataArray = function() { | ||
var data = ode(); | var data = ode(); | ||
var h = 0.1; | |||
this.dataX = []; | this.dataX = []; | ||
this.dataY = []; | this.dataY = []; | ||
for(var i=0; i<data.length; i++) { | for(var i=0; i<data.length; i++) { | ||
this.dataX[i] = | this.dataX[i] = i*h; | ||
this.dataY[i] = data[i][0]; | this.dataY[i] = data[i][0]; | ||
} | } |