Exemplo n.º 1
0
        private void DrawWithRungeKutt(BaseChart chart, Series series, double x, double y, double[] parameters)
        {
            for (int i = 0; i < _iterations; i += IterationsStep)
            {
                double k1 = _stepValue * chart.f(x, y, parameters);
                double l1 = _stepValue * chart.g(x, y, parameters);

                double k2 = _stepValue * chart.f(x + k1 / 2, y + l1 / 2, parameters);
                double l2 = _stepValue * chart.g(x + k1 / 2, y + l1 / 2, parameters);

                double k3 = _stepValue * chart.f(x + k2 / 2, y + l2 / 2, parameters);
                double l3 = _stepValue * chart.g(x + k2 / 2, y + l2 / 2, parameters);

                double k4 = _stepValue * chart.f(x + k3, y + l3, parameters);
                double l4 = _stepValue * chart.g(x + k3, y + l3, parameters);

                series.Points.AddXY(x, y);

                x += RungeKuttConst * Math.Round(k1 + 2 * k2 + 2 * k3 + k4, 5);
                y += RungeKuttConst * Math.Round(l1 + 2 * l2 + 2 * l3 + l4, 5);
            }
        }
Exemplo n.º 2
0
        private void DrawWithEulerMethod(BaseChart chart, Series series, double x, double y, double[] parameters)
        {
            for (int i = 0; i < _iterations; i += IterationsStep)
            {
                series.Points.AddXY(x, y);

                /*Если попытаться написать x += _stepValue * chart.f(x, y); y += _stepValue * chart.g(x, y);
                 * То теряются какие то знаки после запятой, почему?
                 * */
                double nextX = x + _stepValue * chart.f(x, y);
                double nextY = y + _stepValue * chart.g(x, y);

                x = nextX;
                y = nextY;
            }
        }