Quarry School

Substitute the whole inside expression

Subject: MathematicsLeans on: DistributionLeans on: Expanding a squareLeans on: Subtracting a packageLeans on: Like termsLeans on: Nonzero denominatorLeans on: Composition orderLeans on: Multiplying powers
Level 1 · FoundationsAbout 18 min read5 new termsKeystone idea. Later lessons build on this one.
How this was estimated

Programmatic estimate. Rung levels, worked steps, prerequisites, terms and sentence length contribute to this level. It describes the lesson, not your ability.

Reading counts the whole lesson, including folded explanations, at 180 words a minute. Practice allows two minutes per item. These are planning assumptions; take the time you need.

AI estimate unavailable.

Path to here

Open the unit’s lesson list to follow the lesson order.

    Quick review (2 minutes)

    In plain words

    Before filling a form with letters, run the two machines with numbers.

    Rule

    To form f(g(x)), replace every input-variable occurrence in f with the whole parenthesized expression g(x).
    (a + b)2 = a2 + 2ab + b2, because (a + b)(a + b) has two cross products ab.

    Step

    1. 1. Copy the outer formula and identify every input slot.

    2. 2. Write the complete inner formula in parentheses in every slot.

    3. 3. Keep powers outside those parentheses so they act on the entire input.

    4. 4. Expand with distribution. For a square, multiply the two identical parentheses and keep both cross products.

    5. 5. Combine like terms, preserve any domain restrictions, and check a small allowed input by the two-stage route.

    Question

    Let f(x) = x2 − 6 and g(x) = 3x + 2. Find (f ∘ g)(x) and (g ∘ f)(x). You want one formula for each order. Plan: put the complete inner formula into the outer input place, multiply out any square using four products, and collect matching terms.

    Answer

    (f ∘ g)(x) = 9x2 + 12x − 2.
    (g ∘ f)(x) = 3x2 − 16.
    Both domains are all real numbers.

    Trap

    Writing (2x + 1)2 = 4x2 + 1. The square multiplies two whole sums, so the two cross products must appear.

    Strategy

    1. 1. Copy the outer formula and identify every input slot.

    2. 2. Write the complete inner formula in parentheses in every slot.

    3. 3. Keep powers outside those parentheses so they act on the entire input.

    4. 4. Expand with distribution. For a square, multiply the two identical parentheses and keep both cross products.

    5. 5. Combine like terms, preserve any domain restrictions, and check a small allowed input by the two-stage route.

    Term

    Function

    Definition

    A rule that gives exactly one output for each input it accepts.

    Term

    Input

    Definition

    The starting value you give a function. It goes inside the parentheses in function notation.

    Term

    Output

    Definition

    The answer a function produces from an accepted input.

    Term

    Domain

    Definition

    All inputs for which a function is defined.

    Term

    Outer function

    Definition

    The function evaluated second in a two-function composition. It receives the inner function's output.

    Term

    Substitution

    Definition

    Replacing a variable with a number or expression everywhere that variable appears. Parentheses hold a multi-term replacement together.

    Term

    Reciprocal

    Definition

    One divided by a nonzero number. A fraction's reciprocal swaps its top and bottom, and their product is 1.

    Term

    Formula

    Definition

    A written rule using numbers, symbols, and operations to describe how a quantity is calculated.

    Term

    Variable

    Definition

    A symbol that stands for a number or quantity. Its value may change or may be the unknown you need to find.

    Term

    Denominator

    Definition

    The bottom of a fraction. It names the divisor and cannot be zero.

    Term

    Factor

    Definition

    One of the quantities multiplied together in a product.

    Term

    Fraction

    Definition

    One number divided by another nonzero number. The top is divided by the bottom; equal pieces give a picture of its size.

    Term

    Exponent

    Definition

    A raised number indicating a power. A positive whole-number exponent counts how many copies of the input are multiplied together.

    Term

    Linear

    Definition

    A formula built from a constant times the input plus a constant. Its graph is a straight line.

    Term

    Solve

    Definition

    Find every input that makes a stated equality or inequality true. This differs from evaluating at a given input.

    Term

    Like terms

    Definition

    Terms with the same variable part and powers. Their number factors can be added or subtracted.

    Term

    Distribute

    Definition

    Multiply each term inside parentheses by the outside factor.

    Term

    Equation

    Definition

    A statement that two expressions have equal values.

    1 In plain words

    Before filling a form with letters, run the two machines with numbers. Let g multiply by 3 and add 2, and let f square its input and subtract 6. Input 0 goes to 2 and then −2. Input 1 goes to 5 and then 19. Input 2 goes to 8 and then 58. A formula records all these trips at once. Each input letter in the outer rule is a blank on the form. Put the whole inner expression into every blank. Parentheses hold its pieces together until you multiply and combine them. This replacement is substitution. You can run the same rule twice or connect three rules with the same method.

    2 Picture it

    xg: 3x + 2f: u² − 6firstsecond3x + 2(3x + 2)² − 6
    x goes into g: 3x + 2, then 3x + 2 into f: u2 − 6: (3x + 2)2 − 6.
    input xoutput f(g(x))0−2119258
    The formula 9x2 + 12x − 2 reproduces every output in this row.

    Reminder

    Reminder: Distribution, Expanding a square, Subtracting a package, Like terms, Nonzero denominator, Composition order, Multiplying powers
    • Distribution. 2(x − 4) = 2x − 8, because the factor multiplies both terms.
    • Expanding a square. (x+1)2=x2+x+x+1=x2+2x+1.
    • Subtracting a package. −(x+2)=−x−2.
    • Like terms. 2x + 2x = 4x, while x2 and x are different kinds of terms.
    • Nonzero denominator. 2x − 1 ≠ 0 means x ≠ 12.
    • Composition order. f(g(x)) replaces the input slots in f with g(x), not the other way around.
    • Multiplying powers. x × x2 = x × (x × x) = x3. The exponent counts three multiplied copies of x.

    3 Why

    A formula describes what to do to its input, regardless of whether the input is a number or an expression. If f squares its input, then f(g(x)) must square all of g(x). Squaring a sum multiplies the sum by itself, creating middle terms as well as squares. Those terms come from distributing each part across the other package. Parentheses preserve the intended input until this multiplication is finished, so they prevent lost signs and missing terms.

    4 The rule

    To form f(g(x)), replace every input-variable occurrence in f with the whole parenthesized expression g(x).

    (a+b)2=a2+2ab+b2, because (a+b)(a+b) has two cross products ab.

    The same idea, five ways

    Say it

    f of g of x; replace every outer input with the whole inner expression

    Write it

    The outer formula acts on the entire expression produced by the inner formula.

    In math
    • f(g(x))=(3x+2)2−6
    • (f∘g)(x)=9x2+12x−2
    • f(u) = u2 − 6: u is the outer input place
    Like

    Put the same wrapped package into every blank on a form.

    See it
    xg: 3x + 2f: u² − 6firstsecond3x + 2(3x + 2)² − 6
    The same picture again: x goes into g: 3x + 2, then 3x + 2 into f: u2 − 6: (3x + 2)2 − 6.

    The same idea, other ways

    As filling boxes

    The outer formula x2 − x has two boxes. If the inner output is x + 2, fill both boxes with that package: (x + 2)2 − (x + 2).

    f(input) = (input)2 − (input)

    Input = x + 2

    f(g(x))=(x+2)2−(x+2)

    As a wrapped package

    Parentheses are the wrapper. A square outside the wrapper applies to every part of the input. A minus outside the wrapper subtracts every part.

    Square the package: (x + 2)2

    Subtract the package: −(x + 2)

    As a multiplication rectangle

    Squaring 3x + 2 places that same group along both rectangle sides. Four products fill it: 9x2, 6x, 6x, and 4. Both middle rectangles contribute, so their total is 12x.

    9x²6x3x6x423x2
    Every rectangle contributes to the expanded square.
    With a number check

    At x = 1, the inner expression 3x + 2 gives 5, whose square is 25. The expansion gives 9 + 12 + 4 = 25. Dropping the middle term gives 13, so this test catches that mistake.

    13x + 2squarefirstsecond525
    The small-number route checks that the complete group was squared.

    Part 1: A linear outside formula

    If the outer function multiplies its input by a number, that number multiplies the whole inner expression. Put in the package first, then distribute.

    • For f(x) = 3x and g(x) = x − 4, f(g(x)) = 3(x − 4).
    3x−123x−4
    This is a multiplication bookkeeping grid.

    Worked example

    Triple the whole inside

    Let f(x) = 3x and g(x) = x − 4. Find f(g(x)). You want to triple the entire g output. Plan: wrap the inner expression in parentheses in every outer input place, then distribute and collect matching terms.

    Show the steps and the answer
    5g: subtract 4f: triplefirstsecond13
    The direct two-stage result matches the formula.
    1. f(g(x))=f(x−4)=3(x−4).The outer input slot receives x − 4.
    2. =3x−12.3 multiplies x and −4.
    Answer
    f(g(x)) = 3x − 12, for every real x.
    Double-check At x = 5, g(5) = 1 and f(1) = 3; 3(5) − 12 = 3.

    Counterexamples

    What it is not, and the tempting wrong moves.

    ✗ Not this: 3(x−4)=3x−4.
    This triples x while leaving the second part of the same input unchanged.
    ✓ Instead: 3(x−4)=3x−12.

    Tips and tricks

    • Draw one multiplication arrow from the outside factor to each term inside.

    Part 2: A square outside formula

    A square means multiplying the input by itself. If the input is a sum, both copies of the whole sum must be multiplied. The middle term comes from two cross products.

    • (x+1)2=x2+2x+1.
    • A square does not distribute over addition.
    x²xxx11x1
    The two x products add to the middle term 2x.

    Worked example

    A first square composition

    Let f(x) = x2 and g(x) = x + 1. Find f(g(x)). You want to square the complete inner output. Plan: wrap the inner expression in parentheses in every outer input place, then distribute and collect matching terms.

    Show the steps and the answer
    x²xxx11x1
    All four products belong in the expanded square.
    1. f(g(x))=(x+1)2=(x+1)(x+1).Squaring multiplies the whole input by itself.
    2. =x2+x+x+1=x2+2x+1.The four products include two matching middle terms.
    Answer
    f(g(x))=x2+2x+1.
    Double-check At x = 2, g(2) = 3 and f(3) = 9; 4 + 4 + 1 = 9.

    Counterexamples

    What it is not, and the tempting wrong moves.

    ✗ Not this: (x+1)2=x2+1.
    It misses the products x × 1 and 1 × x.
    ✓ Instead: (x+1)2=x2+2x+1.

    Tips and tricks

    • Multiply two written copies if the square formula is hard to remember.

    Part 3: A fraction outside formula

    A fraction's denominator may also contain an input slot. Replace that slot with the complete inner expression. Then check when the new denominator would be zero.

    • For f(x) = 1x−2, f(g(x)) = 1g(x)−2.
    • The original and intermediate restrictions still matter; the next lesson develops both gates.

    f(x)=1x−2

    g(x) = 3x + 1

    f(g(x))=13x−1

    Require x ≠ 13

    Worked example

    A linear output enters a denominator

    Let f(x) = 1x−2 and g(x) = 3x + 1. Find f(g(x)). You want to subtract 2 from the g output, then take the reciprocal. Plan: wrap the inner expression in parentheses in every outer input place, then distribute and collect matching terms.

    Show the steps and the answer
    1gffirstsecond41/2
    The inner output fills the denominator's input slot.
    1. f(g(x))=1(3x+1)−2.The whole inner expression replaces x in the denominator.
    2. =13x−1.The constants 1 − 2 combine to −1.
    3. Find the forbidden starting input by solving 3x−1=0: add 1 to get 3x=1, then divide by 3 to get x=13. Check: 3×13−1=0. Exclude that input.This finds and confirms the one start that makes the new denominator zero. The inner linear function itself accepts every real input.
    Answer
    f(g(x))=13x−1,x≠13.
    Double-check At x = 1, g(1) = 4 and f(4) = 12, agreeing with 13−1.

    Counterexamples

    What it is not, and the tempting wrong moves.

    ✗ Not this: f(g(x))=13x+1−2.
    The −2 belongs inside the denominator of f, so it must stay inside after substitution. At x = 1 the wrong version gives −74 instead of 12.
    ✓ Instead: f(g(x))=1(3x+1)−2=13x−1.

    Tips and tricks

    • Copy the entire fraction first, then replace its input places.

    Part 4: Compose a function with itself

    A machine can send its answer back through the same rule. The second trip uses the first answer as its input. In j(j(x)), the two j names mean two separate applications of the same instructions. This operation is different from multiplying the first answer by itself.

    • (j ∘ j)(x) = j(j(x)).
    • j(j(x)) uses the output as a new input; j(x)2 squares the output instead.
    1jjfirstsecond941
    The second j receives the first j’s output.

    Worked example

    The same formula can receive its own output

    Let j(x) = 4x + 5. Find j(j(x)) and its value at x = 1. You run j twice, using a new input the second time. Plan: put the whole first output 4x + 5 into j, distribute 4, and check with two separate number evaluations.

    Show the steps and the answer
    1j: 4x + 5j: 4u + 5firstsecond941
    1 goes into j: 4x + 5, then 9 into j: 4u + 5: 41.
    1. j(j(x))=4(4x+5)+5.The outer copy of j receives 4x + 5 as its whole input.
    2. =16x+20+5=16x+25.Distribution multiplies both inner terms by 4, then combines the added constants.
    3. At x=1,j(j(1))=16×1+25=41.The composed formula gives the final output for starting input 1.
    Answer
    • j(j(x)) = 16x + 25.
    • j(j(1)) = 41.
    Double-check The direct two-stage route gives j(1) = 9 and j(9) = 4 × 9 + 5 = 41, agreeing with the new formula.

    Counterexamples

    What it is not, and the tempting wrong moves.

    ✗ Not this: j(j(1))=j(1)2=81.
    This squares the first output 9 instead of feeding 9 back into j.
    ✓ Instead: j(1) = 9, then j(9) = 41.

    Tips and tricks

    • Know cold: same name means same instructions again, with a new input.

    Part 5: Connect three functions

    Think of three stations in a kitchen. The first prepares something for the second, and the second prepares something for the third. In p(q(v(x))), v acts first, q second, and p last. Each completed answer replaces the next input. More functions mean more stages, while the inside-first method stays the same.

    • p(q(v(x))) runs v, then q, then p.
    • A chain is defined only when every stage accepts the answer handed to it.
    2v: add 3q: squarefirstsecond525
    Continue from 25 into p to obtain 43.

    Worked example

    Connect three formulas in order

    Let v(x) = x + 3, q(x) = x2, and p(x) = 2x − 7. Find p(q(v(2))) and p(q(v(x))). You run three jobs, starting with the deepest parentheses. Plan: add 3, square the result, then double and subtract 7.

    Show the steps and the answer
    2v: add 3q: squarefirstsecond525
    The same picture again: 2 goes into v: add 3, then 5 into q: square: 25.
    5q: squarep: 2u − 7firstsecond2543
    5 goes into q: square, then 25 into p: 2u − 7: 43.
    1. v(2)=2+3=5.v touches the starting input, so it acts first.
    2. q(v(2))=q(5)=25.The output 5 is now the input to the square.
    3. p(q(v(2)))=p(25)=2×25−7=43.The final rule receives 25, rather than the original 2.
    4. p(q(v(x)))=2(x+3)2−7.The inner expression is squared in full and handed to the last rule.
    5. (x+3)2=x2+3x+3x+9=x2+6x+9.All four products belong to the square.
    6. 2(x2+6x+9)−7=2x2+12x+18−7=2x2+12x+11.The outside factor multiplies each term, then the constants combine.
    Answer
    • p(q(v(2))) = 43.
    • p(q(v(x)))=2x2+12x+11.
    Double-check At x = 2, the expanded formula gives 2 × 4 + 12 × 2 + 11 = 8 + 24 + 11 = 43, agreeing with the three numerical stages.

    Counterexamples

    What it is not, and the tempting wrong moves.

    ✗ Not this: p(q(v(2))) means p(2) × q(2) × v(2).
    That multiplies three independent outputs at the original input instead of passing each output to the next function.
    ✓ Instead: The connected path is 2 → 5 → 25 → 43.

    Tips and tricks

    • Write one line for every function, starting with the innermost parentheses.

    5 How

    1. Copy the outer formula and identify every input slot.
    2. Write the complete inner formula in parentheses in every slot.
    3. Keep powers outside those parentheses so they act on the entire input.
    4. Expand with distribution. For a square, multiply the two identical parentheses and keep both cross products.
    5. Combine like terms, preserve any domain restrictions, and check a small allowed input by the two-stage route.

    Build one formula for a composition

    1
    Does the outer input occur more than once?
    YesPut the complete inner expression, in parentheses, into every occurrence.
    NoPut the complete expression in its one input place.
    ↓
    2
    Is a whole sum or difference squared?
    YesWrite two copies and multiply all four term pairs before collecting terms.
    NoApply the indicated operations in their original order.
    ↓
    3
    Does either original stage have a denominator or an even root?
    YesKeep the original requirements, and check the substituted outer input as the next domain lessons teach.
    NoThese arithmetic formulas accept every real starting input unless a restricted domain is supplied. Keep any stated restriction.
    1. Copy the outer formula and identify every input slot.
    2. Write the complete inner formula in parentheses in every slot.
    3. Keep powers outside those parentheses so they act on the entire input.
    4. Expand with distribution. For a square, multiply the two identical parentheses and keep both cross products.
    5. Combine like terms, preserve any domain restrictions, and check a small allowed input by the two-stage route.

    6 Worked example

    Worked example

    A square makes the middle term

    Let f(x) = x2 − 6 and g(x) = 3x + 2. Find (f ∘ g)(x) and (g ∘ f)(x). You want one formula for each order. Plan: put the complete inner formula into the outer input place, multiply out any square using four products, and collect matching terms.

    Show the steps and the answer
    9x²6x3x6x423x2
    The two middle rectangles contribute 6x each, so the middle term is 12x.
    1g: 3x + 2f: u² − 6firstsecond519
    The input u names the entire number handed to f.
    1. (f∘g)(x)=f(3x+2)=(3x+2)2−6.The outer f squares its whole input before subtracting 6.
    2. (3x+2)2=(3x+2)(3x+2)=9x2+6x+6x+4.Each of the two terms in one copy multiplies each term in the other copy.
    3. (f∘g)(x)=9x2+12x+4−6=9x2+12x−2.The two middle products add to 12x, and 4 − 6 = −2.
    4. (g∘f)(x)=g(x2−6)=3(x2−6)+2.Now g multiplies f’s entire output by 3 and adds 2.
    5. (g∘f)(x)=3x2−18+2=3x2−16.The factor 3 multiplies both x2 and −6, then −18 + 2 = −16.
    Answer
    • (f∘g)(x)=9x2+12x−2.
    • (g∘f)(x)=3x2−16.
    • Both domains are all real numbers.
    Double-check At x = 1, g(1) = 5 and f(5) = 19, matching 9 + 12 − 2 = 19. Reversing gives f(1) = −5 and g(−5) = −13, matching 3 − 16 = −13.

    Ladder: from easy to exam-hard

    Try each rung before you open its steps.

    Rung 1 of 7

    A constant inner answer

    Let g(x) = 4 and f(x) = x + 1. Find f(g(x)). Whatever input you start with, the first machine returns 4. Plan: wrap the inner expression in parentheses in every outer input place, then distribute and collect matching terms.

    Show the steps and the answer
    any xreturn 4add 1firstsecond45
    The starting input does not change this inner output.
    1. f(g(x))=f(4).The inner output is always 4.
    2. f(4)=4+1=5.The outer function adds 1 to its input.
    Answer
    f(g(x)) = 5 for every real x.
    Double-check At x = −7, g(−7) = 4 and f(4) = 5, matching the constant formula.

    Rung 2 of 7

    Distribute over an inner line

    Let f(x) = 2x + 3 and g(x) = x − 4. Find f(g(x)). You want to double the complete inner answer and add 3. Plan: wrap the inner expression in parentheses in every outer input place, then distribute and collect matching terms.

    Show the steps and the answer
    2x−82x−4
    The factor 2 multiplies both signed terms.
    1. f(g(x))=2(x−4)+3.x − 4 replaces the outer input slot.
    2. =2x−8+3=2x−5.Distribute 2 and then combine the constants.
    Answer
    2x−5.
    Double-check At 0, g(0) = −4 and f(−4) = −5, agreeing with 2(0) − 5.

    Rung 3 of 7

    Fill repeated slots

    Let f(x) = x2 − x and g(x) = x + 2. Find f(g(x)). You must use the whole g output twice. Plan: wrap the inner expression in parentheses in every outer input place, then distribute and collect matching terms.

    Show the steps and the answer

    (x+2)2−(x+2)

    x2+4x+4−x−2

    x2+3x+2

    1. f(g(x))=(x+2)2−(x+2).Both occurrences of the outer input receive x + 2.
    2. =x2+2x+2x+4−x−2.Multiplying the square produces four terms, and subtracting the last package changes both signs.
    3. =x2+3x+2.4x − x = 3x and 4 − 2 = 2.
    Answer
    x2+3x+2.
    Double-check At 1, g(1) = 3 and f(3) = 6; 1 + 3 + 2 = 6.

    Rung 4 of 7

    A square with a negative term

    Let f(x) = x2 + 1 and g(x) = 3x − 2. Find f(g(x)). You want to square the whole difference and then add 1. Plan: wrap the inner expression in parentheses in every outer input place, then distribute and collect matching terms.

    Show the steps and the answer
    9x²−6x3x−6x4−23x−2
    The labels record signed products.
    1. f(g(x))=(3x−2)2+1.The square acts on all of g's output.
    2. (3x−2)2=9x2−6x−6x+4.Each cross product contains one negative factor, while (−2)(−2) is positive.
    3. f(g(x))=9x2−12x+5.The cross products add to −12x and 4 + 1 = 5.
    Answer
    9x2−12x+5.
    Double-check At 1, g(1) = 1 and f(1) = 2; 9 − 12 + 5 = 2.

    Rung 5 of 7

    Slots on both sides of a fraction

    Let f(x) = x+1x−1 and g(x) = 2x. Find f(g(x)). You replace the input on both top and bottom. Plan: put 2x into both places, then find the starting input that makes the entire denominator zero.

    Show the steps and the answer
    xg: 2xf: (u+1)/u−1firstsecond2x(2x + 1)/(2x − 1)
    Both fraction slots receive the same inner output.
    1. f(g(x))=2x+12x−1.Each x slot in f receives the full expression 2x.
    2. Solve 2x−1=0 to locate the forbidden input: 2x=1, so x=12. Plug it back in: 2×12−1=0. Exclude 12.The denominator must not be zero. This equation finds the starting input at which that failure would occur; g itself has no restrictions.
    Answer
    2x+12x−1, with x ≠ 12.
    Double-check At 2, g(2) = 4 and f(4) = 53; the combined formula gives 4+14−1 = 53.

    Rung 6 of 7

    The same function twice

    Let j(x) = 4x + 5. Find j(j(x)) and its value at x = 1. You run j twice, using a new input the second time. Plan: put the whole first output 4x + 5 into j, distribute 4, and check with two separate number evaluations.

    Show the steps and the answer
    1j: 4x + 5j: 4u + 5firstsecond941
    The same picture again: 1 goes into j: 4x + 5, then 9 into j: 4u + 5: 41.
    1. j(j(x))=4(4x+5)+5.The outer copy of j receives 4x + 5 as its whole input.
    2. =16x+20+5=16x+25.Distribution multiplies both inner terms by 4, then combines the added constants.
    3. At x=1,j(j(1))=16×1+25=41.The composed formula gives the final output for starting input 1.
    Answer
    • j(j(x)) = 16x + 25.
    • j(j(1)) = 41.
    Double-check The direct two-stage route gives j(1) = 9 and j(9) = 4 × 9 + 5 = 41, agreeing with the new formula.

    Rung 7 of 7

    A three-stage symbolic chain

    Let v(x) = x + 3, q(x) = x2, and p(x) = 2x − 7. Find p(q(v(2))) and p(q(v(x))). You run three jobs, starting with the deepest parentheses. Plan: add 3, square the result, then double and subtract 7.

    Show the steps and the answer
    2v: add 3q: squarefirstsecond525
    The same picture a third time: 2 goes into v: add 3, then 5 into q: square: 25.
    5q: squarep: 2u − 7firstsecond2543
    The same picture again: 5 goes into q: square, then 25 into p: 2u − 7: 43.
    1. v(2)=2+3=5.v touches the starting input, so it acts first.
    2. q(v(2))=q(5)=25.The output 5 is now the input to the square.
    3. p(q(v(2)))=p(25)=2×25−7=43.The final rule receives 25, rather than the original 2.
    4. p(q(v(x)))=2(x+3)2−7.The inner expression is squared in full and handed to the last rule.
    5. (x+3)2=x2+3x+3x+9=x2+6x+9.All four products belong to the square.
    6. 2(x2+6x+9)−7=2x2+12x+18−7=2x2+12x+11.The outside factor multiplies each term, then the constants combine.
    Answer
    • p(q(v(2))) = 43.
    • p(q(v(x)))=2x2+12x+11.
    Double-check At x = 2, the expanded formula gives 2 × 4 + 12 × 2 + 11 = 8 + 24 + 11 = 43, agreeing with the three numerical stages.

    Counterexamples

    What it is not, and the tempting wrong moves.

    ✗ Not this: f(g(x))=(3x+2)2−6=9x2−2.
    This discards the two middle products, 6x and 6x. At x = 1 it gives 7 instead of 19.
    ✓ Instead: f(g(x))=9x2+12x−2.
    ✗ Not this: For f(x) = x2 − x, substituting x + 2 gives (x + 2)2 − x.
    The second input slot was never replaced.
    ✓ Instead: Use (x + 2)2 − (x + 2).

    Tips and tricks

    • Know cold: every slot gets the whole package. Circle each input-variable occurrence before replacing it.
    • Understand, then rebuild: the expanded formula. Parentheses and distribution can recreate it; memorizing the numbers in front of its variable terms is unnecessary.
    • Use x = 1 to check for a missing middle term. At x = 0 that term becomes zero and may hide the error.

    7 The trap

    Writing (2x + 1)2 = 4x2 + 1. The square multiplies two whole sums, so the two cross products must appear.