Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to solve a system of four equations in four variables. I have read a number of threads on similar issues and tried to follow the suggestions. But I think it is a bit messy because of the logs and cross products here. This is the exact system:

7*w = (7*w+5*x+2*y+z) * ( 0.76 + 0.12*Log[w] - 0.08*Log[x] - 0.03*Log[y] - 
           0.07*Log[7*w+5*x + 2*y + z]),   
5*x = (7*w+5*x+2*y+z) * ( 0.84 - 0.08*Log[w] + 0.11*Log[x] - 0.02*Log[y] - 
           0.08*Log[7*w+5*x + 2*y + z]),        
2*y = (7*w+5*x+2*y+z) * (-0.45 - 0.03*Log[w] - 0.02*Log[x] + 0.05*Log[y] + 
           0.12*Log[7*w+5*x + 2*y + z]),                
1*z = (7*w+5*x+2*y+z)*(-0.16 + 0*Log[w]- 0*Log[x] - 0*Log[y] + 0.03*Log[7*w+5*x + 2*y + z])

This is an extension of a consumer demand system and we, theoretically, know that there exists a unique solution to this system that is positive.

Trys

  • Solve & NSolve : As there should be a solution I tried these, but neither works. I guess that the system has too many logs to handle.
  • FindRoot : I started with an initial value of (14,15,10,100) which I get from my data. FindRoot returns the last value (which does not satisfy my system) and the following message.

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable..... `

I tried different initial values, including the value returned by FindRoot. I tried to analyze the pattern of the solution value at each step. I didn’t see any pattern, but noticed that the z values become negative early in the process. So, I put bounds on the values. This just stops the code at the minimum value of 0.1. I also tried an exponential system instead of log - same issues.

Reap[FindRoot[{
       7*w == (7*w+5*x + 2*y + z)*(0.76 + 0.12*Log[w] - 0.08*Log[x] - 0.03*Log[y] - 
            0.07*Log[7*w+5*x + 2*y + z]),
       5*x == (7*w+5*x + 2*y + z)*(0.84 - 0.08*Log[w] + 0.11*Log[x] - 0.02*Log[y] - 
            0.08*Log[7*w+5*x + 2*y + z]),
       2*y == (7*w + 5*x + 2*y + z)*(-0.45 - 0.03*Log[w] - 0.02*Log[x] + 0.05*Log[y] +
            0.12*Log[7*w + 5*x + 2*y + z]),
       z == (7*w + 5*x + 2*y + z)*(-0.16 + 0*Log[w] -0*Log[x] -0*Log[y] + 
            0.03*Log[7*w + 5*x + 2*y + z])},
      {{w, 14, 0.1, 500},{x, 15, 0.1, 500},{y, 10, 0.1, 500}, {z, 100, 0.1, 500}}, 
      EvaluationMonitor :> Sow[{w, x, y, z}] ]]
  • FindMinimum : As we can write this problem as a minimization problem, I tried this (following the suggestion here). The value returned did not converge the system or equations to zero. I tried with only the first two equations, and that sort of converged to zero.

    {g1,g2,g3, g4} = {
               7*w - (7*w+5*x+2*y+z)* (0.76+0.12*Log[w]-0.08*Log[x]-0.03*Log[y] - 
                     0.07*Log[7*w + 5*x + 2*y + z]),
               5*x - (7*w +5*x+2*y+z)*(0.84-0.08*Log[w]+0.11*Log[x]-0.02*Log[y] - 
                     0.08*Log[7*w + 5*x + 2*y + z]),
               2*y - (7*w+5*x+2*y+z)*(-0.45-0.03*Log[w]- 0.02*Log[x] + 0.05*Log[y] + 
                     0.12*Log[7*w+5*x+2*y+z]),
               1*z - (7*w+5*x+2*y+z)*(-0.16+0*Log[w]-0*Log[x] - 0*Log[y] + 
                     0.03*Log[7*w+5*x+2*y+z])};
    
    subdomain = 0 < w < 100 && 0 < x < 100 && 0 < y < 100 && 0 < z < 100;
    res = FindMinimum[{Total[{g1,g2,g3,g4}^2],subdomain},{w,x,y,z}, AccuracyGoal->5]        
    {g1,g2,g3,g4}/.res[[2]]
    

Hope this is engaging enough for the experts here! Any ideas how I should find the solution or why can’t I? It’s the first time I am using Mathematica, and unfortunately the first time I am empirically solving a system/optimizing! Thanks a lot.

share|improve this question

closed as off-topic by Michael E2, Yves Klett, rasher, Sjoerd C. de Vries, Öskå Jul 1 at 9:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Michael E2, Yves Klett, rasher, Sjoerd C. de Vries, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

    
@Sektor Thanks for the edits. I promise to get better at this:). –  Divergent-Economist Mar 18 at 10:16
    
Oh, no need to thank me .. I hope I preserved the consistency :) Have a nice day ! –  Sektor Mar 18 at 10:17
1  
Your system simply has no solutions. What makes you so sure it does? –  george2079 Mar 19 at 20:25
    
This is a system of 4 goods with prices (w,x,y,z). We equate the expenditure of buying (7,5,2,1) units to the total expenditure*budget shares. The budget shares come from a demand system, and we have a theorem which proves that there exists a price vector solving this. Hence, I thought that I might not be using the best methods/code to solve this. But now I am re-checking my model too. Thanks. –  Divergent-Economist Mar 19 at 21:31
    
Your procedure looks basically correct -- first thing I'd advise is work through a problem with just two 'goods' assuming that makes sense. –  george2079 Mar 19 at 21:56

1 Answer 1

Forget about using Solve for Economics problems. Use Reduce instead or FindInstance if you want exact answers (but works only with small systems, see below)

http://www.mathematica-journal.com/2014/03/using-reduce-to-compute-nash-equilibria/

The above article in the Mathematica Journal has an example from consumer theory (2 goods ). To solve larger demand systems you may need to use more processors/memory. It always helps if you can write your systems as a polynomial system (sorry! not the case here) and also try to use rational numbers instead of machine numbers (i.e. write 8/100 instead of 0.008).

For your system Reduce and FIndInstance needs more than 8G of memory. I suspect that more memory will not make a difference. The logs plus the number of variable makes the system intractable. What type of preferences generated this demand system? Could you write with different utilities that are polynomial and don't have logs?

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.