Week 5 Homework - Common Errors Summary
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:
- Implement bisection method for fixed sigma=2
- Implement damped Newton method (alpha=0.5)
- Test from multiple starting guesses (0.2, 0.5, 0.8)
- Record iterations and residuals
- Compare and discuss convergence speed
Frequency: Affected 2-3 students
π‘ Error #7: Incorrect Plot Requirements
Error Examples:
- 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)
- Should plot:
- Plotting convergence paths instead of IS-LM curves
- Should show: IS and LM curves with equilibrium
- NOT: Iteration convergence paths
- 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:
- Properly updating function values: Many students correctly implemented
fa = fc,fb = fcin bisection - Robust implementations: Some students included analytical Jacobians and derivative checks
- Correct bisection logic: Several students properly updated function values at endpoints
- Proper function value updates: Correct handling of sign-change detection
- 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 == 0means 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()orexportgraphics() - 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
- Emphasize bisection algorithm details - Function value storage and update
- Provide more examples of correct vs incorrect bisection implementations
- Highlight common pitfalls during lectures
- Include skeleton code with function value storage templates
- Encourage peer review of bisection logic before submission