Closed
Description
Hi,
I'm working on a problem, which has a system of equations. I would like to get partial derivates of the whole system.
julia> using ForwardDiff
julia> f1(s) = (s/3)^2
f1 (generic function with 1 method)
julia> f2(s, l) = s^2 + exp(3*l/sqrt(4))
f2 (generic function with 1 method)
julia> function f(x)
return f1(x[1]) + f2(x[1], x[2])
end
f (generic function with 1 method)
julia> g = forwarddiff_gradient(f, Float64)
g (generic function with 1 method)
julia> g([0.1, 56.2])
ERROR: BoundsError: attempt to access 1-element Array{DualNumbers.Dual{Float64},
1}:
0.1+0.0du
at index [2]
in dual_fad at C:\Users\ovax03\.julia\v0.4\ForwardDiff\src\dual_fad\univariate_
range.jl:6
in g at C:\Users\ovax03\.julia\v0.4\ForwardDiff\src\dual_fad\univariate_range.j
l:22
Is there an error in my code or should I make a macro, which would derivate all the terms?