🌍 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 disp and fprintf appropriately 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

  1. CRITICAL: Exercise 1 - provide TWO initial guesses as required
  2. 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
    
  3. CRITICAL: Exercise 2 - plot h*(sigma) vs sigma, not Z(h) vs h
  4. Important: Verify both equilibria in Exercise 1 (positive and negative interest rate)
  5. 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)