randVar() shuffle([ new RationalExpression([[randRangeWeighted(1, 5, 1, 0.4), X], randRange(-10, 10)]), new Term(randRange(1, 10)), new Term(randRange(1, 10))]) _.map(TERMS, function(t) { return t.multiply(randFromArray([-1, 1])); }) randRangeWeighted(1, 5, 1, 0.4) randRangeWeighted(-5, 5, 0, 0.4) (function() { var degree = {}; degree[X] = DENOM_CONST === 0 ? randRangeWeighted(1, 3, 1, 0.5) : 1; return new RationalExpression([[DENOM_COEFF, degree], DENOM_CONST]); })() [randRangeWeighted(1, 5, 1, 0.5), randRangeWeighted(1, 5, 1, 0.5), randRangeWeighted(1, 5, 1, 0.5)] _.map(FACTORS, function(f) { return DENOMINATOR.multiply(f); }) (function(){ var GCD = FACTORS[0] * FACTORS[1] / getGCD(FACTORS[0], FACTORS[1]); return GCD * FACTORS[2] / getGCD(FACTORS[2], GCD); })() DENOMINATOR.multiply(COMMON_FACTOR) _.map(FACTORS, function(f) { return COMMON_FACTOR / f; }) _.map(NUMERATORS, function(n, i) { return n.multiply(MULTIPLES[i]); }) (function(){ var s1 = PRODUCTS[1].add(PRODUCTS[2]); return [s1, PRODUCTS[0].add(s1.multiply(-1))]; })() SUMS[1].getCoefficentOfTerm(X) -SUMS[1].getCoefficentOfTerm()

Solve for X,

writeExpressionFraction(NUMERATORS[0], DENOMINATORS[0]) = writeExpressionFraction(NUMERATORS[1], DENOMINATORS[1]) + writeExpressionFraction(NUMERATORS[2], DENOMINATORS[2])

X = \spaceCONSTANT / COEFFICIENT

First we need to find a common denominator for all the expressions. This means finding the least common multiple of DENOMINATORS[0], DENOMINATORS[1] and DENOMINATORS[2].

The common denominator is COMMON_DENOM.

The denominator of the ordinalThrough20(i+1) term is already COMMON_DENOM, so we don't need to change it.

To get COMMON_DENOM in the denominator of the ordinalThrough20(i+1) term, multiply it by \frac{MULTIPLES[i]}{MULTIPLES[i]}.

\qquad writeExpressionFraction(NUMERATORS[i], DENOMINATORS[i]) \times \dfrac{MULTIPLES[i]}{MULTIPLES[i]} = writeExpressionFraction(PRODUCTS[i], COMMON_DENOM)

This gives us:

\qquad writeExpressionFraction(PRODUCTS[0], COMMON_DENOM) = writeExpressionFraction(PRODUCTS[1], COMMON_DENOM) + writeExpressionFraction(PRODUCTS[2], COMMON_DENOM)

If we multiply both sides of the equation by COMMON_DENOM, we get:

\qquad PRODUCTS[0] = PRODUCTS[1] + PRODUCTS[2]
\qquad PRODUCTS[0] = SUMS[0]
\qquad new KhanUtil.Term(COEFFICIENT, X) = CONSTANT -CONSTANT = new KhanUtil.Term(-COEFFICIENT, X)
\qquad X = fraction(CONSTANT, COEFFICIENT, true, true)