Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            int[]     list = { 1, 13, 22, 43, 21, 35, 2, 33, 65, 8, 19 };
            Bisection bise = new Bisection();

            bise.Bise(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Evento que ejecuta el método de bisección al presionar el botón
        /// </summary>
        /// <param name="sender">Objecto mensajero</param>
        /// <param name="e">Objeto de evento</param>
        private void btnConfirmeFunction_Click(object sender, EventArgs e)
        {
            //Creamos un objeto de tipo Bisection
            try {
                Bisection bisection = new Bisection()
                {
                    ES             = double.Parse(txtES.Text),   //Valor de Es
                    CustomFunction = txtFunction.Text,           //Le pasamos la función que vamos a evaluar
                    MaxIterations  = int.Parse(txtMaxIter.Text), //Pasamos el número máximo de iteraciones
                    XL             = double.Parse(txtXL.Text),   //Valor de XL (lower)
                    XU             = double.Parse(txtXU.Text),   //Valor de XU (upper)
                    DataGridValues = dtgValues                   //Para mostrar en la tabla, la pasamos como parámetro también
                };
                dtgValues.Rows.Clear();                          //Limpia los registros de la tabla
                bisectResult = bisection.Bisect();               //Ejecuta el método de Bisección
                                                                 //y colocalo en una variable
                txtXRRespuesta.Text = bisectResult.ToString();

                MessageBox.Show($"La aproximación a la raíz que cumple con el criterio de " +
                                $"{bisection.ES * 100} % es Xr = {txtXRRespuesta.Text}"
                                , "Resultado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Ha ocurrido un fatal error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            Double[] equation = { 25, 5, 1, 106.8 };
            Console.Write("Enter the value for a: ");
            Double a = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter the value for b: ");
            Double    b         = Convert.ToDouble(Console.ReadLine());
            Bisection bisection = new Bisection(equation, a, b);

            bisection.Bisect();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        public static void Main()
        {
            Console.WriteLine(@"Given a function 1x^2 + -2 find the root with in 5-decimal place"
                              + " Let [a, b] = [1, 2]");
            Double[] equation = { 1, 0, -2 };
            //Double[] equation = { 1, 0, -1, -2 };
            Console.Write("Enter the value for a: ");
            Double a = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter the value for b: ");
            Double    b         = Convert.ToDouble(Console.ReadLine());
            Bisection bisection = new Bisection(equation, a, b);

            bisection.Bisect();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Input a");
            double a = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Input b");
            double b = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Input epsilon");
            double epsilon = Convert.ToDouble(Console.ReadLine());

            if (a > b)
            {
                Bisection.Swap(ref a, ref b);
            }
            Bisection.bisection(a, b, epsilon);
        }