Don't use delayed definition := when the rhs contains D
or Integrate
that need to act on a symbolic variable. Do immediate definition:
Clear[t];
v[t_] = D[Sin[t], t]
v[1]
compared with
Clear[v];
v[t_] := D[Sin[t], t]
v[1]
When you do delayed definition and call v[1]
, the variable t
is replaced with 1
BEFORE the derivative is evaluated, resulting in D[Sin[1],1]
, which does not make sense.
An analogy: take the derivative d (x^2)/(d x)
in Leibniz notation. You need the value for x=1
. What you must not do is to replace x
with 1
in the notation: d (1^2)/(d 1)