Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

LGL Costate Estimation and General Pseudospectral Transcription

This section completes the treatment of costate estimation for the three principal Legendre pseudospectral schemes:

  1. Legendre–Gauss (LG),

  2. Legendre–Gauss–Radau (LGR), and

  3. Legendre–Gauss–Lobatto (LGL).

The first part derives the LGL costate equations from the KKT conditions of the LGL nonlinear program. The second part compares the LG, LGR, and LGL costate mappings. The final part extends the pseudospectral transcription from the simplified Mayer problem on [1,1][-1,1] to a general Bolza problem defined on [t0,tf][t_0,t_f] with endpoint constraints and path constraints.

Legendre–Gauss–Lobatto Grid

Let

τ1,,τN\tau_1,\ldots,\tau_N

be the LGL points. Unlike LG and LGR grids, the LGL grid includes both endpoints:

τ1=1,τN=1.\boxed{ \tau_1=-1, \qquad \tau_N=1. }

The interior points are roots of the derivative of an appropriate Legendre polynomial.

LGL State Approximation

Approximate the state by

X(τ)=i=1NXiLi(τ),\boxed{ \boldsymbol{X}(\tau) = \sum_{i=1}^{N}\boldsymbol{X}_iL_i(\tau), }

where

Li(τ)=j=1jiNττjτiτj.L_i(\tau) = \prod_{\substack{j=1\\j\neq i}}^{N} \frac{\tau-\tau_j}{\tau_i-\tau_j}.

This interpolation polynomial has degree at most N1N-1.

Its derivative is

X˙(τ)=i=1NXiLi(τ),\dot{\boldsymbol{X}}(\tau) = \sum_{i=1}^{N} \boldsymbol{X}_iL_i'(\tau),

which has degree at most N2N-2.

LGL Differentiation Matrix

Define

Dji=Li(τj),i,j=1,,N.D_{ji} = L_i'(\tau_j), \qquad i,j=1,\ldots,N.

Thus,

DRN×N.\boxed{ \boldsymbol{D}\in\mathbb{R}^{N\times N}. }

Collocating the dynamics at all LGL points gives

i=1NDjiXi=f(Xj,Uj),j=1,,N.\sum_{i=1}^{N} D_{ji}\boldsymbol{X}_i = \boldsymbol{f}(\boldsymbol{X}_j,\boldsymbol{U}_j), \qquad j=1,\ldots,N.

In matrix form,

DX1:N=F1:N.\boxed{ \boldsymbol{D}\boldsymbol{X}_{1:N} = \boldsymbol{F}_{1:N}. }

Over-Collocation and Singularity

The derivative polynomial has degree at most N2N-2 and is therefore determined by N1N-1 independent coefficients. However, it is collocated at NN points. This creates a redundancy.

As a result,

D is singular.\boxed{ \boldsymbol{D}\ \text{is singular}. }

This fact has important consequences for costate estimation and for the relationship between differential and integral pseudospectral formulations.

Simplified Mayer Problem

Consider

minx(),u()Φ(x(1)),\min_{\boldsymbol{x}(\cdot),\boldsymbol{u}(\cdot)} \Phi\bigl(\boldsymbol{x}(1)\bigr),

subject to

x˙(τ)=f(x(τ),u(τ)),τ[1,1],\dot{\boldsymbol{x}}(\tau) = \boldsymbol{f}\bigl(\boldsymbol{x}(\tau),\boldsymbol{u}(\tau)\bigr), \qquad \tau\in[-1,1],

and

x(1)=x0.\boldsymbol{x}(-1)=\boldsymbol{x}_0.

The Hamiltonian is

H(x,u,λ)=λTf(x,u).H(\boldsymbol{x},\boldsymbol{u},\boldsymbol{\lambda}) = \boldsymbol{\lambda}^{\mathsf{T}}\boldsymbol{f}(\boldsymbol{x},\boldsymbol{u}).

The continuous optimality conditions are

