0
$\begingroup$

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?

$\endgroup$
  • 3
    $\begingroup$ In Mathematica, it is Transpose[A], not A' as in Matlab. Moreover, you might want to have a look at Nullspace. $\endgroup$ – Henrik Schumacher Jan 14 '19 at 10:49
  • 1
    $\begingroup$ 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. $\endgroup$ – Thies Heidecke Jan 14 '19 at 11:01
  • 2
    $\begingroup$ See the documentation. "For underdetermined systems, LinearSolve will return one of the possible solutions." {0,0,0} is a solution. $\endgroup$ – John Doty Jan 14 '19 at 15:51
  • $\begingroup$ 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. $\endgroup$ – m_goldberg Jan 14 '19 at 16:11
1
$\begingroup$

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

|improve this answer|||||
$\endgroup$

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