Message Boards Message Boards

0
|
7699 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:
GROUPS:

NSolve and FindInstance: Why they took me so long?

Posted 10 years ago

I tried to find numerical solution of this equation system (7 equations) but I am waiting for an hour without any solution while the excel solver took me just few seconds. Any comments please.

pi = .35
\[Lambda]h = .81
\[Lambda]l = .80
R = 1.5

FindInstance[((pi*(1 - \[Lambda]h)*(1 - ph)) / (ys + 
        ph*(1 - ys) - \[Lambda]h*
         ds)) + (((1 - pi)*(1 - \[Lambda]l)*(1 - pl)) / (ys + 
        pl*(1 - ys) - \[Lambda]l*ds)) == 
   0 &&  (pi*\[Lambda]h*((1/
          ds) - (1 - \[Lambda]h)/(ys + 
           ph*(1 - ys) - \[Lambda]h*ds))  +  (1 - 
        pi)*\[Lambda]l*((1/
          ds) - (1 - \[Lambda]l)/(ys + 
           pl*(1 - ys) - \[Lambda]l*ds)) ) == 
   0 && ((pi*(1 - ph)) / (yr + 
        ph*(1 - yr))) + (((1 - pi)*(1 - \[Lambda]l)*(1 - pl)) / (yr + 
        pl*(1 - yr) - \[Lambda]l*dr)) == 
   0 && (1 - 
      pi)*\[Lambda]l*((1/
        dr) - (1 - \[Lambda]l)/(yr + pl*(1 - yr) - \[Lambda]l*dr))  ==
    0 && \[Rho]*(ys - \[Lambda]l*ds) == (1 - \[Rho])*(\[Lambda]l*dr - 
      yr) && \[Rho]*(ys - \[Lambda]h*ds)/ph == (1 - \[Rho])*(1 - yr) && 
  pi*(\[Lambda]h*Log[ds] + (1 - \[Lambda]h)*
        Log[((ys + 
             ph*(1 - ys) - \[Lambda]h*
              ds)/((1 - \[Lambda]h)*(ph/R)))]) + (1 - 
       pi)*(\[Lambda]l*Log[ds] + (1 - \[Lambda]l)*
        Log[((ys + 
             pl*(1 - ys) - \[Lambda]l*
              ds)/((1 - \[Lambda]l)*(pl/R)))]) == 
   pi*(\[Lambda]h*Log[(yr + ph*(1 - yr))] + (1 - \[Lambda]h)*
        Log[(yr + ph*(1 - yr))]) + (1 - 
       pi)*(\[Lambda]l*Log[dr] + (1 - \[Lambda]l)*
        Log[((yr + 
             pl*(1 - yr) - \[Lambda]l*
              dr)/((1 - \[Lambda]l)*(pl/R)))]), {\[Rho], ph, pl, ys, 
  ds, yr, dr}, Reals]
3 Replies

Try FindRoot

POSTED BY: Frank Kampas

There are many functions and methods for solving a set of equations. These can't be exactly compared to each other. Some are slower and have special capabilities. Some are faster and more likely to return worse answers. FindInstance and excel's solver are very different things and would be used in very different situations.

Here is how I would go about looking for a quick answer to the problem assuming that the solution is somwhere near the starting values ({{dr, 1}, {ds, 1}, {ph, 1}, {pl, 1}, {yr, 1}, {ys, 1}, {[Rho], 1}})

