Mixed partials

Suppose that I have a scalar function of multiple variables, e.g., z = f(x,y)

How can I compute mixed partials using ForwardDiff? E.g., suppose that I want


The case for the hessian, it is clear, e.g.,


You can use ForwardDiff.hessian for this.

julia> using ForwardDiff

julia> f(x, y) = (x + 2y)^2 * (x - y)
f (generic function with 1 method)

julia> ForwardDiff.hessian(((x, y),) -> f(x,y), [1,2])
2×2 Matrix{Int64}:
 18    6
  6  -48