Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can I do vector calculations without telling Mathematica the vector entries?

I have very many arbitrary linear combinations in $\mathbb{R}^3$ which I want to perform some general calculations on (scalar and vector products) and want to use Mathematica to do this (especially for simplifying stuff like very long equations with scalar prodcuts of vector products).

So, I don't want to write for all my vectors stuff like v1={a1,b1,c1} ... vN={aN,bN,cN} and so on, but just want to say v1 ... vN are vectors.

How is this possible?

share|improve this question
    
You can start here. –  Szabolcs May 24 '13 at 19:31
    
You can always generate stuff like v1={a1,b1,c1} by defining a function, if you don't want to specify this manually. –  mmal May 24 '13 at 19:34
add comment

2 Answers

up vote 10 down vote accepted

Assuming that we have three-dimensional real vectors :

$Assumptions = (u | v | w) ∈ Vectors[3, Reals];

we can use e.g. various tensor functions (new in ver. 9) e.g. TensorReduce to reduce (simplify) a tensor expression, e.g.

TensorReduce[ v.v + w.w - (v + w).(v + w) ]
TensorReduce[u \[Cross] (v \[Cross] w) ]
-2 v.w
-w u.v + v u.w

We can perform more interesting reductions, let's show e.g. the Jacobi identity:

TensorReduce[ u \[Cross] (v \[Cross] w) + v \[Cross] (w \[Cross] u) + 
              w \[Cross] (u \[Cross] v) ]
0

or write it in a traditional form:

Defer[   u \[Cross] (v \[Cross] w) + v \[Cross] (w \[Cross] u)
       + w \[Cross] (u \[Cross] v)] == 
TensorReduce[   u \[Cross] (v \[Cross] w) + v \[Cross] (w \[Cross] u)
              + w \[Cross] (u \[Cross] v) ] // TraditionalForm

enter image description here

Another common identity

TensorExpand[ (u \[Cross] v) \[Cross] (u \[Cross] w) ]
TensorExpand[ (u \[Cross] v).(u \[Cross] v) ]
u u \[Cross] v . w
-(u.v)^2 + u.u  v.v

Take a look at new differential operators:

Curl[ Curl[ f[x, y, z], {x, y, z}], {x, y, z}] == Laplacian[ f[x, y, z], {x, y, z}]
True
share|improve this answer
1  
+1 nice use of new feature of mma9. –  chris May 25 '13 at 9:13
add comment

@Szabolcs is right, use Symbolic Tensors. But in that link it may be a bit confusing to find what you want. There are good examples on 3D vector operations. Read:

For example, proving an identity:

a\[Cross](b\[Cross](c\[Cross]d)) == b a.(c\[Cross]d) - (a.b) c\[Cross]d // TensorExpand

True

Or expanding something very long:

((a\[Cross]b).c)^4 // TensorExpand

(a.c)^4 (b.b)^2 - 4 a.b (a.c)^3 b.b b.c + 4 (a.b)^2 (a.c)^2 (b.c)^2 + 2 a.a (a.c)^2 b.b (b.c)^2 - 4 a.a a.b a.c (b.c)^3 + (a.a)^2 (b.c)^4 + 2 (a.b)^2 (a.c)^2 b.b c.c - 2 a.a (a.c)^2 (b.b)^2 c.c - 4 (a.b)^3 a.c b.c c.c + 4 a.a a.b a.c b.b b.c c.c + 2 a.a (a.b)^2 (b.c)^2 c.c - 2 (a.a)^2 b.b (b.c)^2 c.c + (a.b)^4 (c.c)^2 - 2 a.a (a.b)^2 b.b (c.c)^2 + (a.a)^2 (b.b)^2 (c.c)^2

share|improve this answer
    
How can I add Real prefactors to the vectors with TensorExpand? –  Foo Bar May 24 '13 at 19:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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