λ(1)=xΦ(x(1)),\boldsymbol{\lambda}(1) = \nabla_{\boldsymbol{x}}\Phi\bigl(\boldsymbol{x}(1)\bigr),
λ˙=x(λTf),\dot{\boldsymbol{\lambda}} = - \nabla_{\boldsymbol{x}} \left( \boldsymbol{\lambda}^{\mathsf{T}}\boldsymbol{f} \right),

and

u(λTf)=0.\nabla_{\boldsymbol{u}} \left( \boldsymbol{\lambda}^{\mathsf{T}}\boldsymbol{f} \right) = \boldsymbol{0}.

LGL Nonlinear Program

The LGL transcription is

minX,UΦ(XN)subject toF1:NDX1:N=0,x0X1=0.\boxed{ \begin{aligned} \min_{\boldsymbol{X},\boldsymbol{U}}\quad & \Phi(\boldsymbol{X}_N) \\ \text{subject to}\quad & \boldsymbol{F}_{1:N} - \boldsymbol{D}\boldsymbol{X}_{1:N} = \boldsymbol{0}, \\ & \boldsymbol{x}_0-\boldsymbol{X}_1 = \boldsymbol{0}. \end{aligned} }

The NLP variables are

X1,,XN,U1,,UN.\boldsymbol{X}_1,\ldots,\boldsymbol{X}_N, \qquad \boldsymbol{U}_1,\ldots,\boldsymbol{U}_N.

LGL NLP Lagrangian

Let

Λ1:N=[Λ1ΛN]\boldsymbol{\Lambda}_{1:N} = \begin{bmatrix} \boldsymbol{\Lambda}_1\\ \vdots\\ \boldsymbol{\Lambda}_N \end{bmatrix}

denote the multipliers associated with the collocation equations.

Let

μ\boldsymbol{\mu}

denote the multiplier associated with the initial condition.

The NLP Lagrangian is

L=Φ(XN)+Λ1:N,F1:NDX1:N+μ,x0X1.\begin{aligned} \mathcal{L} ={}& \Phi(\boldsymbol{X}_N) + \left\langle \boldsymbol{\Lambda}_{1:N}, \boldsymbol{F}_{1:N} - \boldsymbol{D}\boldsymbol{X}_{1:N} \right\rangle \nonumber\\ &+ \left\langle \boldsymbol{\mu}, \boldsymbol{x}_0-\boldsymbol{X}_1 \right\rangle. \end{aligned}

KKT Conditions

Because both endpoints are collocation points, the initial and terminal state equations must be treated separately from the interior equations.

Initial Point

Stationarity with respect to X1\boldsymbol{X}_1 gives

X[Λ1Tf(X1,U1)]d1TΛ1:N=μ,\boxed{ \nabla_{\boldsymbol{X}} \left[ \boldsymbol{\Lambda}_1^{\mathsf{T}} \boldsymbol{f}(\boldsymbol{X}_1,\boldsymbol{U}_1) \right] - \boldsymbol{d}_1^{\mathsf{T}}\boldsymbol{\Lambda}_{1:N} = \boldsymbol{\mu}, }

where d1\boldsymbol{d}_1 is the first column of D\boldsymbol{D}.

Terminal Point

Stationarity with respect to XN\boldsymbol{X}_N gives

dNTΛ1:NX[ΛNTf(XN,UN)]=XΦ(XN).\boxed{ \boldsymbol{d}_N^{\mathsf{T}}\boldsymbol{\Lambda}_{1:N} - \nabla_{\boldsymbol{X}} \left[ \boldsymbol{\Lambda}_N^{\mathsf{T}} \boldsymbol{f}(\boldsymbol{X}_N,\boldsymbol{U}_N) \right] = \nabla_{\boldsymbol{X}}\Phi(\boldsymbol{X}_N). }

Interior Points

For

j=2,,N1,j=2,\ldots,N-1,

stationarity gives

X[ΛjTf(Xj,Uj)]=djTΛ1:N,\boxed{ \nabla_{\boldsymbol{X}} \left[ \boldsymbol{\Lambda}_j^{\mathsf{T}} \boldsymbol{f}(\boldsymbol{X}_j,\boldsymbol{U}_j) \right] = \boldsymbol{d}_j^{\mathsf{T}}\boldsymbol{\Lambda}_{1:N}, }

