Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.6K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

NDSolve not working on Mathematica (probably due to a syntax error)

Posted 10 years ago

Hello,

I have a system of equations which I try to solve with the command NDSolve. Probably, I am making a mistake concerning syntax but I could not find since many hours.

Here is my code ;

u[c_] := (c^(1 - \[Sigma]) - 1)/(1 - \[Sigma])
h[s_] := (2 hbar)/(1 + Exp[\[Eta] (1 - s/sbar)])
d[s_] := (b s^2)/2
mit[m_] := m^\[Alpha]
r[m_, s_] := 
pricemit - (D[u[c], c] /. c -> (\[Chi] s + mit[m])/\[Beta]) D[mit[m],m]\[Psi][k_] := \[Omega] + (1 - \[Omega]) Exp[-\[Gamma] k]
co[a_] := x  (a^2)/2
adap[k_, s_] := (\[Rho] + h[s] + \[Delta]) co'[\[Delta] k] + \[Psi]'[k] d[s]

The calibration I use ;

paramFinal2 = {\[Sigma] -> 2.1, \[Rho] -> 0.01, sbar -> 101, \[Eta] -> 5.8, hbar -> 0.04, b -> 0.0001, \[Gamma] -> 0.6, \[Chi] -> 0.025, \[Omega] -> 0.185, \[Delta] -> 0.015, x -> 0.14, \[Beta] -> 0.8, pricemit -> 0.006, \[Alpha] -> 0.33};

For initial conditions ;

{aa} = {0.093944}
{mm} = {122.833}
{cc} = {6.8795}
{kk} = {6.26293}
{ss} = {24.4696}

The system is composed by 5 equations that I define as follows ;

dec1 = c'[t] == u'[c[t]]/u''[c[t]] (-\[Chi] - (\[Rho] + h[s[t]]) + h'[s[t]]/([Rho] + h[s[t]]) (1/(u'[c[t]]/\[Beta]) (u[c[t]] - \[Psi][k[t]] d[s[t]] -co[a[t]] - pricemit mit[m[t]])) + (\[Psi][k[t]]  d'[s[t]])/(u'[c[t]]/\[Beta]) -h'[s[t]]/(\[Rho] + h[s[t]]) (\[Beta] c[t] - \[Chi] s[t] - mit[m[t]]) + (h'[s[t]] co'[a[t]] )/((\[Rho] + h[s[t]]) u'[c[t]]/\[Beta]) (a[t] - \[Delta] k[t]));

dea1 = a'[t] == - (co'[a[t]]/co''[a[t]] (\[Rho] + + \[Psi]'[k[t]]/co'[a[t]] + \[Delta]));

des1 = s'[t] ==   -(\[Beta] c[t] - \[Chi] s[t] - mit[m[t]]);

dek1 = k'[t] == -(a[t] - \[Delta] k[t]);

dem1 = m'[t] == -(mit'[m[t]]/mit''[m[t]] (-\[Chi] - (\[Rho] + h[s[t]]) +h'[s[t]]/(\[Rho] + h[s[t]]) (1/(u'[c[t]]/\[Beta]) (u[c[t]] - \[Psi][k[t]] d[s[t]] - co[a[t]] - pricemit mit[m[t]])) + (\[Psi][k[t]]  d'[s[t]])/(u'[c[t]]/\[Beta]) - h'[s[t]]/(\[Rho] + h[s[t]]) (\[Beta] c[t] - \[Chi] s[t] - mit[m[t]]) + (h'[s[t]] co'[a[t]] )/((\[Rho] + h[s[t]]) u'[c[t]]/\[Beta]) (a[t] - \[Delta] k[t])));

I use NDSolve as follows ;

nbsa = NDSolve[{dec1 /. paramFinal2, des1 /. paramFinal2, dea1 /. paramFinal2, dek1 /. paramFinal2, dem1 /. paramFinal2, c[0] ==  cc (1 - 10^-10), s[0] == ss (1 - 10^-5), a[0] == aa (1 - 10^-5), k[0] == kk (1 + 10^-2), m[0] == mm (1 -10^-2)}, {c[t], s[t], k[t], a[t], m[t]}, {t, 0, 350}]

Mathematica always gives me the error

NDSolve::deqn: Equation or list of equations expected instead of True in the first argument

What am I missing on this code ? Thanks so much in advance for all hints or suggestions.

2 Replies
Posted 10 years ago
POSTED BY: Bill Simpson

Thanks Bill ! I have first posted this on stackoverflow as I was thinking that I was doing a mistake on syntax but after I thought that there could be some singularity problem at the fix point as two differential equations in the system was quite similar and I posted here. I could have deleted the post on stackoverflow, which I have just done. Actually, I have done what you have suggested me and it worked. Thanks again.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard