Mastering Optimal Control: An ODE Challenge

by Andrew McMorgan 44 views

Hey guys! Today, we're diving deep into a super interesting optimal control problem. You know, the kind that makes your brain do a little workout but is incredibly rewarding when you crack it. We're talking about finding the maximum value of a specific integral, given a differential equation and a constraint on our control input. This isn't just abstract math; understanding these problems is crucial in fields ranging from engineering to economics, where we constantly try to optimize processes. So, buckle up, because we're about to embark on a journey through ordinary differential equations (ODEs) and the fascinating world of control theory!

The Core of the Problem: Maximizing an Integral

Our main quest is to find the maximum value of the integral βˆ«βˆ’11(txβˆ’u2)dt\int_{-1}^1 (tx - u^2) dt. Think of this integral as the 'payoff' we're trying to maximize over the time interval from t=βˆ’1t = -1 to t=1t = 1. The integrand, (txβˆ’u2)(tx - u^2), is what we're accumulating. It's composed of two parts: txtx, which depends on time tt and the state variable xx, and βˆ’u2-u^2, which depends on the control input uu. We want to make this combined value as large as possible. This is the objective function we're working with, and it’s the heart of our optimization challenge.

The Dynamics: How 'x' Evolves

Now, the state variable xx isn't just floating around; its behavior is governed by a differential equation: xΛ™=x+u2\dot{x} = x + u^2. This equation tells us how xx changes over time. Specifically, the rate of change of xx (denoted by xΛ™\dot{x}) is equal to the current value of xx plus the square of our control input uu. This means that whatever value xx has, it tends to grow exponentially on its own (due to the 'xx' term), and we can further influence its growth by choosing our control input uu. The u2u^2 term indicates that increasing uu will always increase the rate of change of xx. This relationship is fundamental to how we can steer the system towards our objective.

The Constraint: Keeping 'u' in Check

We can't just pick any value for uu. The problem states that u(t)∈[0,1]u(t) \in [0,1] for every t∈[βˆ’1,1]t \in [-1, 1]. This is a crucial constraint, guys! It means our control input uu must always be between 0 and 1, inclusive. We can't use negative inputs, nor can we exceed the value of 1. This limitation is realistic; in many real-world scenarios, control mechanisms have bounds. For instance, a throttle might only go from fully closed to fully open, or a voltage supply might have a maximum limit. This constraint adds a layer of complexity to finding the optimal uu, as we need to respect these boundaries while still trying to maximize our objective function.

The Boundaries: Where We Start and End

Finally, we have specific conditions for the state variable xx at the beginning and end of our time interval. We are given x(βˆ’1)=0x(-1) = 0 and x(1)=e2βˆ’e1+1ex(1) = e^2 - e^{1 + \frac{1}{e}}. These are the boundary conditions. They tell us that our system must start at a state of 0 at time t=βˆ’1t = -1 and must end up at a very specific, non-trivial value at t=1t = 1. These conditions are vital because they define the exact path our state variable xx must take. Without them, there could be infinitely many solutions; with them, we're looking for a specific trajectory that satisfies both the dynamics and the objective.

Why is This Important, Anyway?

Problems like this, often referred to as optimal control problems, are the backbone of modern system design and analysis. Whether you're designing a rocket's trajectory to reach Mars efficiently, managing an investment portfolio to maximize returns, or even controlling the temperature in a building to minimize energy consumption, you're essentially solving an optimal control problem. The mathematical tools we use, like the calculus of variations and Pontryagin's Maximum Principle, are powerful and widely applicable. Understanding how to formulate and solve these problems gives you a significant edge in tackling complex, real-world optimization challenges. It’s all about finding the best way to do something, given certain rules and limitations. So, when we dive into the specifics of solving this ODE-based problem, remember that you’re learning skills that have tangible impact across a vast array of disciplines. It’s not just about numbers on a page; it’s about intelligent decision-making in dynamic systems.

Setting Up the Solution: The Hamiltonian Approach

To tackle this beast, we'll lean on a powerful tool in control theory: the Hamiltonian. The Hamiltonian, often denoted by HH, is a function that combines the objective function's integrand with the system's dynamics using a costate variable (let's call it Ξ»\lambda). For our problem, the Hamiltonian is defined as:

H(t,x,u,Ξ»)=f(t,x,u)Ξ»βˆ’L(t,x,u)H(t, x, u, \lambda) = f(t, x, u) \lambda - L(t, x, u)

where L(t,x,u)L(t, x, u) is the integrand of our objective function and f(t,x,u)f(t, x, u) is the right-hand side of our state equation (i.e., xΛ™\dot{x}).

In our case, L(t,x,u)=txβˆ’u2L(t, x, u) = tx - u^2 and f(t,x,u)=x+u2f(t, x, u) = x + u^2. So, our Hamiltonian becomes:

H(t,x,u,Ξ»)=(x+u2)Ξ»βˆ’(txβˆ’u2)H(t, x, u, \lambda) = (x + u^2) \lambda - (tx - u^2)

H(t,x,u,Ξ»)=Ξ»x+Ξ»u2βˆ’tx+u2H(t, x, u, \lambda) = \lambda x + \lambda u^2 - tx + u^2

H(t,x,u,Ξ»)=Ξ»xβˆ’tx+(Ξ»+1)u2H(t, x, u, \lambda) = \lambda x - tx + (\lambda + 1)u^2

This Hamiltonian is key because Pontryagin's Maximum Principle states that for an optimal control uβˆ—(t)u^*(t), it must maximize the Hamiltonian with respect to uu at almost every time tt, subject to the control constraints.

Maximizing the Hamiltonian

