Exemplo n.º 1
0
        private void euler_iter(int i, ref Table table, double factor)
        {
            double x_prev, x_next, y_prev, y_next, hi_prev, hi_next;

            double h = H / factor;

            x_prev = table.X(i - 1);
            y_prev = table.Y(i - 1);
            hi_prev = table.Hi(0, i - 1);
            x_next = x_prev + h;
            y_next = y_prev + hi_prev;
            hi_next = h * F(x_next, y_next);
            table.Add(x_next, y_next, hi_next);
        }
Exemplo n.º 2
0
        private void runge_kutti(int i, ref Table table)
        {
            double x_prev = table.X(i - 1);
            double y_prev = table.Y(i - 1);

            double k1 = h * F(x_prev, y_prev);
            double k2 = h * F(x_prev + h / 2.0, y_prev + k1 / 2.0);
            double k3 = h * F(x_prev + h / 2.0, y_prev + k2 / 2.0);
            double k4 = h * F(x_prev + h, y_prev + k3);

            double x_next = x_prev + h;
            double y_next = y_prev + (k1 + 2 * k2 + 2 * k3 + k4) / 6.0;
            double hi_next = h * F(x_next, y_next);
            table.Add(x_next, y_next, hi_next);
        }
Exemplo n.º 3
0
        private void adams_iter(int i, ref Table table)
        {
            double x_prev = table.X(i - 1);
            double y_prev = table.Y(i - 1);

            double hi_prev = table.Hi(0, i - 1);
            double delta_1_hi = table.Hi(1, i - 2);
            double delta_2_hi = table.Hi(2, i - 3);
            double delta_3_hi = table.Hi(3, i - 4);
            double delta_4_hi = table.Hi(4, i - 5);

            double x_next = x_prev + h;
            double y_next = y_prev + hi_prev + delta_1_hi / 2.0 + 5.0 * delta_2_hi / 12.0 +
                            3.0 * delta_3_hi / 8.0 + 251.0 * delta_4_hi / 720.0;
            double hi_next = h * F(x_next, y_next);
            table.Add(x_next, y_next, hi_next);
        }