steady state finder! still works after 6 hours!

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

steady state finder! still works after 6 hours!

Leo07nard
Hey Everybody,
 I am a working on a new economic model.I have tried to write the codes to solve this DSGE model in Octave and find the steady state for using next in Dynare. But I ran the program this morning and after 6 hours, it is still working without any change! Is there anybody who can tell me what is happening? what is the meaning of this? Does it mean there is no solution for this problem? I put the source and the picture of the last line of octave here.
 Also octave always warns me by " warning: Using rat() heuristics for double-precision input (is this what you wanted?)" , what is the meaning of this?

octave.jpg
exam4.m
Reply | Threaded
Open this post in threaded view
|

Re: steady state finder! still works after 6 hours!

Thomas D. Dean-2
On 07/19/15 10:34, Leo07nard wrote:

> Hey Everybody,
>   I am a working on a new economic model.I have tried to write the codes to
> solve this DSGE model in Octave and find the steady state for using next in
> Dynare. But I ran the program this morning and after 6 hours, it is still
> working without any change! Is there anybody who can tell me what is
> happening? what is the meaning of this? Does it mean there is no solution
> for this problem? I put the source and the picture of the last line of
> octave here.
>   Also octave always warns me by " warning: Using rat() heuristics for
> double-precision input (is this what you wanted?)" , what is the meaning of
> this?
>
> octave.jpg <http://octave.1599824.n4.nabble.com/file/n4671705/octave.jpg>
> exam4.m <http://octave.1599824.n4.nabble.com/file/n4671705/exam4.m>

Octave 4.1.0+, I do not get any solution within a reasonable time, 5
minutes...  Maybe a problem with SymPy or the interface between octave
and SymPy is sloooow???

Using maple 15 and fsolve, the solution is returned quickly.

{Qbar = 146.1859101, Omegabar = 1.155594736}

Tom Dean


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: steady state finder! still works after 6 hours!

Thomas D. Dean-2
After running for several minutes, python is using 100% of one CPU.

Tom Dean

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: steady state finder! still works after 6 hours!

fbarbuto
On 19-07-2015 15:59, Thomas D. Dean wrote:
> After running for several minutes, python is using 100% of one CPU.
>
> Tom Dean

After 6.5 seconds Matlab returned this (plus a few intermediate lines):

--------------

eq1 =

Omegabar == (97*Omegabar)/100 - (9603*Omegabar^2*((200/(13*Qbar) + (100/Qbar - 100/99)^2 -
2/1287)^(1/2) - 100/Qbar + 100/99))/(1000000*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 -
2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar +
100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) -
100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330)) -
(9603*Omegabar^2*(1/Qbar - 1/99))/(10000*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 -
2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar +
100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) -
100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330)) + 3/100

eq2 =

-(Qbar*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) +
(100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar +
(99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000
+ (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330))/Omegabar == (301*Qbar)/19800 -
(97*Qbar*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) +
(100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar +
(99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000
+ (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330))/(99*Omegabar) + 199/200

Warning: Possibly spurious solutions. [solvelib::checkVectorSolutions]

c1 =

    33.957166883749936637715845077171
    1.1555947357398960182102501664145
   0.90221275720710083684727996953277
   0.55013082193348723765560802959132
  -0.64295531959083241534459063178293


c2 =

  -192.03106809965518577905241671637
   146.18591007809787081269098818378
   85.835723712966844293022398493044
  -241.42196871797658022054707968869
  -42.107485608195023067359978886338

--------------

Not sure if those are the desired/expected answers, but the code ran almost "as it was"
-- I only had to comment the 2nd and the 3rd lines.

Please attempt to the warning message, though.

Fausto


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: steady state finder! still works after 6 hours!

Doug Stewart-4


On Mon, Jul 20, 2015 at 12:14 AM, Fausto Arinos de A. Barbuto <[hidden email]> wrote:
On 19-07-2015 15:59, Thomas D. Dean wrote:
After running for several minutes, python is using 100% of one CPU.

Tom Dean

After 6.5 seconds Matlab returned this (plus a few intermediate lines):

--------------

eq1 =

Omegabar == (97*Omegabar)/100 - (9603*Omegabar^2*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/(1000000*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330)) - (9603*Omegabar^2*(1/Qbar - 1/99))/(10000*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330)) + 3/100

eq2 =

-(Qbar*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330))/Omegabar == (301*Qbar)/19800 - (97*Qbar*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330))/(99*Omegabar) + 199/200

Warning: Possibly spurious solutions. [solvelib::checkVectorSolutions]

c1 =

   33.957166883749936637715845077171
   1.1555947357398960182102501664145
  0.90221275720710083684727996953277
  0.55013082193348723765560802959132
 -0.64295531959083241534459063178293


c2 =

 -192.03106809965518577905241671637
  146.18591007809787081269098818378
  85.835723712966844293022398493044
 -241.42196871797658022054707968869
 -42.107485608195023067359978886338

--------------

Not sure if those are the desired/expected answers, but the code ran almost "as it was"
-- I only had to comment the 2nd and the 3rd lines.

Please attempt to the warning message, though.

Fausto


This shows that the code is ok, since the second values are the same as Tom got.

I also tried:

xx6=solve(eq1,Qbar)
and 
xx7=solve(eq2,Qbar)

they also ran  for a while and then I broke out of it.

This example should be reported to the python symbolic group.
Doug

--
DASCertificate for 206392


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: steady state finder! still works after 6 hours!

Doug Stewart-4


On Mon, Jul 20, 2015 at 7:01 AM, Doug Stewart <[hidden email]> wrote:


