1
$\begingroup$

This question already has an answer here:

I want to get the Norm of a vector which involves sines and cosines (So I really need to replace it by the Pythagorean theorem). Since I know that all my results are going to be real and positive I don't care about the Abs before squaring the terms.

How can I get $$ \sqrt{ r_x ^ 2 + r_y ^ 2 + r_z ^ 2 }$$

Instead of: $$ \sqrt{ |r_x| ^ 2 + |r_y| ^ 2 + |r_z| ^ 2 }$$

$\endgroup$

marked as duplicate by Michael E2, C. E., Bob Hanlon, J. M. will be back soon Apr 17 '17 at 4:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ Sqrt[vec.vec] where vec is your vector. . in Mathematica is the dot product. $\endgroup$ – C. E. Apr 16 '17 at 19:34
  • $\begingroup$ @C.E. Thanks! I was doing it with loops but I didnt expect such elegant solution! Could you add it as an answer please? $\endgroup$ – Joshua Salazar Apr 16 '17 at 19:41
  • $\begingroup$ Norm[vec] // ComplexExpand $\endgroup$ – Bob Hanlon Apr 16 '17 at 21:54
4
$\begingroup$

That expression is the square root of the dot product of the vector by itself:

Sqrt[vec.vec]

where vec is your vector.

$\endgroup$

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