Gradient descent algorithm applied to wavefront retrieval from through-focus images by an extreme ultraviolet