Optimal control theory: How to maximize Hamiltonian in this case? The problem is to maximize $\int_0^1 y(t) + u(t)^2 dt$ where $y$ is state and $u$ is control.

Further we have $y' = u, y(0) = 5$.

I set up the Maximum Principle equations, but, in particular, I need to maximize the Hamiltonian in the $u$-variable. 

My nstructor's solutions does this by differentiating and letting it equal zero, i.e. he gets $$2u(t) + \lambda = 0.$$

Then he goes on with the other equations, and sovles for $\lambda$, and then $u$.

However, if we differentiate the Hamiltonian again with respect to $u$, then we get $$2 &gt; 0$$
which is not negative, hence surely the 1st equation is not warranted, as we have found a minimum, not maximum?
Hamiltonian
\begin{align}
H(y(t),u(t),\lambda(t)) = y(t)+u(t)^2 + \lambda(t) u(t)
\end{align}

First order conditions read
\begin{align}
&amp;H_u = 0 \quad \Longleftrightarrow \quad u(t) = -\frac{\lambda(t)}{2}\\[2mm]
&amp;\frac{d\lambda(t)}{dt} = -H_y = -1\\[2mm]
&amp;\lambda(1) = 0
\end{align}
Integrate costate
\begin{align}
&amp;\int \frac{d\lambda(t)}{dt} = \int -1\\[2mm]
&amp;\int d\lambda(t) = \int -dt\\[2mm]
&amp;\lambda(t) = -t + C 
\end{align}
with 
\begin{align}
&amp;\lambda(1) = -1 + C = 0 \quad \Longleftrightarrow \quad C = 1\\[2mm]
\Longrightarrow \quad &amp; \lambda(t) = 1-t\\[2mm]
\Longrightarrow \quad &amp; u(t) = \frac{t-1}{2}  
\end{align}
Now integrate state equation
\begin{align}
&amp;\int \frac{dy(t)}{dt} = \int \frac{t-1}{2}\\[2mm]
&amp;\int dy(t) = \int \frac{t-1}{2}dt\\[2mm]
&amp;y(t) = \frac{t}{2}\left(\frac{t}{2}-1\right) + C
\end{align}
with 
\begin{align}
&amp;y(0) =  C = 5\\
\Longrightarrow \quad &amp; y(t) = \frac{t}{2}\left(\frac{t}{2}-1\right) + 5
\end{align}

If I'm not mistaken necessary conditions are sufficient if maximized Hamiltonian is concave in state (Arrow sufficiency if I recall correctly (see e.g. Caputo, 2005, Ch. 3))
\begin{align}
H^*(y,\lambda) = \max_u H(y,u,\lambda) = y - \frac{\lambda^2}{2}.
\end{align}
Now we have
\begin{align}
H_y &gt; 0 = H_{yy}
\end{align}
such that concavity is given.