private void AddData() { double[] x0 = new double[8]; double[] y0 = new double[8]; double[] x = new double[70]; for (int i = 0; i < x0.Length; i++) { x0[i] = 1.0 * i; y0[i] = Math.Sin(x0[i]); } for (int i = 0; i < x.Length; i++) { x[i] = i / 10.0; } double[] y = InterpolationAlgorithms.Lagrangian(x0, y0, x); myChart.DataCollection.DataList.Clear(); // plot interpolated data: LineCharts.DataSeries ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.Transparent; ds.SeriesName = "Interpolated"; ds.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.Dot; ds.Symbols.SymbolSize = 3; ds.Symbols.BorderColor = Brushes.Red; for (int i = 0; i < x.Length; i++) { ds.LineSeries.Points.Add(new Point(x[i], y[i])); } myChart.DataCollection.DataList.Add(ds); // Plot original data ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.Transparent; ds.SeriesName = "Original"; ds.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.Diamond; ds.Symbols.BorderColor = Brushes.DarkBlue; for (int i = 0; i < x0.Length; i++) { ds.LineSeries.Points.Add(new Point(x0[i], y0[i])); } myChart.DataCollection.DataList.Add(ds); myChart.IsLegend = true; myChart.LegendPosition = LineCharts.Legend.LegendPositionEnum.NorthEast; }
private void AddData() { double[] x0 = new double[] { 1, 2, 3 }; double[] y0 = new double[] { 1, 5, 4 }; double[] x = new double[199]; for (int i = 0; i < x.Length; i++) { x[i] = 1.01 + i / 100.0; } double[] y = InterpolationAlgorithms.Spline(x0, y0, x); myChart.DataCollection.DataList.Clear(); LineCharts.DataSeries ds; // Plot original data ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.Transparent; ds.SeriesName = "Original"; ds.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.Dot; ds.Symbols.BorderColor = Brushes.DarkBlue; for (int i = 0; i < x0.Length; i++) { ds.LineSeries.Points.Add(new Point(x0[i], y0[i])); } myChart.DataCollection.DataList.Add(ds); // plot interpolated data: ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.DarkGreen; ds.SeriesName = "Interpolated"; for (int i = 0; i < x.Length; i++) { ds.LineSeries.Points.Add(new Point(x[i], y[i])); } myChart.DataCollection.DataList.Add(ds); myChart.IsLegend = true; myChart.LegendPosition = LineCharts.Legend.LegendPositionEnum.NorthWest; }
private void AddData() { double[] x0 = new double[] { 1950, 1960, 1970, 1980, 1990 }; double[] y0 = new double[] { 150.697, 179.323, 203.212, 226.505, 249.633 }; double[] x = new double[] { 1952, 1955, 1958, 1962, 1965, 1968, 1972, 1975, 1978, 1982, 1985, 1988 }; double[] y = InterpolationAlgorithms.NewtonDividedDifference(x0, y0, x); myChart.DataCollection.DataList.Clear(); LineCharts.DataSeries ds; // plot interpolated data: ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.Transparent; ds.SeriesName = "Interpolated"; ds.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.Circle; ds.Symbols.BorderColor = Brushes.Red; for (int i = 0; i < x.Length; i++) { ds.LineSeries.Points.Add(new Point(x[i], y[i])); } myChart.DataCollection.DataList.Add(ds); // Plot original data ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.DarkGreen; ds.SeriesName = "Original"; ds.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.Dot; ds.Symbols.BorderColor = Brushes.DarkBlue; for (int i = 0; i < x0.Length; i++) { ds.LineSeries.Points.Add(new Point(x0[i], y0[i])); } myChart.DataCollection.DataList.Add(ds); myChart.IsLegend = true; myChart.LegendPosition = LineCharts.Legend.LegendPositionEnum.NorthWest; }
private void AddData() { double[] x0 = new double[15]; double[] y0 = new double[15]; double[] xe = new double[101]; double[] ye = new double[101]; double[] x = new double[31]; for (int i = 0; i < x0.Length; i++) { x0[i] = Math.Round(-1.2 + i / 5.0, 3); y0[i] = Math.Round(Math.Sin(8 * x0[i]) + 0.5 * x0[i] - x0[i] * x0[i], 2); } for (int i = 0; i < xe.Length; i++) { xe[i] = Math.Round(-1.0 + i / 50.0, 3); ye[i] = Math.Round(Math.Sin(8 * xe[i]) + 0.5 * xe[i] - xe[i] * xe[i], 2); } for (int i = 0; i < x.Length; i++) { x[i] = Math.Round(-1.0 + i / 15.0, 3); } double[] y = InterpolationAlgorithms.Lagrangian(x0, y0, x); myChart.DataCollection.DataList.Clear(); LineCharts.DataSeries ds; // Plot exact data: ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.DarkGreen; ds.SeriesName = "Exact"; for (int i = 1; i < xe.Length - 1; i++) { ds.LineSeries.Points.Add(new Point(xe[i], ye[i])); } myChart.DataCollection.DataList.Add(ds); // plot interpolated data: ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.Transparent; ds.SeriesName = "Interpolated"; ds.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.Circle; ds.Symbols.BorderColor = Brushes.Red; for (int i = 1; i < x.Length - 1; i++) { ds.LineSeries.Points.Add(new Point(x[i], y[i])); } myChart.DataCollection.DataList.Add(ds); // Plot original data ds = new LineCharts.DataSeries(); ds.LineColor = Brushes.Transparent; ds.SeriesName = "Original"; ds.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.Dot; ds.Symbols.BorderColor = Brushes.DarkBlue; for (int i = 0; i < x0.Length; i++) { ds.LineSeries.Points.Add(new Point(x0[i], y0[i])); } myChart.DataCollection.DataList.Add(ds); myChart.IsLegend = true; myChart.LegendPosition = LineCharts.Legend.LegendPositionEnum.NorthWest; }