Example #1
0
        /// <summary>
        /// Точка входа в программу
        /// </summary>
        static void Main(string[] args)
        {
            Matrix X = new Matrix(2, 1);

            X[0, 0] = 3;
            X[1, 0] = 1;

            NonLinearSystem.Fx systemTest = SystemTest1;

            NonLinearSystem someSystem = new NonLinearSystem(systemTest);

            X = someSystem.SolutionNewton(X, 0.00000001);
        }
        public void NewtonTest2()
        {
            Matrix X = new Matrix(2, 1);

            X[0, 0] = 1;
            X[1, 0] = 8;

            NonLinearSystem.Fx systemTest = SystemTest2;

            NonLinearSystem someSystem = new NonLinearSystem(systemTest);

            X = someSystem.SolutionNewton(X, 0.1);

            Matrix rightAnswer = new Matrix(2, 1);

            rightAnswer[0, 0] = -1;
            rightAnswer[1, 0] = 9;

            Assert.AreEqual(rightAnswer[0, 0], X[0, 0], 0.1);
            Assert.AreEqual(rightAnswer[1, 0], X[1, 0], 0.1);
        }
        public void NewtonTest1()
        {
            Matrix X = new Matrix(2, 1);

            X[0, 0] = 3;
            X[1, 0] = 1;

            NonLinearSystem.Fx systemTest = SystemTest1;

            NonLinearSystem someSystem = new NonLinearSystem(systemTest);

            X = someSystem.SolutionNewton(X, 0.00000001);

            Matrix rightAnswer = new Matrix(2, 1);

            rightAnswer[0, 0] = 0.1964115066987255;
            rightAnswer[1, 0] = 0.7061541850402057;

            Assert.AreEqual(rightAnswer[0, 0], X[0, 0], 0.00000001);
            Assert.AreEqual(rightAnswer[1, 0], X[1, 0], 0.00000001);
        }