Open JensRyeNielsen opened 4 years ago
Hey Jens I've been tinkering a bit with your problem, and come to the following conclusion (Jeppe might want to elaborate or correct this): I get the NotImplementedError, meaning that Sympy says it's unable to solve the equation. So I think you've simply found a limitation of the algorithms in the Sympy package. Since solving the problem is analytically possible, this is of course unfortunate. Strangely, sm.solve() gets the right answer (along with a wrong one), if you define beta to be negative:
beta = sm.symbols('beta',negative=True) f_CES = (alphakbeta+1-alpha)(1/beta) ss = sm.Eq(k,(sf_CES+(1-delta)k)/((1+n)(1+g))) kss = sm.solve(ss,k)
Gets one wrong and one right answer. Alternatively, you can also help Sympy out a bit, rewriting to:
ss2 = sm.Eq((k((1+n)(1+g)-1+delta)/s)*beta,(alphak**beta+1-alpha)) kss2 = sm.solve(ss2,k)
Allows Sympy to find the right answer without having to constrain beta (it looks strange, but is numerically correct).
I hope this helps somewhat, solving equations with algorithms is a big undertaking, so I think it's understandable that there are pitfalls in the Sympy package. There is actually work on replacing the solve-module with solveset: https://docs.sympy.org/latest/modules/solvers/solveset.html but this isn't finished yet, and I was unable to get it to solve the problem at hand.
Best regards, Asker
Hello Asker
Thank you very much for the help. Your answer was very usefull :)
Best regards, Jens
Hello Jeppe
My question concerns question D in problem set 6, where the steady state value of capital pr. capita must be found for CES-production. I have no trouble solving this problem numerically, which was the goal of the question. However, I was out of curiosity interested in finding the analytical solution like in question A but I am not able to when applying a similiar code:
f_CES=(alpha k beta+1-alpha) (1/beta) sol = sm.solve(1/((1+n) (1+g)) (s f_CES+(1-delta) * k)-k,k) sol[0]
At first I thought the problem was no analytical solution. But I was able to find an analytical solution by hand (Of course I may have been wrong but my study partner was too able to).
What may cause this problem?
Best //Jens