  We derive necessary and sufficient conditions for the approximate
correctability of a quantum code, generalizing the Knill-Laflamme conditions
for exact error correction. Our measure of success of the recovery operation is
the worst-case entanglement fidelity of the overall process. We show that the
optimal recovery fidelity can be predicted exactly from a dual optimization
problem on the environment causing the noise. We use this result to obtain an
easy-to-calculate estimate of the optimal recovery fidelity as well as a way of
constructing a class of near-optimal recovery channels that work within twice
the minimal error. In addition to standard subspace codes, our results hold for
subsystem codes and hybrid quantum-classical codes.
