The gradient is an extension of the last section. The gradient of a function is a vector containing all its partial derivatives as its components.
In the following, we will write all components that the function depends on in a vector x=x1⋮xn.
∇f(x)=∂x1∂f(x)⋮∂xn∂f(x)
The implementation is basically the same as in the previous section, just with a loop.