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

d^2f/dxdy

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

d^2f/dx^2

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