equations = {((pi*(1 - \[Lambda]h)*(1 - ph))/(ys + 
        ph*(1 - ys) - \[Lambda]h*
         ds)) + (((1 - pi)*(1 - \[Lambda]l)*(1 - pl))/(ys + 
        pl*(1 - ys) - \[Lambda]l*ds)) == 
   0, (pi*\[Lambda]h*((1/
          ds) - (1 - \[Lambda]h)/(ys + 
           ph*(1 - ys) - \[Lambda]h*ds)) + (1 - 
        pi)*\[Lambda]l*((1/
          ds) - (1 - \[Lambda]l)/(ys + 
           pl*(1 - ys) - \[Lambda]l*ds))) == 
   0, ((pi*(1 - ph))/(yr + 
        ph*(1 - yr))) + (((1 - pi)*(1 - \[Lambda]l)*(1 - pl))/(yr + 
        pl*(1 - yr) - \[Lambda]l*dr)) == 
   0, (1 - pi)*\[Lambda]l*((1/
        dr) - (1 - \[Lambda]l)/(yr + pl*(1 - yr) - \[Lambda]l*dr)) == 
   0, \[Rho]*(ys - \[Lambda]l*ds) == (1 - \[Rho])*(\[Lambda]l*dr - 
       yr) && \[Rho]*(ys - \[Lambda]h*ds)/ph == (1 - \[Rho])*(1 - yr),
   pi*(\[Lambda]h*Log[ds] + (1 - \[Lambda]h)*
        Log[((ys + 
             ph*(1 - ys) - \[Lambda]h*
              ds)/((1 - \[Lambda]h)*(ph/R)))]) + (1 - 
       pi)*(\[Lambda]l*Log[ds] + (1 - \[Lambda]l)*
        Log[((ys + 
             pl*(1 - ys) - \[Lambda]l*
              ds)/((1 - \[Lambda]l)*(pl/R)))]) == 
   pi*(\[Lambda]h*Log[(yr + ph*(1 - yr))] + (1 - \[Lambda]h)*
        Log[(yr + ph*(1 - yr))]) + (1 - 
       pi)*(\[Lambda]l*Log[dr] + (1 - \[Lambda]l)*
        Log[((yr + 
             pl*(1 - yr) - \[Lambda]l*
              dr)/((1 - \[Lambda]l)*(pl/R)))])}

FindRoot[equations, {{dr, 1}, {ds, 1}, {ph, 1}, {pl, 1}, {yr, 1}, {ys, 1}, {\[Rho], 1}}]
POSTED BY: Sean Clarke

Thank you very much Frank and Sean. I am quite new to Mathematica. Now I got the solution using FindRoot. I got some more questions, any helps would be greatly appreciated.

1) If I want to put inequalities describing the range of variables into FindRoot, what should I do?

2) If I want to find close form solution of a set of equations above, what would you suggest as I tried to use Solve but I have been waiting for 3 days already. A good starting point might be checking whether this set of equations has closed form solution or not. Any suggestion would be very helpful.

Solve[pi*(\[Lambda]h*Log[ds] + (1 - \[Lambda]h)*
       Log[(ys + 
           ph*(1 - ys) - \[Lambda]h*
            ds)/((1 - \[Lambda]h)*(ph/R))]) + (1 - 
      pi)*(\[Lambda]l*Log[ds] + (1 - \[Lambda]l)*
       Log[(ys + 
           pl*(1 - ys) - \[Lambda]l*
            ds)/((1 - \[Lambda]l)*(pl/R))]) == 
  pi*(\[Lambda]h*Log[yr + ph*(1 - yr)] + (1 - \[Lambda]h)*
       Log[yr + ph*(1 - yr)]) + (1 - 
      pi)*(\[Lambda]l*Log[dr] + (1 - \[Lambda]l)*
       Log[(yr + 
           pl*(1 - yr) - \[Lambda]l*
            dr)/((1 - \[Lambda]l)*(pl/R))]), \[Rho]*(ys - \[Lambda]l*
      ds) == (1 - \[Rho])*(\[Lambda]l*dr - 
     yr), \[Rho]*(ys - \[Lambda]h*ds)/
    ph == (1 - \[Rho])*(1 - 
     yr), ((pi*(1 - \[Lambda]h)*(1 - ph)) / (ys + 
       ph*(1 - ys) - \[Lambda]h*
        ds)) + (((1 - pi)*(1 - \[Lambda]l)*(1 - pl)) / (ys + 
       pl*(1 - ys) - \[Lambda]l*ds)) == 
  0, (pi*\[Lambda]h*((1/
         ds) - (1 - \[Lambda]h)/(ys + 
          ph*(1 - ys) - \[Lambda]h*ds))  +  (1 - 
       pi)*\[Lambda]l*((1/
         ds) - (1 - \[Lambda]l)/(ys + 
          pl*(1 - ys) - \[Lambda]l*ds)) ) == 
  0, ((pi*(1 - ph)) / (yr + 
       ph*(1 - yr))) + (((1 - pi)*(1 - \[Lambda]l)*(1 - pl)) / (yr + 
       pl*(1 - yr) - \[Lambda]l*dr)) == 
  0, (1 - pi)*\[Lambda]l*((1/
       dr) - (1 - \[Lambda]l)/(yr + pl*(1 - yr) - \[Lambda]l*dr))  == 
  0, {\[Rho], ph, pl, ys, ds, yr, dr}]

Thank you very much

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