Example #1
0
        public static void TestAlgorithm(double dt, Func <double, Assignment2Result> algorithm)
        {
            Assignment2Result result1 = algorithm(dt);
            Assignment2Result result2 = algorithm(dt / 2);
            Assignment2Result result3 = new Assignment2Result {
                t = Estimate(result2.t, result1.t), v = Estimate(result2.v, result1.v)
            };

            Console.WriteLine("dt = {0}\t{1}", dt, result1);
            Console.WriteLine("dt = {0}\t{1}", dt / 2, result2);
            Console.WriteLine("Estimated\t{0}", result3);
        }
Example #2
0
        static void Main(string[] args)
        {
            double k = 10;
            double m = 1;
            double g = 10;
            double h = 1.75;

            Console.WriteLine("Euler Algorithm");
            TestAlgorithm(0.01, dt => EulerAlgorithm(dt, k, m, g, h));
            Console.WriteLine("\nFeynman Algorithm");
            TestAlgorithm(0.01, dt => FeynmanAlgorithm(dt, k, m, g, h));
            Console.WriteLine("\nAnalytic Solution");
            Assignment2Result analytic = Analytic(k, m, g, h);

            Console.WriteLine("\t\t{0}", analytic);
        }