π Week 5 Homework β Feedback
π Week 5 Homework β Feedback
Student: Sebastiano Bacchi
Assignment: Solving Nonlinear Equations in Economics
β Overall Assessment
Result: β More than 50% Correct
Submission implements all three exercises with good organization and figure saving. However, there are critical errors: (1) Exercise 1 uses only one initial guess instead of two, (2) Exercise 2 bisection has the same critical error affecting multiple students - does not update function values at endpoints, and (3) Exercise 3 bisection also has this error. Exercise 3 damped Newton is correctly implemented. The code structure is organized with proper figure management, but the numerical errors need correction.
π Task-by-Task Check
| Task | Description | Status | Notes |
|---|---|---|---|
| 1.1 | Parameter setup for IS-LM | β | All parameters correctly defined |
| 1.2 | IS-LM system definition | β | Correct formulation: [Y - ...; k*Y - lambda*i - MP] |
| 1.3 | Solve from two initial guesses | β | Critical Error: Only provides ONE initial guess (x_0=[1000;10]) instead of two |
| 1.4 | Plot IS and LM curves | β | Creates proper IS-LM plot with curves |
| 1.5 | Verify positive interest rate | β οΈ | Finds one equilibrium but doesnβt explicitly search for two or verify both |
| 2.1 | Parameter setup for labor supply | β | All parameters correctly defined (A instead of a, but functionally equivalent) |
| 2.2 | Define Z(h) function | β οΈ | Unusual formulation using vector input [h; sigma] - works but unconventional |
| 2.3 | Loop over sigma values | β | Correctly loops over sigma β {1,2,3,4,5} |
| 2.4 | Solve using Bisection method | β | Critical Error: Does not update function values at endpoints (line 88: elseif Z([a;sigma])*Z([c;sigma]) re-evaluates Z([a;sigma]) instead of storing fa) |
| 2.5 | Plot h*(sigma) and interpret | β οΈ | Creates plot of Z(h) for different sigma values (not the required h* vs sigma plot). β Handles corner solutions by manually setting h_star(3:5)=1 when no interior root exists |
| 3.1 | Implement Bisection method | β | Same critical bisection error (line 161: re-evaluates Z([a;Sigma])) |
| 3.2 | Implement Damped Newton method | β | Implements damped Newton with alpha=0.5, analytical derivative, derivative check, and bounds protection |
| 3.3 | Test from multiple starting guesses | β | Tests from three guesses (0.2, 0.5, 0.8) |
| 3.4 | Record iterations and residuals | β | Records and displays all iterations and residuals in table format |
| 3.5 | Compare and discuss convergence | β | Provides discussion comparing bisection vs Newton convergence |
π Technical Implementation
- IS-LM System: Correct formulation but only uses one initial guess
- Labor Supply Function: Unusual formulation with vector input
[h; sigma]- unconventional but works - Bisection Method: β Critical error - does not update function values at endpoints, causing wrong root convergence (same error as Pablo Romanella, Michele Nascia, Chiara Tombolini)
- Corner Solutions: β Good - Recognizes that for sigmaβ₯3 no interior solution exists and sets h*=1 manually with economic interpretation (βmarginal benefit > marginal costβ)
- Damped Newton: Correct implementation with alpha=0.5, analytical derivative, derivative check, and finite value checks
- Error Handling: Includes derivative check and finite value checks for Newton method
- Figure Management: β Saves figures properly in separate figures folder
- Advanced Features: Includes proper derivative safeguards, convergence tracking in table format, and economic analysis of corner solutions
π¬ Style & Clarity
- Code Quality: Excellent organization with separate code and figures folders
- Variable Naming: Clear names (
h_star,sigmas,x_star) - Comments: Good economic interpretation and discussion
- Output: Uses
dispandfprintfappropriately with table display - Organization: Excellent - separates code into parts with clear structure
- Documentation: Includes economic interpretation of results
π Visual Output Assessment
Figure 1: IS-LM Equilibrium β
- Layout: Plot with IS and LM curves
- Features: Shows both curves
- Styling: Appropriate styling with proper labels and legend
- Saving: β Saves in separate figures folder
- Issue: Only one equilibrium point (missing second guess)
Figure 2: Z(h) for Different Sigma Values β οΈ
- Layout: Plot showing Z(h) vs h for different sigma values
- Features: Shows Z functions for sigma β {1,2,3,4,5}
- Styling: Appropriate styling with proper labels
- Saving: β Saves in separate figures folder
- Issue: Not the required plot - should plot h*(sigma) vs sigma, not Z(h) vs h
β Suggestions for Improvement
- CRITICAL: Exercise 1 - provide TWO initial guesses as required
- CRITICAL: Fix bisection in Exercises 2 and 3 - must update function values when updating brackets:
fa = Z([a; sigma]); fb = Z([b; sigma]); if fa * fc < 0 b = c; fb = fc; % Update function value else a = c; fa = fc; % Update function value end - CRITICAL: Exercise 2 - plot h*(sigma) vs sigma, not Z(h) vs h
- Important: Verify both equilibria in Exercise 1 (positive and negative interest rate)
- Style: Consider defining Z function more conventionally with sigma as parameter rather than vector input
π― Summary
Submission with critical numerical errors. The student demonstrates understanding of numerical methods and implements all three exercises with excellent organization (separate code and figures folders). Exercise 1 IS-LM uses only one initial guess instead of two. Exercise 2 has the critical bisection error of not updating function values at endpoints (same error as Pablo, Michele, Chiara), and the plot shows Z(h) vs h instead of h*(sigma) vs sigma. Exercise 3 has the same bisection error but damped Newton is correctly implemented. The code structure is appropriate with proper figure management and table outputs for Exercise 3.
Grade Level: β More than 50% Correct (10/15 tasks fully correct, 2/15 partially correct, 3/15 incorrect)