# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
294 lines (288 sloc) 14.1 KB
 Combining like terms with distribution
randVar() 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))

Expand the expression and combine the like terms:

SOLUTION
(A + F * B) + X + "+" + (F * D)

\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])

(F * B) + X + "+" + (C + F * D)

\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])

(E * A + F * B) + X + "+" + (E * C + F * D)

\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])