1
$\begingroup$

I am trying to solve a linear system of equations with Mathematica. My variables are x1, x2, x3, x4. I use the code shown below, but it gives error saying that:

Equations may not give solutions for all "solve" variables.

Even when I used LinearSolve, I got the same error.

Solve[{(x1 - ((-m3* n2 + m2 * z3 - 0.5*m2*z3)* x2 + (0.5 *n2* z3)*
       x3 + (0.5 *m2 * z3)*x4)/((-1.5) n2* z3)) == (2/
     1.5)   ,  (x2 -  ((m3* n2 - 0.5*m3 *n2 - m2 * z3)*
       x1 + (0.5* m3* n2)* x3 + (0.5* m2* m3)* 
       x4)/((-1.5) (m2* m3)) ) == (-m3* n2 + m2* z3 )/((-1.5) m2* 
      m3)  ,    (x3 - ((-n2*  z1 + .5*n2 * z1)*
       x1 + (.5* m2 * z1 - m2 * z1)*x2 + (m1 *n2  - 0.5* m2* z1)*
       x4 )/((1.5) n2 z1) ) ==  (2/1.5 )  ,   ( 
    x4 - ((-m1 *n2 + 0.5*m1 *n2 )*x1 + (-0.5 *m1* m2) *
       x2 + (-.5* m1* n2 + m2 *z1)*x3)/((1.5) m1* m2) ) == ( 
     m1* n2 - m2* z1)/((1.5)* m1* m2)} , {x1, x2, x3, x4}]

Can anyone help me please. I really appreciate your comments.

$\endgroup$
7
  • $\begingroup$ Apparently, your equations have a certain redundancy such that there is a 1-paremeterfamily of solutions (parameterized by x1). $\endgroup$ Commented Sep 7, 2018 at 22:46
  • $\begingroup$ You can select which of your variables is the parameter: FullSimplify[ Solve[eqns//Rationalize, #, Reals] & /@ Subsets[{x1, x2, x3, x4}, {3}]] $\endgroup$
    – Bob Hanlon
    Commented Sep 7, 2018 at 23:56
  • 1
    $\begingroup$ Use Reduce instead of Solve. $\endgroup$
    – user64494
    Commented Sep 8, 2018 at 4:42
  • 1
    $\begingroup$ In this case, you probably want to use 1/2 rather than 0.5. This uses exact numbers rather than approximate numbers. $\endgroup$
    – mikado
    Commented Sep 8, 2018 at 8:00
  • $\begingroup$ @BobHanlon , I still get the same problem. $\endgroup$
    – mah
    Commented Sep 10, 2018 at 20:16

1 Answer 1

2
$\begingroup$

Extended comment.

eq = Rationalize@{(x1 - ((-m3*n2 + m2*z3 - 0.5*m2*z3)*x2 + (0.5*n2*z3)*
          x3 + (0.5*m2*z3)*x4)/((-1.5) n2*z3)) == (2/
      1.5), (x2 - ((m3*n2 - 0.5*m3*n2 - m2*z3)*x1 + (0.5*m3*n2)*
          x3 + (0.5*m2*m3)*x4)/((-1.5) (m2*m3))) == (-m3*n2 + 
       m2*z3)/((-1.5) m2*
       m3), (x3 - ((-n2*z1 + .5*n2*z1)*x1 + (.5*m2*z1 - m2*z1)*
          x2 + (m1*n2 - 0.5*m2*z1)*x4)/((1.5) n2 z1)) == (2/
      1.5), (x4 - ((-m1*n2 + 0.5*m1*n2)*x1 + (-0.5*m1*m2)*
          x2 + (-.5*m1*n2 + m2*z1)*x3)/((1.5) m1*m2)) == (m1*n2 - 
       m2*z1)/((1.5)*m1*m2)};
sol = Solve[eq, {x1, x2, x3, x4}][[1]];

The generic solution looks like this:

{x1, x2, x3, x4} /. sol

{x1, -(z3/m3) + (x1 z3)/ m3, -((m1 x1 (m3 n2 + m2 z3))/(m3 (m1 n2 + m2 z1))) - (-2 m1 m3 n2 - m2 m3 z1 - m1 m2 z3)/(m3 (m1 n2 + m2 z1)), (z1 (m3 n2 + m2 z3))/( m3 (m1 n2 + m2 z1)) - (x1 z1 (m3 n2 + m2 z3))/(m3 (m1 n2 + m2 z1))}

Let's check that these really are solutions by substituting the solutions rules sol into the equation eq:

eq /. sol // Simplify

{True, True, True, True}

So the equations do not specify a single solution. Because there are 4 equations and four variables, that means that the equations are somewhat redundant. Usually, one would expect to get only finitely many (or countably many) solution. This is not the case here: We have a continuum of solutions. Because that is somewhat unexpected (and because this often causes problems), Solve warns us. That's all. The message is a warning, not an error.

$\endgroup$
2
  • $\begingroup$ I got it. Your explanation was great. $\endgroup$
    – mah
    Commented Sep 10, 2018 at 20:44
  • $\begingroup$ If you like, you can mark it as "accepted", signaling that your question is answered. $\endgroup$ Commented Sep 10, 2018 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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