# Why does LinearSolve return the transpose of the answer matrix?

I am trying to solve an equation of the form $dv=F\cdot dV$ where $dv$ and $dV$ are matrices derived from the row vectors $dx$, $dy$, $dz$ and $dX$, $dY$, $dZ$ respectively. If it helps, $F$ is the deformation gradient operating on material vectors to get spatial.

Problem setup:

dX = {1, 0, 0};
dY = {1, 1, 0};
dZ = {1, 1, 1};
dx = {1, 0, 0};
dy = {0, 1, 1};
dz = {0, 0, 1};

dV = {dX, dY, dZ};
dv = {dx, dy, dz};

F = Table[Subscript[Ff, i, j], {i, 1, 3}, {j, 1, 3}]
varList = Flatten[F]


Solutions:

I saw a video on Youtube where someone took the approach:

Solve[{F.dX == dX, F.dY == dy, F.dZ == dz}, varList]


I rewrote it as:

Solve[{Transpose[F].dV == dv}, varList]


But ultimately went with this approach:

LinearSolve[dV, dv] //Transpose


I knew to add the //Transpose after comparing the output with previous results so my question is whether there a logical reason why the result is transposed though I know that LinearSolve is meant to solve equations of the form $Ax=b$ for $x$ but in this case I am trying to solve for $A$, supplying $x$ and $b$ as arguments.

Please any pointers in the right direction would be greatly appreciated as I might not be able to visually inspect results in more complicated cases.

• Um, note that LinearSolve solves Ax==b. In your case, the equation is b==xA. Teake's solution solves the problem. – Grzegorz Rut Sep 14 '14 at 8:40
• Thanks @Gregory, I didn't quite catch that distinction :) – seyisulu Sep 14 '14 at 9:19

You have to be a bit careful here; your last approach does not give the desired matrix F:

(LinearSolve[dV, dv] // Transpose).dV === dv

False


Then what does give the correct output? We can use the fact that for generic matrices $A$ and $B$ we have $A.B = (B^T.A^T)^T$ and write

F = Transpose @ LinearSolve[Transpose @ dV, Transpose @ dv]


And indeed, we've now got the correct output:

F.dV === dv

True


Note whenever dV is invertible, you may also simply do

F = dv.Inverse[dV]


to get the same result.

• Thank you @Teake Nutma for your insightful answer. I will revise my work accordingly. – seyisulu Sep 14 '14 at 9:14