0

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?

ludo
  • 35
  • 9
  • ForwardDiff is looking for a function of one parameter which is an array. – Chris Rackauckas Aug 22 '17 at 15:01
  • @ChrisRackauckas Thanks for your swift reply. Please still not getting it solved. Any documentation link for ForwardDiff more explicit than: https://github.com/JuliaDiff/ForwardDiff.jl/blob/master/README.md ? – ludo Aug 22 '17 at 15:15
  • Click on the docs badge on the top of the repo. This page helps: http://www.juliadiff.org/ForwardDiff.jl/latest/user/api.html – Chris Rackauckas Aug 22 '17 at 15:24

0 Answers0