Systems of differential equations: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 17: Line 17:


function doIt() {
function doIt() {
   var txt = JXG.GeonextParser.geonext2JS(document.getElementById("odeinput1").value);
   var txt1 = JXG.GeonextParser.geonext2JS(document.getElementById("odeinput1").value);
   f = new Function("x", "yy", "var y = yy[0]; var z = " + txt + "; return [z]");
  var txt2 = JXG.GeonextParser.geonext2JS(document.getElementById("odeinput2").value);
   f = new Function("x", "yy", "var y1 = yy[0], y1 = yy[1]; var z1 = " + txt1 + "; var z2 = " + txt2 + "; return [z1,z2];");
   brd.update();
   brd.update();
}
}


function ode() {
function ode() {
   return JXG.Math.Numerics.rungeKutta(JXG.Math.Numerics.predefinedButcher.Heun, [P1.Y()], [P1.X(), P1.X()+N.Value()], 200, f);
   return JXG.Math.Numerics.rungeKutta(JXG.Math.Numerics.predefinedButcher.Heun, [P1.Y(),P2.Y()], [P1.X(), P1.X()+N.Value()], 200, f);
}
}


var g = brd.createElement('curve', [[0],[0]], {strokeColor:'red', strokeWidth:'2px'});
var g1 = brd.createElement('curve', [[0],[0]], {strokeColor:'red', strokeWidth:'2px'});
g.updateDataArray = function() {
var g2 = brd.createElement('curve', [[0],[0]], {strokeColor:'black', strokeWidth:'2px'});
g1.updateDataArray = function() {
     var data = ode();
     var data = ode();
     var h = N.Value()/200;
     var h = N.Value()/200;
Line 35: Line 37:
         this.dataX[i] = P1.X()+i*h;
         this.dataX[i] = P1.X()+i*h;
         this.dataY[i] = data[i][0];
         this.dataY[i] = data[i][0];
    }
};
g2.updateDataArray = function() {
    var data = ode();
    var h = N.Value()/200;
    this.dataX = [];
    this.dataY = [];
    for(var i=0; i<data.length; i++) {
        this.dataX[i] = P2.X()+i*h;
        this.dataY[i] = data[i][1];
     }
     }
};
};
doIt();
doIt();
</jsxgraph>
</jsxgraph>

Revision as of 08:50, 21 July 2010

Display solutions of the ordinary differential equation

[math]\displaystyle{ y_1'= f_1(x,y_1,y_2) }[/math]
[math]\displaystyle{ y_2'= f_2(x,y_1,y_2) }[/math]

with initial values [math]\displaystyle{ (x_0,y_1) }[/math], [math]\displaystyle{ (x_0,y_2) }[/math].

f1(x,y1,y2)=
f2(x,y1,y2)=