0
$\begingroup$

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[1][Sin[t ω]][t]^2, 
  2 Derivative[1][Cos[t ω]][t] Derivative[1][Sin[t ω]][
    t], 0}, {2 Derivative[1][Cos[t ω]][t] Derivative[1][
    Sin[t ω]][t], 2 Derivative[1][Cos[t ω]][t]^2, 
  0}, {0, 0, 0}}

unevaluated derivatives of known functions

tried forcing a reevaluation wrapping the result with Evaluate, but it doesn't seem to work

$\endgroup$
2
$\begingroup$

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

Mathematica graphics

Note I removed the [t] part from your expressions as that didn't make sense.

$\endgroup$
2
$\begingroup$

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}} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.