<p>After a comment exchange, let's provide the answer under disrete-time formulation. The problem is now written</p>

<p>\begin{align}
      &amp;\max_{\{u\}_1^T, \{y\}_1^T}\sum^T_{t=1}{F(y_t,u_t)}\\
\text{s.t.} \quad &amp; y_{t+1}-y_t = f(y_t,u_t)\\
&amp; y_1 = \text{given}\\
&amp; y_{T+1}~~\text{free}
\end{align}</p>

<p>where $y_{t+1}$ is the value of the stock variable at the begining of period $t+1$/end of period $t$.
The Lagrangean is
\begin{align}
\Lambda = \sum^T_{t=1}{\big(F(y_t,u_t) + \lambda_t[f(y_t,u_t)-y_{t+1}+y_t]\big)}
\end{align}</p>

<p>Note that $\lambda_t$ is associated with $y_{t+1}$.</p>

<p>The FOCS are (to hold $\forall t$ in the horizon)</p>

<p>$$\frac {\partial \Lambda}{\partial u_t} = F_u(y_t,u_t) + \lambda_tf_u(y_t,u_t) = 0 \tag{1}$$</p>

<p>$$\frac {\partial \Lambda}{\partial y_{t+1}} = -\lambda_{t} + F_y(y_{t+1},u_{t+1}) + \lambda_{t+1}[f_u(y_{t+1},u_{t+1}) +1]    = 0 $$</p>

<p>$$\implies F_y(y_{t+1},u_{t+1}) + \lambda_{t+1}f_y(y_{t+1},u_{t+1}) = -(\lambda_{t+1}-\lambda_{t}) \tag{2}$$</p>

<p>which are the conditions we would have obtain if we have used the Hamiltonian formulation. To obtain the terminal value for $\lambda_t$, we set $t=T$ in $(2)$, (since the last variable in the $y$-sequence is $y_{T+1}$), and we obtain:  </p>

<p>$$F_y(y_{T+1},0) + \lambda_{T+1}f_y(y_{T+1},0) = -(\lambda_{T+1}-\lambda_{T})$$</p>

<p>$u_{T+1}=0$ because there is no decision to be made in period $T+1$. Moreover $\lambda_{T+1}$ should also be set to zero, since it is associated with $y_{T+2}$ (end of period $T+1$) and we are out of the horizon. So we are left with</p>

<p>$$F_y(y_{T+1},0) = \lambda_{T}$$</p>

<p>Whether now we will get $\lambda_T=0$ or not depends on the formulation of the objective function  $F(y_{t},u_t)$: does it indeed include the state variable? If yes what is the value of its derivative with respect to the state variable when the decision variable is set to zero? Etc</p>

CC BY-SA 3.0
2015-10-18T00:50:14.333Z
Thanks for the effort, however, that post does not present an answer to the question at hand. Still, how come you changed to discrete time?
clueless
CC BY-SA 3.0
2015-10-18T01:58:45.487Z
@clueless Because as I wrote in a previous comment, obtaining the "Hamiltonian" FOCS using a static Lagrange formulation is straightforward in discrete time, and it will be useful content here.
Alecos Papadopoulos
CC BY-SA 3.0
2015-10-17T11:56:28.333Z
2015-10-17T15:50:19.500Z
2015-10-17T15:50:19.500Z
Alecos Papadopoulos
<p>Consider the simplest problem of optimal control
\begin{align}
      &amp;\max_u\int^T_0{F(y,u)dt}\\
\text{s.t.} \quad&amp;\dot y = f(y,u)\\
&amp; y(0) = y_0\\
&amp; y(T)~~\text{free}
\end{align}
where $y$ is the state and $u$ the control. I'd like to use a static-like approach to derive the necessary conditions of the maximum principle. Build Lagrangian: 
\begin{align}
L^1(y,u,\lambda) = \int^T_0{[F(y,u) + \lambda(f(y,u)-\dot y)]dt}
\end{align}</p>

