4
$\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$
2
  • 3
    $\begingroup$ Maybe x = {x1, x2}; a = {8, -2}; b = {3, 3}; Solve[x + a == b, x] gives {{x1 -> -5, x2 -> 5}} $\endgroup$
    – Nasser
    Commented Sep 27, 2014 at 18:25
  • $\begingroup$ Really good solution, solves my problem. $\endgroup$ Commented Sep 27, 2014 at 18:39

1 Answer 1

7
$\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$
1
  • $\begingroup$ Perfect. Exactly the answer I was looking for. $\endgroup$ Commented Sep 27, 2014 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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