Finite differences: slow + error -> O(n) evaluations for n-dimensional gradient!
A) Finite differences
Expression swell: duplicated computation
B) Symbolic differentiation
C) Autodiff
def f(x1,x2):
a = x1 / x2
b = np.exp(x2)
return (np.sin(a) + a - b) * (a-b)