# 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. – hsmtta Mar 26 '19 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. – John Doty Mar 26 '19 at 18:32
• @JohnDoty I see. Thanks! – hsmtta Mar 26 '19 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. – hsmtta Mar 27 '19 at 13:34

There is a simple way to have things behave as you wish. Define your vector using Array (instead of trying to use an assumption:

aVec = Array[a, 3];
aVec + {1, 2, 3}
{1 + a[1], 2 + a[2], 3 + a[3]}

• Thanks! But can I archive the intended result by not defining the vector elements? As another post says, I don't want to define new variables... – hsmtta Mar 27 '19 at 13:51