Adaptation of a quantitative trait to a changing environment: new analytical insights on the asexual and infinitesimal sexual models