<p>Necessary conditionds for optimum are given by
\begin{align}
L^1_u &amp;= \int^T_0{[F_u + \lambda f_u] dt} = 0\\
L^1_\lambda &amp;= \int^T_0{[f(y,u)-\dot y ]dt} = 0
\end{align}</p>

<p>Define Hamiltonian
\begin{align}
H(y,u,\lambda) := F(y,u) + \lambda f(y,u)
\end{align}</p>

<p>such that the FOCs can be written as
\begin{align}
H_u &amp;= 0~\forall t\\
H_\lambda &amp;= \dot y~\forall t
\end{align}</p>

<p>For last FOC we write Lagrangian as (integrating by parts)
\begin{align}
L^2(y,u,\lambda) = \int^T_0{[H(y,u,\lambda) + \dot\lambda y]dt} + y_0\lambda(0) - y(t)|_{t=T}\lambda(T)
\end{align}</p>

<p>Note that $L^1=L^2$. Last FOC is given by differentiating over $y$ ($y_0$ drops, cause it's fixed)
\begin{align}
L^2_y &amp;= \int^T_0{[H_y + \dot \lambda] dt} - \lambda(T) = 0\\
\end{align}    </p>

<p>and finally 
\begin{align}
H_y &amp;= -\dot \lambda ~\forall t\\
\lambda(T) &amp;= 0 
\end{align}</p>

<p>So we are done here. </p>

<ul>
<li>How can I get those conditions without varying the Lagrangian, i.e. stick to either $L^1$ or $L^2$? </li>
</ul>

CC BY-SA 3.0
2015-10-15T18:01:02.147Z
For all three focs and the terminal condition, it is pretty straightforward in discrete time -do you have a special reason to do it in continuous time?
Alecos Papadopoulos
CC BY-SA 3.0
2015-10-17T08:35:10.860Z
There is no special reason. It's out of curiosity and since the orginial maximum principle is formulated in continuous time. I was just wondering why to use a variational approach, if the conditions can be presented that neatly. Actually, if you come from utility maximization of a consumer, the presented way seems to be more 'natural' than, say, [this](http://economics.stackexchange.com/questions/6435/solving-the-hamilton-jacobi-bellman-equation-necessary-and-sufficient-for-optim) approach.
clueless
<optimization><optimal-control>
Simple Derivation of Maximum Principle
clueless
# Simple Derivation of Maximum Principle

(Asked by: username_0 on 2015-10-15)

Consider the simplest problem of optimal control
\begin{align}
&\max\_u\int^T\_0{F(y,u)dt}\\
\text{s.t.} \quad&\dot y = f(y,u)\\
& y(0) = y\_0\\
& y(T)~~\text{free}
\end{align}
where $y$ is the state and $u$ the control. I'd like to use a static-like approach to derive the necessary conditions of the maximum principle. Build Lagrangian:
\begin{align}
L^1(y,u,\lambda) = \int^T\_0{[F(y,u) + \lambda(f(y,u)-\dot y)]dt}
\end{align}

Necessary conditionds for optimum are given by
\begin{align}
L^1\_u &= \int^T\_0{[F\_u + \lambda f\_u] dt} = 0\\
L^1\_\lambda &= \int^T\_0{[f(y,u)-\dot y ]dt} = 0
\end{align}

Define Hamiltonian
\begin{align}
H(y,u,\lambda) := F(y,u) + \lambda f(y,u)
\end{align}

such that the FOCs can be written as
\begin{align}
H\_u &= 0~\forall t\\
H\_\lambda &= \dot y~\forall t
\end{align}

For last FOC we write Lagrangian as (integrating by parts)
\begin{align}
L^2(y,u,\lambda) = \int^T\_0{[H(y,u,\lambda) + \dot\lambda y]dt} + y\_0\lambda(0) - y(t)|\_{t=T}\lambda(T)
\end{align}

Note that $L^1=L^2$. Last FOC is given by differentiating over $y$ ($y\_0$ drops, cause it's fixed)
\begin{align}
L^2\_y &= \int^T\_0{[H\_y + \dot \lambda] dt} - \lambda(T) = 0\\
\end{align}

and finally
\begin{align}
H\_y &= -\dot \lambda ~\forall t\\
\lambda(T) &= 0
\end{align}

So we are done here.

* How can I get those conditions without varying the Lagrangian, i.e. stick to either $L^1$ or $L^2$?

**Tags:** optimization, optimal-control

> **Comments:**
> **username_1**: For all three focs and the terminal condition, it is pretty straightforward in discrete time -do you have a special reason to do it in continuous time?  
> **username_0**: There is no special reason. It's out of curiosity and since the orginial maximum principle is formulated in continuous time. I was just wondering why to use a variational approach, if the conditions can be presented that neatly. Actually, if you come from utility maximization of a consumer, the presented way seems to be more 'natural' than, say, [this](http://economics.stackexchange.com/questions/6435/solving-the-hamilton-jacobi-bellman-equation-necessary-and-sufficient-for-optim) approach.  

---

## 1 answers

### Answer by username_1 on 2015-10-17. Score: 2

After a comment exchange, let's provide the answer under disrete-time formulation. The problem is now written

\begin{align}
&\max\_{\{u\}\_1^T, \{y\}\_1^T}\sum^T\_{t=1}{F(y\_t,u\_t)}\\
\text{s.t.} \quad & y\_{t+1}-y\_t = f(y\_t,u\_t)\\
& y\_1 = \text{given}\\
& y\_{T+1}~~\text{free}
\end{align}

where $y\_{t+1}$ is the value of the stock variable at the begining of period $t+1$/end of period $t$.
The Lagrangean is
\begin{align}
\Lambda = \sum^T\_{t=1}{\big(F(y\_t,u\_t) + \lambda\_t[f(y\_t,u\_t)-y\_{t+1}+y\_t]\big)}
\end{align}

Note that $\lambda\_t$ is associated with $y\_{t+1}$.

The FOCS are (to hold $\forall t$ in the horizon)

$$\frac {\partial \Lambda}{\partial u\_t} = F\_u(y\_t,u\_t) + \lambda\_tf\_u(y\_t,u\_t) = 0 \tag{1}$$

$$\frac {\partial \Lambda}{\partial y\_{t+1}} = -\lambda\_{t} + F\_y(y\_{t+1},u\_{t+1}) + \lambda\_{t+1}[f\_u(y\_{t+1},u\_{t+1}) +1] = 0 $$

$$\implies F\_y(y\_{t+1},u\_{t+1}) + \lambda\_{t+1}f\_y(y\_{t+1},u\_{t+1}) = -(\lambda\_{t+1}-\lambda\_{t}) \tag{2}$$

which are the conditions we would have obtain if we have used the Hamiltonian formulation. To obtain the terminal value for $\lambda\_t$, we set $t=T$ in $(2)$, (since the last variable in the $y$-sequence is $y\_{T+1}$), and we obtain:

$$F\_y(y\_{T+1},0) + \lambda\_{T+1}f\_y(y\_{T+1},0) = -(\lambda\_{T+1}-\lambda\_{T})$$

$u\_{T+1}=0$ because there is no decision to be made in period $T+1$. Moreover $\lambda\_{T+1}$ should also be set to zero, since it is associated with $y\_{T+2}$ (end of period $T+1$) and we are out of the horizon. So we are left with

$$F\_y(y\_{T+1},0) = \lambda\_{T}$$

Whether now we will get $\lambda\_T=0$ or not depends on the formulation of the objective function $F(y\_{t},u\_t)$: does it indeed include the state variable? If yes what is the value of its derivative with respect to the state variable when the decision variable is set to zero? Etc

> **Comments:**
> **username_0**: Thanks for the effort, however, that post does not present an answer to the question at hand. Still, how come you changed to discrete time?  
> **username_1**: @username_0 Because as I wrote in a previous comment, obtaining the "Hamiltonian" FOCS using a static Lagrange formulation is straightforward in discrete time, and it will be useful content here.  

---

