complex quantum algorithm