diff --git a/omnn/math/Sum.cpp b/omnn/math/Sum.cpp index cef25972b..9eaf5fa0e 100644 --- a/omnn/math/Sum.cpp +++ b/omnn/math/Sum.cpp @@ -1361,10 +1361,23 @@ namespace } if (grade > 2) { + auto lcm = constants::one; OptimizeOn oo; for (auto& c : coefficients) { c.optimize(); + if (c.IsFraction()) { + auto& f = c.as(); + auto& dn = f.getDenominator(); + if (dn != constants::one) { + lcm.lcm(dn); + } + } } + if (lcm != constants::one) { + for (auto& c : coefficients) { + c *= lcm; + } + } } return grade; @@ -1874,6 +1887,10 @@ namespace } } + if (lcm != constants::one) { + LOG_AND_IMPLEMENT("Coefficients meant to be balanced before solving"); + } + if(GetView() != View::Solving && GetView() != View::Equation) { // auto }