# Unevaluated derivatives of known functions after replacement

I want to make the following replacement work correctly:

Array[(2 D[xM[[#1]][t], t] * D[xM[[#2]][t], t]) &, {3,
3}] /. {xM -> {Sin[ω t], Cos[ω t], 0}}


The array is constructed with a symbolic form given in terms of time derivatives of a vector. For some reason, when I evaluate this expression, I obtain the following:

{{2 Derivative[Sin[t ω]][t]^2,
2 Derivative[Cos[t ω]][t] Derivative[Sin[t ω]][
t], 0}, {2 Derivative[Cos[t ω]][t] Derivative[
Sin[t ω]][t], 2 Derivative[Cos[t ω]][t]^2,
0}, {0, 0, 0}} tried forcing a reevaluation wrapping the result with Evaluate, but it doesn't seem to work

You can do this with the Inactivate and Activate functions:

Inactivate[
Array[(2 D[xM[[#1]], t]*D[xM[[#2]], t]) &, {3, 3}],
D | Part
] /. {xM -> {Sin[ω t], Cos[ω t], 0}} // Activate Note I removed the [t] part from your expressions as that didn't make sense.

Also effective is

Unevaluated[Array[(2 D[xM[[#1]], t]*D[xM[[#2]], t]) &, {3, 3}]] /.
{xM -> {Sin[ω t], Cos[ω t], 0}}
(* {{2 ω^2 Cos[t ω]^2, -2 ω^2 Cos[t ω] Sin[t ω], 0},
{-2 ω^2 Cos[t ω] Sin[t ω], 2 ω^2 Sin[t ω]^2, 0},
{0, 0, 0}} *)