Our goal now is to find the value of u∈[0,1]u \in [0, 1] that maximizes HH. Let's look at the term involving uu: (λ+1)u2(\lambda + 1)u^2. To maximize this term, we need to consider the coefficient (λ+1)(\lambda + 1).

  • Case 1: Ξ»+1>0\lambda + 1 > 0 If (Ξ»+1)(\lambda + 1) is positive, then u2u^2 is maximized when uu is as large as possible in magnitude. Since u∈[0,1]u \in [0, 1], the largest possible value for uu is u=1u=1. So, uβˆ—(t)=1u^*(t) = 1.

  • Case 2: Ξ»+1<0\lambda + 1 < 0 If (Ξ»+1)(\lambda + 1) is negative, then u2u^2 is maximized when uu is as small as possible in magnitude. Since u∈[0,1]u \in [0, 1], the smallest possible value for uu is u=0u=0. So, uβˆ—(t)=0u^*(t) = 0.

  • Case 3: Ξ»+1=0\lambda + 1 = 0 If (Ξ»+1)=0(\lambda + 1) = 0, meaning Ξ»=βˆ’1\lambda = -1, then the term (Ξ»+1)u2(\lambda + 1)u^2 becomes 0imesu2=00 imes u^2 = 0. In this situation, the value of uu doesn't affect the Hamiltonian. This is a singular case, and we might need further analysis, but for now, we focus on the non-singular cases.

So, the optimal control uβˆ—(t)u^*(t) will switch between 0 and 1 depending on the sign of (Ξ»+1)(\lambda + 1). This switching behavior is very common in optimal control problems!

The Costate Equation

Besides maximizing the Hamiltonian, Pontryagin's Maximum Principle also gives us the dynamics for the costate variable Ξ»\lambda. The costate equation is given by:

Ξ»Λ™=βˆ’βˆ‚Hβˆ‚x\dot{\lambda} = -\frac{\partial H}{\partial x}

Let's calculate this derivative:

βˆ‚Hβˆ‚x=βˆ‚βˆ‚x(Ξ»xβˆ’tx+(Ξ»+1)u2)=Ξ»\frac{\partial H}{\partial x} = \frac{\partial}{\partial x} (\lambda x - tx + (\lambda + 1)u^2) = \lambda

So, the costate equation is simply:

Ξ»Λ™=βˆ’Ξ»\dot{\lambda} = -\lambda

This is a first-order linear ODE. The solution is straightforward: Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t} for some constant CC. This tells us how the costate variable evolves over time.

Connecting the Dots: The Transversality Condition

We have the state equation (xΛ™=x+u2\dot{x} = x + u^2), the costate equation (Ξ»Λ™=βˆ’Ξ»\dot{\lambda} = -\lambda), and the rule for finding the optimal control uβˆ—(t)u^*(t) based on Ξ»\lambda. However, we still have unknown constants in the solutions for x(t)x(t) and Ξ»(t)\lambda(t), and we need to determine the exact form of uβˆ—(t)u^*(t). This is where the boundary conditions and transversality conditions come into play.

We know x(βˆ’1)=0x(-1) = 0 and x(1)=e2βˆ’e1+1ex(1) = e^2 - e^{1 + \frac{1}{e}}.

The general solution for x(t)x(t) from xΛ™=x+u2\dot{x} = x + u^2 is x(t)=et(βˆ«βˆ’1teβˆ’Ο„u2(Ο„)dΟ„+x(βˆ’1))x(t) = e^t \left( \int_{-1}^t e^{-\tau} u^2(\tau) d\tau + x(-1) \right). Since x(βˆ’1)=0x(-1)=0, we have:

x(t)=etβˆ«βˆ’1teβˆ’Ο„u2(Ο„)dΟ„x(t) = e^t \int_{-1}^t e^{-\tau} u^2(\tau) d\tau

The general solution for Ξ»(t)\lambda(t) is Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t}.

Now, for problems with fixed final time and free final state (which is NOT our case, as x(1)x(1) is fixed), we often use a terminal condition on Ξ»\lambda. However, when the final state is fixed, the transversality condition relates the costate variable at the final time to the gradient of the objective function with respect to the final state. In essence, it tells us how sensitive the optimal value of the integral is to the final state x(1)x(1).

For a problem of the form max⁑∫abL(t,x,u)dt\max \int_a^b L(t, x, u) dt with xΛ™=f(t,x,u)\dot{x} = f(t, x, u), and fixed boundary conditions x(a)=xa,x(b)=xbx(a)=x_a, x(b)=x_b, the transversality condition at the final time t=bt=b is:

Ξ»(b)=βˆ‚Ο•(x(b))βˆ‚x(b)\lambda(b) = \frac{\partial \phi(x(b))}{\partial x(b)}

where Ο•(x(b))\phi(x(b)) is the final value function. In our case, the objective is βˆ«βˆ’11(txβˆ’u2)dt\int_{-1}^1 (tx - u^2) dt. The structure of the problem is a bit different because the state xx appears in the integrand, and the final state x(1)x(1) is specified. Let's consider the standard formulation where we maximize Ο•(x(b))+∫abL(t,x,u)dt\phi(x(b)) + \int_a^b L(t, x, u) dt. Here, Ο•(x(1))\phi(x(1)) would represent any terminal cost or bonus. In our problem, the final state x(1)x(1) is fixed, but it’s not explicitly part of a terminal cost function Ο•\phi. Instead, the final state is a constraint. For problems with fixed endpoints, the costate variable Ξ»(t)\lambda(t) does not typically have a direct boundary condition from the objective function itself, other than what is implicitly imposed by the necessity of meeting the final state condition.

