static MathObject RationalizeSum(MathObject u, MathObject v)
            {
                var m = u.Numerator();
                var r = u.Denominator();
                var n = v.Numerator();
                var s = v.Denominator();

                if (r == 1 && s == 1) return u + v;

                return RationalizeSum(m * s, n * r) / (r * s);
            }
예제 #2
0
            static MathObject RationalizeSum(MathObject u, MathObject v)
            {
                MathObject m = u.Numerator();
                MathObject r = u.Denominator();
                MathObject n = v.Numerator();
                MathObject s = v.Denominator();

                if (r == 1 && s == 1)
                {
                    return(u + v);
                }
                return(RationalizeSum(m * s, n * r) / (r * s));
            }
예제 #3
0
            public static MathObject RationalExpand(this MathObject u)
            {
                var f = u.Numerator().AlgebraicExpand();
                var g = u.Denominator().AlgebraicExpand();

                if (g == 0)
                {
                    return(false);
                }

                var h = (f / g).RationalizeExpression();

                if (h == u)
                {
                    return(u);
                }

                return(h.RationalExpand());
            }