Differential equations and the Bethe ansatz