Cost function is a way to evaluate the performance of the model/algorithm. So if the predicted values differ a lot from the actual values then this cost function will be high. This also indicates that the algorithm is not performing well, or not learning well from the data.
While Gradient descent is used for finding a local minimum, it is an optimization algorithm used to train machine learning models and neural networks.
Gradient descent helps to find the best parameters that minimize the model’s cost function.