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); }
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)); }
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()); }