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

**URL:** https://discourse.julialang.org/t/forwarddiff-jl-does-not-throw-an-error-even-when-i-try-to-put-in-a-function-outputting-an-array-to-calculate-the-hessian/47899
**Category:** New to Julia
**Created:** [October 6, 2020, 10:52pm UTC](https://discourse.julialang.org/t/forwarddiff-jl-does-not-throw-an-error-even-when-i-try-to-put-in-a-function-outputting-an-array-to-calculate-the-hessian/47899 "2020-10-06T22:52:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sarthak\_Choudhury](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sarthak_choudhury/32/18593_2.png) [@Sarthak\_Choudhury](https://discourse.julialang.org/u/Sarthak_Choudhury)
#### Post date: [October 6, 2020, 10:52pm UTC](https://discourse.julialang.org/t/forwarddiff-jl-does-not-throw-an-error-even-when-i-try-to-put-in-a-function-outputting-an-array-to-calculate-the-hessian/47899/1 "2020-10-06T22:52:13Z")

</div>

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.

```julia
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)

---

<div class="post-metadata">

### Author: ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)
#### Post date: [October 7, 2020, 12:00am UTC](https://discourse.julialang.org/t/forwarddiff-jl-does-not-throw-an-error-even-when-i-try-to-put-in-a-function-outputting-an-array-to-calculate-the-hessian/47899/2 "2020-10-07T00:00:36Z")

</div>

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