π Week 5 Homework β Feedback
π 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
fprintfto 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
- 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 - Critical: Check Exercise 1 results - both equilibria appear incorrect
- Important: Add sign change verification before starting bisection
- Style: Remove redundant function definitions (Z(h) defined outside and inside loop in Exercise 2)
- 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)