where dj\boldsymbol{d}_j is the jjth column of D\boldsymbol{D}.

Control Stationarity

For all LGL points,

UΛ1:N,F1:N=0.\boxed{ \nabla_{\boldsymbol{U}} \left\langle \boldsymbol{\Lambda}_{1:N}, \boldsymbol{F}_{1:N} \right\rangle = \boldsymbol{0}. }

LGL Costate Mapping

Let

W=diag(w1,,wN),\boldsymbol{W} = \operatorname{diag}(w_1,\ldots,w_N),

where wiw_i are the LGL quadrature weights.

Define the costate estimate by

λ1:N=W1Λ1:N.\boxed{ \boldsymbol{\lambda}_{1:N} = \boldsymbol{W}^{-1}\boldsymbol{\Lambda}_{1:N}. }

Componentwise,

λi=Λiwi.\boldsymbol{\lambda}_i = \frac{\boldsymbol{\Lambda}_i}{w_i}.

This is algebraically the simplest of the three mappings.

LGL Adjoint Differentiation Matrix

Define

DRN×N\boldsymbol{D}^\dagger\in\mathbb{R}^{N\times N}

such that

Dii=DiiD_{ii}^\dagger=D_{ii}

for interior diagonal entries, while the endpoint diagonal entries are modified:

D11=D111w1,\boxed{ D_{11}^\dagger = -D_{11}-\frac{1}{w_1}, }

and

DNN=DNN+1wN.\boxed{ D_{NN}^\dagger = -D_{NN}+\frac{1}{w_N}. }

For

ij,i\neq j,

define

Dij=wjwiDji.\boxed{ D_{ij}^\dagger = - \frac{w_j}{w_i}D_{ji}. }

Compact Discrete Adjoint Equation

Let

e1=[100]T,eN=[001]T.\boldsymbol{e}_1 = \begin{bmatrix} 1&0&\cdots&0 \end{bmatrix}^{\mathsf{T}}, \qquad \boldsymbol{e}_N = \begin{bmatrix} 0&\cdots&0&1 \end{bmatrix}^{\mathsf{T}}.

Then the transformed KKT system can be written as

Dλ1:N=Xλ1:N,F1:N+e1w1(μλ1)+eNwN[λNXΦ(XN)].\boxed{ \begin{aligned} \boldsymbol{D}^\dagger\boldsymbol{\lambda}_{1:N} ={}& - \nabla_{\boldsymbol{X}} \left\langle \boldsymbol{\lambda}_{1:N}, \boldsymbol{F}_{1:N} \right\rangle \\ &+ \frac{\boldsymbol{e}_1}{w_1} \left( \boldsymbol{\mu}-\boldsymbol{\lambda}_1 \right) + \frac{\boldsymbol{e}_N}{w_N} \left[ \boldsymbol{\lambda}_N- \nabla_{\boldsymbol{X}}\Phi(\boldsymbol{X}_N) \right]. \end{aligned} }

The control stationarity equation becomes

Uλ1:N,F1:N=0.\boxed{ \nabla_{\boldsymbol{U}} \left\langle \boldsymbol{\lambda}_{1:N}, \boldsymbol{F}_{1:N} \right\rangle = \boldsymbol{0}. }

Coupling of Boundary Conditions and Costate Dynamics

For a pure discrete adjoint equation, one would prefer

Dλ1:N=Xλ1:N,F1:N.\boldsymbol{D}^\dagger\boldsymbol{\lambda}_{1:N} = - \nabla_{\boldsymbol{X}} \left\langle \boldsymbol{\lambda}_{1:N}, \boldsymbol{F}_{1:N} \right\rangle.

Instead, the LGL equation contains two additional endpoint terms:

e1w1(μλ1)\frac{\boldsymbol{e}_1}{w_1} \left( \boldsymbol{\mu}-\boldsymbol{\lambda}_1 \right)

and

