A curvilinear search algorithm for unconstrained optimization by automatic differentiation