π Week 5 Homework β Feedback
π Week 5 Homework β Feedback
Student: Alice Ciavatta
Assignment: Solving Nonlinear Equations in Economics
β Overall Assessment
Result: β More than 50% Correct
Good submission implementing all three exercises correctly. Exercise 1 IS-LM is properly solved with two initial guesses and correct verification of positive interest branch. Exercise 2 bisection is correctly implemented with appropriate handling of corner solutions. Exercise 3 comparison is correct with proper bisection and damped Newton methods. However, figures are not properly saved (only .fig files exist instead of PNG files), and thereβs an issue with the bisection sign change logic.
π 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, M_over_P, k, lambda) |
| 1.2 | IS-LM system definition | β | Correct formulation |
| 1.3 | Solve from two initial guesses | β | Two guesses provided (x0_pos=[850;1], x0_neg=[600;-5]) |
| 1.4 | Plot IS and LM curves | β οΈ | Creates plot but figures not saved as PNG (only .fig files exist) |
| 1.5 | Verify positive interest rate | β | Verifies positive interest rate with assert statement |
| 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 with proper consumption function |
| 2.3 | Loop over sigma values | β | Correctly loops over sigma β {1,2,3,4,5} |
| 2.4 | Solve using Bisection method | β | Critical Error: Uses fa*fm <= 0 instead of fa*fm < 0. This causes convergence to wrong root when fm=0 exactly |
| 2.5 | Plot h*(sigma) and interpret | β οΈ | Creates plot but figures not saved as PNG |
| 3.1 | Implement Bisection method | β | Correct bisection implementation |
| 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 in table |
| 3.5 | Compare and discuss convergence | β οΈ | No explicit discussion provided |
π Technical Implementation
- IS-LM System: Correct implementation with two initial guesses and proper verification
- Labor Supply Function: Correct mathematical formulation
- Bisection Method: Correct implementation but uses
<= 0instead of< 0for sign change - Corner Solutions: β
Excellent - Explicitly handles corner solutions (h*=1) when no interior root exists, with
isCornerflag to track which sigma values have corners - Damped Newton: Correct implementation with alpha=0.5 and analytical derivative
- Error Handling: Includes projection to keep h in (0,1) bounds, plus sophisticated corner detection
- Figure Management: β Only saves .fig files, should save PNG files using
saveas()orexportgraphics() - Advanced Features: Includes proper comparison table, bounds checking, and systematic corner solution tracking
π¬ Style & Clarity
- Code Quality: Good structure with clear separation into exercises
- Variable Naming: Clear names (
hstar,sigmas,isCorner) - Comments: Minimal but appropriate comments
- Output: Good use of
fprintfwith formatted tables - Organization: Clear separation into three exercises
- Documentation: Includes sophisticated handling of corner solutions with tracking flags
π Visual Output Assessment
CRITICAL ISSUE: Figures not properly saved
Figure 1: IS-LM Equilibrium β οΈ
- Layout: Plot with IS and LM curves and equilibrium point
- Features: Correctly identifies equilibrium and verifies positive interest rate
- Styling: Appropriate styling
- Saving: β Only saves as .fig file, no PNG saved
- Issue: Figures must be saved as PNG files for submission
Figure 2: Labor Supply h*(Ο) β οΈ
- Layout: Plot showing h* vs sigma
- Features: Shows labor supply for different risk aversion parameters
- Styling: Appropriate styling with proper labels
- Saving: β Only saves as .fig file, no PNG saved
- Issue: Your submitted .fig files look incorrect
β Suggestions for Improvement
- Critical: Add
saveas()commands to save all figures as PNG files (currently only .fig files exist) - Critical: Consider using
exportgraphics()for higher resolution - Critical: Fix bisection sign change logic - must use
< 0instead of<= 0to avoid convergence to wrong root - Style: Add more detailed discussion of convergence comparison in Exercise 3
- Verification: Check that the .fig files are displaying correctly
π― Summary
Good submission with correct implementations but critical bisection error and figure saving issues. The student demonstrates understanding of numerical methods and implements all three exercises. Exercise 1 is properly solved with two initial guesses and verification, Exercise 2 has a critical bisection sign change error (<= 0 instead of < 0), and Exercise 3 demonstrates proper comparison between methods. Critical issues: (1) bisection uses fa*fm <= 0 instead of < 0 which can cause convergence to wrong root, and (2) figures are not properly saved as PNG files (only .fig files exist).
Grade Level: β More than 50% Correct (12/15 tasks fully correct, 2/15 incorrect, 1/15 partially correct)