  The dynamics of a quantum system driven by an external field is well
described by a unitary transformation generated by a time dependent
Hamiltonian. The inverse problem of finding the field that generates a specific
unitary transformation is the subject of study. The unitary transformation
which can represent an algorithm in a quantum computation is imposed on a
subset of quantum states embedded in a larger Hilbert space. Optimal control
theory (OCT) is used to solve the inversion problem irrespective of the initial
input state. A unified formalism, based on the Krotov method is developed
leading to a new scheme. The schemes are compared for the inversion of a
two-qubit Fourier transform using as registers the vibrational levels of the
$X^1\Sigma^+_g$ electronic state of Na$_2$. Raman-like transitions through the
$A^1\Sigma^+_u$ electronic state induce the transitions. Light fields are found
that are able to implement the Fourier transform within a picosecond time
scale. Such fields can be obtained by pulse-shaping techniques of a femtosecond
pulse. Out of the schemes studied the square modulus scheme converges fastest.
A study of the implementation of the $Q$ qubit Fourier transform in the Na$_2$
molecule was carried out for up to 5 qubits. The classical computation effort
required to obtain the algorithm with a given fidelity is estimated to scale
exponentially with the number of levels. The observed moderate scaling of the
pulse intensity with the number of qubits in the transformation is
rationalized.
