randFromArray("abkmnpvx") randRangeNonZero(-1, 1) * randRange(1, randRange(1, 12)) randRangeNonZero(-1, 1) * randRange(1, randRange(1, 12)) randRangeNonZero(-1, 1) * randRange(1, randRange(1, 20)) randRangeNonZero(-1, 1) * randRange(1, randRange(1, 12)) randRangeNonZero(-1, 1) * randRange(1, randRange(1, 10)) randRangeNonZero(-1, 1) * randRange(1, randRange(1, 10)) "(?:" + (A < 0 ? "[-\\u2212]" : "") + abs(A) + (A === 1 ? "|" : "" ) + (A === -1 ? "|[-\\u2212]" : "") + ")\\s*" + X "(?:" + ((F * B) < 0 ? "[-\\u2212]" : "") + abs(F * B) + (F * B === 1 ? "|" : "" ) + (F * B === -1 ? "|[-\\u2212]" : "") + ")\\s*" + X "(?:" + ((A + B) < 0 ? "[-\\u2212]" : "") + abs(A + B) + (A + B === 1 ? "|" : "" ) + (A + B === -1 ? "|[-\\u2212]" : "") + ")\\s*" + X "(?:" + ((A + F * B) < 0 ? "[-\\u2212]" : "") + abs(A + F * B) + (A + F * B === 1 ? "|" : "" ) + (A + F * B === -1 ? "|[-\\u2212]" : "") + ")\\s*" + X "(?:" + ((E * A + F * B) < 0 ? "[-\\u2212]" : "") + abs(E * A + F * B) + (E * A + F * B === 1 ? "|" : "" ) + (E * A + F * B === -1 ? "|[-\\u2212]" : "") + ")\\s*" + X C === 0 ? "" : ((C < 0 ? "[-\\u2212]\\s*" : "") + abs(C)) (C + D) === 0 ? "" : ((C + D) < 0 ? "[-\\u2212]\\s*" : "") + abs(C + D) (F * D) === 0 ? "" : ((F * D) < 0 ? "[-\\u2212]\\s*" : "") + abs(F * D) (C + F * D) === 0 ? "" : ((C + F * D) < 0 ? "[-\\u2212]\\s*" : "") + abs(C + F * D) (E * C + F * D) === 0 ? "" : ((E * C + F * D) < 0 ? "[-\\u2212]\\s*" : "") + abs(E * C + F * D)

Simplify the following expression:

^\s*SOL\s*$
an expression, like -2x + 4
[ TERM_AX_FBX + ((F * D) > 0 ? "\\s*\\+\\s*" : "\\s*") + TERM_FD, TERM_FD + ((A + F * B) > 0 ? "\\s*\\+\\s*" : "\\s*") + TERM_AX_FBX ]

\large{expr(["+", ["*", A, X], ["*", F, ["+", ["*", B, X], D]]])}

The minus sign in front of the parentheses means we multiply each term inside the parentheses by \purple{F}:

Distribute the \purple{F} into the parentheses:

\qquad expr(["*", A, X]) F < 0 ? "" : "+" \purple{F(}\gray{expr(["+", ["*", B, X], D])}\purple{)}

\qquad expr(["*", A, X]) (F * B) < 0 ? "" : "+" \purple{expr(["+", ["*", F * B, X], F * D])}

Combine the X terms:

\qquad\pink{expr(["*", A, X]) + expr(["*", F * B, X])} + F * D

\qquad\pink{expr(["*", A + (F * B), X])} + F * D

The simplified expression is expr(["*", A + (F * B), X])

The simplified expression is expr(["+", ["*", A + (F * B), X], F * D])

[ TERM_FBX + ((C + F * D) > 0 ? "\\s*\\+\\s*" : "\\s*") + TERM_C_FD, TERM_C_FD + ((F * B) > 0 ? "\\s*\\+\\s*" : "\\s*") + TERM_FBX ]

\large{expr(["+", C, ["*", F, ["+", ["*", B, X], D]]])}

The minus sign in front of the parentheses means we multiply each term inside the parentheses by \purple{F}:

Distribute the \purple{F} into the parentheses:

\qquad C F < 0 ? "" : "+" \purple{F(}\gray{expr(["+", ["*", B, X], D])}\purple{)}

\qquad C (F * B) < 0 ? "" : "+" \purple{expr(["+", ["*", F * B, X], F * D])}