On Mon, Jul 20, 2015 at 12:14 AM, Fausto Arinos de A. Barbuto <[hidden email]> wrote:
On 19-07-2015 15:59, Thomas D. Dean wrote:
After running for several minutes, python is using 100% of one CPU.

Tom Dean

After 6.5 seconds Matlab returned this (plus a few intermediate lines):

--------------

eq1 =

Omegabar == (97*Omegabar)/100 - (9603*Omegabar^2*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/(1000000*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330)) - (9603*Omegabar^2*(1/Qbar - 1/99))/(10000*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330)) + 3/100

eq2 =

-(Qbar*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330))/Omegabar == (301*Qbar)/19800 - (97*Qbar*((3*(200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2))/10 - (39*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99)^2)/20 - 30/Qbar + (99*Omegabar*((200/(13*Qbar) + (100/Qbar - 100/99)^2 - 2/1287)^(1/2) - 100/Qbar + 100/99))/10000 + (99*Omegabar*(1/Qbar - 1/99))/100 + 1/330))/(99*Omegabar) + 199/200

Warning: Possibly spurious solutions. [solvelib::checkVectorSolutions]

c1 =

   33.957166883749936637715845077171
   1.1555947357398960182102501664145
  0.90221275720710083684727996953277
  0.55013082193348723765560802959132
 -0.64295531959083241534459063178293


c2 =

 -192.03106809965518577905241671637
  146.18591007809787081269098818378
  85.835723712966844293022398493044
 -241.42196871797658022054707968869
 -42.107485608195023067359978886338

--------------

Not sure if those are the desired/expected answers, but the code ran almost "as it was"
-- I only had to comment the 2nd and the 3rd lines.

Please attempt to the warning message, though.

Fausto


This shows that the code is ok, since the second values are the same as Tom got.

I also tried:

xx6=solve(eq1,Qbar)
and 
xx7=solve(eq2,Qbar)

they also ran  for a while and then I broke out of it.

This example should be reported to the python symbolic group.
Doug

--
DAS


I also tried one that is impossible to solve:
syms x y
eq1= y== x*log(x)+sin(x)
w=solve(eq1,x)

and it reported quickly that it could not solve it.

So sympi is trying to solve it and it is solvable.
Sympi just seems to get lost!!!

--
DAS


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: steady state finder! still works after 6 hours!

Leo07nard
Thanks so much for the all answer!
I think maple gets a reasonable answer! Have you run exactly the same code I had or you change something?
To find the solution I need to use symbolic toolbox that is not free in Matlab either Maple! I moved to Octave because it is free! Is there any solution to deal with it in octave?! or I have to move again to maple or pay for matlab?!
thanks so much
Reply | Threaded
Open this post in threaded view
|

Re: steady state finder! still works after 6 hours!

Nir Krakauer-2

Do you even need symbolic math if all you want is a numeric solution? The system can be solved numerically in Octave with no extra packages:

pbeta=.99;
epsilon=-1; 
sigma=.03; 
theta=.3;
k=13;
delta=.025;
rho=1.1;
Ybar=1;
Lambdabar=pbeta;
Rbar=1/pbeta;
Rebar=1/pbeta;
Rlbar= @(Qbar) 1 + 1 ./ Qbar;
munbar= @(Omegabar) Lambdabar*Omegabar*Rbar;
musbar= @(Omegabar, Qbar) Lambdabar*Omegabar*(Rlbar(Qbar)-Rbar);
muebar = @(Omegabar) Lambdabar*Omegabar*(1-pbeta);
epersbar = @(Omegabar, Qbar) musbar(Omegabar, Qbar) ./ muebar(Omegabar);
xbar = @(Omegabar, Qbar) -epersbar(Omegabar, Qbar)+(epersbar(Omegabar, Qbar)^(2)+(2/k)*(1-epsilon*epersbar(Omegabar, Qbar))).^(1/2);
Thetabar = @(Omegabar, Qbar) theta*(1+epsilon*xbar(Omegabar, Qbar)+(k/2)*xbar(Omegabar, Qbar).^(2));
phibar = @(Omegabar, Qbar) Omegabar ./ (Thetabar(Omegabar, Qbar)-musbar(Omegabar, Qbar)-xbar(Omegabar, Qbar).*muebar(Omegabar));
Ebar = @(Omegabar, Qbar) xbar(Omegabar, Qbar) .* Qbar;
Nbar = @(Omegabar,Qbar) Qbar ./ phibar(Omegabar, Qbar);
Dbar = @(Omegabar,Qbar) Qbar-Nbar(Omegabar,Qbar)-Ebar(Omegabar,Qbar);
Nnbar = @(Qbar) delta*(Qbar+Ybar);
eqs = @(Omegabar, Qbar) [Omegabar - (sigma+(1-sigma)*(munbar(Omegabar)+phibar(Omegabar, Qbar)*musbar(Omegabar, Qbar)+phibar(Omegabar, Qbar).*xbar(Omegabar, Qbar)*muebar(Omegabar))), Nbar(Omegabar,Qbar) - ((1-sigma)*(Qbar+Ybar-Rebar*Ebar(Omegabar,Qbar)-Rbar*Dbar(Omegabar,Qbar))+Nnbar(Qbar))];
v = fsolve (@(x) eqs(x(1), x(2)), [1, 100]);
#v = 1.1556   146.1857


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: steady state finder! still works after 6 hours!

Leo07nard
Thanks a lot! This one really works!! I was so confused how to come back to Matlab or Maple! but now it works!
I did that directly with Sympy but it has also problem and couldn't! I think there is a problem in Symbolic mode of that!