MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Simultaneous equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25320] Re: Simultaneous equations
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 23 Sep 2000 03:35:45 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <8q75t1$sq4@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I would be greatful if you would give the correct, original
equations and not a pice of code without any comments.

Before a difference equation can be solved a stability analysis
should be done. Every book that deal with the numerical
treatment of differential/difference equation has a chapter
about the stability analysis *and* you should try to
understand your equation *before* you use a computer.

Mathematica can help you to solve the equations and make the
stability analysis.

I will pick only one of your equations, simplify it and
show you that the equation is unstable

>           k[t]=y[t-1]+(1+r[t-1])*k[t-1]-c[t-1],

To get a idea I simplify it to
>           k[t]=(1+r)*k[t-1]

with constant r. The solution is

k[t]=(1+r)^t k[0]

since your r[0] >0 k[t]= (1+r)^t will quickly 
arrive a huge numerical value. This has
*nothing* to do with Mathematica.

If your "equations" come from a system of differential
equations you have probably choosen a false (unstable) 
scheme to trun it into d difference equation. You should
use NDSolve[] instead.

BTW: Your For[] loop syntax is wrong. For[] has only 4
arguments and the last argument is the loop body. You have to
write

> 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]
> ];

where does the last "}" come from ??? Mathematica can't handle
invalid user input .

Hope that helps
  Jens


"N.Tsotros" wrote:
> 
> 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: Strange behaviour of FiniteFields?
  • Next by Date: RE: Point inside a plygon? and PointInsidePolyhedronQ
  • Previous by thread: Re: Simultaneous equations
  • Next by thread: RE: Re: Simultaneous equations