ECO4145 Mathematical Economics II Assignment 3
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
ECO4145 Mathematical Economics II
Assignment 3
1. Find a continuous function c : t ct, 0 ≤ t ≤ 1, to minimize(ct)0≤t≤1 ∫0(1)ct(4) t
subject to = xt + ct, x0 = x0, x1 = 0.
The Hamiltonian is
ℋ = c4 + λ (x + c)
4
4
The state equation
eq [1] = x' [t ] x [t ] + c [t ]
x′ [t ] c [t ] + x [t ]
The first-order condition for minimizing the Hamiltonian is
ℋ t = ℋ / . {x x [t ] , λ λ[t ]}
4
4
foct = D[ℋt, c ] 0
偏导
c3 + λ[t ] 0
The second-order condition for minimizing the Hamiltonian is satisfied.
soct = D[foct〚1〛, c ]
偏导
3 c2
The optimal control at time t
s [0] = Solve[foct, c ]
解方程
c - λ[t ]1/3 , c (- 1)1/3 λ[t ]1/3 , c - (- 1)2/3 λ[t ]1/3
Note that the three solutions are the same. So, any one of them will do. Let us pick the first 0ne.
In[]:= s [1] = s [0]〚1〛
Out[]= c - λ[t ]1/3
The optimal control at time t
In[]:= c [t_ ] := Evaluate[c / . s [1]]
计算
In[]:= c [t ]
Out[]= - λ[t ]1/3
In[]:= c [1]
Out[]= - λ[1]1/3
The adjoint equation is
In[]:= dℋdx = D[ℋ , x ]
偏导
Out[]= λ
In[]:= dℋdxt = dℋdx / . {x x [t ] , c c [t ] , λ λ[t ]}
Out[]= λ[t ]
In[]:= eq [2] = λ ' [t ] - dℋdxt
Out[]= λ′ [t ] - λ[t ]
In[]:= s [2] = DSolve[{eq [1], eq [2], x [0] x0, λ[0] λ0} , {x, λ}, t ] // Flatten
求解微分方程 压平
Out[]= λ Function {t } , -t λ0 , x Function {t } , -
In[]:= x [1] / . s [2]
- 4 x0 λ0 + 3 λ04/3 -
Out[]= -
4 λ0
The final condition for xt
In[]:= eq [3] = (x [1] / . s [2]) 0
0
In[]:= s [3] = Solve[eq [3] , λ0] // Flatten
解方程 压平
Solve : There may be values of the parameters for which some or all solutions are not valid .
Out[]= λ 0
In[ ]:= s [3] = s [3] // FullSimplify
完全简化
64 4 x03
Out[ ]= λ 0
In[ ]:= λ0 = λ0 / . s [3]
Out[ ]=
With the value ofλ0 just found, solve the system again
In[ ]:= s [3] = DSolve[{eq [1], eq [2], x [0] x0, λ[0] λ0} , {x, λ}, t ] // Flatten
求解微分方程 压平
Out[ ]= λ Function {t } , ,
-4+t - 4 x04 + 16/3 x04 - 16/3 x03 4/3 + 4 -t x03 4/3
x Function {t } ,
The optimal control at time t is
In[ ]:= c [t ]
Out[ ]= - λ[t ]1/3
In[ ]:= c [t ] / . s [3]
4 4-t x03 1/3
Out[ ]= -
3 × - 1 + 4/3
The minimum cost is
In[ ]:= v = 01 c [t ]4 / . s [3] t
16 4 x03 4/3
Out[ ]= 27 - 1 + 4/3 3
In[ ]:= v = v // PowerExpand
幂展开
Out[ ]=
In[ ]:= ClearAll[ℋ, x, c, λ , x0, λ0, v, s, eq, foc]
清除全部
2. Find a continuous function c : t ct, 0 ≤ t ≤ 2, to
maximize(ct)0≤t≤2 ∫0(2) 2 xt - 3 ct - c tt(2)
subject to = xt + ct, x0 = 5, x2 = 0.
4 ECO4145_Assignment 3_04_04_2022_Solution.nb
In[ ]:= ℋ = 2 x - 3 c - c2 + λ (x + c)
Out[ ]= - 3 c - c2 + 2 x + (c + x ) λ
The state equation is
In[ ]:= eq [1] = x' [t ] x [t ] + c [t ]
Out[ ]= x′ [t ] c [t ] + x [t ]
Maximizing the Hamiltonian
In[ ]:= ℋ t = ℋ / . {x x [t ] , λ λ[t ]}
Out[ ]= - 3 c - c2 + 2 x [t ] + (c + x [t ]) λ[t ]
The optimal control at each instant is obtained by maximizing the Hamiltonian ℋ[xt(*), c, λt, t] at that instant. The first-order condition that characterizes ct(*) is
In[ ]:= foct = D[ℋt, c ] 0
偏导
Out[ ]= - 3 - 2 c + λ[t ] 0
The second-order condition that characterizes ct(*) is satisfied.
In[ ]:= soct = D[foct〚1〛, c ]
偏导
Out[ ]= - 2
The optimal control at time t
In[ ]:= s [0] = Solve[foct, c ] // Flatten
解方程 压平
Out[ ]= c × (- 3 + λ[t ])
In[ ]:= c [t_ ] := Evaluate[c / . s [0]]
计算
In[ ]:= c [t ]
Out[ ]= × (- 3 + λ[t ])
In[ ]:= eq [1]
Out[ ]= x′ [t ] x [t ] + × (- 3 + λ[t ])
The adjoint equation
In[ ]:= dℋdx = D[ℋ , x ]
偏导
Out[ ]= 2 + λ
In[ ]:= dℋdxt = dℋdx / . {x x [t ] , c c [t ] , λ λ[t ]}
Out[ ]= 2 + λ[t ]
In[ ]:= eq [2] = λ ' [t ] - dℋdxt
Out[ ]= λ′ [t ] - 2 - λ[t ]
In[ ]:= eq [1]
Out[ ]= x′ [t ] x [t ] + × (- 3 + λ[t ])
Solve the system ofdifferential equations {eq[1], eq[2]}
In[ ]:= s [1] =
DSolve[{eq [1], eq [2], x [0] 5, λ[0] λ0} , {x, λ}, t ] // Flatten // FullSimplify
求解微分方程 压平 完全简化
Out[ ]= x Function {t } , -t 1 + t × - 2 + 12 t - λ0 + t λ0 ,
λ Function {t } , - -t - 2 + 2 t - λ0
The final condition for xt
In[ ]:= eq [3] = (x [2] / . s [1]) 0
1 + 2 × - 2 + 12 2 - λ0 + 2 λ0
Out[ ]= 0
4 2
In[ ]:= s [2] = Solve[eq [3] , λ0] // Flatten
解方程 压平
Out[ ]= λ 0 -
In[ ]:= λ0 = λ0 / . s [2]
Out[ ]= -
Use the value ofλ0, solve the system ofdifferential equations {eq[1], eq[2]} again
In[ ]:= s [3] =
DSolve[{eq [1], eq [2], x [0] 5, λ[0] λ0} , {x, λ}, t ] // Flatten // FullSimplify
求解微分方程 压平 完全简化
Out[ ]= x Function {t } , - ,
λ Function {t } , -
The optimal control at time t
In[ ]:= c [t ] / . s [3]
Out[ ]= × - 3 -
The optimal payoff
In[ ]:= v = 2 2 x[t ] - 3 c[t ] - c [t ]2 / . s [3] t
Out[ ]= -
In[ ]:= ClearAll[ℋ , ℋ t, dℋdx, dℋdxt, eq, s, λ , λ0, foct, c, x, v]
清除全部
3. Find a continuous function c : t ct, 0 ≤ t ≤ 2, to maximize(ct)0≤t≤2 ∫0(2) 2 xt - 3 ct - ct(2) t
subject to = xt + ct, x0 = 5.
Note that the endpoint x2 is free, i.e., not constrained.
Let
(1) v[ξ , τ ] = maximize(ct) τ ≤t≤ 2 2 xt - 3ct - ct(2) t
subject to = xt + ct, xτ = ξ , x2 = 0.
As defined, v[ξ , τ ] gives the value attained by the objective function, given that the system begins at time 0 ≤ τ ≤ 2 in state ξ. For τ = 2, we have v[ξ , 2] = 0 because the problem begins at the end of the time horizon and ends immediately, with the ensuing consequence that there is no payoff: v[ξ , 2] = 0 no matter what the value of ξ is, and, thus, D1 v[ξ , 2] = 0.
Let ct(*) be the optimal control at time t, 0 ≤ t ≤ 2, for the original problem and xt(*), 0 ≤ t ≤ 2, be the state of the system at time t under the optimal control ct(*), 0 ≤ t ≤ 2. Also, let λt= D1 v[xt(*), t] denote the co-state at time t along the optimal trajectory.
The Hamiltonian is
In[ ]:= ℋ = 2 x - 3 c - c2 + λ (x + c)
Out[ ]= - 3 c - c2 + 2 x + (c + x ) λ
The state equation is
In[ ]:= eq [1] = x' [t ] x [t ] + c [t ]
Out[ ]= x′ [t ] c&nbs
2022-04-12