Message Boards Message Boards

NSolve takes too long to solve equation?

Posted 3 years ago
Attachments:
POSTED BY: Sabrina Chui
13 Replies
Posted 3 years ago

Thank you so much Professor Gianluca! You've been so helpful!!!

POSTED BY: Sabrina Chui

Then you can simply write the condition into your system:

Solve[Simplify[{(-r + 
       9/40 b ((7 Sqrt[c] Sqrt[r] + Sqrt[q + b iy q + 49 c r])^2/(1 + 
              b ix)^2 + (2 q^2)/(Sqrt[
              q + b ix q + 49 c r] (-14 Sqrt[c] Sqrt[r] + 
               Sqrt[q + b ix q + 49 c r] + 
               Sqrt[q + b iy q + 49 c r]))) == 0), ix == iy, 
    ix > 0} /. {q -> 50, r -> 50, c -> 1/100, b -> 1}], {ix, 
  iy}, Reals]
POSTED BY: Gianluca Gorni

Are you trying to find solutions where ix==iy?

POSTED BY: Gianluca Gorni
Posted 3 years ago

Yes, I am expecting ix==iy as the nash equilibrium because this is symmetrical.

POSTED BY: Sabrina Chui
Posted 3 years ago

Thanks Professor Gianluca, I tried to replicate these same steps to do the opposite to plot iy as a function of ix, but how would I then combine them? I'm trying to figure out the nash equilibrium solution for iy and ix, and in easier example, I'd normally be plotting iy as a function of ix, and ix as a function of iy and seeing where they cross, but since they're not showing up in the plot, how would I figure how where these functions intersect?

Thank you again!

POSTED BY: Updating Name

Your code ix >= 0 && iy >= 0 makes Solve accept only the solutions in the first quadrant. The existence condition is iy > 338.568. I chose a simple number larger than that, iy=400, and f[400.] is the corresponding value of ix.

POSTED BY: Gianluca Gorni

f[iy] is a ConditionalExpression. The existence condition is its last element. It seems that there are indeed positive solutions:

In[36]:= Last[f[iy]] // N
f[400.]

Out[36]= iy > 338.568

Out[37]= 0.742669
POSTED BY: Gianluca Gorni
Posted 3 years ago

Thank you Gianluca, if you don't mind me asking more questions, which part of the code is parsing out the positive solutions? What is the purpose of the f[400.]? And I'm a little confused by Out[36] and Out[37], does this mean the solution is that iy > 338.568 AND/OR iy = 0.742669? Are these the only two positive solutions? Once again, thank you so much!

POSTED BY: Sabrina Chui
Posted 3 years ago

Thanks for the explanation Gianluca! Plotting it out, it seems like the solution is in the 4th quadrant. In my model, ix and iy can't be negative numbers, I modified the code you had to include the constraints for ix and iy, and the plot turned out empty. I'm not sure if this is because I didn't put the constraint in the right area of the code, or does a positive solution just not exist for ix and iy? (and how would I be able to tell for the latter?) Thank you so much!

f[iy_] = ix /. 
   First@Solve[
     Simplify[(-r + 
           9/40 b ((7 Sqrt[c] Sqrt[r] + 
                  Sqrt[q + b iy q + 49 c r])^2/(1 + 
                  b ix)^2 + (2 q^2)/(Sqrt[
                  q + b ix q + 49 c r] (-14 Sqrt[c] Sqrt[r] + 
                   Sqrt[q + b ix q + 49 c r] + 
                   Sqrt[q + b iy q + 49 c r]))) == 0 && ix >= 0 && 
         iy >= 0) /. {q -> 50, r -> 50, c -> 1/100, b -> 1/10}], ix, 
     Reals];
Plot[f[iy], {iy, -15, 20}]
POSTED BY: Sabrina Chui

It is a way of representing algebraic numbers in terms of the normalized equation they solve. In this case the equation is of degreeĀ 16 in the dummy variable #1, with coefficients that are themselves polynomials in iy. The Root object can be used as any other algebraic expression. There is also a validity condition on iy. For example you can plot ix as a function of iy this way:

f[iy_] = ix /. 
   First@Solve[
     Simplify[(-r + 
          9/40 b ((7 Sqrt[c] Sqrt[r] + 
                 Sqrt[q + b iy q + 49 c r])^2/(1 + 
                 b ix)^2 + (2 q^2)/(Sqrt[
                 q + b ix q + 49 c r] (-14 Sqrt[c] Sqrt[r] + 
                  Sqrt[q + b ix q + 49 c r] + 
                  Sqrt[q + b iy q + 49 c r]))) == 0) /. {q -> 50, 
        r -> 50, c -> 1/100, b -> 1/10}], ix, Reals];
Plot[f[iy], {iy, -15, -9}]
POSTED BY: Gianluca Gorni
Posted 3 years ago

Hi Gianluca, thanks for giving an alternative way of doing it. I entered that and got this whole blob. I'm not quite sure what kind of "answer" this means. Is this a real number? or is it now a complex number? I'm still new to mathematica so when the output looks like this I'm a bit confused. Thank you!

enter image description here

POSTED BY: Sabrina Chui

Don't post code as an image. It is difficult to read or put into Mathematica.

POSTED BY: Moderation Team

This variation gives a quick answer:

Solve[Simplify[(-r + 
      9/40 b ((7 Sqrt[c] Sqrt[r] + Sqrt[q + b iy q + 49 c r])^2/(1 + 
           b ix)^2 + (2 q^2)/(
         Sqrt[q + b ix q + 
           49 c r] (-14 Sqrt[c] Sqrt[r] + Sqrt[q + b ix q + 49 c r] + 
            Sqrt[q + b iy q + 49 c r]))) == 0) /. {q -> 50, r -> 50, 
    c -> 1/100, b -> 1/10}], ix, Reals]
POSTED BY: Gianluca Gorni
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