//Model private void plot_Computation() { try { exact = new Exact(N, x_0, y_0, x_max); eu = new Euler(N, x_0, y_0, x_max); ie = new Euler_Impr(N, x_0, y_0, x_max); rk = new Runge_Kutta(N, x_0, y_0, x_max); eu.LTE(exact); ie.LTE(exact); rk.LTE(exact); plot_Draw(null, null); } catch (DiscontinuityException ex) { MessageBox.Show("There is a point of discontinuity in the x interval (x = " + ex.Message + ")", "Discontinuity", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception exp) { MessageBox.Show("Something does wrong...\n" + exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal void LTE(Exact e) { er = new double[y.Length]; for (int i = 0; i < y.Length; i++) { er[i] = Math.Abs(e.y[i] - y[i]); } }
private void change_err_Click(object sender, EventArgs e) { if (N_mode == false) { try { int N_start = Int32.Parse(enter_N_start.Text); int N_end = Int32.Parse(enter_N_end.Text); if (N_start <= 0) throw new WrongDataException("Start N must be greater than 0"); if (N_end <= N_start) throw new WrongDataException("Upper bound N have to be greater than start N"); double[] max_er_eu = new double[N_end - N_start + 1]; double[] max_er_ie = new double[N_end - N_start + 1]; double[] max_er_rk = new double[N_end - N_start + 1]; double[] N_ = new double[N_end - N_start + 1]; int index = 0; for (int i = N_start; i <= N_end; i++) { Exact exact_N = new Exact(i, x_0, y_0, x_max); Euler eu_N = new Euler(i, x_0, y_0, x_max); eu_N.LTE(exact_N); max_er_eu[index] = eu_N.max_LTE(); Euler_Impr ie_N = new Euler_Impr(i, x_0, y_0, x_max); ie_N.LTE(exact_N); max_er_ie[index] = ie_N.max_LTE(); Runge_Kutta rk_N = new Runge_Kutta(i, x_0, y_0, x_max); rk_N.LTE(exact_N); max_er_rk[index] = rk_N.max_LTE(); N_[index] = i; index++; } Errors.ChartAreas[0].AxisX.Minimum = N_start; Errors.ChartAreas[0].AxisX.Maximum = N_end; Errors.Series[0].Points.DataBindXY(N_, max_er_eu); Errors.Series[1].Points.DataBindXY(N_, max_er_ie); Errors.Series[2].Points.DataBindXY(N_, max_er_rk); N_mode = true; change_err.Text = "Back to LTE to x dependence"; } catch (DiscontinuityException ex) { MessageBox.Show("There is a point of discontinuity in the x interval (x = " + ex.Message + ")", "Discontinuity", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (WrongDataException exp) { MessageBox.Show(exp.Message, "Wrong data", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch(FormatException) { MessageBox.Show("Only integer numbers are allowed to enter", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception exp) { MessageBox.Show("Something does wrong...\n" + exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { Errors.ChartAreas[0].AxisX.Minimum = x_0; Errors.ChartAreas[0].AxisX.Maximum = x_max; Errors.Series[0].Points.DataBindXY(eu.x, eu.er); Errors.Series[1].Points.DataBindXY(ie.x, ie.er); Errors.Series[2].Points.DataBindXY(rk.x, rk.er); change_err.Text = "Explore max_LTE to N dependence"; N_mode = false; } }