ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 20 Jul 2020 21:15:30 +0200The Cake Eating Problem in Sagehttps://ask.sagemath.org/question/52559/the-cake-eating-problem-in-sage/Im interested in running a basic cake eating problem in sage. In its recursive formulation we have to solve the following bellman equations:
$$v(k_t)=ln(k_t-k_{t+1})+\beta v(k_{t+1}), \ \ \ \beta\in(0,1)$$
The algorithm for solving this problem is as follows:
Step 1: Take an initial guess of $v(k_{t+1})=0$<br>
Step 2: Solve for the maximum of $v(k_t)$ (in the first iteration this is $v(k_t)=ln(k_t-k_{t+1})$, the maximum here is simply where $k_{t+1}=0$ thus $v(k_t)=ln(k_{t})$ )<br>
Step 3: Using our maximum for $v(k_t)$ iterate it forward and update our bellman (in this case we have $v(k_t)=ln(k_t-k_{t+1})+\beta [ln(k_{t+1}]$)<br>
Step 4: Maximize this updated equation and repeat until convergence.
Any help is appreciated.Sun, 19 Jul 2020 09:16:17 +0200https://ask.sagemath.org/question/52559/the-cake-eating-problem-in-sage/Comment by slelievre for <p>Im interested in running a basic cake eating problem in sage. In its recursive formulation we have to solve the following bellman equations:
$$v(k_t)=ln(k_t-k_{t+1})+\beta v(k_{t+1}), \ \ \ \beta\in(0,1)$$
The algorithm for solving this problem is as follows:</p>
<p>Step 1: Take an initial guess of $v(k_{t+1})=0$<br>
Step 2: Solve for the maximum of $v(k_t)$ (in the first iteration this is $v(k_t)=ln(k_t-k_{t+1})$, the maximum here is simply where $k_{t+1}=0$ thus $v(k_t)=ln(k_{t})$ )<br>
Step 3: Using our maximum for $v(k_t)$ iterate it forward and update our bellman (in this case we have $v(k_t)=ln(k_t-k_{t+1})+\beta [ln(k_{t+1}]$)<br>
Step 4: Maximize this updated equation and repeat until convergence.</p>
<p>Any help is appreciated.</p>
https://ask.sagemath.org/question/52559/the-cake-eating-problem-in-sage/?comment=52583#post-id-52583Related question: [Ask Sage question 52565: Recursive problems](https://ask.sagemath.org/question/52565).Mon, 20 Jul 2020 20:18:17 +0200https://ask.sagemath.org/question/52559/the-cake-eating-problem-in-sage/?comment=52583#post-id-52583Comment by EconJohn for <p>Im interested in running a basic cake eating problem in sage. In its recursive formulation we have to solve the following bellman equations:
$$v(k_t)=ln(k_t-k_{t+1})+\beta v(k_{t+1}), \ \ \ \beta\in(0,1)$$
The algorithm for solving this problem is as follows:</p>
<p>Step 1: Take an initial guess of $v(k_{t+1})=0$<br>
Step 2: Solve for the maximum of $v(k_t)$ (in the first iteration this is $v(k_t)=ln(k_t-k_{t+1})$, the maximum here is simply where $k_{t+1}=0$ thus $v(k_t)=ln(k_{t})$ )<br>
Step 3: Using our maximum for $v(k_t)$ iterate it forward and update our bellman (in this case we have $v(k_t)=ln(k_t-k_{t+1})+\beta [ln(k_{t+1}]$)<br>
Step 4: Maximize this updated equation and repeat until convergence.</p>
<p>Any help is appreciated.</p>
https://ask.sagemath.org/question/52559/the-cake-eating-problem-in-sage/?comment=52585#post-id-52585@jaydfox I have a video which goes through the pen and paper work on solving a planners problem here:https://www.youtube.com/watch?v=Bv_tP3GP5Qg&list=PLLAPgKPWbsiQ0Ejh-twYC3Fr8_WA9BKCc&index=4. Its pretty much the same problem for a cake eating problem except the production function changed.Mon, 20 Jul 2020 21:15:30 +0200https://ask.sagemath.org/question/52559/the-cake-eating-problem-in-sage/?comment=52585#post-id-52585Comment by jaydfox for <p>Im interested in running a basic cake eating problem in sage. In its recursive formulation we have to solve the following bellman equations:
$$v(k_t)=ln(k_t-k_{t+1})+\beta v(k_{t+1}), \ \ \ \beta\in(0,1)$$
The algorithm for solving this problem is as follows:</p>
<p>Step 1: Take an initial guess of $v(k_{t+1})=0$<br>
Step 2: Solve for the maximum of $v(k_t)$ (in the first iteration this is $v(k_t)=ln(k_t-k_{t+1})$, the maximum here is simply where $k_{t+1}=0$ thus $v(k_t)=ln(k_{t})$ )<br>
Step 3: Using our maximum for $v(k_t)$ iterate it forward and update our bellman (in this case we have $v(k_t)=ln(k_t-k_{t+1})+\beta [ln(k_{t+1}]$)<br>
Step 4: Maximize this updated equation and repeat until convergence.</p>
<p>Any help is appreciated.</p>
https://ask.sagemath.org/question/52559/the-cake-eating-problem-in-sage/?comment=52581#post-id-52581Hi there. Could you provide a little more detail of what you're after? I'm not famliar with the cake eating problem, so I had to do a bit of googling to get the background needed to understand the question. As far as I can tell, you're looking at something like the [example here](https://en.wikipedia.org/wiki/Dynamic_programming#Example_from_economics:_Ramsey's_problem_of_optimal_saving), with *A* and *a* both set to 1 (so that the cake doesn't change size), and *b* set to your beta (discounted utility for eating the cake in the future):
Using the worked example in that wikipedia page, I played around with the problem. I think I have a feel for the problem, but I'm not sure quite what you're asking.Mon, 20 Jul 2020 18:37:57 +0200https://ask.sagemath.org/question/52559/the-cake-eating-problem-in-sage/?comment=52581#post-id-52581