Group Abstract Group Abstract

Message Boards Message Boards

Solving system of equations with Solve takes too long?

Hello, I have been trying to solve the system below but it executes forever and doesn't seem to find an answer.

F[x_]:=x/(1+x)

lambda=l1+l2+l3

c1=RandomReal[3]

c2=RandomReal[3]

c3=RandomReal[3]

c4=RandomReal[3]

pn=(P1^(-2)+P2^(-2)+P3^(-2)+(P4*F[lambda]/2)^(-2))^(-1/2)

s1=(P1/pn)^(-1/2)

s2=(P2/pn)^(-1/2)

s3=(P3/pn)^(-1/2)

s4=(P4/pn)^(-1/2)  

Solve[P1\[Equal] (2*(1-s1))/(3*(1-s1)+s1)*c1&&P2\[Equal] (2*(1-s2))/(3*(1-s2)+s2)*c2&&P3==(2*(1-s3))/(3*(1-s3)+s3)*c3&& P4\[Equal] (2*(1-s4))/(3*(1-s4)+s4)*c4&&y*(1-c1/P1)*2*s1*(s4)\[Equal](1+F[lambda]/2)^3 /(D[F[lambda],l1]/2)&&y*(1-c2/P2)*2*s2*(s4)\[Equal](1+F[lambda]/2)^3 /(D[F[lambda],l2]/2)&&y*(1-c3/P3)*2*s3*(s4)\[Equal](1+F[lambda]/2)^3 /(D[F[lambda],l3]/2),{P1,P2,P3,P4,l1,l2,l3}]  

I have been trying to solve the equations one after the other in the following way :

sol1=Solve[P1 == (2*(1-s1))/(3*(1-s1)+s1)*c1,{P1}] 

X1=Array[x1,{Length@sol1}]

x1[k_] /; MemberQ[Range[Length@sol1],l] :=sol1[[k,1,2]]

P1=X1


sol2=Solve[P2 == (2*(1-s2))/(3*(1-s2)+s2)*c2,{P2}] 

X2=Array[x2,{Length@sol2}]

x2[k_] /; MemberQ[Range[Length@sol2],l] :=sol2[[k,1,2]]

P2=X2  

The first part works and I was planning to continue this way but the second part returns with a serie of errors. And still, even the first part takes a very long time to run...

Can you tell please tell me why it doesn't work or/and whether there is an other way to have a result in a faster way?

12 Replies
Posted 5 years ago

I'm glad that I could help a little.

POSTED BY: Werner Geiger

Dear Werner, Thank you very much for all your work and great explanations. I have been working on it for the last couple of days, and your help was very useful.

First of all thanks a lot for the reformulation of my code in the "first attempt", as you have noticed I am very new to this language, and it helped me a lot to learn.

It is true that I consider y as a fixed general parameter and you are totally right, that the first derivatives are the same and this simplifies the code. The conditions that pn must be a real positive is totally fine by assumption (and lambda different from one too).

For your second attempt, I think fixing pn and lambda in a first step should be a godd way to proceed even if it not working yet and I think I will continue on this way, 1) simplifying the problem (I will try to remove one equation by imposing p3=l3=0), 2) trying to show that this second system - where we replace lambda and pn afterwards is equivalent to the first one. I will certainly let you know here if this way I manage to solve it.

I also wanted to tell that one of the reasons I wanted to solve this problem was to find whether their actually is a solution (and I have the intuition there might not be).

Again, thanks a lot!

Posted 5 years ago
POSTED BY: Werner Geiger
Posted 5 years ago
POSTED BY: Werner Geiger

I have edited my post to correct for your observations, thank you.

So, then be so kind and show the corrected code. But these equations look complicated.

POSTED BY: Hans Dolhaine

You are right about F[lambda], thank you. About the RandomReal[3,1] I guess you are right too, even if I am not sure it is problematic to have a list of one element instead of a number. I have corrected my post anyway, for both of your remarks.

Another typo, I am sorry. I have corrected it.

Yes, thank you, I have edited my post

And what is

pP

it is nowhere defined

POSTED BY: Hans Dolhaine

Are you sure it is F(lambda) instead of F[lambda]? If you define c1 = RandomReal[3,1] you get a list instead of a number: is that really what you want? I would simply write c1 = RandomReal[3].

POSTED BY: Gianluca Gorni

I think, this

2=(P2/pn)^(-1/2)

is a typo. Shouldn't it be

s2=(P2/pn)^(-1/2)
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard