Group Abstract Group Abstract

Message Boards Message Boards

how to write an NRSolve function ?

Posted 12 years ago
The Mathematica function RSolve has limitations on the form of recurrence formulas that it will handle (these limitatiions seem to give rise to many similar questions on this discussion group).
What existing parts of Mathematica would I need to utilize, to try to write a new function to numerically solve systems of coupled nonlinear recurrence equations?
(call the new function NRSolve)
These nonlinear systems of recurrence equations often arise in macroeconomics.   

To be specific, here is a small model (small by macroeconomic standards) that I want to numerically solve using Mathematica, written in a RSolve-type recurrence-equation form:
 alpha = 10;
 beta = -1/2;
 lambda = 1;
 epsilon = 3/4;
 sigma = 1/2;
 At = 200;
 Cn = 400;
 
 gL = 2/100;
gMult[t_] := Piecewise[{{1, t <= 1}}, 1 + gL];
mua[t_] := (alpha*Ar[t]^beta - lambda);

eqs = {Cw[t] == (vC[t]*pc[t] + Aw[t - 1]*pa[t] - L[t - 1] +
      Ar[t]*(epa[t] - pa[t]))/(epc[t] + pc[t]),
  Cr[t] == (vD[t - 1] + Ar[t - 1]*pa[t])/pc[t],
  vC[t] == Cw[t] + Cr[t], L[t] == L[t - 1]*gMult[t], vD[t] == L[t],
  Aw[t] == At - Ar[t],
  Ar[t] == (Cr[t]*pc[t] + Aw[t - 1]*pa[t] - L[t - 1] - vD[t])/pa[t],
  pc[t] == pc[t - 1]*gMult[t]*(vC[t]/Cn)^sigma,
  pa[t] == epa[t]/(1 - mua[t]),
  epc[t] == epc[t - 1]*gMult[t]*(pc[t]/epc[t - 1])^epsilon,
  epa[t] == epa[t - 1]*gMult[t]*(pa[t]/epa[t - 1])^epsilon,
 
  Ar[0] == 100, Aw[0] == 100, vC[0] == 400, Cr[0] == 200,
  Cw[0] == 200, vD[0] == 100, L[0] == 100, pa[0] == 1, pc[0] == 1,
  epa[0] == 1, epc[0] == 1,
 
  Ar[1] == 100, Aw[1] == 100, vC[1] == 400, Cr[1] == 200,
  Cw[1] == 200, vD[1] == 100, L[1] == 100, pa[1] == 1, pc[1] == 1,
  epa[1] == 1, epc[1] == 1}

vars = {Ar[t], Aw[t], vC[t], Cr[t], Cw[t], vD[t], L[t], pa[t], pc[t],
   epa[t], epc[t]};

(* numerical solution desired for t>=2  *)
POSTED BY: Terry Heidelberg
2 Replies
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard