Using analytical derivatives for the stretching energy