Hello!
I've encountered a problem with loss of pattern information after using "function-producing" Derivative
function.
Assume I have a scalar-valued function defined on vectors:
H[r_?VectorQ] := r.r
(evidently, r
is assumed to be a three-dimentional vector, but id does not matter)
And then I would like to solve a differential equation like dr / dt == grad(H). Note that I would like to keep the vectorial notation i.e. the solution must be a vector-valued function. I've tried the following:
NDSolveValue[{D[r[t], t] == Table[Derivative[xspec][H][r[t]], {xspec, IdentityMatrix[3]}],
r[0] == {1, 1, 1}}, r, {t, 0, 100}]
This returns an interpolated function, but it does not handle the derivatives of H
properly. For example, if in the output of Derivative
appeared term like #1[[1]]
then it accepts r[t]
as argument and evaluates simply to t
and if there's #1[[2]]
it throws a message that this part does not exist. It seems like Derivative
loses argument check and the returned function does not formally require vectorial input anymore.
So, the question is: can I somehow tell WL that this derivative is still a function of a vector?