🌍 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 fprintf to 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

  1. CRITICAL: Fix Exercise 2 bracket to [0,1] instead of [0,2]. Hours worked h must be between 0 and 1.
  2. CRITICAL: Fix Exercise 3 - set sigma=2 and compare bisection vs Newton methods, don’t loop over sigma again.
  3. Important: Add projection to keep h in [0,1] in the Newton method implementation
  4. Important: Display residuals Z(h*) in Exercise 3 for completeness
  5. Style: Consider using exportgraphics() instead of saveas() for better quality (optional)
  6. 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)