  Recent progress in quantum technologies with ultracold atoms has been
propelled by spatially fine-tuned control of lasers and diffraction-limited
imaging. The state-of-the-art precision of optical alignment to achieve this
fine-tuning is reaching the limits of manual control. Here, we show how to
automate this process. One of the elementary techniques of manual alignment of
optics is cross-walking of laser beams. Here, we generalize this technique to
multi-variable cross-walking. Mathematically, this is a variant of the
well-known Alternating Minimization (AM) algorithm in convex optimization and
is closely related to the Gauss-Seidel algorithm. Therefore, we refer to our
multi-variable cross-walking algorithm as the modified AM algorithm. While
cross-walking more than two variables manually is challenging, one can do this
easily for machine-controlled variables. We apply this algorithm to
mechanically align high numerical aperture (NA) objectives and show that we can
produce high-quality diffraction-limited tweezers and point spread functions
(PSF). After a rudimentary coarse alignment, the algorithm takes about 1 hour
to align the optics to produce high-quality tweezers. Moreover, we use the same
algorithm to optimize the shape of a deformable mirror along with the
mechanical variables and show that it can be used to correct for optical
aberrations produced, for example, by glass thickness when producing tweezers
and imaging point sources. The shape of the deformable mirror is parametrized
using the first 14 non-trivial Zernike polynomials, and the corresponding
coefficients are optimized together with the mechanical alignment variables. We
show PSF with a Strehl ratio close to 1 and tweezers with a Strehl ratio >0.8.
The algorithm demonstrates exceptional robustness, effectively operating in the
presence of significant mechanical fluctuations induced by a noisy environment.
