Esempio n. 1
0
        /* CALCULATION -- MULTIPLICATION */
        private static IntervalStruct IntervalMultiplication(IntervalStruct x, IntervalStruct y)
        {
            // Comparing a1 * a2 and a1 * b2
            double min = System.Math.Min(x.GetMinBound() * y.GetMinBound(), x.GetMinBound() * y.GetMaxBound());
            double max = System.Math.Max(x.GetMinBound() * y.GetMinBound(), x.GetMinBound() * y.GetMaxBound());

            // Comparing the previous results to b1 * a2
            min = System.Math.Min(min, x.GetMaxBound() * y.GetMinBound());
            max = System.Math.Max(max, x.GetMaxBound() * y.GetMinBound());

            // Comparing the previous results to b1 * b2
            min = System.Math.Min(min, x.GetMaxBound() * y.GetMaxBound());
            max = System.Math.Max(max, x.GetMaxBound() * y.GetMaxBound());

            return(new IntervalStruct("", min, max, true, true));
        }
Esempio n. 2
0
        private static IntervalStruct IntervalDivisionPositiveDivisor(IntervalStruct x, IntervalStruct y)
        {
            double min = 0;
            double max = 0;

            // 0 < a1 <= b1
            if (x.GetMinBound() > 0)
            {
                min = x.GetMinBound() / y.GetMaxBound();
                max = x.GetMaxBound() / y.GetMinBound();
            }
            // a1 = 0, a1 <= b1
            else if (x.GetMinBound() == 0)
            {
                min = 0;
                max = x.GetMaxBound() / y.GetMinBound();
            }
            // a1 < 0 < b1
            else if (x.GetMaxBound() > 0)
            {
                min = x.GetMinBound() / y.GetMinBound();
                max = x.GetMaxBound() / y.GetMinBound();
            }
            // b1 = 0, a1 <= b1
            else if (x.GetMaxBound() == 0)
            {
                min = x.GetMinBound() / y.GetMinBound();
                max = 0;
            }
            // a1 <= b1 < 0
            else if (x.GetMaxBound() < 0)
            {
                min = x.GetMinBound() / y.GetMinBound();
                max = x.GetMaxBound() / y.GetMaxBound();
            }

            return(new IntervalStruct("", min, max, true, true));
        }
Esempio n. 3
0
        private static IntervalStruct IntervalAsBase(IntervalStruct x, double n)
        {
            IntervalStruct exp      = null;
            double         roundedN = System.Math.Round(n);

            if (n >= 0)
            {
                if (n != roundedN)
                {
                    frm_Main.UpdateLog("Warning: The value provided for the exponent" + System.Convert.ToString(n) + "is not a natural number. It has been rounded to " + System.Convert.ToString(roundedN) + System.Environment.NewLine);
                }

                if (roundedN % 2 != 0)
                {
                    exp = new IntervalStruct("", System.Math.Pow(x.GetMinBound(), roundedN), System.Math.Pow(x.GetMaxBound(), roundedN), true, true);
                }
                else if (x.GetMinBound() >= 0)
                {
                    exp = new IntervalStruct("", System.Math.Pow(x.GetMinBound(), roundedN), System.Math.Pow(x.GetMaxBound(), roundedN), true, true);
                }
                else if (x.GetMaxBound() < 0)
                {
                    exp = new IntervalStruct("", System.Math.Pow(x.GetMaxBound(), roundedN), System.Math.Pow(x.GetMinBound(), roundedN), true, true);
                }
                else
                {
                    exp = new IntervalStruct("", 0, System.Math.Max(System.Math.Pow(x.GetMinBound(), roundedN), System.Math.Pow(x.GetMaxBound(), roundedN)), true, true);
                }
            }
            else
            {
                frm_Main.UpdateLog("Error: An unsupported operation was encountered while solving for the range of the equation (Exponent < 0)." + System.Environment.NewLine);
            }


            return(exp);
        }
Esempio n. 4
0
        /* CALCULATION -- EXPONENTS */
        private static IntervalStruct IntervalExponents(IntervalStruct x, IntervalStruct y)
        {
            IntervalStruct exp = null;

            if (x.GetMinBound() == x.GetMaxBound())
            {
                exp = IntervalAsExponent(x.GetMinBound(), y);
            }
            else if (y.GetMinBound() == y.GetMaxBound())
            {
                exp = IntervalAsBase(x, y.GetMinBound());
            }
            else
            {
                frm_Main.UpdateLog("Error: An unsupported operation was encountered while solving for the range of the equation (Exponents)." + System.Environment.NewLine);
            }

            return(exp);
        }
Esempio n. 5
0
        /* CALCULATION -- DIVISION */
        private static IntervalStruct IntervalDivision(IntervalStruct x, IntervalStruct y)
        {
            IntervalStruct divInterval = null;

            // 0 < a2 <= b2
            if (y.GetMinBound() > 0)
            {
                divInterval = IntervalDivisionPositiveDivisor(x, y);
            }
            // a2 <= b2 < 0
            else if (y.GetMaxBound() < 0)
            {
                divInterval = IntervalDivisionNegativeDivisor(x, y);
            }
            // a2 = 0 v b2 = 0
            else
            {
                frm_Main.UpdateLog("Error: An unsupported operation was encountered while solving for the range of the equation (Mixed interval division)." + System.Environment.NewLine);
            }

            return(divInterval);
        }
Esempio n. 6
0
        private static IntervalStruct IntervalAsExponent(double b, IntervalStruct x)
        {
            IntervalStruct exp = null;

            if (b > 1)
            {
                exp = new IntervalStruct("", System.Math.Pow(b, x.GetMinBound()), System.Math.Pow(b, x.GetMaxBound()), true, true);
            }
            else
            {
                frm_Main.UpdateLog("Error: An unsupported operation was encountered while solving for the range of the equation (Exponent base <= 1)." + System.Environment.NewLine);
            }

            return(exp);
        }
Esempio n. 7
0
 /* CALCULATION -- SUBTRACTION */
 private static IntervalStruct IntervalSubtraction(IntervalStruct x, IntervalStruct y)
 {
     return(new IntervalStruct("", x.GetMinBound() - y.GetMinBound(), x.GetMaxBound() - y.GetMaxBound(), true, true));
 }