However, if we were to define a terminal cost Ο•(x(1))\phi(x(1)) that forces x(1)x(1) to be its specified value, we could think of it as Ο•(x(1))=0\phi(x(1)) = 0 if x(1)x(1) is at the target, and ∞\infty otherwise. A more standard approach is to use the condition that the Hamiltonian should be constant along the optimal trajectory if it doesn't explicitly depend on time. In our case, HH does depend on tt through the βˆ’tx-tx term. Let's re-evaluate our approach.

Revisiting the Problem Structure and Strategy

This problem has fixed boundary conditions for xx, i.e., x(βˆ’1)=0x(-1)=0 and x(1)=e2βˆ’e1+1ex(1)=e^2 - e^{1 + \frac{1}{e}}. The standard Pontryagin's Maximum Principle (PMP) is designed for problems where either the initial state is fixed and the final state is free, or the initial and final states are fixed, but the objective might include a terminal cost. Our objective function is an integral, and the final state is fixed to a specific value. This means we are looking for a trajectory x(t)x(t) that satisfies the ODE, the control constraint, and the boundary conditions, while maximizing the integral.

Let's consider the implications of the fixed final state x(1)x(1). The costate variable Ξ»(t)\lambda(t) at the final time t=1t=1 is related to the sensitivity of the optimal value of the objective functional to the final state x(1)x(1). For a problem like max⁑∫abL(t,x,u)dt\max \int_a^b L(t,x,u)dt with xΛ™=f(t,x,u)\dot{x} = f(t,x,u), x(a)=xax(a)=x_a and x(b)x(b) free, the transversality condition is Ξ»(b)=βˆ‚Ο•βˆ‚x(b)\lambda(b) = \frac{\partial \phi}{\partial x(b)} where Ο•\phi is a terminal cost. If there is no terminal cost, Ο•=0\phi=0, so Ξ»(b)=0\lambda(b)=0. In our case, x(1)x(1) is fixed.

A common technique when the final state is fixed is to use a Lagrange multiplier approach in conjunction with the PMP. However, the costate equation Ξ»Λ™=βˆ’Ξ»\dot{\lambda} = -\lambda with Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t} and the condition uβˆ—(t)=1u^*(t) = 1 if Ξ»>βˆ’1\lambda > -1 and uβˆ—(t)=0u^*(t) = 0 if Ξ»<βˆ’1\lambda < -1 still hold.

Let's assume uβˆ—(t)u^*(t) is a function of time. We need to determine which intervals uβˆ—(t)=1u^*(t)=1 and which uβˆ—(t)=0u^*(t)=0. This depends on Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t}.

  • If Ceβˆ’t>βˆ’1C e^{-t} > -1 for some tt, then uβˆ—(t)=1u^*(t)=1. This happens when eβˆ’t>βˆ’1/Ce^{-t} > -1/C (if C>0C>0) or eβˆ’t<βˆ’1/Ce^{-t} < -1/C (if C<0C<0). Note that eβˆ’te^{-t} is always positive.
  • If Ceβˆ’t<βˆ’1C e^{-t} < -1 for some tt, then uβˆ—(t)=0u^*(t)=0. This happens when eβˆ’t<βˆ’1/Ce^{-t} < -1/C (if C>0C>0) or eβˆ’t>βˆ’1/Ce^{-t} > -1/C (if C<0C<0).

Since eβˆ’te^{-t} is always positive, the condition Ceβˆ’t>βˆ’1C e^{-t} > -1 is always satisfied if C>0C > 0. If C<0C < 0, then Ceβˆ’tC e^{-t} is always negative. The condition Ceβˆ’t<βˆ’1C e^{-t} < -1 requires eβˆ’t>βˆ’1/Ce^{-t} > -1/C (since CC is negative, βˆ’1/C-1/C is positive). The condition Ceβˆ’t>βˆ’1C e^{-t} > -1 requires eβˆ’t<βˆ’1/Ce^{-t} < -1/C. The value eβˆ’te^{-t} decreases as tt increases.

Let's consider the possibility that uβˆ—(t)u^*(t) switches. This would happen if Ξ»(t)=βˆ’1\lambda(t) = -1 at some point. Ceβˆ’t=βˆ’1implieseβˆ’t=βˆ’1/CC e^{-t} = -1 \\implies e^{-t} = -1/C. This requires C<0C < 0. Let t0t_0 be the time such that eβˆ’t0=βˆ’1/Ce^{-t_0} = -1/C. Then for t<t0t < t_0, eβˆ’t>eβˆ’t0=βˆ’1/Ce^{-t} > e^{-t_0} = -1/C, which means Ceβˆ’t<βˆ’1C e^{-t} < -1, so uβˆ—(t)=0u^*(t)=0. For t>t0t > t_0, eβˆ’t<eβˆ’t0=βˆ’1/Ce^{-t} < e^{-t_0} = -1/C, which means Ceβˆ’t>βˆ’1C e^{-t} > -1, so uβˆ—(t)=1u^*(t)=1. This implies a switch from u=0u=0 to u=1u=1 at t0t_0.

Alternatively, if C>0C > 0, then Ξ»(t)=Ceβˆ’t>0>βˆ’1\lambda(t) = C e^{-t} > 0 > -1 for all tt. In this case, uβˆ—(t)=1u^*(t) = 1 for all tt. Let's test this simpler scenario first.

Scenario 1: uβˆ—(t)=1u^*(t) = 1 for all t∈[βˆ’1,1]t \in [-1, 1]

