Optimal pulses for enhanced interferometer sensitivity and contrast