https://cdanielaam.medium.com/optimization-partial-derivatives-and-gradients-for-multivariate-functions-f7691ce7b162