Coupled State–Costate Dynamics, Hamiltonian Matrices, and Shooting Instability
The first-order necessary conditions of optimal control form a coupled dynamical system. The state and costate cannot generally be solved independently because the optimal control depends on both.
This section develops that structure through a scalar quadratic optimal-control example and uses the result to explain why simple shooting can fail, even when:
the original dynamics are linear;
the optimality equations are solved analytically;
there is no numerical integration error; and
the initial costate guess is extremely accurate.
The main topics are:
coupled state–costate equations;
the costate as a sensitivity or dual variable;
a fixed-endpoint quadratic example;
eigenvalue and eigenvector analysis;
Hamiltonian matrix structure;
spectral symmetry of Hamiltonian systems;
propagation of shooting errors;
long-horizon instability; and
motivation for robust numerical optimal-control methods.
Canonical State–Costate Equations¶
Consider the optimal-control problem
subject to
The Hamiltonian is
The canonical equations are
Expanding the costate equation gives
Thus, the costate generally depends on:
the state;
the control;
the costate itself; and
possibly time.
Why the State and Costate Are Coupled¶
Suppose the pointwise optimality condition gives
Substitution into the state equation gives
Therefore,
Similarly,
The combined optimality system is
The two systems must be solved simultaneously.
Interpretation of the Costate¶
The costate is a dual or adjoint variable associated with the state dynamics.
Conceptually, it measures the sensitivity of the optimal cost to a perturbation in the state.
A common interpretation is
where denotes the optimal value function, subject to sign and formulation conventions.
If perturbing the state had no influence on the cost, then there would be no meaningful optimization pressure associated with that state direction.
The costate transmits this sensitivity through the optimality system and directly affects the optimal control.
A Scalar Quadratic Example¶
Consider
subject to
The time horizon is fixed, and the state is fixed at both endpoints:
There is no terminal cost.
Hamiltonian and Optimal Control¶
The Hamiltonian is
The Hamiltonian is quadratic in , and the control is unconstrained. Therefore, the stationarity condition applies:
Hence,
This formula explicitly demonstrates that the optimal control depends on the costate.
Coupled Optimality Dynamics¶
The state equation becomes
The costate equation is
Therefore,
Define
Then
Boundary Conditions¶
The state is fixed at both endpoints:
Because both endpoint values of the state are fixed, the costate has no directly prescribed initial or final value.
Thus, the problem is a two-point boundary-value problem with:
one known state condition at ;
one known state condition at ; and
an unknown initial costate that must be selected correctly.
Eigenvalue Analysis¶
For
the eigenvalues satisfy
Here,
Therefore,
Hence,
One eigenvalue is negative and the other is positive.
Thus, the state–costate dynamics contain:
one exponentially decaying mode in forward time; and
one exponentially growing mode in forward time.
Eigenvectors¶
For
an eigenvector satisfies
Choosing the second component equal to one gives
For
one may choose
The general solution is
Stable and Unstable Modes¶
In forward time:
whereas
In backward time, the roles reverse.
Therefore, integrating the full Hamiltonian system in either direction generally exposes one unstable mode.
Figure 1:A Hamiltonian system exposes paired stable and unstable eigenvalues during forward integration.
Hamiltonian Matrix Structure¶
For a general canonical system,
the Jacobian of the Hamiltonian vector field has the block form
This is a Hamiltonian matrix under the standard smoothness and symmetry assumptions on second derivatives.
A real matrix is Hamiltonian if
where
Equivalently,
is symmetric.
Spectral Symmetry¶
Hamiltonian matrices have a characteristic eigenvalue symmetry.
If
is an eigenvalue, then the spectrum also contains
For real matrices, complex conjugacy adds
Thus, a complex eigenvalue generally appears in a quartet:
For a two-dimensional Hamiltonian system, only two eigenvalues exist. Therefore, a nonreal eigenvalue with nonzero real part would require four eigenvalues and cannot occur. The pair must instead lie:
symmetrically on the real axis; or
symmetrically on the imaginary axis.
In the present example, the pair is
Simple Shooting Formulation¶
Suppose the unknown initial costate is guessed as
Then
The shooting method adjusts until
Define the residual
The desired initial costate satisfies
Propagation of Initial-Costate Error¶
Let the exact initial costate be
Define the initial error
The trajectory error is
Because the initial state is exact,
Therefore,
Using the eigendecomposition
we have
Unless the initial error lies exactly in the stable eigenspace, it has a component that grows like
Long-Horizon Error Amplification¶
Suppose the initial costate error has magnitude
The unstable contribution at the final time behaves approximately as
Thus, even a tiny initial error becomes large when is sufficiently long.
To maintain a fixed final error tolerance , the initial error must satisfy roughly
The required initial-costate accuracy therefore becomes exponentially severe with the horizon length.
Overflow Can Occur Without Integration Error¶
The instability is not caused only by numerical integration.
Even if
is evaluated analytically or exactly to machine precision, the unstable mode can exceed the largest representable floating-point number.
Thus, overflow may occur because of:
not because of a low-order integration method.
A numerical integrator adds truncation and roundoff errors, which provide additional disturbances that can excite the unstable mode.
Why Backward Integration Does Not Solve the Problem¶
Forward integration contains the growing mode
One might attempt backward integration from . However, backward time reverses stability:
becomes the growing mode under backward propagation.
Therefore, the Hamiltonian boundary-value problem is generally not converted into a well-conditioned initial-value problem merely by changing the direction of integration.
Shooting Jacobian Conditioning¶
For scalar shooting,
Its derivative is
This sensitivity is a component of the state-transition matrix:
Because this matrix contains exponentially large and small singular directions, the shooting Jacobian can become poorly scaled or ill-conditioned.
This makes Newton corrections sensitive to:
residual errors;
Jacobian approximation errors;
finite precision; and
the initial guess.
Stable and Unstable Manifold Interpretation¶
The exact optimal trajectory lies at the intersection of conditions imposed at opposite ends of the interval.
The initial endpoint conditions define a set of allowable initial points. The terminal conditions define a set of trajectories that arrive at the required terminal set.
The correct solution must lie on a special manifold that balances stable and unstable Hamiltonian modes.
A small error moves the trajectory away from this manifold, after which the unstable mode dominates.
Why Multiple Shooting Helps¶
Multiple shooting divides
into shorter intervals.
Instead of propagating one initial error over the full horizon, each segment propagates errors only over a shorter duration.
If the maximum segment length is , the local amplification behaves like
rather than
Continuity constraints connect the segment solutions.
The method introduces more variables but improves conditioning.
Why Direct Methods Are Attractive¶
Direct methods avoid solving the continuous Hamiltonian boundary-value problem by shooting from one endpoint.
Instead, they discretize:
states;
controls;
dynamics;
path constraints; and
endpoint conditions.
The resulting nonlinear programming problem can exploit:
sparse linear algebra;
defect constraints;
scaling;
robust globalization strategies; and
simultaneous adjustment of the complete trajectory.
This does not eliminate all numerical difficulties, but it often avoids catastrophic initial-value sensitivity.
Practical Diagnostic Workflow¶
Before implementing simple shooting:
derive the coupled state–costate dynamics;
substitute the optimal control;
linearize around a representative trajectory;
inspect eigenvalues or finite-time growth;
estimate the amplification across the horizon;
inspect scaling and endpoint sensitivity;
test a short horizon first; and
use multiple shooting or direct methods if the system is strongly unstable.
Common Errors¶
Treating state and costate dynamics as decoupled.
Solving the costate first and substituting it afterward without justification.
Forgetting that the optimal control depends on the costate.
Assuming a linear original plant produces a stable Hamiltonian system.
Attributing every shooting failure to the ODE solver.
Assuming backward integration removes instability.
Ignoring exponential error amplification over long horizons.
Using simple shooting without inspecting the spectrum or sensitivities.
Confusing machine overflow with an algebraic error in the equations.
Simplifying the physical problem instead of selecting a suitable numerical method.
Summary¶
The main conclusions are:
State and costate equations form a coupled optimality system.
The costate represents the sensitivity of the cost to state perturbations.
In the quadratic example, the optimal control is .
The resulting Hamiltonian dynamics contain eigenvalues .
Hamiltonian spectra are symmetric about the real and imaginary axes.
One mode grows in forward time and another grows in backward time.
Initial-costate errors can grow exponentially across the horizon.
This failure can occur even with analytic propagation and no integration error.
Long-horizon simple shooting can exceed finite-precision capability.
Multiple shooting and direct methods provide more practical alternatives.
Connection. The final complication for the indirect framework is a constraint that acts continuously along the trajectory, creating active sets, multipliers, and constrained arcs.