# How to add a vector variable to a vector value?

If we have a three dimensional vector variable:

\$Assumptions = a ∈ Vectors[3];


and a three dimensional vector value for example:

b = {1, 2, 3};


Then a + b evaluates to {1 + a, 2 + a, 3 + a}. We would expect the sum to generate a + {1, 2, 3}, because the elements of vector $$\mathbf{a}$$ are, as yet, unspecified. It looks Mathematica recognizes a as a scalars, which is not intended.

How can we get Mathematica to generate a + {1, 2, 3} as expected?

The behavior you're seeing is a consequence of the Listable attribute of Plus. This means that mixing explicit and symbolic vectors in arithmetic will not work correctly, and should be avoided.

Phrased another way: Since Plus is Listable, a + {1, 2, 3} will always evaluate to {1+a, 2+a, 3+a}. The only exceptions are when a evaluates to a List object, in which case it will thread, or issue a message if dimensions are incompatible. In other words, your desired endpoint will always evaluate further.

• Thank you for your answer, but why the replication is applied to a? It is assumed as a list, and the manual tells replication is applied only for that are not list. Commented Mar 26, 2019 at 18:29
• Specific assumptions apply to specific transformations. Plus doesn't apply any assumptions at all, it simply sees a as a symbol, and transforms the expression accordingly. It's only a list if it has the head List. Commented Mar 26, 2019 at 18:32
• @JohnDoty I see. Thanks! Commented Mar 26, 2019 at 18:54
• @CarlWoll Thank you so much for editing your answer. I completely understood how Mathematica recognizes and deals with a. Assuming object as a vectors is not equal to making list object! I hope Mathematica supports vector calculus which contains both explicit and symbolic vectors. Commented Mar 27, 2019 at 13:34

This is now possible in version 14.1 either by defining a with a VectorSymbol, which has an attribute NonThreadable:

ClearAll[a, b];

a = VectorSymbol["a"];
b = {1, 2, 3};

a + b
(* {1, 2, 3} + VectorSymbol["a"] *)


or directly giving a the NonThreadable attribute:

ClearAll[a, b];


aVec = Array[a, 3];