Message Boards Message Boards

Solve a linear system M x = S ?

Posted 7 years ago

I have these two matrices

M = {{q^2, 0, q, 0, 0, 0, 0, 0}, {0, q^2, 0, q, 0, 0, 0, 0}, 
{q, -q, 1, -1, 0, 0, 0, 0}, {0, 0, 0, 0, 1, -1, q, q}, {0, 0, q, -q, 0, 0, 0, 0}};

S := {c1, c2, 0, 0, c1 - c2};

I am trying to solve the linear system M x=S by writing the following

LinearSolve[M, S];

First q,c1,c2 are real quantities. Mathematica is replying to me the following: LinearSolve::nosol: Linear equation encountered that has no solution. This is clearly an admissible answer. However when c1 and c2 are zero, then there is for sure a solution. It is the vector (0,0,0,0,0,0,0,0). I tried to change the parameters c1 and c2 and LinearSolve provides me solutions sometme. This means that Mathematica manages quite well the not defined values q,c1,c2.

My question is: Where am I wrong? How can I lead the software to be more precise for his output? Is The set of solutions really null (except for some trivial cases)?

Thanks very Much for your attention. Francesco

You can turn it into explicit equations and let Reduce or `Solve try to sort out conditions for existence of solutions.

mat = {{q^2, 0, q, 0, 0, 0, 0, 0}, {0, q^2, 0, q, 0, 0, 0, 0}, {q, -q, 1, -1, 0, 0, 0, 0},
 {0, 0, 0, 0, 1, -1, q, q}, {0, 0,  q, -q, 0, 0, 0, 0}};
rhs = {c1, c2, 0, 0, c1 - c2};
vars = Array[x, Length[mat[[1]]]];

Solve[mat.vars == rhs, Join[vars, Variables[rhs]]]

(* During evaluation of In[53]:= Solve::svars: Equations may not give solutions for all "solve" variables.

Out[53]= {{x[2] -> x[1], x[4] -> x[3], 
  x[8] -> -(x[5]/q) + x[6]/q - x[7], c1 -> q^2 x[1] + q x[3], 
  c2 -> q^2 x[1] + q x[3]}} *)
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract