π Week 5 Homework β Feedback
π Week 5 Homework β Feedback
Student: Davide Magnini
Assignment: Solving Nonlinear Equations in Economics
β Overall Assessment
Result: β More than 50% Correct
The student demonstrates good effort and code organization, implementing both bisection and Newton methods with proper figure saving. The IS-LM implementation is correct and figures are properly saved. However, there are critical errors: (1) Exercise 2 shows incorrect results - h* values exceed 1.0 (ranging from 1.18 to 1.25), which is economically impossible since h represents hours worked and must be in [0,1], and (2) Exercise 3 is incomplete - the student loops over sigma values again instead of fixing sigma=2 and comparing methods. The student needs to fix the bracket bounds and restructure Exercise 3.
π Task-by-Task Check
| Task | Description | Status | Notes | Β | Β |
|---|---|---|---|---|---|
| 1.1 | Parameter setup for IS-LM | β | All parameters correctly defined (C0, c, I0, beta, T, G, MP, k, landa) | Β | Β |
| 1.2 | IS-LM system definition | β | Correct formulation: [Y-C0-c*(Y-T)-I0+beta*i^2-G; MP-k*Y+landa*i] |
Β | Β |
| 1.3 | Solve from two initial guesses | β | Two guesses provided (x0=[850;1.25], x0_bis=[840;1]) with good reasoning | Β | Β |
| 1.4 | Plot IS and LM curves | β | Creates proper IS-LM plot with curves and equilibrium point marked | Β | Β |
| 1.5 | Verify positive interest rate | β | Finds equilibrium with positive interest rate (iβ1.05) | Β | Β |
| 2.1 | Parameter setup for labor supply | β | All parameters correctly defined (w, tau, a, g, phi, chi) | Β | Β |
| 2.2 | Define Z(h) function | β | Correct formulation: c(h)^(-sigma)*(1-tau)*w - chi*(1-h)^phi |
Β | Β |
| 2.3 | Loop over sigma values | β | Correctly loops over sigma β {1,2,3,4,5} | Β | Β |
| 2.4 | Solve using Bisection method | β | Critical Error: Uses wrong bracket [0,2] instead of [0,1]. Results show h*>1.0 which is impossible. | Β | Β |
| 2.5 | Plot h*(sigma) | β οΈ | Creates plot but shows incorrect results (h* ranging from 1.18 to 1.25, exceeding 1.0) | Β | Β |
| 3.1 | Implement Bisection method | β οΈ | Implements bisection but loops over sigma again instead of fixing sigma=2 | Β | Β |
| 3.2 | Implement Damped Newton method | β | Implements damped Newton with alpha=0.5 and analytical derivative | Β | Β |
| 3.3 | Test from multiple starting guesses | β | Tests from three guesses (0.2, 0.5, 0.8) as required | Β | Β |
| 3.4 | Record iterations and residuals | β οΈ | Records iterations but doesnβt display residuals | Z(h*) | Β |
| 3.5 | Compare and discuss convergence | β | Provides discussion comparing bisection vs Newton convergence | Β | Β |
π Technical Implementation
- IS-LM Approach: Correct implementation using
fsolve()with proper system formulation - Code Structure: Clean organization with clear sections and good comments
- Numerical Methods: Both bisection and damped Newton correctly implemented
- Analytical Derivatives: Uses analytical derivative for Newton method (correct formulation)
- Constraints: Missing proper bounds checking - h should be constrained to [0,1]
- Figure Management: β
Uses
saveas()to save figures properly - Advanced Features: Includes convergence tracking and proper bounds checking for Newton
- Critical Issue: Exercise 2 uses bracket [0,2] instead of [0,1], resulting in h*>1.0 which is economically impossible
- Critical Issue: Exercise 3 loops over sigma again instead of fixing sigma=2 and comparing methods
π¬ Style & Clarity
- Code Quality: Clean and well-structured with clear section headers
- Variable Naming: Logical names (
roots_h,sigma_values,h_initial) - Comments: Good comments explaining the methodology and economic interpretation
- Output: Appropriate use of
fprintfto display results clearly - Organization: Clear separation into three exercises with proper headers
- Documentation: Includes economic interpretation and discussion of results
- Advanced: Includes discussion of when Newton outperforms bisection
π Visual Output Assessment
Good job saving figures!
Figure 1: IS-LM Equilibrium β
- Layout: Single plot with IS and LM curves
- Features: Marks equilibrium point correctly
- Styling: Good styling with proper labels and legend
- Saving: β
Correct: Uses
saveas()to save figure - Issue: None significant
Figure 2: Labor Supply vs Risk Aversion β
- Layout: Single plot showing h* vs sigma
- Features: Visualization shows incorrect results (h* exceeding 1.0)
- Styling: Good styling with proper labels
- Saving: β
Correct: Uses
saveas()to save figure - Issue: CRITICAL: Shows h* ranging from 1.18 to 1.25, which exceeds 1.0. This is economically impossible since h represents hours worked and must be in [0,1]. The bracket [0,2] is wrong.
β Suggestions for Improvement
- CRITICAL: Fix Exercise 2 bracket to [0,1] instead of [0,2]. Hours worked h must be between 0 and 1.
- CRITICAL: Fix Exercise 3 - set sigma=2 and compare bisection vs Newton methods, donβt loop over sigma again.
- Important: Add projection to keep h in [0,1] in the Newton method implementation
-
Important: Display residuals Z(h*) in Exercise 3 for completeness - Style: Consider using
exportgraphics()instead ofsaveas()for better quality (optional) - Verification: Always check that results are economically reasonable (e.g., h in [0,1])
π― Summary
Good effort with critical errors. The student demonstrates solid understanding of numerical methods and implements both bisection and damped Newton correctly. The IS-LM implementation is correct and figures are properly saved. However, there are critical issues: (1) Exercise 2 uses wrong bracket [0,2] resulting in h*>1.0 which is economically impossible, and (2) Exercise 3 is incomplete - loops over sigma again instead of fixing sigma=2 and comparing methods. The student needs to fix the bracket bounds and restructure Exercise 3 to properly compare convergence speed.
Grade Level: β More than 50% Correct (10/15 tasks fully correct, 3/15 partially correct, 2/15 incorrect)