MathGroup Archive 2007

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

Search the Archive

Re: vector representation

  • To: mathgroup at
  • Subject: [mg82791] Re: vector representation
  • From: David Bailey <dave at>
  • Date: Wed, 31 Oct 2007 06:09:06 -0500 (EST)
  • References: <fg6r8c$e19$>

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}.
> Thank You in advance!
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 

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

  • 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