1
$\begingroup$

I have a function that outputs a large expression containing dot products of vectors. None of the vector components are known, so all dot products are symbolic. For instance, part of the output may look like2(p1.q1)(p3.p2) + (p1.p2)^2.

I know what some of the dot products evaluate to. For example, I know things like:

p1.p1 = m
p1.p2 = 0

I want mathematica to simplify the expression as much as possible, making use of the known dot products and being sure to simplify all possible cancellation.

What is a good way to do this?

The way I am currently doing it is clunky and doesn't always work well. What I did was define a dot product function d[x,y] and then explicitly specified some of the dot products like d[p1,p2] = m and d[p1,p2] = 0. This became cumbersome because I constantly had to explicitly input commutitivity for each dot product (i.e. d[p1,p2] = d[p2,p1] = 0), and even when I did this, mathematica was not fully taking commutitivity into account when simplifying (via FullSimplify) my expression. Is there a better way?

$\endgroup$
  • 2
    $\begingroup$ To help you with your d function, you could SetAttributes[d,Orderless]. Then all you need to define is d[p1,p2]=m (shouldn't the m be squared?). Then d[p1,p2] and d[p2,p1] will automatically be replaced with m. $\endgroup$ – QuantumDot Nov 29 '14 at 23:00
  • $\begingroup$ I also suggest that you investigate the option TransformationFuntions that is given to Simplify to teach it to handle expressions involving your d function. $\endgroup$ – QuantumDot Nov 29 '14 at 23:02
  • $\begingroup$ The orderless attribute simplifies the code a lot, and Mathematica seems to have an easier time simplifying expressions after I added that. $\endgroup$ – user2397833 Nov 30 '14 at 20:15
1
$\begingroup$

You might formulate a list of rules that take into account the existing relations, such as the following. Assume there are 2 known relations p1.p2=mand p1.q1=s. The rules are as follows:

rules = {p1.p2 -> m, p2.p1 -> m, p1.q1 -> s, q1.p1 -> s};

Their application is straightforard:

    2 (p1.q1) (p3.p2) + (p1.p2)^2 /. rules

(*  m^2 + 2 s p3.p2   *)

Have fun!

$\endgroup$
1
$\begingroup$

TensorExpand knows about commutativity of vectors. So, one approach is to define UpValues for your known relations (in canonical order):

p1 /: p1.p1 = m;
p2 /: p1.p2 = 0;

Then, use TensorExpand on your expression with the assumption that your variables are vectors:

TensorExpand[
    2 (p1.q1) (p3.p2) + (p1.p2)^2,
    Assumptions->(p1|p2|p3|q1) ∈ Vectors[d]
]

2 p1.q1 p2.p3

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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