Visual walkthrough — Fourier series — motivation from periodic functions
We work with a function that repeats. Before any formula, let us pin down what "repeats" even means.
Step 1 — What "periodic" looks like
WHAT. A function is a machine: feed it a number (a position on a line), it returns a height . A periodic function is one whose graph is a stencil you slide sideways and it lands exactly on itself. The slide distance that makes it land is the period : in symbols, — "shift the input by , the output is unchanged."
WHY. Everything below lives on one period. If the shape endlessly repeats, we only ever need to understand one tile of it; the rest is copies. That is the entire reason we integrate over just one width later.
PICTURE. Below, the same tile (blue) is stamped over and over. The orange bracket is one period . Notice the height at and at (red dots) are level — that is the definition.

Step 2 — The building bricks: waves that fit the tile
WHAT. Our bricks are the pure waves and , one for each whole number Read the inside piece as a speed dial: counts how many complete wiggles the wave packs into one tile of width .
WHY these bricks and not, say, straight lines? Because each one already repeats with period : push up by and the angle jumps by , a whole number of full turns, so the wave returns to where it was. A sum of things that each repeat every automatically repeats every — the bricks match the wall.
PICTURE. Three bricks: (one wiggle), (two), (three). All start and end their period together at the tile edges (dashed).

Step 3 — The idea from vectors: "dot to extract"
WHAT. Suppose a 2-D arrow is . To pull out just the number , you dot with : , because but . The perpendicular partner contributes nothing.
WHY bring vectors in? Because our series has the exact same shape: is an arrow, the bricks are the axis directions, and are its coordinates. If we can find a "dot product" for functions in which different bricks are perpendicular, the same extraction trick works.
PICTURE. Left: the vector case — projecting onto ignores the part. Right: the analogy — is the arrow, cosine-1 and sine-1 are two perpendicular axes.

The function "dot product" is the integral over one period: . (Why an integral? It sums the product height-by-height across the tile, exactly like a dot sums component-by-component.) See Orthogonality of Functions.
Step 4 — Why different bricks are perpendicular (orthogonality)
WHAT. We check: multiply two different bricks together and integrate across one tile. The answer is zero. Multiply a brick by itself and integrate: you get a nonzero number ().
WHY it must be true — the mechanism. Use the product-to-sum identity With and , each right-hand piece is — another pure wave with integer speed . Integrating a pure wave over a whole number of its cycles sweeps equal area above and below the axis: they cancel to zero. The only escape is when the speed is (i.e. in the term): then , a flat line of height , whose integral over width is , and the makes it .
PICTURE. Top: — shaded area above (blue) exactly matches area below (orange): net . Bottom: sits entirely , so its area survives.

Step 5 — Extracting by "dotting with "
WHAT. Take the whole series, multiply both sides by one chosen cosine brick , and integrate from to .
WHY. Step 4 promised that this "dot" makes every wrong term vanish. Watch the wreckage:
Everything dies except the single term , which leaves . Divide by :
Term-by-term: undoes the from self-overlap; is the given shape; is the probe selecting the -th cosine dial.
PICTURE. The infinite tangle on the left; the sieve of "multiply-and-integrate" on the right lets exactly one marble () through.

Step 6 — Extracting by "dotting with "
WHAT. Same move, sine probe. Multiply the series by , integrate over the tile.
WHY. By the sine–cosine cross fact ( always) all cosine terms and the baseline vanish; by sine orthogonality only the sine survives with value :
PICTURE. The same sieve, sine-coloured, catches only .

Step 7 — The degenerate cases (never leave the reader stranded)
WHAT & WHY — three edges the formula must survive:
- is even (, mirror-symmetric about ). Then is even·odd = odd, so every . Only cosines survive — cosines are themselves even, so they fit an even shape. Half the integrals are free.
- is odd (, spins under a half-turn about the origin). Then is odd·even = odd, so every , including : an odd function has average . Only sines remain.
- is a flat constant . It is even, so all ; and it has zero net cycles against any wave , so those too. Only survives — a constant is its own average, no waves needed.
PICTURE. Left: even shape lays flush against a cosine. Middle: odd shape matches a sine, and its signed area against any cosine cancels. Right: a constant is pure baseline.

Step 8 — Watching it work: the square wave rebuilds itself
WHAT. Take the odd square wave on , on , period so . Odd ⟹ all (Step 7). The sine dials come out to
WHY it convinces. Each new odd brick steepens the vertical wall and flattens the plateau — the dials found in Steps 5–6 are exactly the amounts that make the pile agree with the square.
PICTURE. The partial sums with 1, 3, and 15 terms climbing toward the square; note the little Gibbs ear at the jump that never fully shrinks.

The one-picture summary

Read it left to right: a repeating tile () → decompose into perpendicular wave-axes → probe each axis by multiply-and-integrate (orthogonality kills all but one) → out drop the dials → stack the bricks back into .
Recall Feynman retelling — say it back in plain words
We had a shape that repeats every . We guessed it's a pile of pure waves, each set to some unknown loudness. To read off one wave's loudness, we borrowed the vector trick: to get a vector's -part you dot with and the -part drops out because they're perpendicular. For functions, "dot" means multiply the two and integrate across one tile, and here's the miracle — two different waves multiply-and-integrate to zero (their overlap cancels above and below the axis), while a wave with itself gives . So when we multiply the whole pile by one probe wave and integrate, every stranger vanishes and one survivor remains, handing us that exact dial: , . Even shapes need only cosines, odd shapes only sines, constants only the baseline; and at a cliff-edge jump the pile agrees on the midpoint, forever wearing a tiny 9% Gibbs ear.
Recall
Extract : multiply by which probe, then do what? ::: Multiply by and integrate over to ; orthogonality leaves , so . Why do all wrong terms vanish? ::: Distinct sines/cosines are orthogonal — their product integrates to zero over one period; only the matching brick survives with value . Square-wave coefficient ? ::: : for odd , for even .