Week 5 Homework - Common Errors Summary

Document Date: Week 5 Homework Assessment
Purpose: Summary of recurring mistakes to present to students in class


πŸ“Š Overall Statistics

  • Total students assessed: 21
  • Passing (β‰₯50%): 17 students
  • Partial (<50%): 4 students
  • Major error frequency: Bisection sign-change logic error affected 7+ students

πŸ”΄ Critical Error #1: Bisection Method - Not Updating Function Values

Error Description:

Many students re-evaluated Z(a) at each iteration instead of storing and updating the function value.

Wrong Implementation:

for t = 1:maxit
    c = (a + b)/2;
    if abs(Z(c)) < tol, break; end
    if Z(a)*Z(c) < 0    % ❌ WRONG: Re-evaluates Z(a) each time!
        b = c;
    else
        a = c;
    end
end

Correct Implementation:

fa = Z(a); fb = Z(b);   % Store initial values
for t = 1:maxit
    c = (a + b)/2;
    fc = Z(c);
    if abs(fc) < tol, break; end
    if fa * fc < 0
        b = c; fb = fc;  % βœ… Update function value
    else
        a = c; fa = fc;  % βœ… Update function value
    end
end

Why This Is Critical:

  • Causes convergence to wrong root
  • Results look incorrect in plots
  • Fundamental numerical analysis error
  • Frequency: Affected 7+ students (most common critical error)

🟑 Error #2: Incorrect Sign-Change Logic

Error Description:

Using <= 0 instead of < 0 in bisection sign-change detection.

Wrong:

if fa * fc <= 0    % ❌ WRONG
    b = c;
else
    a = c;
end

Correct:

if fa * fc < 0     % βœ… CORRECT
    b = c;
else
    a = c;
end

Why This Matters:

  • When fa * fc == 0, both endpoints have same sign or one is exactly zero
  • Should be treated as β€œno sign change” in the left subinterval
  • Causes convergence issues

Frequency: Affected 2-3 students


🟠 Error #3: Only One Initial Guess

Error Description:

Providing only one initial guess for IS-LM Exercise 1 instead of two.

Required:

x0_1 = [800; 1];   % First guess
x0_2 = [500; -1];  % Second guess
sol1 = fsolve(F, x0_1);
sol2 = fsolve(F, x0_2);

Why This Is Important:

  • Nonlinear IS-LM has multiple equilibria
  • Need to find both (or verify uniqueness)
  • Demonstrates understanding of multiple solutions

Frequency: Affected 2-3 students


🟠 Error #4: Wrong Model Implementation

Error Description:

Implementing different economic models than required.

Examples:

  • Completely different IS-LM formulation (not the required quadratic investment model)
  • Wrong system formulation with incorrect signs or equations

Why This Is Critical:

  • Not implementing the assigned problem
  • Shows lack of attention to requirements
  • Cannot assess understanding of correct model

Frequency: Affected 2 students


🟠 Error #5: Using Built-in Functions Instead of Manual Implementation

Error Description:

Using fzero or similar instead of implementing manual bisection.

Wrong:

h_star = fzero(Z, [a, b]);  % Uses MATLAB's fzero

Required:

% Implement manual bisection with updates as shown above

Why This Matters:

  • Assignment requires demonstrating understanding of bisection algorithm
  • Need to show manual implementation with proper logic
  • Cannot assess if student understands the method

Frequency: Affected 1-2 students


🟑 Error #6: Missing Exercise 3

Error Description:

Exercise 3 incomplete or missing.

Required Elements:

  1. Implement bisection method for fixed sigma=2
  2. Implement damped Newton method (alpha=0.5)
  3. Test from multiple starting guesses (0.2, 0.5, 0.8)
  4. Record iterations and residuals
  5. Compare and discuss convergence speed

Frequency: Affected 2-3 students


🟑 Error #7: Incorrect Plot Requirements

Error Examples:

  1. Plotting Z(h) vs h instead of h*(sigma) vs sigma
    • Should plot: plot(sigma_values, h_star, 'o-')
    • NOT: plot(h_values, Z_values)
  2. Plotting convergence paths instead of IS-LM curves
    • Should show: IS and LM curves with equilibrium
    • NOT: Iteration convergence paths
  3. Plotting wrong relationships
    • Example: Plotting h* vs tau instead of h* vs sigma

Frequency: Affected 2-3 students


🟑 Error #8: Missing Figure Saving

Error Description:

Creating plots but not saving them with saveas() or exportgraphics().

Correct Approach:

figure;
plot(...);
xlabel('...'); ylabel('...'); title('...');
grid on;
saveas(gcf, 'filename.png');           % PNG format
saveas(gcf, 'filename.fig');           % MATLAB figure
% OR
exportgraphics(gcf, 'filename.png', 'Resolution', 300);  % Higher quality

Frequency: Affected 1-2 students


πŸ“ Good Practices Observed

βœ… Excellent Implementations:

  1. Properly updating function values: Many students correctly implemented fa = fc, fb = fc in bisection
  2. Robust implementations: Some students included analytical Jacobians and derivative checks
  3. Correct bisection logic: Several students properly updated function values at endpoints
  4. Proper function value updates: Correct handling of sign-change detection
  5. Figure management: Most students saved figures properly

βœ… Strong Code Organization:

  • Separate functions for bisection/Newton (observed in multiple submissions)
  • Good documentation and comments
  • Proper error handling (sign change checks, derivative checks)
  • Table outputs for comparison

βœ… Good Mathematical Understanding:

  • Proper interpretation of corner solutions (sigma > 2)
  • Understanding of multiple equilibria in IS-LM
  • Discussion of convergence speed differences
  • Manual Newton implementation demonstrating algorithm understanding

🎯 Key Teaching Points for Class Discussion

1. Bisection Algorithm Fundamentals

  • Must store and update function values at endpoints
  • Do NOT re-evaluate Z(a) each iteration
  • This is a fundamental numerical analysis principle

2. Sign-Change Logic

  • Use < 0, not <= 0
  • Edge case: fa * fc == 0 means no sign change in left subinterval

3. Multiple Solutions in Nonlinear Systems

  • Always provide multiple initial guesses
  • Verify which solution is economically meaningful
  • IS-LM typically has two equilibria

4. Read Requirements Carefully

  • Implement the exact model specified
  • Follow the exact plotting requirements
  • Complete all exercises, not just some

5. Figure Management

  • Always save figures with saveas() or exportgraphics()
  • Save in both PNG and .fig formats
  • Verify figures are correct before submission

πŸ“ˆ Grade Distribution Summary

  • βœ… More than 50% Correct: 17 students
  • ⚠️ Partial <50% Correct: 4 students
  • ❌ Incorrect/Incomplete: 0 students (though some submissions were missing)

Most common grade: βœ… (Passing)

Key takeaway: Most students demonstrated solid understanding of numerical methods, with the bisection function-value update error being the most common critical issue affecting results. Overall performance was strong, with 81% of students passing the homework.


πŸ’‘ Recommendations for Future Classes

  1. Emphasize bisection algorithm details - Function value storage and update
  2. Provide more examples of correct vs incorrect bisection implementations
  3. Highlight common pitfalls during lectures
  4. Include skeleton code with function value storage templates
  5. Encourage peer review of bisection logic before submission