It is shown that, over an arbitrary ring, the functions computed by polynomial-size algebraic formulas are also computed by polynomial-length algebraic straight-line programs that use only three registers. This was previously known for Boolean formulas [D.A. Barrington, J. Comput. System Sci, 38 (1989), pp. 150-164], which are equivalent to algebraic formulas over the ring GF(2). For formulas over arbitrary rings, the result is an improvement over previous methods that require the number of registers to be logarithmic in the size of the formulas in order to obtain polynomial-length straight-line programs. Moreover, the straight-line programs that arise in these constructions have the property that they consist of statements whose actions on the registers are linear and bijective. A consequence of this is that the problem of determining the iterated product of n 3 × 3 matrices is complete (under P projections) for algebraic NC1 Also, when the ring is GF(2), the programs that arise in the constructions are equivalent to bounded-width permutation branching programs.