Example #1
0
        static void AdamsTable(double a, double b, double h, double y0, double eps, double divider)
        {
            Console.WriteLine($"\n\t Multistep Adams method, ε = {eps}\n");
            Console.WriteLine(" |  Average error, Δ    |      Step value      |");
            var    points = CauchyProblem.AdamsMethod(a, b, h, y0);
            double error  = AvgError(points);

            Console.WriteLine($" | {error,-20} | {h,-20} |");
            while (error > eps)
            {
                points = CauchyProblem.AdamsMethod(a, b, h /= divider, y0);
                error  = AvgError(points);
                Console.WriteLine($" | {error,-20} | {h,-20} |");
            }
            Console.WriteLine(" |______________________|______________________|");
        }
Example #2
0
        static void WriteCSV(double a, double b, double y0, double h)
        {
            var points = CauchyProblem.RungeKuttaMethod(a, b, h, y0);

            using (var sw = new StreamWriter("RungeKuttaPoints.csv"))
            {
                foreach (Point p in points)
                {
                    sw.WriteLine($"{p.X};{p.Y}");
                }
            }
            points = CauchyProblem.AdamsMethod(a, b, h, y0);
            using (var sw = new StreamWriter("AdamsPoints.csv"))
            {
                foreach (Point p in points)
                {
                    sw.WriteLine($"{p.X};{p.Y}");
                }
            }
        }