Group Abstract Group Abstract

Message Boards Message Boards

Solving a system of linear equations with a parameter.

Posted 1 year ago

I'm trying to solve the following system of linear equations, to determine in which cases it has unique solutions, no solution, or infinitely many solutions. When there are infinitely many solutions, I have been asked to represent all the solutions using a basic solution set.

The system of equations is:

x1 - 3 x2 + 2 x3 + x4 =0, 
2 x1 - 5 x2 + 3 x3 - x4 = 1,
x1 - 3 x2 + 2 x3 + x4 = lambda

I'm planning to solve this using Mathematica.

I've tried as follows, but in vain:

In[29]:= Solve[{x1 - 3 x2 + 2 x3 + x4 == 0, 
  2 x1 - 5 x2 + 3 x3 - x4 == 1, x1 - 3 x2 + 2 x3 + x4 == lambda}, {x1,
   x2, x3, x4}]

Out[29]= {}

In[13]:= M = {{1, -3, 2, 1}, {2, -5, 3, -1}, {1, -3, 2, 1}};
B = {0, 1, \[Lambda]};
LinearSolve[M, B]

During evaluation of In[13]:= LinearSolve::nosol: Linear equation encountered that has no solution.

Out[15]= LinearSolve[{{1, -3, 2, 1}, {2, -5, 3, -1}, {1, -3, 2, 
   1}}, {0, 1, \[Lambda]}]

In[16]:= Solve[M . {x1, x2, x3, x4} == B, {x1, x2, x3, x4}]

Out[16]= {}

Can I seek your guidance on how to proceed with representing solutions for all possible scenarios using Mathematica?

Thanks in advance for your help.

Regards,
Zhao

POSTED BY: Hongyi Zhao
4 Replies
Posted 1 year ago

Then, I tried to use LinearSolve to find the general form of the solution set, but only got a particular solution:

In[86]:= M = {{1, -3, 2, 1}, {2, -5, 3, -1}, {1, -3, 2, 1}};
B = {0, 1, \[Lambda]};
(*\[Lambda] !=0, in this case, there is no solution*)
augM = Join[M // Transpose, {B}] // Transpose;
% // RowReduce

Out[89]= {{1, 0, -1, -8, 0}, {0, 1, -1, -3, 0}, {0, 0, 0, 0, 1}}

(*\[Lambda]=0, in this case, there are infinite solutions.*)
augM1 = augM /. \[Lambda] -> 0 // RowReduce;
M1 = augM1[[1 ;; 2, 1 ;; 4]];
B1 = augM1[[1 ;; 2, 5]];
LinearSolve[M1, B1]
M1 . % == B1

Out[84]= {3, 1, 0, 0}

Out[85]= True

Regards, Zhao

POSTED BY: Hongyi Zhao

Reduce will give you more details than Solve:

Reduce[{x1 - 3 x2 + 2 x3 + x4 == 0,
  2 x1 - 5 x2 + 3 x3 - x4 == 1,
  x1 - 3 x2 + 2 x3 + x4 == lambda},
 {x1, x2, x3, x4}]
POSTED BY: Gianluca Gorni
Posted 1 year ago

Nice. Thank you for your tip.

POSTED BY: Hongyi Zhao
Posted 1 year ago

First look at two of your equations

x1 - 3 x2 + 2 x3 + x4 = 0, 
x1 - 3 x2 + 2 x3 + x4 = lambda

The only way for both those equations to be true is if

lambda = 0

That leaves you with two equations and four unknowns

  x1 - 3 x2 + 2 x3 + x4 = 0, 
2 x1 - 5 x2 + 3 x3 - x4 = 1

You can uniquely solve for any two of those variables in terms of the other two variables.

That seems to represent all possible scenarios unless there are one or more mistakes in the equations.

POSTED BY: Bill Nelson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard