When an environmental disturbance to a quantum system has a wavelength much larger than the system size, all qubits in the system are under the action of the same error operator. The noiseless subsystem and decoherence-free subspace are immune to such collective noise. We construct simple quantum circuits that implement these error-avoiding codes for a small number
n of physical qubits. A single logical qubit is encoded with
n=3 and 4, while two and three logical qubits are encoded with
n=5 and 7, respectively. Recursive relations among subspaces employed in these codes play essential roles in our implementation.
We introduce a generalized theory of decoherence-free subspaces and subsystems (DFSs), which do not require accurate initialization. We derive a set of conditions for the existence of DFSs within this generalized framework. By relaxing the initialization requirement we show that a DFS can tolerate arbitrarily large preparation errors. This has potentially significant implications for experiments involving DFSs, in particular for the experimental implementation, over DFSs, of the large class of quantum algorithms which can function with arbitrary input states.