private void Calculate_Click(object sender, EventArgs e) { string Method = comboBox1.Text; string[] allMethod = { "newton" }; string AnyOfMethod = Array.Find(allMethod, s => s.Equals(Method)); if ((Method != AnyOfMethod)) { MessageBox.Show("This Is Not Method", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { bool XarrayZero = false; bool YarrayZero = false; xcolum = CreatXarray(ref ThereIsErrorX); ycolum = CreatYarray(ref ThereIsErrorY); XarrayZero = Share.IfallZero(xcolum); YarrayZero = Share.IfallZero(ycolum); if ((ThereIsErrorX != true) && (ThereIsErrorY != true) && (XarrayZero != true) && (YarrayZero != true)) { switch (Method) { case "newton": { textBox2.Visible = true; textBox3.Visible = true; Polynomial newton = new Polynomial(); newton = deriveationclass.Newton(ycolum, xcolum[1] - xcolum[0], NumOfNode, xcolum[0]); textBox2.Text = Polynomial.tostring(newton); newton = deriveationclass.Newtonsecond(ycolum, xcolum[1] - xcolum[0], NumOfNode, xcolum[0]); textBox3.Text = Polynomial.tostring(newton); } break; } } } }
private void Send_Click(object sender, EventArgs e) { bool XarrayZero = false; bool YarrayZero = false; string Method = comboBox1.Text; string[] allMethod = { "General Methode", "Spline", "Lagrange", "Newton", "Least Square Method" }; if (Method != ".......") { xcolum = CreatXarray(ref ThereIsErrorX); XarrayZero = Share.IfallZero(xcolum); if (XarrayZero != true) { ycolum = CreatYarray(ref ThereIsErrorY); } YarrayZero = Share.IfallZero(ycolum); string AnyOfMethod = Array.Find(allMethod, s => s.Equals(Method)); if ((XarrayZero != true) && (YarrayZero != true) && (ThereIsErrorX != true) && (ThereIsErrorY != true)) { if ((Method == AnyOfMethod)) { comboBox1.Enabled = false; } else { MessageBox.Show("This Is Not Method", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } XarrayZero = Share.IfallZero(xcolum); YarrayZero = Share.IfallZero(ycolum); switch (Method) { case "General Methode": { if ((XarrayZero != true) && (YarrayZero != true) && (ThereIsErrorX != true) && (ThereIsErrorY != true)) { #region General Methode double[,] matrx; matrx = new double[NumOfNode, NumOfNode]; matrx = InterpolationClass.CreatVandrmondmatrix(NumOfNode, xcolum); double determatrx = InterpolationClass.determine(matrx); double[,] another = new double[NumOfNode, NumOfNode]; Polynomial temp = new Polynomial(); double[] Constant; Constant = new double[NumOfNode]; for (int j = 0; j < NumOfNode; j++) { another = InterpolationClass.creatanothermatrix(j, xcolum, ycolum, NumOfNode); double deternother = InterpolationClass.determine(another); Constant[j] = deternother / determatrx; } for (int i = 0; i < Constant.Length; i++) { temp = Polynomial.insert(Constant[i], i, temp); } string result = Polynomial.tostring(temp); if (MessageBox.Show("If You Have An Internet Connection Click Yes To Show The Function On Net Or Click No To See It Here", "Internet Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string url = "http://texify.com/?" + result; Process.Start(url); } else { label3.Visible = true; richTextBox1.Visible = true; richTextBox1.Text = result; } Send.Enabled = false; Refresh.Visible = true; #endregion } } break; case "Least Square Method": { if ((XarrayZero != true) && (YarrayZero != true) && (ThereIsErrorX != true) && (ThereIsErrorY != true)) { #region Least Square Method int exp = NumOfNode - 1; double sum; double[] tableX = new double[2 * exp]; double[] tableY = new double[NumOfNode]; for (int j = 0; j < (2 * exp); j++) { sum = 0; for (int i = 0; i < NumOfNode; i++) { sum = sum + Math.Pow(xcolum[i], j + 1); tableX[j] = sum; } } for (int j = 0; j < NumOfNode; j++) { sum = 0; for (int i = 0; i < NumOfNode; i++) { if (j == 0) { sum = sum + ycolum[i]; } else { sum = sum + (Math.Pow(xcolum[i], j) * ycolum[i]); } tableY[j] = sum; } } double[,] squer = new double[NumOfNode, NumOfNode]; squer[0, 0] = NumOfNode; for (int i = 1; i < NumOfNode; i++) { squer[0, i] = tableX[i - 1]; } for (int i = 1; i < NumOfNode; i++) { for (int j = 0; j < NumOfNode; j++) { squer[i, j] = tableX[i + j - 1]; } } double[] A = new double[NumOfNode]; double d = InterpolationClass.determine((double[, ])squer.Clone()); for (int j = 0; j < NumOfNode; j++) { A[j] = InterpolationClass.ChangeXY((double[, ])squer.Clone(), tableY, j, NumOfNode) / d; } Send.Enabled = false; Refresh.Visible = true; #endregion } } break; case "Lagrange": { if ((XarrayZero != true) && (YarrayZero != true) && (ThereIsErrorX != true) && (ThereIsErrorY != true)) { #region Lagrange { string result = InterpolationClass.lagrang(xcolum, NumOfNode, ycolum); if (MessageBox.Show("If You Have An Internet Connection Click Yes To Show The Function On Net Or Click No To See It Here", "Internet Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string url = "http://texify.com/?" + result; Process.Start(url); } else { label3.Visible = true; richTextBox1.Visible = true; richTextBox1.Text = result; } } #endregion } } break; case "Spline": { if ((XarrayZero != true) && (YarrayZero != true) && (ThereIsErrorX != true) && (ThereIsErrorY != true)) { #region Splin { double point = 0; if ((textBox2.Text != null) && (Share.Isnumber(textBox2.Text))) { point = double.Parse(textBox2.Text); string result = Polynomial.tostring(InterpolationClass.Splin(xcolum, ycolum, NumOfNode, point)); if (MessageBox.Show("If You Have An Internet Connection Click Yes To Show The Function On Net Or Click No To See It Here", "Internet Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string url = "http://texify.com/?" + result; Process.Start(url); } else { label3.Visible = true; richTextBox1.Visible = true; richTextBox1.Text = result; } } else { MessageBox.Show("Error Entry", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } #endregion } } break; case "Newton": { if ((XarrayZero != true) && (YarrayZero != true) && (ThereIsErrorX != true) && (ThereIsErrorY != true)) { #region Newton double[,] Temp = InterpolationClass.newtonftab(xcolum, ycolum, NumOfNode); Polynomial Newton = InterpolationClass.newtonemethod(xcolum, ycolum, Temp, NumOfNode); string result = Polynomial.tostring(Newton); if (MessageBox.Show("If You Have An Internet Connection Click Yes To Show The Function On Net Or Click No To See It Here", "Internet Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string url = "http://texify.com/?" + result; Process.Start(url); } else { label3.Visible = true; richTextBox1.Visible = true; richTextBox1.Text = result; } #endregion } } break; default: { if (Method == ".......") { MessageBox.Show("No Method Is Selceted ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } break; } }
private void Send_Click(object sender, EventArgs e) { string Method = comboBox1.Text; string[] allMethod = { "Simpson", "Trapezoidal", "Oblong" }; string AnyOfMethod = Array.Find(allMethod, s => s.Equals(Method)); if ((Method != AnyOfMethod)) { MessageBox.Show("This Is Not Method", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { bool XarrayZero = false; bool YarrayZero = false; xcolum = CreatXarray(ref ThereIsErrorX); ycolum = CreatYarray(ref ThereIsErrorY); XarrayZero = Share.IfallZero(xcolum); YarrayZero = Share.IfallZero(ycolum); if ((ThereIsErrorX != true) && (ThereIsErrorY != true) && (XarrayZero != true) && (YarrayZero != true)) { switch (Method) { case "Simpson": { #region Simpson if (((NumOfNode / 2) != 0)) { Result.Visible = true; label3.Visible = true; double result = IntegrationClass.Simpson(ycolum, NumOfNode, xcolum[1] - xcolum[0]); Result.Text = String.Format("{0:0.00000}", result); } else { Result.Visible = true; label3.Visible = true; double result = IntegrationClass.Simpson(ycolum, NumOfNode - 1, xcolum[1] - xcolum[0]); double result1 = IntegrationClass.oblong(ycolum, NumOfNode - 1, NumOfNode, xcolum[1] - xcolum[0]); Result.Text = String.Format("{0:0.00000}", result + result1); } #endregion } break; case "Oblong": { #region Oblong Result.Visible = true; label3.Visible = true; double result = IntegrationClass.oblong(ycolum, 0, NumOfNode - 1, xcolum[1] - xcolum[0]); Result.Text = String.Format("{0:0.00000}", result); #endregion } break; case "Trapezoidal": { #region Trapezoidal Result.Visible = true; label3.Visible = true; double result = IntegrationClass.Trapezoidal(ycolum, NumOfNode - 1, xcolum[1] - xcolum[0]); Result.Text = String.Format("{0:0.00000}", result); #endregion } break; } } else { MessageBox.Show("Entry Error ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }