예제 #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));
        }
예제 #3
0
        public static void test_solve_newton()
        {
            Console.WriteLine("\nTesting solve_newton() ...\n");
            MyFunction mFunction = new MyFunction();

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

            Console.WriteLine("\n\tExpecting:\t solve_newton(0.5) ~ 2");
            Console.WriteLine("\t   Result:\t solve_newton(0.5) = " + mFunction.solve_newton(0.5));
        }
예제 #4
0
        public static void test_function_class()
        {
            Console.WriteLine("\nTesting Function Class ...\n");
            MyFunction mFunction = new MyFunction();

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

            Console.WriteLine("\n\tExpecting:\t f(2) = 0");
            Console.WriteLine("\t   Result:\t f(2) = " + mFunction.f(2));
            Console.WriteLine("\n\tExpecting:\t f(5) = 39");
            Console.WriteLine("\t   Result:\t f(5) = " + mFunction.f(5));
            Console.WriteLine("\n\tExpecting:\t Df(2) ~ 10");
            Console.WriteLine("\t   Result:\t Df(2) = " + mFunction.Df(2));
            Console.WriteLine("\n\tExpecting:\t Df(5) ~ 16");
            Console.WriteLine("\t   Result:\t Df(5) = " + mFunction.Df(5));
            Console.WriteLine("\n\tExpecting:\t DDf(2) ~ 2");
            Console.WriteLine("\t   Result:\t Df(2) = " + mFunction.DDf(2));
            Console.WriteLine("\n\tExpecting:\t DDf(5) ~ 2");
            Console.WriteLine("\t   Result:\t Df(5) = " + mFunction.DDf(5));
        }