0
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ Of course I read the documentation. LinearSolve[m,b] solves an equation of the form m.X=b , where X is your unknown matrix. The above equation has the left hand side switched, it's the only way a square matrix can be multiplied with a vector. Thus, I need to somehow modify LinearSolve. $\endgroup$ – PhysNerd90 Nov 14 '14 at 14:07
  • $\begingroup$ the m in the docs is not the unknown. reference.wolfram.com/language/ref/LinearSolve.html $\endgroup$ – PhysNerd90 Nov 14 '14 at 14:15
  • 2
    $\begingroup$ You're right, I didn't read carefully. But the problem you state doesn't make a lot of sense. For an $n\times n$ matrix you only have $n$ equations but $n^2$ unknowns. So there are infinitely many solutions. There's always a trivial solution in the form of a diagonal matrix. The diagonal entries will just be c/b. $\endgroup$ – Szabolcs Nov 14 '14 at 14:54
5
$\begingroup$

Take 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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you so much for your help, works great. $\endgroup$ – PhysNerd90 Nov 17 '14 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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