Message Boards Message Boards

Solve a system of equations and avoid calculations without response?

Posted 5 years ago

Hello. I am trying to solve a system of equations (actually, it seems to be solvable by hand, just a bit messy). Mathematica thinks for some time ("Running") and then just stops. With no answer. Has happened multiple times already with multiple systems. Is it common? Please find the system below:

Simplify[Solve[ 
  p1*a1*(-x0 + (e1b + e1l - x1)*a1)^(-2) + 
     p2*a2*((e1b + e1l - x1)*a2)^(-2) == (w0l + 
        x0*P00 - (e1b - x1)*P01)^(-2)*P01 && 
   p1*(-x0 + (e1b + e1l - x1)*a1)^(-2) == (w0l + 
        x0*P00 - (e1b - x1)*P01)^(-2)*P00, {x0, x1}]]

Is there any way to resolve it? Thank you very much in advance.

8 Replies

I believe it's very unlikely that you could solve this system symbolically... I may be mistaken but see:

If you take the equation 1 and solve for “x0” you have a very large solutions (which should be subsequently equated with the equation 2, also solved to “x0”, to then solve a definitive “x1” equation). Look at equation 1 solved for "x0":

Solve[p1*a1*(-x0 + (e1b + e1l - x1)*a1)^(-2) + 
    p2*a2*((e1b + e1l - x1)*a2)^(-2) == (w0l + 
       x0*P00 - (e1b - x1)*P01)^(-2)*P01, {x0}] // InputForm

i0

If you observe this solution in Word with Arial font and size 9, you will see that it gives 119 pages only to the symbolic solution of equation 1 for "x0":

i1

Then you would still have to isolate the “x0” in equation 2 to match these solutions and solve an even more complex equation later...!

You may solve this system if you have fewer variables and more numeric values in some (many) of the positions... At least that's what I believe...

POSTED BY: Claudio Chaib

I just had a similar problem and also asked here for help. In my case it finally turned out that the processor got too hot. Running your code on my computer also heated up the processor considerably.

So, my suggestion is to monitor the processor temperature during your computation and compare it with computations that don't stop your computer. If it then looks like a temperature problem, you will find ways to solve it. I have no experience with the matter.

POSTED BY: Ulrich Mutze

Dear Dmitry, yes, core power consumption and temperature strongly vary during a computation, at least on my system (Windows 10, Mathematica vs. 12) as my core temperature monitor program (freely downloaded from www.alcpu.com/CoreTemp/) tells me. I append a file that on my system causes thermal stop on a regular basis. I worked with such freely running manipulate programs for years (often over night just as you write) without encountering any thermal problem - until recently when they took me by surprise. I remember that I had problems with mysterious program stops may years ago. Here experts argued in favor of thermal problems but I had no monitoring program to verify this suspicion. In my present case of the problem it took me some time to remember these old problems that I thought to be due to old versions of Mathematica and old computers …

Attachments:
POSTED BY: Ulrich Mutze

The question is, why does Mathematica fail here. I do not think I am smarter then my computer after all...

Good question - who knows?

Following your proposal you are looking for this

In[143]:= lsg = 
 Solve[p1*a1*z1 + p2*a2*z2 == z3*P01 && p1*z1 == z3*P00, {z1, z2, 
    z3}] // Flatten

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

Out[143]= {z2 -> -(((a1 P00 - P01) z3)/(a2 p2)), z1 -> (P00 z3)/p1}

In[168]:= 
rr = {z1 -> (-x0 + (e1b + e1l - x1)*a1)^(-2), 
   z2 -> ((e1b + e1l - x1)*a2)^(-2), 
   z3 -> (w0l + x0*P00 - (e1b - x1)*P01)^(-2)};

In[150]:= t1 = z1/z3 /. lsg

Out[150]= P00/p1

In[151]:= t2 = z2/z3 /. lsg

Out[151]= -((a1 P00 - P01)/(a2 p2))

In[162]:= q1 = Sqrt[z1/z3] /. rr // PowerExpand

Out[162]= (w0l + P00 x0 - P01 (e1b - x1))/(-x0 + a1 (e1b + e1l - x1))

In[164]:= q2 = Sqrt[z2/z3] /. rr // PowerExpand

Out[164]= (w0l + P00 x0 - P01 (e1b - x1))/(a2 (e1b + e1l - x1))

In[165]:= lsg1 = 
 Solve[{Sqrt[t1] == q1, Sqrt[t2] == q2}, {x0, x1}] // FullSimplify // 
  Flatten

Out[165]= {x0 -> -(((a1 Sqrt[P00/p1] - 
      a2 Sqrt[(-a1 P00 + P01)/(a2 p2)]) (e1l P01 + w0l))/(
   a1 P00 Sqrt[P00/p1] - P01 Sqrt[P00/p1] - 
    a2 (P00 + Sqrt[P00/p1]) Sqrt[(-a1 P00 + P01)/(a2 p2)])), 
 x1 -> -(-P00 (e1b (P01 + a1 Sqrt[P00/p1]) + a1 e1l Sqrt[P00/p1] - 
         w0l) + (P00 + Sqrt[P00/
         p1]) (e1b (P01 + a2 Sqrt[(-a1 P00 + P01)/(a2 p2)]) + 
         a2 e1l Sqrt[(-a1 P00 + P01)/(a2 p2)] - w0l))/(P00 (P01 + 
         a1 Sqrt[P00/p1]) - (P00 + Sqrt[P00/p1]) (P01 + 
         a2 Sqrt[(-a1 P00 + P01)/(a2 p2)]))}

In[166]:= 
p1*a1*(-x0 + (e1b + e1l - x1)*a1)^(-2) + 
    p2*a2*((e1b + e1l - x1)*a2)^(-2) == (w0l + 
       x0*P00 - (e1b - x1)*P01)^(-2)*P01 /. lsg1 // FullSimplify

Out[166]= True

In[167]:= 
p1*(-x0 + (e1b + e1l - x1)*a1)^(-2) == (w0l + 
       x0*P00 - (e1b - x1)*P01)^(-2)*P00 /. lsg1 // FullSimplify

Out[167]= True
POSTED BY: Hans Dolhaine

Dear Claudio, I still think it is solvable.

 p1*a1*z1 + p2*a2*z2 == z3*P01 && p1*z1 == z3*P00

Above I denote the terms in brackets of the initial system as z1, z2 and z3 respectively. This linear system has a solution for z1/z3 and z2/z3, provided z3<>0. This solution will not contain x0 or x1 as arguments, they will be all inside z1/z3 and z2/z3. But then one can just invert the power (given that it is an integer and that the roots are non-negative). Then one can just solve the resulting system, which will be linear in x0 and x1, just a bit ugly.

The question is, why does Mathematica fail here. I do not think I am smarter then my computer after all...

Dear Ulrich,

Thank you very much for the comment! I think it is very possible. I was not aware of such a possibility. Actually, I sometimes leave the laptop overnight and it works fine, but sometimes (like in this case) it stops in some 15 minutes. Is it that some problems warm up the processor more then other?

Thank you!! I will keep it in mind!

Dear Hans,

Thank you for coding it! This is a nice and concise script, much better then what I usually do, so I learned something. It is strange that Mathematica did not go this way. Maybe it tries the solution that Claudio pointed out, which may lead to overload due to operations with quite messy objects... Anyways, thanks a lot once again!

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