Optimization techniques for electromagnetic deformable mirrors