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
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 &quot;what is the derivative of the Hamiltonian with respect to the state variable?&quot;
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 &quot;policy&quot; 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.