Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Oh why is life never easy? Need help with |vector|

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2798] Re: Oh why is life never easy? Need help with |vector|
  • From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
  • Date: Sun, 17 Dec 1995 02:08:39 -0500
  • Organization: University of Colorado, Boulder

In article <4ar5ut$2hq at dragonfly.wri.com>,
ULI WORTMANN <ULI12 at HOMER.geol.chemie.tu-muenchen.de> wrote:
>Hi All,
>
>I need to calculate v0 = v / |v| where v is a vector of size 3.
>However, |v|, which is a scalar, is for some reason (I don't
>understand) treated like a vector (at least VectorQ[|v|] gives
>TRUE). Obviously, it is impossible to divide two vectors of different
>length. 
>
> |v| is defined as:
>	absvec[u_] :=
>		Module[{a},
>		{a = Sqrt[(u[[1]]^2+u[[2]]^2+u[[3]]^2)]}]

The problem is that the body of your calculation is wrapped in list
braces, so the result comes back wrapped in list braces, which is
a vector of length 1.

Anyway, a much better way to calculate the magnitude of a vector is
like this:

    absvec[u_] := Sqrt[Plus @@ (u^2)]

This function works on vectors of any length.

		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at princon.com
		http://www.princon.com/princon



  • Prev by Date: Re: math notebook on sgi doesn't work ???
  • Next by Date: ParametricPlot3D, color with function ?
  • Previous by thread: Re: Oh why is life never easy? Need help with |vector|
  • Next by thread: Re: Oh why is life never easy? Need help with |vector|