If uβˆ—(t)=1u^*(t)=1, the state equation is xΛ™=x+12=x+1\dot{x} = x + 1^2 = x + 1. The solution with x(βˆ’1)=0x(-1)=0 is:

x(t)=etβˆ«βˆ’1teβˆ’Ο„(1)dΟ„=et[βˆ’eβˆ’Ο„]βˆ’1t=et(βˆ’eβˆ’tβˆ’(βˆ’e1))=et(βˆ’eβˆ’t+e)=βˆ’1+et+1x(t) = e^t \int_{-1}^t e^{-\tau}(1) d\tau = e^t [-e^{-\tau}]_{-1}^t = e^t (-e^{-t} - (-e^{1})) = e^t (-e^{-t} + e) = -1 + e^{t+1}.

Let's check the final state: x(1)=βˆ’1+e1+1=e2βˆ’1x(1) = -1 + e^{1+1} = e^2 - 1.

Our required final state is x(1)=e2βˆ’e1+1ex(1) = e^2 - e^{1 + \frac{1}{e}}. Since e1+1e>1e^{1 + \frac{1}{e}} > 1, our calculated x(1)x(1) is not equal to the required x(1)x(1). So uβˆ—(t)=1u^*(t)=1 is not the optimal control.

Scenario 2: uβˆ—(t)=0u^*(t) = 0 for all t∈[βˆ’1,1]t \in [-1, 1]

If uβˆ—(t)=0u^*(t)=0, the state equation is xΛ™=x+02=x\dot{x} = x + 0^2 = x. The solution with x(βˆ’1)=0x(-1)=0 is:

x(t)=etβˆ«βˆ’1teβˆ’Ο„(0)dΟ„=et(0)=0x(t) = e^t \int_{-1}^t e^{-\tau}(0) d\tau = e^t (0) = 0.

This gives x(1)=0x(1)=0, which is not our required final state. So uβˆ—(t)=0u^*(t)=0 is not the optimal control.

Scenario 3: uβˆ—(t)u^*(t) switches.

This means we must have Ξ»(t0)=βˆ’1\lambda(t_0) = -1 for some t0∈(βˆ’1,1)t_0 \in (-1, 1), and Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t}.

If Ξ»(t0)=βˆ’1\lambda(t_0) = -1, then Ceβˆ’t0=βˆ’1C e^{-t_0} = -1, so C=βˆ’et0C = -e^{t_0}.

Then Ξ»(t)=βˆ’et0eβˆ’t=βˆ’et0βˆ’t\lambda(t) = -e^{t_0} e^{-t} = -e^{t_0 - t}.

We have Ξ»(t)<βˆ’1\lambda(t) < -1 if βˆ’et0βˆ’t<βˆ’1implieset0βˆ’t>1impliest0βˆ’t>0impliest<t0-e^{t_0 - t} < -1 \\implies e^{t_0 - t} > 1 \\implies t_0 - t > 0 \\implies t < t_0. So uβˆ—(t)=0u^*(t)=0 for t<t0t < t_0.

We have Ξ»(t)>βˆ’1\lambda(t) > -1 if βˆ’et0βˆ’t>βˆ’1implieset0βˆ’t<1impliest0βˆ’t<0impliest>t0-e^{t_0 - t} > -1 \\implies e^{t_0 - t} < 1 \\implies t_0 - t < 0 \\implies t > t_0. So uβˆ—(t)=1u^*(t)=1 for t>t0t > t_0.

