示例#1
0
        public static void test_solve_newton_stabilized()
        {
            Console.WriteLine("\nTesting solve_newton_stabilized() ...\n");
            MyFunction mFunction = new MyFunction();
            MyFunction2 mFunction2 = new MyFunction2();

            Console.WriteLine("\n\tf(x) = (x - 2) * (x + 8)");

            Console.WriteLine("\n\tExpecting:\t solve_newton_stabilized(-0.5, 9) = 2.000000002707719");
            Console.WriteLine("\t   Result:\t solve_newton_stabilized(-0.5, 9) = " + mFunction.solve_newton_stabilized(-0.5, 9));

            Console.WriteLine("\n\tf(x) = (x - 2) * (x - 2) * (x - 2) + x");

            Console.WriteLine("\n\tExpecting:\t solve_newton_stabilized(-10, 9) = 0.9999999946201354");
            Console.WriteLine("\t   Result:\t solve_newton_stabilized(-10, 9) = " + mFunction2.solve_newton_stabilized(-10, 9));
        }
示例#2
0
        public static void test_solve_bisection()
        {
            Console.WriteLine("\nTesting solve_bisection() ...\n");
            MyFunction mFunction = new MyFunction();
            MyFunction2 mFunction2 = new MyFunction2();

            Console.WriteLine("\n\tf(x) = (x - 2) * (x + 8)");

            Console.WriteLine("\n\tExpecting:\t solve_bisection(-0.5, 9) = 2.0000267028808594");
            Console.WriteLine("\t   Result:\t solve_bisection(-0.5, 9) = " + mFunction.solve_bisection(-0.5, 9));

            Console.WriteLine("\n\tf(x) = (x - 2) * (x - 2) * (x - 2) + x");

            Console.WriteLine("\n\tExpecting:\t solve_bisection(-10, 9) = 0.9999942779541016");
            Console.WriteLine("\t   Result:\t solve_bisection(-10, 9) = " + mFunction2.solve_bisection(-10, 9));
        }