1
$\begingroup$

I am following the answer of Jens from following post: How do I simplify a vector expression?

vec /: Cross[vec[x_], HoldPattern[Cross[y__]]] := 

I want to create following identities (I use x to represent \[Cross] for readability):

vec[a]x(vec[b] x vec[c]) = (vec[a] x vec[b]) x vec[c] - (vec[a] x vec[c]) x vec[b]

(vec[a] x vec[b]) x vec[c] = vec[a] x (vec[b] x vec[c]) + (vec[a] x vec[c]) x vec[b]

but unable to make. I tried the following command Map[Cross[Cross[vec[x], #], #] &, Plus[y]] but in product it gives

vec[a]x(vec[b] x vec[c]) = (vec[a] x vec[b]) x vec[b] - (vec[a] x vec[c]) x vec[c]

Thanks in advance.

$\endgroup$
3
  • $\begingroup$ First of all you can't input a simple x-character and expect that to be the operator for cross product. $\endgroup$
    – Sascha
    Jan 30, 2016 at 13:39
  • $\begingroup$ Hi! I have shared the link of the an answer that I am following. I didn't copy the whole procedure as it might b bulky. I am sharing again here: Answer by Jens . Please look into first answer by Jens $\endgroup$
    – aly
    Jan 30, 2016 at 13:41
  • 1
    $\begingroup$ @aly I incorporated your comment into the body of the question, since the x was causing confusion. I think it's fine the way it is, but one thing to keep in mind is that people using the site usually have M running and can copy and paste ugly code into the front end to see it formatted nicely and have the syntax checked. The question is whether having the desired code with proper syntax is helpful to those who are interested in your question. It might seem so to some, I suppose. $\endgroup$
    – Michael E2
    Jan 30, 2016 at 13:52

1 Answer 1

2
$\begingroup$

To implement your first identity you can use:

vec /: Cross[vec[x_], Cross[vec[y_], vec[z_]]] := 
 Cross[Cross[vec@x, vec@y], vec@z] -Cross[Cross[vec@x, vec@z], vec@y]

Resulting in:

In[1] := vec[x]\[Cross](vec[y]\[Cross]vec[z])
Out[1] = (vec[x]\[Cross]vec[y])\[Cross]vec[z] - (vec[x]\[Cross]vec[z])\[Cross]vec[y]

The other identity is implemented similarly

$\endgroup$
3
  • $\begingroup$ Instead of Dot it will be cross. I changed it and works fine with me. Thanks gIS $\endgroup$
    – aly
    Jan 30, 2016 at 16:34
  • $\begingroup$ @aly of course! Sorry for the typo, Dot would not even make sense as it generates a scalar. $\endgroup$
    – glS
    Jan 30, 2016 at 16:35
  • $\begingroup$ @gIS: I extended your suggestion and trying to implement this vec /: Cross[Cross[vec[x_], vec[y_]], Cross[vec[x_], vec[z_]]] := Cross[vec@x, Cross[vec@y, Cross[vec@x, vec@z]]] - Cross[vec@y, Cross[vec@x, Cross[vec@x, vec@z]]] but it gives error "Tag vec in (vec[x_][Cross]vec[y_])[Cross](vec[x_][Cross]vec[z_]) \ is too deep for an assigned rule to be found." $\endgroup$
    – aly
    Jan 30, 2016 at 17:15

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.