Thus, the optimal control candidate is uβˆ—(t)={0ifΒ t<t01ifΒ t>t0u^*(t) = \begin{cases} 0 & \text{if } t < t_0 \\ 1 & \text{if } t > t_0 \end{cases} for some t0∈(βˆ’1,1)t_0 \in (-1, 1).

Now we need to find t0t_0 such that x(1)=e2βˆ’e1+1ex(1) = e^2 - e^{1 + \frac{1}{e}}.

Let's calculate x(t)x(t) with this piecewise control.

For t∈[βˆ’1,t0]t \in [-1, t_0], xΛ™=x\dot{x} = x, with x(βˆ’1)=0x(-1)=0. This gives x(t)=0x(t) = 0 for t∈[βˆ’1,t0]t \in [-1, t_0]. So x(t0)=0x(t_0) = 0.

For t∈[t0,1]t \in [t_0, 1], xΛ™=x+1\dot{x} = x + 1, with initial condition x(t0)=0x(t_0) = 0. The solution is x(t)=et∫t0teβˆ’Ο„(1)dΟ„=et[βˆ’eβˆ’Ο„]t0t=et(βˆ’eβˆ’tβˆ’(βˆ’eβˆ’t0))=βˆ’1+etβˆ’t0x(t) = e^t \int_{t_0}^t e^{-\tau}(1) d\tau = e^t [-e^{-\tau}]_{t_0}^t = e^t (-e^{-t} - (-e^{-t_0})) = -1 + e^{t-t_0}.

Now, let's evaluate x(1)x(1) using this expression:

x(1)=βˆ’1+e1βˆ’t0x(1) = -1 + e^{1 - t_0}.

We need this to equal the required final state: e2βˆ’e1+1ee^2 - e^{1 + \frac{1}{e}}.

So, βˆ’1+e1βˆ’t0=e2βˆ’e1+1e-1 + e^{1 - t_0} = e^2 - e^{1 + \frac{1}{e}}.

e1βˆ’t0=e2βˆ’e1+1e+1e^{1 - t_0} = e^2 - e^{1 + \frac{1}{e}} + 1.

This equation looks complicated to solve for t0t_0 analytically. Let's double-check the transversality condition for fixed final state.

For a fixed final state x(T)=xTx(T)=x_T, the PMP requires that there exists a Ξ»(t)\lambda(t) such that

  1. xΛ™=βˆ‚H/βˆ‚Ξ»\dot{x} = \partial H / \partial \lambda
  2. Ξ»Λ™=βˆ’βˆ‚H/βˆ‚x\dot{\lambda} = -\partial H / \partial x
  3. H(xβˆ—(t),uβˆ—(t),Ξ»(t),t)β‰₯H(x(t),u,Ξ»(t),t)H(x^*(t), u^*(t), \lambda(t), t) \ge H(x(t), u, \lambda(t), t) for all admissible uu.
  4. Ξ»(T)=βˆ‚Ο•/βˆ‚x(T)\lambda(T) = \partial \phi / \partial x(T) (terminal cost)
  5. Hamiltonian is constant if not explicitly time-dependent.

In our problem, the objective is βˆ«βˆ’11(txβˆ’u2)dt\int_{-1}^1 (tx - u^2) dt. The final state x(1)x(1) is fixed. This setup can be viewed as maximizing βˆ«βˆ’11(txβˆ’u2)dt+ΞΌ(x(1)βˆ’(e2βˆ’e1+1e))\int_{-1}^1 (tx - u^2) dt + \mu(x(1) - (e^2 - e^{1 + \frac{1}{e}})), where ΞΌ\mu is a Lagrange multiplier. However, the standard PMP formulation handles terminal costs Ο•(x(T))\phi(x(T)). If there is no explicit terminal cost function Ο•\phi, but just a fixed value x(T)x(T), the transversality condition on Ξ»(T)\lambda(T) is often taken to be related to the gradient of the value function V(x(T))V(x(T)), which is implicitly defined by the problem. For problems with fixed endpoints, the costate variable Ξ»(T)\lambda(T) isn't necessarily zero.

Let's reconsider the value of uβˆ—(t)u^*(t). The Hamiltonian is H=Ξ»xβˆ’tx+(Ξ»+1)u2H = \lambda x - tx + (\lambda + 1)u^2. We found uβˆ—(t)=1u^*(t)=1 if Ξ»>βˆ’1\lambda > -1 and uβˆ—(t)=0u^*(t)=0 if Ξ»<βˆ’1\lambda < -1. Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t}.

Could there be a scenario where uβˆ—(t)=1u^*(t)=1 always, but it's not the one we calculated? No, because the final condition was not met.

Let's re-evaluate the boundary condition for Ξ»\lambda. The condition Ξ»(t0)=βˆ’1\lambda(t_0)=-1 implies uu switches at t0t_0. This is called a chattering control if the switch happens infinitely often, but here it's a single switch. A single switch occurs when Ξ»(t)\lambda(t) passes through βˆ’1-1. The value of CC determines where this crossing happens.

Consider the final state: x(1)=e2βˆ’e1+1ex(1) = e^2 - e^{1 + \frac{1}{e}}. We have x(t)=et(x(a)+extrmintegral)x(t) = e^t (x(a) + extrm{integral}).

If u(t)=1u(t)=1 for t∈[t1,t2]t \in [t_1, t_2], then xΛ™=x+1\dot{x}=x+1, x(t)=C1etβˆ’1x(t) = C_1 e^t - 1. If u(t)=0u(t)=0 for t∈[t1,t2]t \in [t_1, t_2], then xΛ™=x\dot{x}=x, x(t)=C2etx(t) = C_2 e^t.

Let's try to guess the structure of the control. The term txtx in the integral encourages larger xx values, especially for positive tt. The term βˆ’u2-u^2 penalizes using uu. The dynamics xΛ™=x+u2\dot{x} = x + u^2 mean that using uu increases xx. To maximize the integral, we want xx to be large, especially for positive tt. This suggests we'd prefer u=1u=1 for larger tt. However, u=1u=1 also drives xx up faster, which could lead to a large x(1)x(1) that we don't want if it means violating the constraint. The constraint is x(1)=e2βˆ’e1+1ex(1) = e^2 - e^{1 + \frac{1}{e}}.

Let xtarget=e2βˆ’e1+1ex_{target} = e^2 - e^{1 + \frac{1}{e}}. This value is approximately e2βˆ’e1.367β‰ˆ7.389βˆ’3.92approx3.469e^2 - e^{1.367} \approx 7.389 - 3.92 \\approx 3.469.

If u(t)=1u(t)=1 for all tt, x(1)=e2βˆ’1β‰ˆ6.389x(1) = e^2 - 1 \approx 6.389. This is larger than xtargetx_{target}.

If u(t)=0u(t)=0 for all tt, x(1)=0x(1) = 0. This is smaller than xtargetx_{target}.

This suggests that we need a control that results in a final x(1)x(1) smaller than e2βˆ’1e^2-1 but larger than 0. This supports the idea of a switching control.

If u(t)u(t) switches from 1 to 0 at t0t_0, then for t<t0t < t_0, xΛ™=x+1\dot{x} = x+1, and for t>t0t > t_0, xΛ™=x\dot{x} = x. This would lead to a lower x(1)x(1) than if u(t)=1u(t)=1 always, which is what we need. The switch would be from u=1u=1 to u=0u=0 if Ξ»\lambda goes from >βˆ’1>-1 to <βˆ’1<-1. This requires C<0C<0. So Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t}. If Ξ»(t0)=βˆ’1\lambda(t_0) = -1, then C=βˆ’et0C = -e^{t_0}. Ξ»(t)=βˆ’et0βˆ’t\lambda(t) = -e^{t_0-t}. For t<t0t < t_0, t0βˆ’t>0t_0-t > 0, et0βˆ’t>1e^{t_0-t} > 1, so Ξ»(t)<βˆ’1\lambda(t) < -1, uβˆ—(t)=0u^*(t)=0. For t>t0t > t_0, t0βˆ’t<0t_0-t < 0, et0βˆ’t<1e^{t_0-t} < 1, so Ξ»(t)>βˆ’1\lambda(t) > -1, uβˆ—(t)=1u^*(t)=1. This leads to uβˆ—(t)u^*(t) switching from 0 to 1, which increases x(1)x(1). This is the opposite of what we need.

