MathGroup Archive 2003

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

Search the Archive

RE: How to use vector analysis without using suffix notation

  • To: mathgroup at
  • Subject: [mg39561] RE: [mg39543] How to use vector analysis without using suffix notation
  • From: "David Park" <djmp at>
  • Date: Sun, 23 Feb 2003 05:00:16 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Shi Jin,

I am not certain of the exact meaning of your question. I am going to take
it as: Can we do derivations in vector algebra in Mathematica without
resorting to the list representation of vectors?

The answer is definitely yes, but you have to work at it and probably write
a lot of definitions and rules that implement the algebra in a symbolic

Here is an example for vector algebra. We are going to prove the vector
triple product identity, (u x v) x w == (u.w)v - (v.w) u. The following
proof was from the text "A Brief on Tensor Analysis" (p13) by James G.
Simmonds and follows his notation.

First, here is a little routine I find useful.

LinearBreakout::usage =
    "LinearBreakout[f1, f2,...][v1, v2,...][expr] will break out the linear
terms of any expressions within expr that have heads matching the patterns
fi \
over variables matching the patterns vj. Example:\n f[a x + b \
y]//LinearBreakout[f][x,y] -> a f[x] + b f[y]";
LinearBreakout[f__][vars__][expr_] :=
  expr //. {(g : Alternatives @@ {f})[p1___, a_ + b__, p2___] :>
        g[p1, a, p2] + g[p1, Plus[b], p2], (g : Alternatives @@ {f})[p1___,
          a_ b : Alternatives @@ {vars}, p2___] :> a g[p1, b, p2]}

Now we can implement the linear behavior of vectors under the Dot product.
Suppose that x and y are vectors. Then

(a x + b y).(c x + d y)
% // LinearBreakout[Dot][x, y]
(a x + b y).(c x + d y)
a c x.x + a d x.y + b c y.x + b d y.y

We supplied LinearBreakout with the symbols that were to be regarded as
vectors and everything else was treated as a scalar. To do the proof we
first need a Lemma. (At this point it would be useful to switch to
TraditionalForm by using menu\Cell\Default Output Format

Cross[u, v] . Cross[u, v]
Abs[Cross[u, v]]^2
% /. Abs[Cross[u, v]] -> Abs[u]*Abs[v]*Sin[\[Theta]]
% /. Sin[x_]^2 -> 1 - Cos[x]^2
% /. (Abs[u]*Abs[v]*Cos[\[Theta]])^2 -> (u . v)^2
lemma1 = Abs[Cross[u_, v_]]^2 -> %

The following code then sets out the derivation, complete with comments.

Print["The result must lie in the plane of u and v. A and B are scalar
step1 = Cross[Cross[u, v], w] == A[u, v, w]*u + B[u, v, w]*v
Print["So a dot product with w must be 0"]
(Distribute[#1 . w] & ) /@ step1
step2 = LinearBreakout[Dot][u, v][0 == %[[2]]]
Print["The following is also a general scalar function"]
ruleB = B[u, v, w] -> C[u, v, w]*u . w
  "Substitute and solve for A, Substitute in the initial expression, giving
step2 /. ruleB
ruleA = Solve[%, A[u, v, w]][[1,1]]
step3 = step1 /. {ruleA, ruleB}
Print["In the sepecial case when w \[Equal] u (step4)"]
step4 = step3 /. w -> u
Print["Taking the dot product of both sides with v"]
step5 = Simplify[(LinearBreakout[Dot][u, v][#1 . v] & ) /@ step4]
Print["Permuting the left hand side, simplifying and using lemma1."]
step5 /. Cross[a_, b_] . c_ -> Cross[b, c] . a
% /. x_Dot :> Sort[x] /. a_ . a_ -> Abs[a]^2
% /. lemma1
Solve[%, C[u, v, u]][[1,1]]
Print["Taking the dot product of both sides of step3 with u"]
step6 = Simplify[(LinearBreakout[Dot][u, v][#1 . u] & ) /@ step3]
Print["Permuting the left hand side."]
step7 = step6 /. Cross[a_, b_] . c_ -> -Cross[a, c] . b
Print["Substituting from step4 and solving for C."]
LinearBreakout[Dot][u, v][step7 /. Cross[Cross[u, v], u] -> Abs[u]^2*v - v .
% /. x_Dot :> Sort[x] /. a_ . a_ -> Abs[a]^2
Solve[%, C[u, v, w]][[1,1]]
Print["Therefore, substituting in step3..."]
step3 /. %%

I don't show the output because it is lenghtly and all in TraditionalForm,
but you should get it by pasting all the above code into a notebook and
evaluating. In a notebook I would close the Input cell so just the output
was visible.

In general, it should be possible to implement any kind of algebra in
symbolic form by writing definitions or rules that implement its axioms, and
perhaps by keeping a list of which symbols represent vectors or other
special entities in the algebra.

David Park
djmp at

From: Shi Jin [mailto:jinzishuai at]
To: mathgroup at

Hi there,

I want to derive some formula with Mathematica.
I need to use many vectors and tensors.
But it seems I have to define these vectors thru list, i.e., I have to
define velocity vector as
v={v1,v2,v3}, then Mathematica will know it is a vector.
Then when I need v, it will use the expanded component form {v1,v2,v3}
instead. This is a mess.
Is there a to write vectors in a neat way, just like we do on paper?
Thank you very much.

  • Prev by Date: RE: Programing in MATHEMATICA
  • Next by Date: Re: Re: Finding the closest number from a list
  • Previous by thread: How to use vector analysis without using suffix notation
  • Next by thread: Re: How to use vector analysis without using suffix notation