I have 4 known matrices:
- mA = 4x4 ->
{{-4, 1, 5, 0}, {1, -1, 1, 2}, {-1, 0, 1, 0}, {1, 17, 0, 1}}
- mB = 3x3 ->
{{-4, 7, 10}, {2, -1, 1}, {1, 0, 1}}
- mC = 4x3 ->
{{1, 2, 2}, {0, -1, 0}, {1, 0, 1}, {0, 0, 0}}
- mD = 4x3 ->
{{1, 2, 3}, {0, 0, 0}, {1, 0, 2}, {0, 0, -1}}
And one unknown:
- X = 4x3
I want to solve an equation for X in the form mA.X.B+C=D
. How can I do this in mathematica? I'm brand new to this language. =)
[EDIT] What I tried and my thought process:
- AXB+C=D -> AXB = D-C -> D-C=E
- AXB=E
- A^-1x(AXB)=A^-1xE
- I(XB)=A^-1xE
- XB=A^-1xE
matrixE = matrixD-MatrixC
invA = Inverse[matrixA]
right_equation = invA.matrixE
LinearSolve[matrixB, right_equation]
mX = Array[x, {4, 3}]; solution = mX /. First[Solve[(mA . mX . mB + mC) == mD]]
$\endgroup$Solve
finds the solution(s) and returns lists of lists of rules mapping x[i,j] to some number - in this case there's only one list of rules so we take theFirst
. ThemX /.
then takes themX
array of x[i,j] variables and applies those rules leaving you with just a 4x3 matrix of numbers. $\endgroup$