Let's reconsider the condition Ξ»+1\lambda+1. If Ξ»+1>0\lambda+1>0, u=1u=1. If Ξ»+1<0\lambda+1<0, u=0u=0. This means Ξ»>βˆ’1impliesu=1\lambda > -1 \\implies u=1 and Ξ»<βˆ’1impliesu=0\lambda < -1 \\implies u=0. With Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t}.

If C>0C>0, Ξ»(t)=Ceβˆ’t>0>βˆ’1\lambda(t) = C e^{-t} > 0 > -1 for all tt. So uβˆ—(t)=1u^*(t)=1 for all tt. We already showed this doesn't work.

If C<0C<0, let C=βˆ’AC = -A where A>0A>0. Then Ξ»(t)=βˆ’Aeβˆ’t\lambda(t) = -A e^{-t}.

  • We need Ξ»(t)>βˆ’1\lambda(t) > -1, so βˆ’Aeβˆ’t>βˆ’1impliesAeβˆ’t<1implieseβˆ’t<1/Aimpliesβˆ’t<ln⁑(1/A)=βˆ’ln⁑(A)et>ln⁑(A)-A e^{-t} > -1 \\implies A e^{-t} < 1 \\implies e^{-t} < 1/A \\implies -t < \ln(1/A) = -\ln(A) e t > \ln(A).
  • We need Ξ»(t)<βˆ’1\lambda(t) < -1, so βˆ’Aeβˆ’t<βˆ’1impliesAeβˆ’t>1implieseβˆ’t>1/Aimpliesβˆ’t>ln⁑(1/A)=βˆ’ln⁑(A)et<ln⁑(A)-A e^{-t} < -1 \\implies A e^{-t} > 1 \\implies e^{-t} > 1/A \\implies -t > \ln(1/A) = -\ln(A) e t < \ln(A).

Let ts=ln⁑(A)t_s = \ln(A). So, if t<tst < t_s, Ξ»(t)<βˆ’1\lambda(t) < -1 and uβˆ—(t)=0u^*(t)=0. If t>tst > t_s, Ξ»(t)>βˆ’1\lambda(t) > -1 and uβˆ—(t)=1u^*(t)=1. This implies uβˆ—(t)u^*(t) switches from 0 to 1 at tst_s. We need ts∈(βˆ’1,1)t_s \in (-1, 1).

Let's calculate x(1)x(1) with uβˆ—(t)={0ifΒ t<ts1ifΒ t>tsu^*(t) = \begin{cases} 0 & \text{if } t < t_s \\ 1 & \text{if } t > t_s \end{cases}.

For t∈[βˆ’1,ts]t \in [-1, t_s], xΛ™=x\dot{x}=x, x(βˆ’1)=0x(-1)=0. So x(t)=0x(t)=0 for t∈[βˆ’1,ts]t \in [-1, t_s]. Thus x(ts)=0x(t_s)=0.

For t∈[ts,1]t \in [t_s, 1], xΛ™=x+1\dot{x}=x+1, x(ts)=0x(t_s)=0. Solution is x(t)=et∫tsteβˆ’Ο„(1)dΟ„=et[βˆ’eβˆ’Ο„]tst=et(βˆ’eβˆ’tβˆ’(βˆ’eβˆ’ts))=βˆ’1+etβˆ’tsx(t) = e^t \int_{t_s}^t e^{-\tau}(1) d\tau = e^t [-e^{-\tau}]_{t_s}^t = e^t (-e^{-t} - (-e^{-t_s})) = -1 + e^{t-t_s}.

So x(1)=βˆ’1+e1βˆ’tsx(1) = -1 + e^{1-t_s}.

We need x(1)=e2βˆ’e1+1ex(1) = e^2 - e^{1 + \frac{1}{e}}.

βˆ’1+e1βˆ’ts=e2βˆ’e1+1e-1 + e^{1-t_s} = e^2 - e^{1 + \frac{1}{e}}

e1βˆ’ts=e2βˆ’e1+1e+1e^{1-t_s} = e^2 - e^{1 + \frac{1}{e}} + 1

This is the same equation as before. It seems there might be an issue with my understanding of the transversality condition for fixed endpoints or a numerical value that needs to be calculated.

Let's re-evaluate the problem structure. Is it possible that the optimal control is bang-bang, meaning it only takes values 0 or 1?

The Hamiltonian is H=Ξ»xβˆ’tx+(Ξ»+1)u2H = \lambda x - tx + (\lambda + 1)u^2. Maximizing HH wrt u∈[0,1]u \in [0,1] gives u=1u=1 if Ξ»+1>0\lambda+1>0 and u=0u=0 if Ξ»+1<0\lambda+1<0. This is bang-bang control.

The costate equation is Ξ»Λ™=βˆ’Ξ»\dot{\lambda} = -\lambda, so Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t}.

We need to satisfy x(βˆ’1)=0x(-1)=0 and x(1)=e2βˆ’e1+1ex(1)=e^2 - e^{1 + \frac{1}{e}}.

Let's try to find CC and potentially a switching time t0t_0 such that these conditions are met.

