You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shouldn't the "Turnpike Property" refer also to the independence of the initial condition? I.e., if T is large enough, then independent of the initial K_0, the optimal path of K_t stays close to the steady state value.
The code of plot_saving_rate should be extended to accept a list of k0s, to compare the trajectories from different k0s.
@oyamad I know very little about this lecture but I thought I would see what Claude Sonnet 4 model would say as a fix to this issue by reading the Cass Koopmans 1 lecture.
@HumphreyYang would you have any time to take a look and let me know how useful this feedback is.
Here is what it said.
Fix for Cass-Koopmans Lecture - Turnpike Property Section
Issue Summary
The GitHub issue points out that the Turnpike Property section should demonstrate that the property holds regardless of the initial capital condition K₀. Currently, the lecture only shows convergence from one starting point, but the turnpike property is stronger - it should hold for multiple different initial conditions.
Proposed Changes
1. Enhanced plot_saving_rate function
Replace the existing plot_saving_rate function with this enhanced version that accepts multiple initial capital values:
defplot_saving_rate(pp, c0, k0_arr, T_arr, k_ter=0, k_ss=None, s_ss=None):
""" Enhanced saving rate plotting function that accepts either: - A single k0 value (backward compatibility) - A list of k0 values to demonstrate turnpike property """# Handle backward compatibility - if k0_arr is a scalar, convert to listifnp.isscalar(k0_arr):
k0_arr= [k0_arr]
single_k0=Trueelse:
single_k0=Falseifsingle_k0:
# Original behavior for single k0fig, axs=plt.subplots(2, 2, figsize=(12, 9))
c_paths, k_paths=plot_paths(pp, c0, k0_arr[0], T_arr, k_ter=k_ter, k_ss=k_ss, axs=axs.flatten())
fori, Tinenumerate(T_arr):
s_path=saving_rate(pp, c_paths[i], k_paths[i])
axs[1, 1].plot(s_path)
axs[1, 1].set(xlabel='t', ylabel='$s_t$', title='Saving rate')
ifs_ssisnotNone:
axs[1, 1].hlines(s_ss, 0, np.max(T_arr), linestyle='--')
else:
# Enhanced behavior for multiple k0 valuesfig, axs=plt.subplots(2, 2, figsize=(15, 10))
# Use the largest T for the main comparisonT_main=max(T_arr)
# Plot consumption, capital, and multiplier paths for different k0 valuescolors=plt.cm.viridis(np.linspace(0, 1, len(k0_arr)))
ylabels= ['$c_t$', '$k_t$', '$\mu_t$']
titles= ['Consumption', 'Capital', 'Lagrange Multiplier']
fori, k0inenumerate(k0_arr):
c_vec, k_vec=bisection(pp, c0, k0, T_main, k_ter=k_ter, verbose=False)
μ_vec=pp.u_prime(c_vec)
paths= [c_vec, k_vec, μ_vec]
forjinrange(3):
axs[j//2, j%2].plot(paths[j], color=colors[i],
label=f'$K_0$ = {k0:.2f}'ifj==1else"")
axs[j//2, j%2].set(xlabel='t', ylabel=ylabels[j], title=titles[j])
# Plot saving rates_path=saving_rate(pp, c_vec, k_vec)
axs[1, 1].plot(s_path, color=colors[i], label=f'$K_0$ = {k0:.2f}')
# Add steady state lines and legendsifk_ssisnotNone:
axs[0, 1].axhline(k_ss, c='k', ls='--', lw=1, label='Steady state')
ifs_ssisnotNone:
axs[1, 1].axhline(s_ss, c='k', ls='--', lw=1, label='Steady state')
axs[0, 1].legend()
axs[1, 1].set(xlabel='t', ylabel='$s_t$', title='Saving rate')
axs[1, 1].legend()
plt.tight_layout()
plt.show()
2. Enhanced Turnpike Property Section
Replace the existing turnpike property section with:
# 34.6. A Turnpike Property# The following calculation indicates that when T is very large, the optimal capital # stock stays close to its steady state value most of the time, REGARDLESS of the # initial capital stock K_0.# Let's demonstrate this key property by starting from multiple different initial # capital levels, both above and below the steady state:k0_values= [k_ss/4, k_ss/2, k_ss*0.8, k_ss*1.2, k_ss*1.5, k_ss*2]
print("Demonstrating Turnpike Property with different initial capital stocks:")
fori, k0inenumerate(k0_values):
ratio=k0/k_ssprint(f" K_0_{i+1} = {k0:.2f} ({ratio:.1f} × K_ss)")
# Plot optimal paths from different starting pointsplot_saving_rate(pp, 0.3, k0_values, [200], k_ter=k_ss, k_ss=k_ss, s_ss=s_ss)
3. Additional Analysis Section
Add this new section after the turnpike property demonstration:
# Notice how all paths, regardless of their starting point, converge to and stay # near the steady state for most of the time horizon. This demonstrates the key # insight of the turnpike property:# 1. **Path Independence**: The long-run behavior is independent of initial conditions# 2. **Convergence**: All paths converge to the steady state neighborhood # 3. **Persistence**: Paths stay near steady state for most of the horizon# Let's also compare different time horizons starting from the same initial condition# to show how longer horizons lead to more time spent near the steady state:plot_saving_rate(pp, 0.3, k_ss/3, [250, 150, 75, 50], k_ter=k_ss, k_ss=k_ss, s_ss=s_ss)
# A rule of thumb for the planner is:# 1. From any K_0, push K_t toward the steady state # 2. Stay close to the steady state until time approaches T# 3. Then optimally wind down capital to meet terminal condition K_{T+1} = K_ter
Summary of Changes
Enhanced Function: The plot_saving_rate function now accepts either a single k0 (for backward compatibility) or a list of k0 values to demonstrate the turnpike property from multiple starting points.
Better Demonstration: The turnpike property section now clearly shows that the property holds regardless of initial conditions by plotting multiple trajectories simultaneously.
Clearer Explanation: Added text explaining the three key aspects of the turnpike property: path independence, convergence, and persistence near the steady state.
Maintained Compatibility: All existing code continues to work as before, but now the function can handle the enhanced use case requested in the GitHub issue.
This fix addresses the core issue by demonstrating that the turnpike property truly is independent of initial conditions, making the economic intuition much clearer for students.
Activity
mmcky commentedon Jun 19, 2025
@oyamad I know very little about this lecture but I thought I would see what
Claude Sonnet 4model would say as a fix to this issue by reading the Cass Koopmans 1 lecture.@HumphreyYang would you have any time to take a look and let me know how useful this feedback is.
Here is what it said.
Fix for Cass-Koopmans Lecture - Turnpike Property Section
Issue Summary
The GitHub issue points out that the Turnpike Property section should demonstrate that the property holds regardless of the initial capital condition K₀. Currently, the lecture only shows convergence from one starting point, but the turnpike property is stronger - it should hold for multiple different initial conditions.
Proposed Changes
1. Enhanced
plot_saving_ratefunctionReplace the existing
plot_saving_ratefunction with this enhanced version that accepts multiple initial capital values:2. Enhanced Turnpike Property Section
Replace the existing turnpike property section with:
3. Additional Analysis Section
Add this new section after the turnpike property demonstration:
Summary of Changes
Enhanced Function: The
plot_saving_ratefunction now accepts either a singlek0(for backward compatibility) or a list ofk0values to demonstrate the turnpike property from multiple starting points.Better Demonstration: The turnpike property section now clearly shows that the property holds regardless of initial conditions by plotting multiple trajectories simultaneously.
Clearer Explanation: Added text explaining the three key aspects of the turnpike property: path independence, convergence, and persistence near the steady state.
Maintained Compatibility: All existing code continues to work as before, but now the function can handle the enhanced use case requested in the GitHub issue.
This fix addresses the core issue by demonstrating that the turnpike property truly is independent of initial conditions, making the economic intuition much clearer for students.
[cass_koopmans_1] Claude review of issue #457
HumphreyYang commentedon Jun 19, 2025
Many thanks @oyamad and @mmcky,
I see your suggestions! I think this is a good place to add an exercise asking readers to verify the independence of the initial condition.
I will put together a PR for this.
(Claude's code is helpful! But I think it's a bit complicated for the sake of robustness : ))