I am not able to obtain the gradient of a multivariate function using ForwardDiff, (Julia V.06) as shown in the code below:
using ForwardDiff
function f1(c1::Real,c2::Real,k1::Real,k2::Real,z::Real,σ::Real;β=0.99,α=0.33,ρ=0.95,η=0.01,ϵ=Normal())
1/c1-(β*α*exp(ρ*z+σ*η*ϵ)*(k2/c2))
end
c1=0.388
c1=0.388
k1=0.188
k1=0.188
z=0.
σ=0.
g=(c1,c2,k1,k2,z,σ)->ForwardDiff.gradient(f1,(c1,c2,k1,k2,z,σ))
g([c1,c2,k1,k2,z,σ])
The error message is the following: MethodError: no method matching (::##25#26)(::Array{Float64,1}) Closest candidates are: #25(::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at In[15]:15 Please, is there something missing or wrong in my code?