If u(t)=1u(t)=1 always, x(1)=e2βˆ’1x(1) = e^2-1. Target is e2βˆ’e1+1/ee^2 - e^{1 + 1/e}. Since e1+1/e>1e^{1+1/e} > 1, target x(1)x(1) is smaller than e2βˆ’1e^2-1. This suggests we need a control that reduces x(1)x(1) compared to always using u=1u=1. This implies we should use u=0u=0 for some interval.

If u(t)=0u(t)=0 always, x(1)=0x(1)=0. Target x(1)x(1) is positive. This suggests we need a control that increases x(1)x(1) compared to always using u=0u=0. This implies we should use u=1u=1 for some interval.

This leads to a switching control. For uu to switch from 1 to 0, we need Ξ»+1\lambda+1 to go from positive to negative. This means Ξ»\lambda goes from >βˆ’1>-1 to <βˆ’1<-1. This requires C>0C>0. Ξ»(t)=Ceβˆ’t\lambda(t) = C e^{-t}. If Ξ»(t0)=βˆ’1\lambda(t_0)=-1, then Ceβˆ’t0=βˆ’1ightarrowC=βˆ’et0C e^{-t_0} = -1 ightarrow C = -e^{t_0}. This contradicts C>0C>0. So uu cannot switch from 1 to 0.

For uu to switch from 0 to 1, we need Ξ»+1\lambda+1 to go from negative to positive. This means Ξ»\lambda goes from <βˆ’1<-1 to >βˆ’1>-1. This requires C<0C<0. Let C=βˆ’AC = -A with A>0A>0. Ξ»(t)=βˆ’Aeβˆ’t\lambda(t) = -A e^{-t}. If Ξ»(t0)=βˆ’1\lambda(t_0)=-1, then βˆ’Aeβˆ’t0=βˆ’1ightarrowA=et0-A e^{-t_0}=-1 ightarrow A = e^{t_0}. Then Ξ»(t)=βˆ’et0eβˆ’t=βˆ’et0βˆ’t\lambda(t) = -e^{t_0} e^{-t} = -e^{t_0-t}.

For t<t0t < t_0, t0βˆ’t>0t_0-t > 0, et0βˆ’t>1e^{t_0-t} > 1, so Ξ»(t)<βˆ’1\lambda(t) < -1. Thus uβˆ—(t)=0u^*(t)=0. For t>t0t > t_0, t0βˆ’t<0t_0-t < 0, et0βˆ’t<1e^{t_0-t} < 1, so Ξ»(t)>βˆ’1\lambda(t) > -1. Thus uβˆ—(t)=1u^*(t)=1.

