0
$\begingroup$

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.

ϵ^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)
$\endgroup$
2
  • $\begingroup$ 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 $\endgroup$
    – rm -rf
    Commented Jan 29, 2013 at 18:44
  • $\begingroup$ Perhaps this is of interest. $\endgroup$
    – Jens
    Commented Jan 29, 2013 at 20:37

1 Answer 1

2
$\begingroup$
ϵ^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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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