public DifferentialEquation( List <double> x, List <double> t, c_del func_c, c_del func_f, y_0_del y_x0, y_0_del y_0t ) { this.c = func_c; this.f = func_f; collection = new Dictionary <double, List <Point> >(t.Count); for (int i = 0; i < t.Count; i++) { List <Point> points = new List <Point>(); collection.Add(Math.Round(t.ElementAt(i), 2), points); for (int j = 0; j < x.Count; j++) { collection[Math.Round(t.ElementAt(i), 2)].Add(new Point(x.ToArray()[j], 0)); } } for (int i = 0; i < x.Count; i++) { SetY(i, 0, y_x0(collection[0].ElementAt(i).X)); } for (int i = 0; i < t.Count; i++) { SetY(0, i, y_0t(GetX(0, i))); } for (int i = 0; i < t.Count - 1; i++) { for (int j = 1; j < x.Count; j++) { if (Criteria(j, i)) { collection[Math.Round(t.ElementAt(i + 1), 2)].ElementAt(j).Y = t_step(i) * ( f(GetX(j, i), GetT(i)) - GetC(j, i + 1) * (GetY(j, i) - GetY(j - 1, i)) / x_step(j - 1) ) + GetY(j, i) ; } else { collection[Math.Round(t.ElementAt(i + 1), 2)].ElementAt(j).Y = ( f(GetX(j, i), GetT(i)) + ((GetY(j, i) - GetY(j - 1, i + 1)) / t_step(i)) //t_step(j)) * x_step(j - 1) / GetC(j, i + 1) ) + GetY(j - 1, i + 1); } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { lst_x = new List <double>(); //lst_t = new List<double>(); for (int i = 0; i < 10; i++) { lst_x.Add(i); } c_del c_func = new c_del((x, t) => 1); c_del f_func = new c_del((x, t) => - 2 * t + 2 * x); y_0_del yX0 = new y_0_del((x) => x * x); y_0_del y0T = new y_0_del((t) => - t * t); diffur = new DifferentialEquation(lst_x, lst_t, c_func, f_func, yX0, y0T); chart.ChartAreas.Add(new ChartArea(ChartAreaName)); // Добавим линию, и назначим ее в ранее созданную область "Default" chart.Series.Add(new Series(ChartSerieName)); chart.Series[ChartSerieName].ChartArea = ChartAreaName; chart.Series[ChartSerieName].ChartType = SeriesChartType.Point; chart.Series[ChartSerieName].Color = Color.Blue; chart.Series.Add(new Series("Original")); chart.Series["Original"].ChartArea = ChartAreaName; chart.Series["Original"].ChartType = SeriesChartType.Point; chart.Series["Original"].Color = Color.OrangeRed; // добавим данные линии chart.Series[ChartSerieName].Points.DataBindXY(lst_x, diffur.GetListY(0)); x_org = new List <double>(); for (int i = 0; i < 60; i++) { x_org.Add(i * 0.1); } chart.Series["Original"].Points.DataBindXY(x_org, diffur.GetOriginValues(x_org, 0)); }