Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.2K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to solve for 4x4 Matrix? Solve[x.M==y]]

Posted 10 years ago

Hello,

I have two vectors:

x={{1},{1},{0},{0}} (*Input vector*)
y={{1},{-1},{0},{0}} (*Output vector*)

Is it somehow possible to let Mathematica solve the system for the 4x4 Matrix M?

The following solutions did not work:

x={{1},{1},{0},{0}} (*Input vector*)
y={{1},{-1},{0},{0}} (*Output vector*)
Solve[x.M==y]]
LinearSolve[M,y]    (*Whereas I know that this is not the proper way to use "Linearsolve"*)

Best regards

POSTED BY: Chris Smith
2 Replies

If you don't care for the general solution, but only need one, you can use FindInstance instead of Solve:

x = {1, 1, 0, 0};
y = {1, -1, 0, 0};
M0 = Array[m0, {4, 4}];
MatrixForm[M0] /. First@FindInstance[x.M0 == y, Flatten@M0, Integers]

The simplest single solution may be this:

MatrixForm[M0] /. First@Solve[x.M0 == y, Flatten@M0] /. m0[__] -> 0
POSTED BY: Gianluca Gorni

You can't in general. You have 4 equations and 16 unknowns. For your vectors, you can try

x = {1, 1, 0, 0} ;(*Input vector*)
y = {1, -1, 0, 0};
M0 = Array[m0, {4, 4}]; (*make some 4 by 4 matrix *)
sol = Thread[x.M0 == y]; (*make 4 equations*)
var = DeleteDuplicates@Cases[sol, _m0, Infinity];
Reduce[sol, var]
(*m0[2, 1] == 1 - m0[1, 1] && m0[2, 2] == -1 - m0[1, 2] &&  m0[2, 3] == -m0[1, 3] && m0[2, 4] == -m0[1, 4]*)

If you try Solve, you'll get

 Solve[sol, var]
 Solve::svars: Equations may not give solutions for all "solve" variables. >>

For general case,

ClearAll[a, b, c, d, e, f, g, h, m0]
x = {a, b, c, d} ;(*Input vector*)
y = {e, f, g, h};
M0 = Array[m0, {4, 4}];
sol = Thread[x.M0 == y];
var = DeleteDuplicates@Cases[sol, _m0, Infinity]
Solve[sol, var]
Solve::svars: Equations may not give solutions for all "solve" variables. >>
{{m0[4, 1] -> e/d - (a m0[1, 1])/d - (b m0[2, 1])/d - (c m0[3, 1])/d, 
  m0[4, 2] -> f/d - (a m0[1, 2])/d - (b m0[2, 2])/d - (c m0[3, 2])/d, 
  m0[4, 3] -> g/d - (a m0[1, 3])/d - (b m0[2, 3])/d - (c m0[3, 3])/d, 
  m0[4, 4] -> h/d - (a m0[1, 4])/d - (b m0[2, 4])/d - (c m0[3, 4])/d}}
POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard