Another issue I have with Mathematica today is that I want to solve the following matrix equation:
X.b=c
where b and c are two vectors, and X is a square matrix. How can I use LinearSolve to find X ? Or another function?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityTake the 2 by 2 case: {{a11,a12},{a21,a22}}.{x1,x2}={b1,b2}
. If x
and b
are known and a
is unknown, you can reformulate the problem to look like this: {{x1,x2,0,0},{0,0,x1,x2}}.{a11,a12,a21,a22}={b1,b2}
. Now it is in the form where you can apply Solve
or LinearSolve
to find the a
. Of course the answer will not be unique. In this case an answer is
x = {{x1, x2, 0, 0}, {0, 0, x1, x2}};
a = {a11, a12, a21, a22};
b = {b1, b2}
LinearSolve[x, b]
{b1/x1, 0, b2/x1, 0}
or more generally:
Solve[x.a == b, a]
{{a12 -> b1/x2 - (a11 x1)/x2, a22 -> b2/x2 - (a21 x1)/x2}}
Solve
gives a warning, letting you know that this answer is not unique.
c/b
. $\endgroup$