# Take overall minus sign in front in dot product with symbolic variables

I have the following as the output of a calculation

a.b+(-a).b


and I would like Mathematica to evaluate this to zero. Is there a way to specify that for my purposes (-a).b is the same as -(a.b)?

(I've been searching for a solution and tried a number of things but thought it would be better to keep my question clear and concise not to distract with irrelevant descriptions of my attempts solving it.)

• Try TensorExpand[a . b + (-a) . b] and report back. – J. M.'s ennui Jan 28 at 11:26
• That solves it! Thank you very much. If you want you can submit it as an answer such that I can accept it. – Alwin Jan 28 at 11:59
• Another way around: (a.b + (-a).b) /. (-x_).y_ :> -x.y returns zero. – Alexei Boulbitch Jan 28 at 13:11
• Thank you for this alternative, it also works well for my purposes. But could you tell me why you use the :> operator and not the -> operator in the ReplaceAll command? The normal arrow also works for this example. I see that in the documentation they moslty use the normal arrow and sometimes the colon-arrow, though without explanation. It seems that the colon version is more used to replace patterns and normal arrow to replace symbols, but this is also not generally true. – Alwin Jan 29 at 14:28