3
$\begingroup$

I made this very simple module to try and solve vector X:

Module[{a, b, x},
 a = {8, -2};
 b = {3, 3};
 Solve[x + a == b, x]
 ]

I get no output so I guess I am doing something wrong. Does anyone know how I can find the x and y value of vector x?

$\endgroup$
  • 3
    $\begingroup$ Maybe x = {x1, x2}; a = {8, -2}; b = {3, 3}; Solve[x + a == b, x] gives {{x1 -> -5, x2 -> 5}} $\endgroup$ – Nasser Sep 27 '14 at 18:25
  • $\begingroup$ Really good solution, solves my problem. $\endgroup$ – Christian Bill Pedersen Sep 27 '14 at 18:39
5
$\begingroup$

Mathematica doesn't realise you want x to be a vector, so you have to tell it what you want more precisely:

Module[{a, b, x, y}, a = {8, -2}; b = {3, 3}; 
 Flatten@({x, y} /. Solve[{x, y} + a == b, {x, y}])]

This gives as output:

 {-5, 5}
$\endgroup$
  • $\begingroup$ Perfect. Exactly the answer I was looking for. $\endgroup$ – Christian Bill Pedersen Sep 27 '14 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.