  We proposed a method to engineer the light matter interaction while
initializing a qubit in presence of physical constraints utilizing the inverse
engineering. Combining the multiple degrees of freedom in the pulse parameters
with the perturbation theory, we developed pulses to initialize the qubit
within a tightly packed frequency interval to an arbitrary superposition state
with high fidelity. Importantly, the initialization induces low off-resonant
excitations to the neighboring qubits, and it is robust against the spatial
inhomogeneity in the laser intensity. We applied the method to the ensemble
rare-earth ions system, and simulations show that the initialization is more
robust against the variations in laser intensity than the previous pulses, and
reduces the time that ions spend in the intermediate excited state by a factor
of 17. The method is applicable to any systems addressed in frequency such as
NV centers, superconducting qubits, quantum dots, and molecular qubit systems.
