🌍 Week 5 Homework β€” Feedback

Student: Pablo Romanella
Assignment: Solving Nonlinear Equations in Economics


βœ… Overall Assessment

Result: βœ… More than 50% Correct

Submission implements all three exercises. Exercise 1 IS-LM is solved with two initial guesses, but both figures show wrong results (as you noted). Exercise 2 bisection has a critical numerical error: the method does not update function values (fa, fb) after updating brackets, causing convergence to the wrong root. Exercise 3 demonstrates the same bisection error. The code structure is clear but the results are incorrect.


πŸ” 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
1.3 Solve from two initial guesses βœ… Two guesses provided (z1=[900;7], z2=[500;1])
1.4 Plot IS and LM curves ❌ Creates IS-LM plot but shows wrong results (you noted β€œFigure 1 wrong”)
1.5 Verify positive interest rate ❌ Both figures show wrong results
2.1 Parameter setup for labor supply βœ… All parameters correctly defined
2.2 Define Z(h) function ⚠️ Function defined outside loop but redefined inside loop (inefficient)
2.3 Loop over sigma values βœ… Correctly loops over sigma ∈ {1,2,3,4,5}
2.4 Solve using Bisection method ❌ Critical Error: Bisection does not update function values at endpoints (fa/fb), causing wrong root convergence. Code updates p_a/p_b but not function values at endpoints.
2.5 Plot h*(sigma) and interpret ❌ Creates plot but shows wrong results (you noted β€œFigure 2 wrong”) - caused by bisection error
3.1 Implement Bisection method ❌ Same critical bisection error - does not update Z(a_h)/Z(b_h) values
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)
3.4 Record iterations and residuals βœ… Records and displays all iterations and residuals
3.5 Compare and discuss convergence ⚠️ Provides output table but no explicit discussion comparing methods

πŸ“ˆ Technical Implementation

  • IS-LM System: Correct formulation with two initial guesses
  • Labor Supply Function: Correct mathematical formulation (though defined twice)
  • Bisection Method: ❌ Critical error - does not update function values at endpoints, causing wrong root convergence
  • Damped Newton: Correct implementation with alpha=0.5 and analytical derivative
  • Error Handling: No sign change verification
  • Figure Management: Saves figures as PNG and .fig files
  • Advanced Features: Includes bounds projection for Newton method

πŸ’¬ Style & Clarity

  • Code Quality: Clear structure with good organization
  • Variable Naming: Clear names (h_star, sigma_v, zstar1, zstar2)
  • Comments: Minimal comments
  • Output: Appropriate use of fprintf to display results
  • Organization: Clear separation into three exercises

πŸ“Š Visual Output Assessment

Figure 1: IS-LM Equilibrium ❌

  • Layout: Plot with IS and LM curves and equilibrium points
  • Features: Attempts to identify equilibria from both guesses
  • Styling: Appropriate styling with proper labels and legend
  • Saving: βœ… Saves as PNG and .fig files
  • Issue: Your note: β€œBoth figures show wrong results” - Figure 1 shows incorrect equilibrium points

Figure 2: Labor Supply h*(Οƒ) ❌

  • Layout: Plot showing h* vs sigma values
  • Features: Shows labor supply for different risk aversion parameters
  • Styling: Appropriate styling with proper labels
  • Saving: βœ… Saves as PNG and .fig files
  • Issue: Your note: β€œFigure 2 wrong” - the plot shows incorrect results due to bisection error

βœ… Suggestions for Improvement

  1. Critical: Fix bisection in Exercises 2 and 3 - must update function values when updating brackets:
    fa = Z(a); fb = Z(b);
    if fa * fm < 0
        b = m; fb = fm;  % Update function value
    else
        a = m; fa = fm;  % Update function value
    end
    
  2. Critical: Check Exercise 1 results - both equilibria appear incorrect
  3. Important: Add sign change verification before starting bisection
  4. Style: Remove redundant function definitions (Z(h) defined outside and inside loop in Exercise 2)
  5. Documentation: Add more detailed comments explaining the methodology

🎯 Summary

Submission with critical bisection error affecting results. The student demonstrates understanding of numerical methods and implements all three exercises. Exercise 1 solves with two initial guesses but shows incorrect equilibrium points (as you noted, both figures are wrong). Exercise 2 and 3 bisection implementations have the critical error of not updating function values (fa, fb) when updating brackets, causing convergence to wrong roots. Exercise 3 damped Newton is correctly implemented. The code structure is appropriate but results are incorrect.

Grade Level: βœ… More than 50% Correct (9/15 tasks fully correct, 1/15 partially correct, 5/15 incorrect)