eNwN[λNXΦ(XN)].\frac{\boldsymbol{e}_N}{w_N} \left[ \boldsymbol{\lambda}_N- \nabla_{\boldsymbol{X}}\Phi(\boldsymbol{X}_N) \right].

Therefore,

This differs from LG, where both endpoint conditions are decoupled, and LGR, where only one endpoint requires special treatment.

Why LGL Costate Estimates Can Be Less Accurate

The LGL differentiation matrix is square and singular. Consequently:

The primal state and control solution may still be accurate. The limitation is specifically associated with recovering the continuous adjoint from the NLP multipliers.

Summary of Costate Mappings

LG Collocation

Let Λ1:N\boldsymbol{\Lambda}_{1:N} be the collocation multipliers and let ΛN+1\boldsymbol{\Lambda}_{N+1} be the multiplier of the terminal quadrature equation.

The costate at the Gauss points is

λ1:N=W1Λ1:N+1ΛN+1.\boxed{ \boldsymbol{\lambda}_{1:N} = \boldsymbol{W}^{-1}\boldsymbol{\Lambda}_{1:N} + \boldsymbol{1}\boldsymbol{\Lambda}_{N+1}. }

The final costate is

λN+1=ΛN+1.\boxed{ \boldsymbol{\lambda}_{N+1} = \boldsymbol{\Lambda}_{N+1}. }

The initial costate is recovered from

λ0=λN+1d0TΛ1:N,\boxed{ \boldsymbol{\lambda}_0 = \boldsymbol{\lambda}_{N+1} - \boldsymbol{d}_0^{\mathsf{T}}\boldsymbol{\Lambda}_{1:N}, }

with the precise column notation chosen consistently with the LG differentiation matrix.

LGR Collocation

The costate at the LGR points is

λ1:N=W1Λ1:N.\boxed{ \boldsymbol{\lambda}_{1:N} = \boldsymbol{W}^{-1}\boldsymbol{\Lambda}_{1:N}. }

The terminal costate is

λN+1=dN+1TΛ1:N.\boxed{ \boldsymbol{\lambda}_{N+1} = \boldsymbol{d}_{N+1}^{\mathsf{T}}\boldsymbol{\Lambda}_{1:N}. }

For a left-Radau grid,

τ1=1,\tau_1=-1,

so λ1\boldsymbol{\lambda}_1 directly approximates the initial costate.

LGL Collocation

The costate at all LGL points, including both endpoints, is

λ1:N=W1Λ1:N.\boxed{ \boldsymbol{\lambda}_{1:N} = \boldsymbol{W}^{-1}\boldsymbol{\Lambda}_{1:N}. }

However, the endpoint transversality residuals remain coupled to the discrete adjoint dynamics.

Comparison of LG, LGR, and LGL

FeatureLGLGRLGL
Included endpointsNeitherOneBoth
Differentiation matrixRectangularRectangularSquare
Matrix singularityNo relevant square singularityNo relevant square singularitySingular
Equivalent integral formYesYesNot uniquely invertible
Endpoint couplingDecoupledOne endpoint partly coupledBoth endpoints coupled
Interior mappingW1Λ+1ΛN+1\boldsymbol{W}^{-1}\boldsymbol{\Lambda}+\boldsymbol{1}\boldsymbol{\Lambda}_{N+1}W1Λ\boldsymbol{W}^{-1}\boldsymbol{\Lambda}W1Λ\boldsymbol{W}^{-1}\boldsymbol{\Lambda}
Typical costate qualityHighHighCan be less accurate

Comparison of Legendre pseudospectral costate estimation methods.

General Bolza Optimal-Control Problem

Consider

minx(),u(),t0,tfJ=Φ(x(t0),t0,x(tf),tf)+t0tfL(x(t),u(t),t)dt.\begin{aligned} \min_{\boldsymbol{x}(\cdot),\boldsymbol{u}(\cdot),t_0,t_f} J ={}& \Phi \left( \boldsymbol{x}(t_0),t_0, \boldsymbol{x}(t_f),t_f \right) \nonumber\\ &+ \int_{t_0}^{t_f} L\left( \boldsymbol{x}(t),\boldsymbol{u}(t),t \right)\,\mathrm{d} t. \end{aligned}

