How to solve xA=B matrix which I need x
You did not give example of A
and B
A0 = {{1, 1, 3}, {2, 0, 4}, {-1, 6, -1}};
B0 = {{2, 19, 8}};
x = Transpose@LinearSolve[Transpose[A0], Transpose[B0]]
Verify in Matlab:
>> A=[1 1 3;2 0 4;-1 6 -1];
>> B=[2 19 8];
>> x=B/A
x =
1.000000000000000 2.000000000000000 3.000000000000000
Why this works? Because B/A is the same as (A'\B')' and \
is Mathematica's LinearSolve
Another example
A0={{1,2,3},{4,5,8},{9,8,7}};
B0={{1,3,4},{5,6,7}};
x=Transpose@LinearSolve[Transpose[A0],Transpose[B0]]//N
Matlab:
>> A=[1 2 3;4 5 8;9 8 7];
>> B=[1 3 4;5 6 7];
>> x=B/A
x =
2.550000000000000 -0.500000000000000 0.050000000000000
1.400000000000000 0 0.400000000000000
eqns = Thread /@
Thread[{{x1 + x2 + x3, 5 x1 + 6 x2 + 11 x3}, {y1 + y2 + y3,
5 y1 + 6 y2 + 11 y3}} == {{1, 0}, {0, 1}}] // Flatten
(* {x1 + x2 + x3 == 1, 5 x1 + 6 x2 + 11 x3 == 0, y1 + y2 + y3 == 0,
5 y1 + 6 y2 + 11 y3 == 1} *)
sol = Solve[eqns, {x1, x2, x3, y1, y2, y3}][[1]] //
Simplify // Quiet
(* {x2 -> 1/5 (11 - 6 x1), x3 -> 1/5 (-6 + x1), y2 -> 1/5 (-1 - 6 y1),
y3 -> (1 + y1)/5} *)
x1
and y1
are arbitrary
Verifying,
And @@ (eqns /. sol) // Simplify
(* True *)
For simplicity choose {x1 -> 0, y1 -> 0}
sol2 = {{x1 -> 0, y1 -> 0}, sol /. {x1 -> 0, y1 -> 0}} //
Flatten // SortBy[#, First] &
(* {x1 -> 0, x2 -> 11/5, x3 -> -(6/5), y1 -> 0, y2 -> -(1/5), y3 -> 1/5} *)
And @@ (eqns /. sol2)
(* True *)