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.

What rule can you think of to replace the first line by the second?

Mathematica graphics

Mathematica graphics

I have a bunch of expression like these, which I would like to simplify. All dependent cross terms must be written in the same order, using $\epsilon^{i j} A_i \times B_j = \epsilon^{i j} B_i \times A_j $.

The other expressions look like this, but there are a few differences:

  • The names of the fields in the crossproduct differ; e.g. $e_{2 i}$ and $\omega_{2 i}$ instead of $e_{1 i}$ and $e_{2 i}$
  • The sum can contain more terms. In particular it can contain more cross products
  • Terms that are dependent may not appear right after each other in the sum

Which rule would cover all such expressions?

This is the input for the first line.

\[Epsilon]^ij*((\[Sigma]*Cross[Subscript[Subscript[e, 1], i], Subscript[Subscript[\[Omega], 1], j]]*Subscript[M, 1])/4 + (\[Sigma]*Cross[Subscript[Subscript[\[Omega], 1], i], Subscript[Subscript[e, 1], j]]*Subscript[M, 1])/4)
share|improve this question
    
The only correct answer is to not use replacement rules and instead do it mathematically. Also, ditch the subscripts. Possible duplicate: mathematica.stackexchange.com/q/3463/5 –  rm -rf Jan 29 '13 at 18:44
    
Perhaps this is of interest. –  Jens Jan 29 '13 at 20:37
add comment

1 Answer

up vote 2 down vote accepted
ϵ^ij*((σ*Cross[Subscript[Subscript[e, 1], i], Subscript[Subscript[ω, 1], j]]*Subscript[M, 1])/4 +
     (σ*Cross[Subscript[Subscript[ω, 1], i], Subscript[Subscript[e, 1], j]]*Subscript[M, 1])/4 +
     (σ*Subscript[Subscript[e, 1], j]*Subscript[M, 1]*Subscript[P, 1])/2) /. 
 {Cross[Subscript[A_, i_], Subscript[B_, j_]] /; OrderedQ[{B, A}] :> 
   Cross[Subscript[B, i], Subscript[A, j]]}

(* ϵ^ij (1/ 2 σ Subscript[Subscript[e, 1], i]\[Cross]Subscript[Subscript[ω, 1], j] Subscript[M, 1] + 
   1/2 σ Subscript[M, 1] Subscript[P, 1] Subscript[Subscript[e, 1], j]) *)

It gives the right answer to your first question. You can check the second. Ditching the subscripts is good advice, too. You can use Format if you want subscripts in the output.

share|improve this answer
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.