# A Cake Eating Problem in Continuous Time: Hamiltonian or HJB?

Your standard continuous time cake eating problem is defined as follows:

$$\max_{c(t)}\int_0^\infty e^{-rt} \ln (c(t)) dt$$ subject to $$f(k(t))=k(t)$$ $$\dot{k}(t)=-c(t)$$

Approaching this problem by using the Hamilton Jacobi Bellman Equation (the continuous time analogue of the discrete time bellman) with the appropriate drop of time parametrization we have: $$rv(k)=ln(c)+v'(k)\dot{k}$$

However in the context of using the (present valued) Hamiltonian proper we have: $$\mathcal{H}=e^{-rt} \ln(c(t))+\lambda(t)\dot{k}(t)$$

My question is, under what circumstances would one use the Hamiltonian over the HJB?

Note for more detail on this question see:
https://math.stackexchange.com/questions/3293825/transversality-condition-with-unbounded-value-function

• What kind of "different circumstances" do you have in mind? It is too vague for the moment. Nov 18, 2020 at 10:59
• @AlecosPapadopoulos I'm wondering if there are differences in terms of deriving policy functions VS deriving Euler Equations. As you could see I have little knowledge regarding the solution concept in HJB environments even though I've been working with them for some time now.
– EconJohn
Nov 18, 2020 at 14:35
• I seem to recall that the HJB solution is more general and also allows to derive policies off the optimal path. The Hamiltonian does not, but is generally easier to solve and allows for more intuition on its FOC. Nov 18, 2020 at 15:12

The comment by user @MaartenPunt is accurate. I don't think that in general one can identify situations where one should have a clear preference over one formulation over the other. It is more of a case-specific issue (and maybe for some twisted problems where one of the two may fail for usually technical reasons). See this post for some related discussion, https://economics.stackexchange.com/a/14289/61.

...Or sometimes one may get a bit confused, for example, in the specific problem, one could momentarily stop and wonder "what is the derivative of the Hamiltonian with respect to the state variable?"

Well, it is what it appears to be: zero. Because

$$\frac{\partial \mathcal H}{\partial k}= \frac{\partial \lambda \dot k}{\partial k} = -\frac{\partial \lambda c}{\partial k} = 0,$$

because we do not differentiate the decision variable, or the multiplier, with respect to the state variable. Now, optimally, we have

$$\frac{\partial \mathcal H}{\partial k} = -\dot \lambda,$$

and so it follows that the multiplier is constant along the time axis, $$\dot \lambda = 0$$. Then for the other first-order condition, we have

$$\frac{\partial \mathcal H}{\partial c} = 0 \implies e^{-rt} \frac 1 c = \lambda.$$

Differentiating this with respect to time we get

$$-re^{-rt} \frac 1 c - e^{-rt} \frac{\dot c}{c^2} = 0 \implies \dot c = -rc,$$

which is what we get from HJB as "policy" function.

As for whether this is a maximum, it is, because the Hamiltonian is jointly concave in $$c$$ and $$k$$, see, https://economics.stackexchange.com/a/6063/61.

• The word "policy" with the quotation marks is making me wonder, what else would you call this in such a context.
– EconJohn
Nov 19, 2020 at 0:39
• @EconJohn We don't usually call it a "policy function" when we do the Hamiltonian, although of course it is. We usually call it the "optimal path", the "optimal rule", things like that. That's why I used quotation marks. Nov 19, 2020 at 1:07