# What is going wrong when I try to solve a simple linear equation? [closed]

I'm trying to understand how does the LinearSolve function works. I'm trying it out like this:

A'


{{2, 1, 1}, {3, 1, 3}, {3, 2, 0}}

A' . {-2, 3, 1}


{0, 0, 0}

LinearSolve[A', {0, 0, 0}]


{0, 0, 0} (* <- Here I'd like to have {-2, 3, 1} *)

As the answer I was expecting to get {-2, 3, 1}, but I got {0, 0, 0} instead. Could someone explain to me why it works like this?

• In Mathematica, it is Transpose[A], not A' as in Matlab. Moreover, you might want to have a look at Nullspace. – Henrik Schumacher Jan 14 '19 at 10:49
• Additionally to what Henrik wrote, you can use a shorthand notation to get the postfix operator form of Transpose by entering Escape tr Escape, see here under Examples->Basic Examples. This has a very similar look as the MATLAB version. – Thies Heidecke Jan 14 '19 at 11:01
• See the documentation. "For underdetermined systems, LinearSolve will return one of the possible solutions." {0,0,0} is a solution. – John Doty Jan 14 '19 at 15:51
• I'm voting to close this question as off-topic because the issue it raises is not really a Mathematica issue but a matter of the OP not having grasped the relavant mathematics. – m_goldberg Jan 14 '19 at 16:11

While it is true, that {-2, 3, 1} is a solution of a.{x, y, z} == {0, 0, 0}, it is only one of an infinite number of solutions. {0, 0, 0 is also a solution and therefore, a valid result. To get the set of solutions for your system use Reduce.

a = {{2, 1, 1}, {3, 1, 3}, {3, 2, 0}};
sol = Reduce[a.{x, y, z} == {0, 0, 0}, {x, y, z}]


y == -((3 x)/2) && z == -(x/2)

sol /. x -> 0


y == 0 && z == 0

sol /. x -> -2


y == 3 && z == 1