I have this set of equations (the Hamilton ray equations) which is the partial derivative of vector x with respect to t equal to the negative derivative of some function D and vise versa. An example function D is shown below
function D(x::AbstractVector,k::AbstractVector)
-k.*k - x
end
In julia I implemented this the gradients of D as:
∂D∂k(x,k) = ForwardDiff.gradient(D(x,k),k)
∂D∂x(x,k) = ForwardDiff.gradient(D(x,k),x)
but when I call ∂D∂x(x,k) with some vectors x and k, I get
MethodError: objects of type Vector{Float64} are not callable
Use square brackets [] for indexing an Array.
Is it only possible to implement piece-wise (i.e not vectorially) or am I missing some syntax?
Thanks in advance and kind regards
I was expecting a vector output, not an error