2.2.8 · D2Functions

Visual walkthrough — Composition of functions — f(g(x)), g(f(x))

1,889 words9 min readBack to topic

We only assume you know what a function is: a rule that takes one number in and gives exactly one number out. Everything else is drawn.


Step 1 — A function is a machine with one slot in, one slot out

WHAT. Draw each function as a labelled box. A number goes into the left slot, the box does its job, a new number comes out the right slot.

WHY. Before we can "chain" two functions, we need a picture of what one function does to a single number. If we cannot see one machine clearly, two machines will be a blur.

PICTURE. Feed into the machine . The box swallows and spits out . The label under the arrow, , tells you which machine did the work.


Step 2 — Put a second machine right after the first

WHAT. Place a second machine so that whatever falls out of drops straight into . Their slots line up: out-slot of touches in-slot of .

WHY. This is the entire idea of composition — we want the output of one machine to become the input of the next, with no human touching the number in between. We are building an assembly line.

PICTURE. goes into , out comes ; that same slides into , out comes . Notice the middle number is never written by us — the machines hand it over.


Step 3 — Give the whole assembly line one name:

WHAT. Draw a big dashed box around both machines. From the outside it looks like a single machine: goes in one end, comes out the far end. Call this combined machine .

WHY. We want to treat "do , then " as one operation we can reuse and study. Naming it lets us ask questions about the whole pipeline at once.

PICTURE. The outer dashed box has the label . Inside, the same two boxes from Step 2 are hidden. The little circle is just a symbol meaning "chained with."


Step 4 — Swap the machines and watch the answer change

WHAT. Build the other assembly line: , meaning first, then . Same two machines, opposite order. Feed in the same .

WHY. People expect order not to matter (like ). We must see that for machines it usually does — this is the property called non-commutativity.

PICTURE. Top rail: gives . Bottom rail: gives . Same start, different finish. The two coloured end-numbers ( vs ) are the punchline.


Step 5 — Where can legally enter? The domain squeezes

WHAT. Not every number may enter the pipeline. A machine can refuse certain inputs (a square-root machine refuses negatives). Draw the refusal by shading the numbers each machine rejects.

WHY. The parent note warned that the composite's domain is not just "wherever the outer machine works." We must trace the number through both machines and keep only inputs that survive the whole trip. (See Domain and range of function.)

PICTURE. Take then , so . Numbers below turn the middle value negative; the machine slams its door. Only (the green stretch of the number line) make it all the way through.


Step 6 — Degenerate machine: the identity does nothing

WHAT. Insert the special machine that hands back exactly what it received. Watch it act as a "pass-through pipe."

WHY. Every operation needs a "do-nothing" element to compare against (like or ). Seeing it makes later ideas — especially Inverse functions — click, because an inverse is the machine that undoes another back to .

PICTURE. Whether sits before or after , the number is unchanged by the pipe, so the whole line behaves like alone.


Step 7 — Three machines, and why brackets don't matter

WHAT. Chain three machines , , . Group them two different ways: first glue then add , versus first glue then add . Trace one number through both groupings.

WHY. This is associativity. If grouping changed the answer, "do , then , then " would be ambiguous. We prove by picture it never is.

PICTURE. Both dashed groupings sit over the same three boxes in the same order. A single number flows through identically; the dashed brackets are just cosmetic fences that don't touch the flow.


The one-picture summary

Everything on this page lives in this one diagram: a number enters, passes through machines glued output-to-input, the whole run gets one name , swapping order changes the exit number, gates decide who may enter, the identity pipe changes nothing, and grouping fences are invisible.

Recall Feynman retelling — say it to a 12-year-old

Imagine a toy factory. Each machine has a slot on the left where you drop a number and a slot on the right where a new number pops out. To compose two machines you just shove them together so the second one's mouth is right under the first one's chute — no hands in between. Now the pair looks like one big machine; we nickname it , and the trick is the machine closest to your hand () always fires first, even though we write it last. If you swap the two machines, the number that falls out the far end is usually different — order matters, like putting on socks then shoes versus shoes then socks. Some machines are picky: a square-root machine refuses negative numbers, so if the machine before it hands over a negative, the whole line jams — that's why the allowed inputs can shrink. One boring machine, the identity, is just a straight pipe: it gives back exactly what you fed it, so gluing it on changes nothing. And if you have three machines in a row, it doesn't matter which pair you mentally bracket first — the number tumbles through the same three boxes in the same order and lands on the same answer. That's the whole story of composition.

Recall Quick self-check

Order symbol reads which way ::: right-to-left; the rightmost machine acts first. Domain of ::: , because the inner value must be . with ::: . Why usually ::: each machine transforms differently, so processing order changes the result.

See also: Inverse functions (the machine that undoes another back to the identity), Bijective functions (when a machine is reversible), Derivatives - chain rule (how fast a composed machine responds), Function transformations and Exponential and logarithmic functions.