// program by (c) J-P Moreau E-mail:  jpmoreau@wanadoo.fr// home page http://perso.orange.fr/jean-pierre.moreau/cplus.html// globals:var theTestFunx = 'x*y + cos(t) - 0.5*sin(2*t)';var theTestFuny = 'x^2 + y^2 - (1 + sin(t))';function displayResults() {// var theScriptString = '<STYLE TYPE=' + quoteMark + 'text/css' + quoteMark + '>BODY, LAYER, P, DIV, TABLE, TR, TD, TH {font-size: 12px; font-family: times; color: 000000}</STYLE>';var theString = '<center><TABLE BORDER = 1 cellspacing = 0 cellpadding = 2 noshade border = 0 bordercolor = #FF7272 STYLE="background-color: FFE9EE; border-collapse: collapse"><tr>';for (var j = 1; j <= numCurves; j++) {	theString += '<td align = center><i>t</i></td><td align = center><i>x</i></td><td align = center><i>y</i></td>';	} // jtheString += '</tr><tr>';for (var i = 0; i <= numPoints; i++) {	for (var j = 1; j <= numCurves; j++) {		theString+= '<td>' + roundSigDig(theCombinedResult[j][1][i],8) + '</td>';		theString+= '<td>' + roundSigDig(theCombinedResult[j][2][i],8) + '</td>';		theString+= '<td>' + roundSigDig(theCombinedResult[j][3][i],8) + '</td>';		} // j	theString += '</tr>'	} // itheString += '</table></center>';document.getElementById("data").innerHTML = theString;//var tb="toolbar=0,directories=0,status=0,menubar=0"//tb+=",scrollbars=1,resizable=1,"//var tbend="width=500,height=500";//tb+=tbend;//var Win_1 = window.open("","win1",tb);//Win_1.document.write(theString);//Win_1.document.close();//Win_1.focus();}function RungeKutta2(xFunc, yFunc, x0, y0, tStart, tEnd, numSteps) {// will return a two dim array [1, t] = value of t, [2, t] = value of x(t)// [3, t] = value of y[t]numPoints = numSteps;  // set the globalvar theResult = new makeArray2(3, numSteps+1); // cusion for extra coordvar h = (tEnd - tStart)/numSteps;var h2 = h/2;theResult[1][0] = parseFloat(tStart);theResult[2][0] = parseFloat(x0); // initial valuetheResult[3][0] = parseFloat(y0);t = tStart;var x1 = 0, y1= 0, c1= 0, d1= 0, c2= 0, d2= 0, c3= 0, d3= 0;for (k = 0; k < numSteps; k++) {// RK4(X[k],Y[k],Z[k],h,&X[k+1],&Y[k+1],&Z[k+1]);	x = theResult[2][k];	y = theResult[3][k];	x1 = theResult[2][k];	y1 = theResult[3][k];	c1 = myEval(xFunc); 	d1 = myEval(yFunc); 	t+=h2; x = x1+h2*c1; y = y1 + h2*d1;	c2 = myEval(xFunc); //alert("x = " + x + " y = " + y + "t = " + t + "c2 = " + c2);	d2 = myEval(yFunc);	x = x1+h2*c2; y = y1 + h2*d2;	c3 = myEval(xFunc);	d3 = myEval(yFunc);	t += h2; x = x1+h*c3; y = y1 + h*d3;	c4 = myEval(xFunc);	d4 = myEval(yFunc);	theResult[1][k+1] = t;	theResult[2][k+1] = x1 + h*(c1+2*c2+2*c3+c4)/6;	theResult[3][k+1] = y1 + h*(d1+2*d2+2*d3+d4)/6;	}  // kreturn(theResult);} // RungeKutta2