2

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?

orome
  • 12,819
  • 3
  • 52
  • 100

1 Answers1

2

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
orome
  • 12,819
  • 3
  • 52
  • 100