The dynamics are

x˙(t)=f(x(t),u(t),t).\dot{\boldsymbol{x}}(t) = \boldsymbol{f}\left( \boldsymbol{x}(t),\boldsymbol{u}(t),t \right).

Endpoint constraints may be written as

ϕ(x(t0),t0,x(tf),tf)=0.\boldsymbol{\phi} \left( \boldsymbol{x}(t_0),t_0, \boldsymbol{x}(t_f),t_f \right) = \boldsymbol{0}.

Path constraints may be written as

cminc(x(t),u(t),t)cmax.\boldsymbol{c}_{\min} \leq \boldsymbol{c}\left( \boldsymbol{x}(t),\boldsymbol{u}(t),t \right) \leq \boldsymbol{c}_{\max}.

Mapping the Time Interval to [1,1][-1,1]

Define

τ=2(tt0)tft01.\boxed{ \tau = \frac{2(t-t_0)}{t_f-t_0}-1. }

The inverse transformation is

t=tft02τ+tf+t02.\boxed{ t = \frac{t_f-t_0}{2}\tau + \frac{t_f+t_0}{2}. }

Differentiation gives

dτdt=2tft0,\frac{\,\mathrm{d}\tau}{\,\mathrm{d} t} = \frac{2}{t_f-t_0},

and

dtdτ=tft02.\boxed{ \frac{\,\mathrm{d} t}{\,\mathrm{d}\tau} = \frac{t_f-t_0}{2}. }

Transformed Bolza Problem

The endpoint states map as

x(t0)=x(1),x(tf)=x(1).\boldsymbol{x}(t_0)=\boldsymbol{x}(-1), \qquad \boldsymbol{x}(t_f)=\boldsymbol{x}(1).

The cost becomes

J=Φ(x(1),t0,x(1),tf)+tft0211L(x(τ),u(τ),t(τ;t0,tf))dτ.\begin{aligned} J ={}& \Phi \left( \boldsymbol{x}(-1),t_0, \boldsymbol{x}(1),t_f \right) \nonumber\\ &+ \frac{t_f-t_0}{2} \int_{-1}^{1} L \left( \boldsymbol{x}(\tau),\boldsymbol{u}(\tau), t(\tau;t_0,t_f) \right) \,\mathrm{d}\tau. \end{aligned}

The transformed dynamics are

dxdτ=tft02f(x(τ),u(τ),t(τ;t0,tf)).\boxed{ \frac{\,\mathrm{d}\boldsymbol{x}}{\,\mathrm{d}\tau} = \frac{t_f-t_0}{2} \boldsymbol{f} \left( \boldsymbol{x}(\tau),\boldsymbol{u}(\tau), t(\tau;t_0,t_f) \right). }

The endpoint constraints become

ϕ(x(1),t0,x(1),tf)=0.\boldsymbol{\phi} \left( \boldsymbol{x}(-1),t_0, \boldsymbol{x}(1),t_f \right) = \boldsymbol{0}.

The path constraints become

cminc(x(τ),u(τ),t(τ;t0,tf))cmax.\boldsymbol{c}_{\min} \leq \boldsymbol{c} \left( \boldsymbol{x}(\tau),\boldsymbol{u}(\tau), t(\tau;t_0,t_f) \right) \leq \boldsymbol{c}_{\max}.

LGR Discretization of the General Bolza Problem

For a left-LGR grid, the initial point is τ1=1\tau_1=-1 and the final interpolation point is τN+1=1\tau_{N+1}=1.

Discrete Objective

The objective is approximated by

JN=Φ(X1,t0,XN+1,tf)+tft02i=1NwiL(Xi,Ui,ti),\begin{aligned} J_N ={}& \Phi \left( \boldsymbol{X}_1,t_0, \boldsymbol{X}_{N+1},t_f \right) \nonumber\\ &+ \frac{t_f-t_0}{2} \sum_{i=1}^{N} w_i L \left( \boldsymbol{X}_i,\boldsymbol{U}_i,t_i \right), \end{aligned}