So the control is uβˆ—(t)={0t<t01t>t0u^*(t) = \begin{cases} 0 & t < t_0 \\ 1 & t > t_0 \end{cases} for some t0∈(βˆ’1,1)t_0 \in (-1, 1).

We calculated x(1)=βˆ’1+e1βˆ’t0x(1) = -1 + e^{1-t_0} with this control.

We need x(1)=e2βˆ’e1+1ex(1) = e^2 - e^{1 + \frac{1}{e}}.

So, βˆ’1+e1βˆ’t0=e2βˆ’e1+1e-1 + e^{1-t_0} = e^2 - e^{1 + \frac{1}{e}}.

e1βˆ’t0=e2βˆ’e1+1e+1e^{1-t_0} = e^2 - e^{1 + \frac{1}{e}} + 1.

It seems the problem might be set up such that t0t_0 is not easily solvable or there's a detail missed. Let's check the Hamiltonian at the final time. For fixed endpoints, Ξ»(T)\lambda(T) is not necessarily zero. The value of x(1)x(1) is fixed, so its variation is zero. The condition Ξ»(T)=βˆ‚Ο•/βˆ‚x(T)\lambda(T) = \partial \phi / \partial x(T) becomes tricky.

Let's consider the structure of the objective function and the state equation again. max⁑extrmIntegral=extrmIntegralof(txβˆ’u2)\max extrm{Integral} = extrm{Integral of } (tx - u^2). Dynamics: xΛ™=x+u2\dot{x} = x + u^2. Boundary x(βˆ’1)=0x(-1)=0, x(1)=e2βˆ’e1+1/ex(1)=e^2 - e^{1 + 1/e}.

What if we try to work backward from the final state? This is sometimes useful for fixed final states.

If u(t)=1u(t)=1 on [t0,1][t_0, 1], x(t)=βˆ’1+etβˆ’t0x(t) = -1 + e^{t-t_0}. x(1)=βˆ’1+e1βˆ’t0x(1) = -1 + e^{1-t_0}. If u(t)=0u(t)=0 on [βˆ’1,t0][-1, t_0], x(t)=0x(t) = 0. This gives x(t0)=0x(t_0)=0. Then x(1)=βˆ’1+e1βˆ’t0x(1) = -1 + e^{1-t_0}. Setting this equal to the target: βˆ’1+e1βˆ’t0=e2βˆ’e1+1e-1 + e^{1-t_0} = e^2 - e^{1 + \frac{1}{e}}. This requires e1βˆ’t0=e2βˆ’e1+1e+1e^{1-t_0} = e^2 - e^{1 + \frac{1}{e}} + 1. Let's evaluate the right side numerically: e2βˆ’e1+1/e+1β‰ˆ7.389βˆ’3.922+1=4.467e^2 - e^{1 + 1/e} + 1 \approx 7.389 - 3.922 + 1 = 4.467. So e1βˆ’t0=4.467e^{1-t_0} = 4.467. 1βˆ’t0=ln⁑(4.467)β‰ˆ1.51-t_0 = \ln(4.467) \approx 1.5. t0=1βˆ’1.5=βˆ’0.5t_0 = 1 - 1.5 = -0.5. This value t0=βˆ’0.5t_0 = -0.5 is within (βˆ’1,1)(-1, 1).

So the proposed optimal control is uβˆ—(t)={0t<βˆ’0.51t>βˆ’0.5u^*(t) = \begin{cases} 0 & t < -0.5 \\ 1 & t > -0.5 \end{cases}.

Let's check the costate Ξ»(t)\lambda(t). We need Ξ»(t0)=βˆ’1\lambda(t_0) = -1 for the switch to occur at t0t_0. We found Ξ»(t)=βˆ’et0βˆ’t\lambda(t) = -e^{t_0-t}. With t0=βˆ’0.5t_0=-0.5, Ξ»(t)=βˆ’eβˆ’0.5βˆ’t\lambda(t) = -e^{-0.5-t}. At t=t0=βˆ’0.5t = t_0 = -0.5, Ξ»(βˆ’0.5)=βˆ’eβˆ’0.5βˆ’(βˆ’0.5)=βˆ’e0=βˆ’1\lambda(-0.5) = -e^{-0.5 - (-0.5)} = -e^0 = -1. This confirms the switch condition.

Now, we need to verify that this control maximizes the integral βˆ«βˆ’11(txβˆ’u2)dt\int_{-1}^1 (tx - u^2) dt subject to x(βˆ’1)=0,x(1)=e2βˆ’e1+1ex(-1)=0, x(1)=e^2 - e^{1 + \frac{1}{e}}, and xΛ™=x+u2\dot{x} = x + u^2, uextrmin[0,1]u extrm{ in } [0,1].

The PMP guarantees that if the Hamiltonian is maximized, we have an optimal control candidate. The issue with fixed final states is ensuring the transversality conditions are met, which determines the constant CC for Ξ»\lambda. In our case, we found CC implicitly by setting Ξ»(t0)=βˆ’1\lambda(t_0)=-1 and then solving for t0t_0 using the state equation and boundary conditions. This implicitly satisfies a form of transversality.

The value of the integral can be computed. With uβˆ—(t)={0t<βˆ’0.51t>βˆ’0.5u^*(t) = \begin{cases} 0 & t < -0.5 \\ 1 & t > -0.5 \end{cases}:

For t∈[βˆ’1,βˆ’0.5]t \in [-1, -0.5], x(t)=0x(t)=0. For t∈[βˆ’0.5,1]t \in [-0.5, 1], x(t)=βˆ’1+et+0.5x(t) = -1 + e^{t+0.5}.

Integral =βˆ«βˆ’1βˆ’0.5(times0βˆ’02)dt+βˆ«βˆ’0.51(t(βˆ’1+et+0.5)βˆ’12)dt= \int_{-1}^{-0.5} (t imes 0 - 0^2) dt + \int_{-0.5}^1 (t(-1+e^{t+0.5}) - 1^2) dt

=0+βˆ«βˆ’0.51(βˆ’t+tet+0.5βˆ’1)dt= 0 + \int_{-0.5}^1 (-t + t e^{t+0.5} - 1) dt

We need to evaluate ∫tet+0.5dt\int t e^{t+0.5} dt. Let s=t+0.5s = t+0.5, ds=dtds=dt. t=sβˆ’0.5t = s-0.5. ∫(sβˆ’0.5)esds=∫sesdsβˆ’0.5∫esds=(sβˆ’1)esβˆ’0.5es=(sβˆ’1.5)es=(t+0.5βˆ’1.5)et+0.5=(tβˆ’1)et+0.5\int (s-0.5) e^s ds = \int s e^s ds - 0.5 \int e^s ds = (s-1)e^s - 0.5 e^s = (s - 1.5) e^s = (t+0.5-1.5)e^{t+0.5} = (t-1)e^{t+0.5}.

So, βˆ«βˆ’0.51(βˆ’t+tet+0.5βˆ’1)dt=[βˆ’t22+(tβˆ’1)et+0.5βˆ’t]βˆ’0.51\int_{-0.5}^1 (-t + t e^{t+0.5} - 1) dt = [-\frac{t^2}{2} + (t-1)e^{t+0.5} - t]_{-0.5}^1

=[βˆ’t22βˆ’2t+(tβˆ’1)et+0.5]βˆ’0.51= [-\frac{t^2}{2} - 2t + (t-1)e^{t+0.5}]_{-0.5}^1

At t=1t=1: βˆ’12βˆ’2+(1βˆ’1)e1.5=βˆ’2.5-\frac{1}{2} - 2 + (1-1)e^{1.5} = -2.5. At t=βˆ’0.5t=-0.5: βˆ’(βˆ’0.5)22βˆ’2(βˆ’0.5)+(βˆ’0.5βˆ’1)eβˆ’0.5+0.5=βˆ’0.252+1+(βˆ’1.5)e0=βˆ’0.125+1βˆ’1.5=βˆ’0.625-\frac{(-0.5)^2}{2} - 2(-0.5) + (-0.5-1)e^{-0.5+0.5} = -\frac{0.25}{2} + 1 + (-1.5)e^0 = -0.125 + 1 - 1.5 = -0.625.

Value =βˆ’2.5βˆ’(βˆ’0.625)=βˆ’2.5+0.625=βˆ’1.875= -2.5 - (-0.625) = -2.5 + 0.625 = -1.875.

This is the value of the integral. The problem asked for the maximum value of the integral. We found the optimal control. The value itself is βˆ’1.875-1.875. The problem phrasing is