Gradient of the Cost Function Via the Adjoint Method for Underwater Acoustic Inversion