MathGroup Archive 2003

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

Search the Archive

RE: Simplification of vector and scalar products

  • To: mathgroup at
  • Subject: [mg39647] RE: [mg39613] Simplification of vector and scalar products
  • From: "David Park" <djmp at>
  • Date: Thu, 27 Feb 2003 00:28:34 -0500 (EST)
  • Sender: owner-wri-mathgroup at


Here is a routine I posted last week that is helpful for such calculations.

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 //.\[InvisibleSpace]{(g : (Alternatives @@ {f}))[p1___, a_ + b__,
          p2___] :>
        g[p1, a, p2] + g[p1, +b, p2], (g : (Alternatives @@ {f}))[p1___,
          a_ b : (Alternatives @@ {vars}), p2___] :> a g[p1, b, p2]}

Here are some examples. If we want our expression to be Linear in Cross with
respect to vectors a and b: (I'm pasting in Mathematica's InputForm but with
StandardForm these would display with the cross symbol and look better.)

6*Cross[a/2, b]
LinearBreakout[Cross][a, b][%]


6*Cross[a/2, b]
3*Cross[a, b]

For a dot product...

6 (a/2).b
% // LinearBreakout[Dot][a, b]


6*(a/2) . b
3 a.b

Here is an example with a cross product where x and y are the vectors. I
have added some other rules to simplify the expression.

Cross[a*x + b*y, c*x + d*y]
LinearBreakout[Cross][x, y][%]
% /. Cross[x_, x_] -> 0
Simplify[% /. Cross[x_, y_] /;  !OrderedQ[{x, y}] :>
    -Cross[y, x]]


Cross[a*x + b*y, c*x + d*y]
a*c*Cross[x, x] + a*d*Cross[x, y] + b*c*Cross[y, x] +
  b*d*Cross[y, y]
a*d*Cross[x, y] + b*c*Cross[y, x]
((-b)*c + a*d)*Cross[x, y]

David Park
djmp at

From: John Stokes [mailto:john at]
To: mathgroup at

I want to simplify vector and scalar products as for instance

       6 (a / 2) x b  //Simplify

where a and b are assumed to be vectors and "x" is the vector product..
Simplify and FullSimplify do nothing, nor does the following command
change anything:

       6 (a / 2) x b  /. p_ Cross[a_ / q_ , b_] => p Cross[a, b] / q

The simplification is only performed when explicit numbers are introduced:

       6 (a / 2) x b  /. 6 Cross[a_ / 2 , b_] => 6 Cross[a, b] / 2

thus giving the result

       3 a x b

How do I proceed?

John Stokes

  • Prev by Date: Re: Area Between Contours in ContourPlot
  • Next by Date: Re: Why Plot cannot run under package?
  • Previous by thread: Re: Simplification of vector and scalar products
  • Next by thread: Area Between Contours in ContourPlot