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.

Exercises

  1. Direct shooting with a polynomial control parameterization

    Consider

    x˙(t)=x(t)+u(t),x(0)=x0,\dot{x}(t) = -x(t)+u(t), \qquad x(0)=x_0,

    with fixed final time TT, terminal constraint

    x(T)=xf,x(T)=x_f,

    and performance index

    J=120T(x2(t)+ρu2(t))dt.J = \frac{1}{2} \int_0^T \left( x^2(t)+\rho u^2(t) \right) \,\mathrm{d}t.

    Approximate the control by

    u(t)=c0+c1t+c2t2.u(t) = c_0+c_1t+c_2t^2.

    (a) Identify the finite-dimensional decision vector.

    (b) Write the state obtained by integrating the dynamics for a given coefficient vector.

    (c) Express the terminal constraint as a nonlinear algebraic constraint on c0,c1,c2c_0,c_1,c_2.

    (d) Introduce an accumulated-cost state and write the complete direct-shooting nonlinear program.

  2. Forward and backward Euler stability

    Apply forward Euler and backward Euler to

    x˙=5x,x(0)=1.\dot{x} = -5x, \qquad x(0)=1.

    (a) Derive the update equation and amplification factor for each method.

    (b) Derive the forward-Euler stability restriction on hh.

    (c) Show that backward Euler is stable for every h>0h>0.

    (d) For a uniform mesh, derive explicit expressions for xkFEx_k^{\mathrm{FE}} and xkBEx_k^{\mathrm{BE}}.

    (e) Compare both discrete solutions with

    x(tk)=e5tk.x(t_k)=e^{-5t_k}.
  3. Generalized θ\theta-method

    Consider the convention

    xk+1=xk+h[θf(tk,xk)+(1θ)f(tk+1,xk+1)].x_{k+1} = x_k + h \left[ \theta f(t_k,x_k) + (1-\theta)f(t_{k+1},x_{k+1}) \right].

    (a) Identify the values of θ\theta corresponding to forward Euler, backward Euler, and the trapezoidal method.

    (b) Determine which value of θ\theta produces an explicit method for a general nonlinear vector field.

    (c) For the test equation

    x˙=λx,z=hλ,\dot{x}=\lambda x, \qquad z=h\lambda,

    derive the stability function

    Rθ(z).R_\theta(z).

    (d) Recover the stability functions of the three special cases.

    (e) Compare the limits of the backward-Euler and trapezoidal stability functions as zz\rightarrow-\infty.

  4. Runge–Kutta integration of controlled dynamics

    Consider one mesh interval for

    x˙=x3+u,\dot{x} = -x^3+u,

    where the control is constant on the interval:

    u(t)=uk,t[tk,tk+1].u(t)=u_k, \qquad t\in[t_k,t_{k+1}].

    (a) Write the four classical RK4 stage equations.

    (b) Derive the RK4 update for xk+1x_{k+1}.

    (c) State the number of vector-field evaluations required per interval.

    (d) Explain why RK4 is a one-step method despite using four stages.

    (e) State its expected global order of accuracy.

  5. Euler direct-collocation transcription

    Transcribe

    minx(),u()  J=120T(x2+u2)dt\min_{x(\cdot),u(\cdot)} \; J = \frac{1}{2} \int_0^T \left( x^2+u^2 \right) \,\mathrm{d}t

    subject to

    x˙=x3+u,x(0)=a,x(T)=b,\dot{x} = -x^3+u, \qquad x(0)=a, \qquad x(T)=b,

    using forward-Euler collocation on KK uniform intervals.

    (a) Define the mesh and step size.

    (b) Define the complete NLP decision vector.

    (c) Derive all Euler defect constraints.

    (d) Derive the left-rectangle discrete objective.

    (e) Write the two endpoint constraints.

    (f) Determine the number of decision variables, equality constraints, and remaining degrees of freedom.

  6. Global residual equations and their Jacobian

    For the scalar nonlinear initial-value problem

    x˙=f(t,x),x(t0)=x0,\dot{x}=f(t,x), \qquad x(t_0)=x_0,

    on a mesh with KK intervals:

    (a) Write all forward-Euler equations as one simultaneous algebraic residual system.

    (b) Derive the nonzero Jacobian entries of a generic forward-Euler residual.

    (c) Repeat parts (a) and (b) for backward Euler.

    (d) Explain mathematically why the backward-Euler residual is implicit.

    (e) State how Newton’s method would be applied to the global backward-Euler residual system.

  7. Sparse Jacobian structure

    For the scalar Euler-collocation problem in Exercise 5, use

    z=[x0xKu0uK1]T.\boldsymbol{z} = \begin{bmatrix} x_0 & \cdots & x_K & u_0 & \cdots & u_{K-1} \end{bmatrix}^{\mathsf T}.

    (a) Derive the three nonzero partial derivatives in one defect row.

    (b) Show that the complete equality-constraint Jacobian has dimensions

    (K+2)×(2K+1).(K+2)\times(2K+1).

    (c) Show that it has 3K+23K+2 nonzero entries.

    (d) Derive its exact density.

    (e) Compute the density for K=10K=10.

    (f) Prove that the density is asymptotically

    O ⁣(1K).\mathcal{O}\!\left(\frac{1}{K}\right).

    (g) Extend the variable count, constraint count, and maximum local nonzero count to nxn_x states and nun_u controls.

  8. Time normalization and free final time

    Map

    t[t0,tf]t\in[t_0,t_f]

    to

    τ[1,1].\tau\in[-1,1].

    (a) Derive the forward and inverse affine transformations.

    (b) Derive dt/dτ\mathrm{d}t/\mathrm{d}\tau.

    (c) Transform

    dxdt=f(t,x,u).\frac{\mathrm{d}\boldsymbol{x}}{\mathrm{d}t} = \boldsymbol{f}(t,\boldsymbol{x},\boldsymbol{u}).

    (d) Transform the Bolza objective

    J=Φ+t0tfL(t,x,u)dt.J = \Phi + \int_{t_0}^{t_f} L(t,\boldsymbol{x},\boldsymbol{u}) \,\mathrm{d}t.

    (e) On a normalized mesh, derive the forward-Euler defect constraints.

    (f) When tft_f is free, identify every part of the NLP in which it appears.

    (g) Explain why the tft_f column is globally coupled while the remaining defect Jacobian is still sparse.

  9. Piecewise-constant shooting with an unknown switching time

    Consider

    x˙=u,x(0)=0,x(T)=xf,\dot{x}=u, \qquad x(0)=0, \qquad x(T)=x_f,

    and parameterize the control as

    u(t)={u1,0t<ts,u2,tstT,u(t) = \begin{cases} u_1, & 0\leq t<t_s,\\ u_2, & t_s\leq t\leq T, \end{cases}

    where u1u_1, u2u_2, and tst_s are decision variables.

    (a) Integrate the dynamics analytically on both intervals.

    (b) Derive the continuity condition at tst_s.

    (c) Express the terminal constraint as an algebraic equation in u1,u2,tsu_1,u_2,t_s.

    (d) For

    J=120Tu2(t)dt,J = \frac{1}{2} \int_0^T u^2(t)\,\mathrm{d}t,

    derive the finite-dimensional objective.

    (e) Write the resulting direct-shooting NLP, including bounds

    uminu1,u2umax,0tsT.u_{\min}\leq u_1,u_2\leq u_{\max}, \qquad 0\leq t_s\leq T.
  10. Analytical mesh-refinement study

    Apply forward Euler to

    x˙=x,x(0)=1,\dot{x}=-x, \qquad x(0)=1,

    on [0,T][0,T] using KK uniform intervals.

    (a) Show that

    xK=(1TK)K.x_K = \left( 1-\frac{T}{K} \right)^K.

    (b) Show that

    limKxK=eT.\lim_{K\rightarrow\infty}x_K=e^{-T}.

    (c) Use a logarithmic expansion to obtain the leading-order terminal error.

    (d) Show that the terminal error is first order in h=T/Kh=T/K.

    (e) Derive the error ratio expected when the mesh size is doubled.

    (f) State how this result can be used to verify a direct-collocation implementation.