diff --git a/web/app/sketcher/constr/AlgNumSystem.js b/web/app/sketcher/constr/AlgNumSystem.js index 74c7f518..30c53d0b 100644 --- a/web/app/sketcher/constr/AlgNumSystem.js +++ b/web/app/sketcher/constr/AlgNumSystem.js @@ -207,6 +207,7 @@ export class AlgNumSubSystem { } this.polynomials[i] = null; } else if (polynomial.isLinear && polynomial.monomials.length === 1) { + this.polynomials[i] = null; const monomial = polynomial.monomials[0]; const terms = monomial.terms; if (terms.length === 1) { @@ -218,9 +219,9 @@ export class AlgNumSubSystem { this.eliminatedParams.set(p, val); - for (let polynomial of this.polynomials) { - if (polynomial) { - polynomial.eliminate(p, val); + for (let otherPolynomial of this.polynomials) { + if (otherPolynomial) { + otherPolynomial.eliminate(p, val); } } @@ -228,7 +229,6 @@ export class AlgNumSubSystem { } } - this.polynomials[i] = null; } else if (polynomial.monomials.length === 2 && polynomial.isLinear) { let [m1, m2] = polynomial.monomials; @@ -244,22 +244,21 @@ export class AlgNumSubSystem { const constant = - m2.constant / m1.constant; if (eqEps(polynomial.constant, 0)) { - for (let polynomial of this.polynomials) { - if (polynomial) { - polynomial.substitute(p1, p2, constant); + this.polynomials[i] = null; + this.substitute(p1, new Polynomial().monomial(constant).term(p2, POW_1_FN)); + for (let otherPolynomial of this.polynomials) { + if (otherPolynomial) { + otherPolynomial.substitute(p1, p2, constant); } } - this.substitute(p1, new Polynomial().monomial(constant).term(p2, POW_1_FN)); - this.polynomials[i] = null; - requirePass = true; } else { const b = - polynomial.constant / m1.constant; let transaction = compositeFn(); - for (let polynomial of this.polynomials) { - if (polynomial) { - const polyTransaction = polynomial.linearSubstitution(p1, p2, constant, b); + for (let otherPolynomial of this.polynomials) { + if (otherPolynomial && otherPolynomial !== polynomial) { + const polyTransaction = otherPolynomial.linearSubstitution(p1, p2, constant, b); if (!polyTransaction) { transaction = null; break; diff --git a/web/app/sketcher/constr/polynomial.js b/web/app/sketcher/constr/polynomial.js index 835ba6b0..c17d2f12 100644 --- a/web/app/sketcher/constr/polynomial.js +++ b/web/app/sketcher/constr/polynomial.js @@ -363,7 +363,7 @@ export class ToThePowerFunction { if (this.degree === 1) { return new Polynomial(b).monomial(k).term(x, POW_1_FN); } else if (this.degree === 2) { - return new Polynomial(b*b).monomial(k*k).term(x, POW_2_FN).monomial(2*k).term(x, POW_1_FN); + return new Polynomial(b*b).monomial(k*k).term(x, POW_2_FN).monomial(2*k*b).term(x, POW_1_FN); } else { return null; }