Re: Simultaneous equations

• To: mathgroup at smc.vnet.net
• Subject: [mg25331] Re: [mg25282] Simultaneous equations
• From: "Richard Finley" <rfinley at medicine.umsmed.edu>
• Date: Sat, 23 Sep 2000 03:35:54 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

Nick,
Your code blows up because k(t) becomes less than zero and then you start getting complex roots for terms such as k(t)^a...that is terms such as (-.2)^.36  ; this then propatates to all your other terms since they mostly depend on k(t).    How you handle that would depend on the details of your problem.  regards..RF

>>> "N.Tsotros" <travis at beackle.fsnet.co.uk> 09/19/00 01:45AM >>>
Hi,

The following problem may, at first sight, look like a "debugging" problem
but, in fact, it is not. I'd therefore be very grateful if you could have a
quick look at it.

Consider the following simple code:

g=0.983;  d=0.1; dg=0.1; a=0.36; z=0.2; rtp=0.04; s=g/(1+rtp); prod=1;

r[-1]=0.0434463; c[-1]=0.706982; y[-1]=0.604069;
w[-1]=12.8993; h[-1]=10.4277; q[-1]=1.34837; k[-1]=2.36875;
invgp[-1]=0.0943875;
inv[-1]=0.236875;  gp[-1]=0.943857;

For[t=0, t<=400, t++,

tp[t]=0.07,
tc[t]=0.23,
k[t]=y[t-1]+(1+r[t-1])*k[t-1]-c[t-1],
gp[t]=invgp[t-1]+(1-dg)*gp[t-1],
r[t]=a*(1-tp[t]-tc[t])*prod*(k[t]^(a-1))*(gp[t]^z)-d,
q[t]=prod*(k[t]^a)*(gp[t]^z),
y[t]=(1-a)*(1-tp[t]-tc[t])*prod*(k[t]^a)*(gp[t]^z),
invgp[t]=tp[t]*q[t],
h[t]=((1+r[t-1])*(h[t-1]-y[t-1]))/g,
w[t]=h[t]+(1+r[t])*k[t],
c[t]=(1-s)*w[t]
}];

Print["  "]
Print["q    k    gp "]
Print["_________________"]
For[t=-1, t<=400, t++,
{
var[t,1]=N[q[t]/q[-1],4],
var[t,2]=N[k[t]/k[-1],4],
var[t,3]=N[gp[t]/gp[-1],4],
Print[var[t,1],"                ",var[t,2],"               ",var[t,3]]
}
]

I want to find how variables like q, k and gp evolve over time (400
periods), from t=0 to t=400. Running the program, however, I find that,
after a few periods, the path (FOR loop) "explodes". The right transition
path should produce a value of unity for all variables in each period t. Any
ideas why is this so?  The equations of the program are correct (checked n
times, believe me!) so I wonder whether the problem arises simply because
Mathematica cannot handle these sort of simultaneous calculations, ie.
solving the 9 difference equations in the FOR loop simultaneously.
Any help/reply would be greatly appreciated.

Nick

• Prev by Date: RE: Point inside a plygon?
• Next by Date: Re: Noise Sphere
• Previous by thread: Simultaneous equations
• Next by thread: Re: Simultaneous equations