Message Boards Message Boards

0
|
15036 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Avoid message "Equations may not give solutions for all "solve" variables"?

Posted 9 years ago

I'm new to Mathematica and want to solve a system of equations. First I have to do some matrix calculations and then I want to solve the set of equations for r11, r12, ....., r33 (which stands for the density matrix elements). I always get the error message:

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

and I get the solutions for r11 up to r32 in dependence of r33, so mathematica doesn't solve r33. Maybe there is a problem with the parameters? I already searched the web but couldn't find any help. Although I'm pretty sure the calculation is possible, since it is a common excercise in atomic physics. I post my mathematica code below and as a file attached, I hope someone can help me :)

ClearAll;
H={{0,0,OmP},{0,2*d,OmC},{OmP,OmC,2*d}};
r={{r11,r12,r13},{r21,r22,r23},{r31,r32,r33}};
Kommutator=(i/2)*(H.r-r.H);
G={{G1*r33,0,-(1/2)*r13*(G1+G2)},{0,G2*r33,-(1/2)*r23*(
        G1+G2)},{-(1/2)*r31*(G1+G2),-(1/2)*r32*(G1+G2),-r33*(G1+G2)}};
Nul={{0,0,0},{0,0,0},{0,0,0}};
Solve[{Kommutator+G==Nul},{r11,r12,r13,r21,r22,r23,r31,r32,r33}]
Attachments:
POSTED BY: Simon CC
3 Replies

Then click the error message (ref/message/Solve/svars) to read

This message is generated when the number of variables listed in the second argument of Solve is greater than the number of variables that could be determined from the equations.

That's clear enough. Next thing you could do, leave this or that variable out to see, whether is makes an effect:

Solve[{Kommutator + G == Nul}, {r11, r12, r13, r21, r22, r23, r31, r32 (*,r33 *)}]

Now r33 is a linear factor and no warning appears.

Solve[{Kommutator + G == Nul}, {r11, r12,(* r13, *) r21, r22, r23, r31, r32, r33 }]

Now r13 is a linear factor. What does it mean?

My mathematica code is not the problem, right?

You need to add a norm condition to the equation to get rid of the warning message.

Solve[{Kommutator + G == Nul}, {(* r11, *)r12, r13, r21, r22, r23, r31, r32, r33 }]

All are solved with the skipped variable as linear factor: With other words, the missing condition fixes the up-to-now free linear factor.

POSTED BY: Udo Krause

This time

ClearAll;
H = {{0, 0, OmP}, {0, 2*d, OmC}, {OmP, OmC, 2*d}};
r = {{r11, r12, r13}, {r21, r22, r23}, {r31, r32, r33}};
Kommutator = (i/2)*(H.r - r.H);
G = {{G1*r33, 0, -(1/2)*r13*(G1 + G2)}, {0, G2*r33, -(1/2)*r23*(G1 + G2)}, {-(1/2)*r31*(G1 + G2), 
        -(1/2)*r32*(G1 + G2), -r33*(G1 + G2)}};
Nul = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};



In[81]:= Solve[{Kommutator + G == Nul}, {r11, r12, r13, r21, r22, r23, r31, r32, r33}]

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

Out[81]= {{r11 -> -(((-4 d^2 G1^3 - 8 d^2 G1^2 G2 - 4 d^2 G1 G2^2 + 
       16 d^4 G1 i^2 - 8 d^2 G1 i^2 OmC^2 + G1 i^2 OmC^4 + 
       4 d^2 G1 i^2 OmP^2 + G1 i^2 OmC^2 OmP^2 + G2 i^2 OmC^2 OmP^2 + 
       G2 i^2 OmP^4) r13)/(
    2 d i OmP (-2 d G1^2 - 2 d G1 G2 + 4 d^2 G1 i - G1 i OmC^2 - 
       G2 i OmP^2))), 
  r12 -> -(((-2 d G1^2 OmC^2 - 2 d G1 G2 OmC^2 + 4 d^2 G1 i OmC^2 - 
       G1 i OmC^4 - 2 d G1 G2 OmP^2 - 2 d G2^2 OmP^2 - 
       G1 i OmC^2 OmP^2 - G2 i OmC^2 OmP^2 - G2 i OmP^4) r13)/(
    2 d OmC (-2 d G1^2 - 2 d G1 G2 + 4 d^2 G1 i - G1 i OmC^2 - 
       G2 i OmP^2))), 
  r21 -> -(((2 d G1^2 OmC^2 + 2 d G1 G2 OmC^2 + 4 d^2 G1 i OmC^2 - 
       G1 i OmC^4 + 2 d G1 G2 OmP^2 + 2 d G2^2 OmP^2 - 
       G1 i OmC^2 OmP^2 - G2 i OmC^2 OmP^2 - G2 i OmP^4) r13)/(
    2 d OmC (-2 d G1^2 - 2 d G1 G2 + 4 d^2 G1 i - G1 i OmC^2 - 
       G2 i OmP^2))), 
  r22 -> (OmP (4 d^2 G1^2 G2 + 8 d^2 G1 G2^2 + 4 d^2 G2^3 - 
      4 d^2 G2 i^2 OmC^2 - G1 i^2 OmC^4 - G1 i^2 OmC^2 OmP^2 - 
      G2 i^2 OmC^2 OmP^2 - G2 i^2 OmP^4) r13)/(
   2 d i OmC^2 (-2 d G1^2 - 2 d G1 G2 + 4 d^2 G1 i - G1 i OmC^2 - 
      G2 i OmP^2)), 
  r23 -> (OmP (2 d G1 G2 + 2 d G2^2 - G1 i OmC^2 - G2 i OmP^2) r13)/(
   OmC (2 d G1^2 + 2 d G1 G2 - 4 d^2 G1 i + G1 i OmC^2 + G2 i OmP^2)),
   r31 -> -(((-2 d G1^2 - 2 d G1 G2 - 4 d^2 G1 i + G1 i OmC^2 + 
       G2 i OmP^2) r13)/(-2 d G1^2 - 2 d G1 G2 + 4 d^2 G1 i - 
     G1 i OmC^2 - G2 i OmP^2)), 
  r32 -> -((
    OmP (2 d G1 G2 + 2 d G2^2 + G1 i OmC^2 + G2 i OmP^2) r13)/(
    OmC (2 d G1^2 + 2 d G1 G2 - 4 d^2 G1 i + G1 i OmC^2 + 
       G2 i OmP^2))), 
  r33 -> (2 (d G1 + d G2) i OmP r13)/(
   2 d G1^2 + 2 d G1 G2 - 4 d^2 G1 i + G1 i OmC^2 + G2 i OmP^2)}}

Mathematica (10.4.1.0) does not solve for r13 but r13 is a linear factor to all other (r11, r12, r21, r22, r23, r31, r32, r33) terms, so it appears that r13 has the role of a norm, hasn`t it? And if so, it is not Mathematica's fault, but a hint to you to normalize your expressions, please.

Just to mention it, more readable expressions for Nul are

In[83]:= DiagonalMatrix[{0, 0, 0}]
Out[83]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}

In[85]:= ConstantArray[0, {3, 3}]
Out[85]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}

In[86]:= DiagonalMatrix[ConstantArray[0, {3}]]
Out[86]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}

In[91]:= 0 IdentityMatrix[3]
Out[91]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
POSTED BY: Udo Krause
Posted 9 years ago

You might be right, but I'm not sure. My mathematica code is not the problem, right? I'm new to this software.

POSTED BY: Simon CC
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