private void calcDavButton_Click(object sender, EventArgs e) { //string f = "(Euler^x[1])-x[1]^3+1"; //var res = Newton.Calcular(-1, f, 0.01); //Console.WriteLine(res); //string f1 = "(x[1]-2)^4 + (x[1]-2x[2])^2"; //string f2 = "x[1]^2-2x[1]x[2]+4x[2]^2"; //var res1 = Gradiente.Calcular(2, f2, 0.1, "1 1"); //foreach (var item in res1) //{ // Console.WriteLine(item); //} double[,] A = new double[2, 2] { { 3, 2 }, { 1, 2 } }; double[] B = new double[2] { 10, 5 }; //foreach (var item in NewtonMulti.SS(2, A, B)) //{ // Console.WriteLine(item); //} //double[] x0 = new double[2] { 0, 2 }; //string f3 = "2x[1]^2+2x[1]x[2]+x[2]^2+x[1]+x[2]"; //var x = NewtonMulti.Calcular(2, f3, 0.1, "2 2"); //double[,] M = new double[2, 2] //{ // { 2, 1 }, // { 1, 4 } //}; //double[,] N = new double[2, 2] //{ // { 2, 2 }, // { 3, 4 } //}; //var r = GradConjugado.MultMatriz(M, N); //for (int i = 0; i < r.GetLength(0); i++) //{ // for (int j = 0; j < r.GetLength(1); j++) // { // Console.WriteLine(r[i, j]); // } //} //string f4 = "x[1]^2+3x[1]^3+2x[1]"; //var asd = DerivadasMultivariaveis.Derivada2(1, f4, new double[1] { 0.5 }, 0); //double[,] Q = new double[2, 2] //{ // { 5, 1 }, // { 1, 2 } //}; //double[] b = new double[2] { 24, 12 }; //var t = GradConjugado.Calcular(2, 0.2, "0 0", Q, "24 12"); string f = "(x[1]-2)^4+(x[1]-2*x[2])^2"; double[] xk = { 0, 3 }; double erro = 0.01; Console.WriteLine(f); int n = 2; var t = HookeJeeves.Calcular(f, xk, erro, n); //double[] xk = { 0, 3 }; //double erro = 0.01; //Console.WriteLine(f); //int n = 2; //var t = CoordCiclicas.Calcular(f, xk, erro, n); //Console.WriteLine(t[0]); //Console.WriteLine(t[1]); //string f = "x[1]^3-x[1]^2+2x[2]^2-2x[2]"; //var t = FletcherReeves.Calcular(2, f, 0.01, "1 1"); //var t = DavidonFletcherPowell.Calcular(2, f, 0.1, "0 0"); }
private void Button_Click(object sender, EventArgs e) { try { switch (tipo_selec) { case Métodos.Coordenadas_Cíclicas: var xotimo = CoordCiclicas.Calcular(funcCiclicasTextBox.Text, (x1CiclicasTextBox.Text).SplitToDoubles(), double.Parse(eCiclicasNumericUpDown.Value.ToString()), int.Parse(nCiclicasNumericUpDown.Value.ToString())); xotimoCiclicasTextBox.Text = xotimo.ParaString(); break; case Métodos.Hooke_and_Jeeves: string f = fHookeTextBox.Text; string x1 = x1HookeTextBox.Text; double err = double.Parse(eHookeNumericUpDown.Value.ToString()); int n = int.Parse(nHookeNumericUpDown.Value.ToString()); var aux = x1.SplitToDoubles(); xotimo = HookeJeeves.Calcular(f, aux, err, n); xotimoHookeTextBox.Text = xotimo.ParaString(); break; case Métodos.Gradiente: f = fGradTextBox.Text; x1 = x1GradTextBox.Text; err = double.Parse(eGradNumericUpDown.Value.ToString()); n = int.Parse(nGradNumericUpDown.Value.ToString()); xotimo = Gradiente.Calcular(n, f, err, x1); xotimoGradTextBox.Text = xotimo.ParaString(); break; case Métodos.Newton: f = fNewtonTextBox.Text; x1 = x1NewtonTextBox.Text; err = double.Parse(eNewtonNumericUpDown.Value.ToString()); n = int.Parse(nNewtonNumericUpDown.Value.ToString()); xotimo = NewtonMulti.Calcular(n, f, err, x1); xotimoNewtonTextBox.Text = xotimo.ParaString(); break; case Métodos.Gradiente_Conj_Gen: f = fGradConjTextBox.Text; x1 = x1GradConjTextBox.Text; err = double.Parse(eGradConjNumericUpDown.Value.ToString()); n = int.Parse(nGradConjNumericUpDown.Value.ToString()); xotimo = GradConjugado.Calcular(n, err, f, x1); xotimoGradConjTextBox.Text = xotimo.ParaString(); break; case Métodos.Fletcher_and_Reeves: f = fNewtonTextBox.Text; x1 = x1FletchTextBox.Text; err = double.Parse(eFletchNumericUpDown.Value.ToString()); n = int.Parse(nFletchNumericUpDown.Value.ToString()); xotimo = FletcherReeves.Calcular(n, f, err, x1); xotimoFletchTextBox.Text = xotimo.ParaString(); break; case Métodos.Davidon_Fletcher_Powell: f = fDavTextBox.Text; x1 = x1DavTextBox.Text; err = double.Parse(eDavNumericUpDown.Value.ToString()); n = int.Parse(nDavNumericUpDown.Value.ToString()); xotimo = DavidonFletcherPowell.Calcular(n, f, err, x1); xotimoDavTextBox.Text = xotimo.ParaString(); break; default: break; } } catch (Exception excep) { MessageBox.Show(excep.Message); } }