       Re: vector representation

• To: mathgroup at smc.vnet.net
• Subject: [mg82791] Re: vector representation
• From: David Bailey <dave at Remove_Thisdbailey.co.uk>
• Date: Wed, 31 Oct 2007 06:09:06 -0500 (EST)
• References: <fg6r8c\$e19\$1@smc.vnet.net>

```Vlad Luca wrote:
> Hi,
> Having the vector r(a,b,c) = {a i, b j, c k} where i, j, k are the unit vectors and a, b, c arbitrary coefficients, I want to calculate, for example r(1,2,1) etc. Also I want to be able to add 2 or more of such vectors trough their indexes, for example: r(0,0,1) + r(1,2,3) and the sum to be expressed like this r(1,2,4) and not like {1i, 2j, 4k}.
>
Mathematica lets you define your own notation, so you could manipulate
vectors represented as r[a,b,c] (note that you must use square brackets
here):

r /: r[a1_, b1_, c1_] + r[a2_, b2_, c2_] :=
r[a1 + a2, b1 + b2, c1 + c2]

r[1, 2, 3] + r[3, 4, 5]

(out) r[4, 6, 8]

However, I would use the standard notation for now until you get used to
Mathematica. The standard notation for a vector is a list.

David Bailey
http://www.dbaileyconsultancy.co.uk

```

• Prev by Date: ANN: Fixing polygon-based plots
• Next by Date: Re: Setting Negatives to Zero
• Previous by thread: Re: vector representation
• Next by thread: Problem with element and Maximize