As soon as gradient_descent function is called, the for loop will iterate over the number of iterations passed to the range function, in this case 1,500. But I don’t understand where the arrows are pointing.

What is the gradient_function argument doing?

What is the cost_function argument doing?

Are these two arguments calling another function with global variables such as (x, y) and local variables such as (w, b), and the assigning those to the different variables? or I am missing something else.

The gradient_function() computes the gradients using the training set and the current values for the weights and bias. Its return values are the gradients.

The cost_function() computes the cost for the training set with the updated weights and bias. Its return value is the cost, which is used to create the cost history.

As you rightly noted, when the gradient_descent function is called, we pass compute_cost and compute_gradient arguments. These are the name of the global function we have already defined earlier in the notebook.

Now in the definition of the function, the arguments cost_function and gradient_function act as a pointer to the function whose name was passed when the function was called. So the argument cost_function basically points to the global function compute_cost , and the argument gradient_function points to the global function compute_gradient. So when inside the function gradient_descent, we call gradient_function or cost_function, we are essentially calling the global compute_cost and compute_gradient functions respectively.

We could have used any other meaningful name as well instead of cost_function and gradient_function.