Skip to content

Commit 285b3fe

Browse files
blkboxeconomistcc7768jstacclaude
authored
BUG: Fix Samuelson quadratic formula (#1066)
* Fix sign error in by-hand characteristic roots The polynomial is z^2 - ρ1 z - ρ2 = 0, so the roots are (ρ1 ± sqrt(ρ1^2 + 4 ρ2)) / 2. The by-hand formula in y_nonstochastic used -ρ1 in every branch. * Align class docstring with the lecture's recurrence The Samuelson class and analyze_roots use ρ1 = α+β, ρ2 = -β from I_t = β(Y_{t-1} - Y_{t-2}). The docstring still had the 1939 consumption-accelerator form α(1+β), -αβ. * Make Samuelson docstring raw and include the shock term The non-raw docstring turned \a and \b in \alpha and \beta into control characters. Also add the sigma epsilon_t term, since the class supports a stochastic model. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Chase Coleman <[email protected]> Co-authored-by: John Stachurski <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 4f8bcd6 commit 285b3fe

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎lectures/samuelson.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -684,17 +684,17 @@ def y_nonstochastic(y_0=100, y_1=80, α=0.92, β=0.5, γ=10, n=80):
684684
discriminant = ρ1**2 + 4 * ρ2
685685
686686
if discriminant == 0:
687-
roots.append(-ρ1 / 2)
687+
roots.append(ρ1 / 2)
688688
print("Single real root: ")
689689
print("".join(f"{r:.2f}" for r in roots))
690690
elif discriminant > 0:
691-
roots.append((-ρ1 + sqrt(discriminant).real) / 2)
692-
roots.append((-ρ1 - sqrt(discriminant).real) / 2)
691+
roots.append((ρ1 + sqrt(discriminant).real) / 2)
692+
roots.append((ρ1 - sqrt(discriminant).real) / 2)
693693
print("Two real roots: ")
694694
print(" ".join(f"{r:.2f}" for r in roots))
695695
else:
696-
roots.append((-ρ1 + sqrt(discriminant)) / 2)
697-
roots.append((-ρ1 - sqrt(discriminant)) / 2)
696+
roots.append((ρ1 + sqrt(discriminant)) / 2)
697+
roots.append((ρ1 - sqrt(discriminant)) / 2)
698698
print("Two complex roots: ")
699699
print(" ".join(f"{r.real:.2f}{r.imag:+.2f}j" for r in roots))
700700
@@ -965,7 +965,7 @@ for the Samuelson model
965965

966966
```{code-cell} ipython3
967967
class Samuelson:
968-
"""
968+
r"""
969969
This class represents the Samuelson model, otherwise known as the
970970
multiplier-accelerator model.
971971
The model combines the Keynesian multiplier
@@ -976,7 +976,7 @@ class Samuelson:
976976
977977
.. math::
978978
979-
Y_t = \alpha (1 + \beta) Y_{t-1} - \alpha \beta Y_{t-2}
979+
Y_t = (\alpha + \beta) Y_{t-1} - \beta Y_{t-2} + (\gamma + G_t) + \sigma \epsilon_t
980980
981981
Parameters
982982
----------

0 commit comments

Comments
 (0)