Commit 86d38c9
Fix IFP lecture: Complete NumPy and JAX implementations with verification
Major fixes and improvements:
1. NumPy Implementation (K_numpy and solve_model_numpy):
- Fixed type hints (np.ndarray instead of jnp.ndarray)
- Fixed loop iteration bug (range(n_z) instead of n_z)
- Fixed undefined variable references (savings_grid[i], z_grid[k])
- Added missing γ parameter to u_prime() and u_prime_inv() calls
- Fixed boundary condition assignment (new_c_vals instead of c_vals)
- Fixed broadcasting in endogenous grid calculation
- Fixed return values (c_vals, ae_vals instead of undefined σ)
2. JAX Implementation (K and solve_model):
- Fully implemented K operator using jax.vmap for vectorization
- Fixed solve_model body function variable names
- Added JAX 64-bit precision configuration for numerical accuracy
- Verified results match NumPy to machine precision (~10^-15)
3. Code Throughout Lecture:
- Fixed all solve_model unpacking (returns tuple, not single value)
- Fixed asset law of motion plot (interpolate on endogenous grid)
- Fixed cake eating sanity check (removed non-existent function)
- Fixed compute_asset_stationary to use correct interpolation grid
- Fixed all exercise solutions (1, 2, 3)
- Improved variable naming consistency (σ_init → c_vals_init, z → k, lb → label)
4. Added Verification Section:
- Compares NumPy and JAX implementations
- Shows numerical differences at machine precision
- Validates correctness of JAX implementation
All code tested end-to-end and verified working correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 0b8723d commit 86d38c9
3 files changed
+276
-1419
lines changedThis file was deleted.
0 commit comments