where

ti=tft02τi+tf+t02.t_i = \frac{t_f-t_0}{2}\tau_i + \frac{t_f+t_0}{2}.

Discrete Dynamics

The collocation equations are

DX1:N+1=tft02F1:N.\boxed{ \boldsymbol{D}\boldsymbol{X}_{1:N+1} = \frac{t_f-t_0}{2} \boldsymbol{F}_{1:N}. }

Equivalently,

DX1:N+1tft02F1:N=0.\boldsymbol{D}\boldsymbol{X}_{1:N+1} - \frac{t_f-t_0}{2} \boldsymbol{F}_{1:N} = \boldsymbol{0}.

Endpoint Constraints

The endpoint constraints become

ϕ(X1,t0,XN+1,tf)=0.\boxed{ \boldsymbol{\phi} \left( \boldsymbol{X}_1,t_0, \boldsymbol{X}_{N+1},t_f \right) = \boldsymbol{0}. }

Path Constraints

At each collocation point,

cminc(Xi,Ui,ti)cmax,i=1,,N.\boxed{ \boldsymbol{c}_{\min} \leq \boldsymbol{c} \left( \boldsymbol{X}_i,\boldsymbol{U}_i,t_i \right) \leq \boldsymbol{c}_{\max}, \qquad i=1,\ldots,N. }

Interpretation of the Time-Scaling Factor

The only structural change in the dynamics and integral cost is the factor

tft02.\boxed{ \frac{t_f-t_0}{2}. }

When

t0=1,tf=1,t_0=-1, \qquad t_f=1,

this factor equals one. Thus, the simplified problem used in the derivations is a special case of the general transcription.

The initial and final times may themselves be NLP variables. In that case, they enter:

Extension to LG and LGL

The same time transformation applies to LG and LGL schemes.

LG

The LG transcription additionally requires a quadrature equation for the terminal state because neither endpoint is a collocation point.

LGR

The LGR transcription requires one noncollocated endpoint state and has a rectangular differentiation matrix.

LGL

The LGL transcription includes both endpoint states directly and has a square singular differentiation matrix.

Differential and Integral Interpretations

For LG and LGR, a suitable square portion of the rectangular differentiation matrix is invertible. Its inverse acts as an integration matrix. Consequently, their differential collocation forms have equivalent integral forms.

For LGL, the differentiation matrix is singular. Therefore, no unique ordinary inverse exists, and the differential form does not possess the same uniquely equivalent integration representation.

This distinction explains much of the difference in costate recovery quality.

Implementation Considerations

A practical implementation should carefully manage:

  1. the ordering of state, control, time, and parameter variables;

  2. the ordering of defect, endpoint, and path constraints;

  3. the sign convention used for equality constraints;

  4. the association between solver multipliers and constraint blocks;

  5. state, control, defect, and objective scaling;

  6. exact or algorithmic derivatives;

  7. mesh refinement;

  8. endpoint consistency;

  9. primal and dual residuals.

Summary

  1. LGL collocation includes both endpoints.

  2. Its state differentiation matrix is square and singular.

  3. The LGL costate estimate is obtained by

λ1:N=W1Λ1:N.\boldsymbol{\lambda}_{1:N} = \boldsymbol{W}^{-1}\boldsymbol{\Lambda}_{1:N}.
  1. The transformed adjoint equation contains both initial and terminal boundary residuals.

  2. These endpoint terms couple the transversality conditions to the costate dynamics.

  3. LG and LGR generally provide cleaner costate mappings because their rectangular differentiation matrices admit equivalent integration forms.

  4. A general Bolza problem on [t0,tf][t_0,t_f] is mapped to [1,1][-1,1] by an affine time transformation.

  5. The transformed cost and dynamics acquire the factor

(tft0)/2.(t_f-t_0)/2.
  1. Endpoint and path constraints are imposed directly in the resulting NLP.

Connection. With the mathematical transcription complete, attention shifts to the data layout and function interfaces required by a general NLP solver.