Experiments in coherent magnetic resonance, microwave, and optical spe
ctroscopy control quantum-mechanical ensembles by guiding them from in
itial states toward target states by unitary transformation. Often, th
e coherences detected as signals are represented by a non-Hermitian op
erator. Hence, spectroscopic experiments, such as those used in nuclea
r magnetic resonance, correspond to unitary transformations between op
erators that in general are not Hermitian, A gradient-based systematic
procedure for optimizing these transformations is described that find
s the largest projection of a transformed initial operator onto the ta
rget operator and, thus, the maximum spectroscopic signal. This method
can also be used in applied mathematics and control theory.