public void RungeKutta4Test2() { Matrix YX = new Matrix(3, 1); YX[0, 0] = -6; YX[1, 0] = -3; YX[2, 0] = 0; double h0 = 1; double m = 10; DifferentialSystem.Fx[] equationTest = { EquationTest2, EquationTest3 }; DifferentialSystem someEquation = new DifferentialSystem(equationTest); Matrix newYX = someEquation.SolutionRungeKutta4(YX, h0, m); Matrix rightAnswer = new Matrix(3, 1); rightAnswer[0, 0] = -16.2496299625; rightAnswer[1, 0] = -15.1459916390; rightAnswer[2, 0] = 1; Assert.AreEqual(rightAnswer[0, 0], newYX[0, 0], 0.001); Assert.AreEqual(rightAnswer[1, 0], newYX[1, 0], 0.001); Assert.AreEqual(rightAnswer[2, 0], newYX[2, 0], 0.001); }
public void RungeKutta4Test1() { Matrix YX = new Matrix(2, 1); YX[0, 0] = 1; YX[1, 0] = 0; double h0 = 2.5; double m = 10; DifferentialSystem.Fx[] equationTest = { EquationTest1 }; DifferentialSystem someEquation = new DifferentialSystem(equationTest); Matrix newYX = someEquation.SolutionRungeKutta4(YX, h0, m); Matrix rightAnswer = new Matrix(2, 1); rightAnswer[0, 0] = 1.81930573495; rightAnswer[1, 0] = 2.5; Assert.AreEqual(rightAnswer[0, 0], newYX[0, 0], 0.001); Assert.AreEqual(rightAnswer[1, 0], newYX[1, 0], 0.001); }