A matrix function of a scalar argument is a function that takes a scalar as input and produces a matrix as output. The derivative of a matrix function with respect to a scalar is computed element-wise. For a matrix function $\mathbf{F}(x)$, the derivative is given by:
$$\frac{d\mathbf{F}}{dx} = \begin{bmatrix} \frac{dF_{11}}{dx} & \cdots & \frac{dF_{1n}}{dx} \ \vdots & \ddots & \vdots \ \frac{dF_{m1}}{dx} & \cdots & \frac{dF_{mn}}{dx} \end{bmatrix}$$
def matrix_function(x):
return np.array([[x, x**2], [x**3, x**4]])
x = 2
print(f"F({x}) = {matrix_function(x)}")