The wavefront sensing and reconstruction algorithms needed for the control signals for the actuators of a deformable mirror when utilizing the Hartmann-Shack wavefront sensing method are discussed. The algorithms determine the actuator's use of the measured data of image displacement to control the mirror. An analysis is presented regarding the limitations inherent in various techniques of wavefront reconstruction. The direct control of subaperture wavefront gradients is discussed, in which a single step replaces the multistep process associated with wavefront reconstruction and decoupling. The single-step process is tested experimentally on a 19-element deformable mirror with subaperture dividing optics and an optical path for purposes of comparison. By increasing the number of fitting terms, coupling can be alleviated, and modal reconstruction is shown to prevent aliasing. Controlling gradients are found to make wavefront correcting more precise by modeling the response function between actuators and subapertures.