A scalar function of a vector argument is a function that takes a vector as input and produces a scalar as output. The derivative of a scalar function with respect to a vector is a vector of the derivatives of the function with respect to each element of the vector. For a scalar function $f(\mathbf{x})$ where $\mathbf{x} = [x_1, x_2, …, x_n]^T$, the derivative is given by:
$$\nabla f(\mathbf{x}) = \left[\frac{\partial f}{\partial x_1}, \frac{\partial f}{\partial x_2}, …, \frac{\partial f}{\partial x_n}\right]^T$$
def scalar_function(v):
return np.sum(v)
v = np.array([1, 2, 3])
print(f"f({v}) = {scalar_function(v)}")