# How do I solve for a vector-valued variable?

Is there a way specify the variables for Solve so that it can be used to solve for vector-valued variables?

For example I'd like to solve

$$(1,i)+v = 0$$

which it seems I can only do by solving for each of he components of $v$ explicitly with

Solve[{1,I}+{a,b}=={0,0},{a,b}]


since none of the likely alternative approaches work:

Solve[{1,I}+v=={0,0},{v}]
Solve[{1,I}+v=={0,0},{v},Vectors[2,Complexes]]
Solve[{1,I}+v=={0,0},{v},TensorProduct[Complexes,Complexes]]
Solve[{1,I}+v=={0,0}&&v\[Element]TensorProduct[Complexes,Complexes],{v}]


all fail to produce any solutions (and produce various errors).

Is there a way to solve directly for v without specifying components?

• @swish: Yes, thats what I'm asking: is there a way to solve for the vector, not it's components? So the answer is 'no'? – orome Sep 20 '17 at 13:38
• Note that {1, I} + v evaluates to {1+v, I+v}. Basically, you shouldn't mix symbolic and explicit arrays/tensors. – Carl Woll Sep 20 '17 at 14:44
• @CarlWoll: Good point. I've run into that before and it makes a mess of things. – orome Sep 20 '17 at 14:48

Perhaps not entirely satisfactory, but this

With[{v=Array[_,2]}, v/.First@Solve[{1,I}+v=={0,0},v]]


gives

{-1,-I}


In effect v=Array[_,2] serves to specify the domain of the solution as being vectors of length 2.

Even without the clever substitution, the result is meaningful:

With[{v=Array[_,2]},Solve[{1,I}+v=={0,0},v]]


gives

{{_[1]->-1,_[2]->-I}}


which is fairly easily understood, since once a solution, sol, is picked substitition works as expected:

Array[_,2] /. sol


Things git a bit more awkward though (and not all that different from specifying operate variables for each element) when more than one such vector is involved. In that case it is necessary to distinguish the elements:

With[{v=Array[v,2],w=Array[w,2]}, Solve[{1,I}+v=={0,0} && v+w=={0,0}, Flatten@{v,w}]]


and once a solution is picked the vectors no need to be distinguished by name, of course:

v = Array[v,2]/.sol
w = Array[w,2]/.sol