コード例 #1
0
        private bool setRows()
        {
            int cont = 0;

            x0 = a;
            while (true)
            {
                // MessageBox.Show(x0.ToString());
                fx0 = FUNCTIONS.getImage(x0);
                // MessageBox.Show(fx0.ToString());
                fdx0 = RAPHSON.getFunctionDerivate(x0);
                // MessageBox.Show(fdx0.ToString());
                this.detx = fx0 / fdx0;
                //MessageBox.Show(detx.ToString());
                xn = x0 - detx;
                //  MessageBox.Show(xn.ToString());
                fxn = FUNCTIONS.getImage(xn);
                // MessageBox.Show(fxn.ToString());
                tabla.Rows.Add(x0, fx0, fdx0, detx, xn, fxn);

                if (Math.Abs(detx) <= tolerancy)
                {
                    return(true);
                }

                x0 = xn;

                cont++;
                if (cont > 100000)
                {
                    msgbox.error("Desbordamiento!");
                    return(true);
                }
            }
        }
コード例 #2
0
        private bool setRows()
        {
            bool   flag = false;
            double c    = 0;
            string ttol;

            fa = FUNCTIONS.getImage(a);
            fb = FUNCTIONS.getImage(b);


            if (!((fa < 0 && fb > 0) || (fb < 0 && fa > 0)))
            {
                MessageBox.Show("No existe cambio de signo!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                flag = false;
                return(flag);
            }


            while (true)
            {
                c = (b - a) / 2;


                xn  = a + c;
                fxn = FUNCTIONS.getImage(xn);

                if (Math.Abs(c) <= tolerancy)
                {
                    ttol = "CUMPLIDA";
                    flag = true;
                }
                else
                {
                    ttol = "NO CUMPLIDA";
                }

                try
                {
                    this.tabla.Rows.Add(a, b, c, xn, fxn, ttol);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                asignLimits(fxn);

                if (flag)
                {
                    break;
                }
            }

            return(flag);
        }
コード例 #3
0
        private bool setRow()
        {
            bool rule = false;

            if (a < b)
            {
                rule = false;
            }
            else if (a > b)
            {
                rule = true;
            }

            this.fa = FUNCTIONS.getImage(a);
            this.fb = FUNCTIONS.getImage(b);

            MessageBox.Show(fa.ToString());
            MessageBox.Show(fb.ToString());

            if (!((fa > 0 && fb < 0) || (fb > 0 && fa < 0)))
            {
                MessageBox.Show("No existe un cambio de signo!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            while (true)
            {
                this.fa    = FUNCTIONS.getImage(a);
                this.fb    = FUNCTIONS.getImage(b);
                this.deltx = (fa) * (b - a) / (Math.Abs(fa) + Math.Abs(fb));

                if (rule)
                {
                    convertNegative(ref deltx);
                }
                else
                {
                    convertPositive(ref deltx);
                }

                xn  = a + deltx;
                fxn = FUNCTIONS.getImage(xn);

                this.tabla.Rows.Add(a, b, fa, fb, deltx, xn, fxn);

                if (Math.Abs(deltx) <= tolerancy)
                {
                    return(true);
                }
                a = xn;
            }
        }