1
$\begingroup$
(a[1]^2 + a[2]^2 + a[3]^2) /. {{a[1], a[2], a[3]} -> Normalize[{1, 2, 3}]}

I would like to replace each a[i] accordingly.

$\endgroup$
  • $\begingroup$ you mean (a[1]^2 + a[2]^2 + a[3]^2) /. a[i_] :> Normalize[a[i]]? $\endgroup$ – kglr Dec 30 '17 at 0:02
  • $\begingroup$ .. or (a[1]^2 + a[2]^2 + a[3]^2) /. Thread[{a[1], a[2], a[3]} -> Normalize[{1, 2, 3}]] ? $\endgroup$ – kglr Dec 30 '17 at 0:03
  • $\begingroup$ @kglr Thank you. $\endgroup$ – Phillip Dukes Dec 30 '17 at 0:10
  • $\begingroup$ Philip, my pleasure. By to replace each a[i] accordingly, do you mean a[i_] :> Normalize[a[i]] or Thread[{a[1], a[2], a[3]} -> Normalize[{1, 2, 3}]]? $\endgroup$ – kglr Dec 30 '17 at 0:14
  • $\begingroup$ @kglr I needed the latter. $\endgroup$ – Phillip Dukes Dec 30 '17 at 0:53
3
$\begingroup$
(a[1]^2 + a[2]^2 + a[3]^2) /. Thread[{a[1], a[2], a[3]} -> Normalize[{1, 2, 3}]]

1

$\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.