Two kinds of algorithm for an adaptive optics (AO) system that uses two deformable mirrors (DMs), one with large stroke and the other with high spatial frequency, to correct different aberrations are described. The algorithms are based on modal method and direction-gradient method, respectively. Numerical simulations for the algorithms have been made. The simulation results indicate that the two DMs in the AO system can correct different aberrations with different characteristics, and the closed-loop performance of a double-DM AO system will be almost the same as that of an AO system that uses a single DM with an ideal stroke. (c) 2006 Optical Society of America.