I'm starting to learn a bit about gradient descent, and that method attempts to minimize the cost function. I've seen examples using linear regression, and the corresponding cost function, but now I'm wondering, given an arbitrary function $g(x)$ which computes an output $y$, will the cost function to use for gradient decent always be:
$$y_{k} - g(x_{k})$$
resulting in the gradient descent of
$$y_{k+1} = y_{k} - {d \over dx} g(x_{k})$$