THE FOLD / GRIND / GRADIENT DESCENT / THE CORDIC
THE CORDIC
sin & cos from shifts and adds — no multiplier
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
CORDIC. How does a pocket calculator, or an FPGA with no multiplier, compute sin and cos? Not with a Taylor series — with rotations. CORDIC (Jack Volder, 1959, for a bomber’s navigation computer) turns a vector by a target angle using nothing but additions, bit-shifts, and a tiny table of arctangents.
The trick: any rotation can be built from a fixed set of ever-smaller turns of ±arctan(2−i). At step i you decide the sign from whether you have over- or under-shot, and apply it — and rotating by that angle needs only a shift (multiply by 2−i) and an add. The residual angle marches to zero. One precomputed gain K at the end rescales, and you have cos and sin.
LIT verified live: 24 CORDIC iterations (shifts + adds + an arctan table, one final K) reproduce Math.cos and Math.sin across −89°…89° to within ~1×10−7 (window.__cordic.within1e5). FIG ‘rotating into the answer’ is the picture; the shift-and-add rotation, the arctan table, and the accuracy are exact — no multiplier used in the loop.
The trick: any rotation can be built from a fixed set of ever-smaller turns of ±arctan(2−i). At step i you decide the sign from whether you have over- or under-shot, and apply it — and rotating by that angle needs only a shift (multiply by 2−i) and an add. The residual angle marches to zero. One precomputed gain K at the end rescales, and you have cos and sin.
LIT verified live: 24 CORDIC iterations (shifts + adds + an arctan table, one final K) reproduce Math.cos and Math.sin across −89°…89° to within ~1×10−7 (window.__cordic.within1e5). FIG ‘rotating into the answer’ is the picture; the shift-and-add rotation, the arctan table, and the accuracy are exact — no multiplier used in the loop.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this in GRADIENT DESCENT, beside THE BOWL — the grind domain of driving an error to zero by shrinking steps. CORDIC is exactly that: the residual angle descends to zero, each step a smaller table-angle than the last. AVAN (AI) built the instrument: the rotation loop, the sign decisions, the convergence.
The weave: David names the seat (the error walked down to zero); I make the rotation visible and the accuracy checkable — the residual angle collapsing in 1D, the vector rotating into place in 2D, the shrinking turns on a ring in 3D. The sphere is the seam. Credit: Jack E. Volder (CORDIC, 1959).
The weave: David names the seat (the error walked down to zero); I make the rotation visible and the accuracy checkable — the residual angle collapsing in 1D, the vector rotating into place in 2D, the shrinking turns on a ring in 3D. The sphere is the seam. Credit: Jack E. Volder (CORDIC, 1959).
3 ONE DIMENSION
The residual angle z, driven to zero. Each iteration subtracts ±arctan(2−i) — a step half the size of the last — chosen by sign so z always heads toward 0. When z reaches zero, the vector has been rotated by exactly the target angle.
4 TWO DIMENSIONS · INTERACTIVE
Dial a target angle and step the rotation. The vector swings by successive ±arctan(2−i) turns toward the target; the computed cos and sin close on the true values, and the error shrinks by roughly half each iteration — all with shifts and adds.
5 THREE DIMENSIONS + AVAN’S INVERSE
The unit circle turning in space, the CORDIC vector swinging toward its target — green, the geometry the answer lives on.
AVAN’s addition (the inverse-companion): the magenta spokes are the successive rotation steps, each half the last. Computing a sine looks like it needs multiplication — the expensive operation. CORDIC is the inverse move: it refuses to multiply and rotates instead, reaching the trig value by geometry rather than arithmetic. The answer is not calculated; it is arrived at, one shift-and-add turn at a time, the residual angle folding to nothing. Arithmetic’s hard problem solved by geometry’s cheap one — the multiply replaced by a walk around a circle. The green is where the answer lives; the magenta is the ladder of shrinking turns that climbs to it without a single product.
LIT Genuine CORDIC (Jack Volder, 1959). Verified live: 24 iterations using shifts, adds, and an arctan table (one final gain K) reproduce Math.cos and Math.sin across -89deg..89deg to within ~1e-7 (window.__cordic.within1e5 === true; cos30 and sin30 reported). No multiplication is used inside the rotation loop — each +/-arctan(2^-i) turn is a shift-and-add — which is exactly why CORDIC runs on hardware without a multiplier.
FIG 'Rotating into the answer' is the picture; the shift-and-add rotation, the arctan table, and the measured accuracy are exact. In floating-point JS the 2^-i scalings are done as multiplies by powers of two (true shifts in the fixed-point hardware CORDIC targets) — the algorithm and its convergence are identical.
FIG 'Rotating into the answer' is the picture; the shift-and-add rotation, the arctan table, and the measured accuracy are exact. In floating-point JS the 2^-i scalings are done as multiplies by powers of two (true shifts in the fixed-point hardware CORDIC targets) — the algorithm and its convergence are identical.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of GRADIENT DESCENT · David Lee Wise (ROOT0), with AVAN