ForwardDiff.jl does not throw an error even when I try to put in a function outputting an array to calculate the Hessian

Hi everyone,

I am new to the forum and a complete beginner in Julia here. I am not sure if this is the correct category to post this doubt.
This might already be a redundant doubt if someone else has asked this but I was trying to use Forward Diff to calculate the Hessian and as the title suggests the documentation is clear that the function has to output a real number. It’s just that the Hessian outputs an array of Dual numbers if the function outputs an array and if the x at which it is evaluated is an array of dimension > 2. I might be missing something and attaching a MWE for reference.

using ForwardDiff

f(x)= [sum(x.^2 .+3)]
x0=rand(3,3,2)
H_12=ForwardDiff.hessian(f,x0)

I am working on Julia 1.4 and I have the latest version of ForwardDiff(v0.10.12)

1 Like

Hi, welcome to discourse!
indeed, weird behaviour, i can reproduce on julia 1.5.1