Rewrite the expression to group the numeric terms:

\qquad expr(["*", F * B, X]) C < 0 ? "" : "+" \blue{C + F * D}

Combine the numeric terms:

\qquad expr(["*", F * B, X]) (C + F * D) < 0 ? "" : "+" \blue{C + F * D}

The simplified expression is expr(["*", F * B, X])

The simplified expression is expr(["+", ["*", F * B, X], C + F * D])

[ TERM_EAX_FBX + ((E * C + F * D) > 0 ? "\\s*\\+\\s*" : "\\s*") + TERM_EC_FD, TERM_EC_FD + ((E * A + F * B) > 0 ? "\\s*\\+\\s*" : "\\s*") + TERM_EAX_FBX ]

\large{expr(["+", ["*", E, ["+", C, ["*", A, X]]], ["*", F, ["+", ["*", B, X], D]]])}

The minus sign in front of the parentheses means we multiply each term inside the first parentheses by \purple{E}:

Distribute the \purple{E} into the first set of parentheses:

\qquad \purple{E(}\gray{expr(["+", C, ["*", A, X]])}\purple{)} + expr(["*", F, ["+", ["*", B, X], D]])

\qquad \purple{expr(["+", E * C, ["*", E * A, X]])} + expr(["*", F, ["+", ["*", B, X], D]])

The minus sign in front of the parentheses means we multiply each term inside the parentheses by \purple{F}:

Distribute the \purple{F} into the parentheses:

\qquad expr(["+", E * C, ["*", E * A, X]]) F < 0 ? "" : "+" \purple{F(}\gray{expr(["+", ["*", B, X], D])}\purple{)}

\qquad expr(["+", E * C, ["*", E * A, X]]) (F * B) < 0 ? "" : "+" \purple{expr(["+", ["*", F * B, X], F * D])}

Rewrite the expression to group the \pink{X} terms and numeric terms:

\qquad\pink{expr(["*", E * A, X]) + expr(["*", F * B, X])} (E * C) < 0 ? "" : "+" \blue{E * C + F * D}

Combine the \pink{X} terms:

\qquad\pink{expr(["*", E * A + F * B, X])} (E * C) < 0 ? "" : "+" \blue{E * C + F * D}

Combine the numeric terms:

\qquad\pink{expr(["*", E * A + F * B, X])} (E * C + F * D) < 0 ? "" : "+" \blue{E * C + F * D}

The simplified expression is expr(["*", E * A + F * B, X])

The simplified expression is expr(["+", ["*", E * A + F * B, X], E * C + F * D])

\large{expr(["+", ["*", E, ["+", ["*", A, X], C]], ["*", F, ["+", D, ["*", B, X]]]])}

The minus sign in front of the parentheses means we multiply each term inside the first parentheses by \purple{E}:

Distribute the \purple{E} into the first set of parentheses:

\qquad \purple{E(}\gray{expr(["+", ["*", A, X], C])}\purple{)} + expr(["*", F, ["+", D, ["*", B, X]]])

\qquad \purple{expr(["+", ["*", E * A, X], E * C])} + expr(["*", F, ["+", D, ["*", B, X]]])

The minus sign in front of the parentheses means we multiply each term inside the parentheses by \purple{F}:

Distribute the \purple{F} into the parentheses:

\qquad expr(["+", ["*", E * A, X], E * C]) F < 0 ? "" : "+" \purple{F(}\gray{expr(["+", D, ["*", B, X]])}\purple{)}

\qquad expr(["+", ["*", E * A, X], E * C]) (F * D) < 0 ? "" : "+" \purple{expr(["+", F * D, ["*", F * B, X]])}

Rewrite the expression to group the \pink{X} terms and numeric terms:

\qquad\pink{expr(["*", E * A, X]) + expr(["*", F * B, X])} (E * C) < 0 ? "" : "+" \blue{E * C + F * D}

Combine the \pink{X} terms:

\qquad\pink{expr(["*", E * A + F * B, X])} (E * C) < 0 ? "" : "+" \blue{E * C + F * D}

Combine the numeric terms:

\qquad\pink{expr(["*", E * A + F * B, X])} (E * C + F * D) < 0 ? "" : "+" \blue{E * C + F * D}

The simplified expression is expr(["*", E * A + F * B, X])

The simplified expression is expr(["+", ["*", E * A + F * B, X], E * C + F * D])