@@ -17,19 +17,17 @@ kernelspec:
17
17
## Introduction
18
18
19
19
20
- This lecture can be viewed as a sequel to {doc}` eigen_I `
20
+ This lecture can be viewed as a sequel to {doc}` eigen_I ` .
21
21
22
22
It provides an example of how eigenvectors isolate * invariant subspaces* that help construct and analyze solutions of linear difference equations.
23
23
24
24
When vector $x_t$ starts in an invariant subspace, iterating the different equation keeps $x_ {t+j}$
25
25
in that subspace for all $j \geq 1$.
26
26
27
- Invariant subspace methods are used throughout applied economic dynamics, for example, in the lecture {doc}` money_inflation `
27
+ Invariant subspace methods are used throughout applied economic dynamics, for example, in the lecture {doc}` money_inflation ` .
28
28
29
29
Our approach here is to illustrate the method with an ancient example, one that ancient Greek mathematicians used to compute square roots of positive integers.
30
30
31
- In this lecture we assume that we have yet
32
-
33
31
## Perfect squares and irrational numbers
34
32
35
33
An integer is called a ** perfect square** if its square root is also an integer.
@@ -46,11 +44,11 @@ The ancient Greeks invented an algorithm to compute square roots of integers, in
46
44
47
45
Their method involved
48
46
49
- * computing a particular sequence of integers $\{ y_t\} _ {t=0}^\infty$
47
+ * computing a particular sequence of integers $\{ y_t\} _ {t=0}^\infty$;
50
48
51
- * computing $\lim_ {t \rightarrow \infty} \left(\frac{y_ {t+1}}{y_t}\right) = \bar r$
49
+ * computing $\lim_ {t \rightarrow \infty} \left(\frac{y_ {t+1}}{y_t}\right) = \bar r$;
52
50
53
- * deducing the desired square root from $\bar r$
51
+ * deducing the desired square root from $\bar r$.
54
52
55
53
In this lecture, we'll describe this method.
56
54
@@ -90,7 +88,7 @@ equation {eq}`eq:2diff1` for each $t \geq 0$.
90
88
We seek an expression for $y_t, t \geq 0$ as functions of the initial conditions $(y_{-1}, y_{-2})$:
91
89
92
90
$$
93
- y_t = g((y_ {-1}, y_ {-2});t), \quad t \geq 0
91
+ y_t = g((y_ {-1}, y_ {-2});t), \quad t \geq 0.
94
92
$$ (eq:2diff2)
95
93
96
94
We call such a function $g$ a *solution* of the difference equation {eq}`eq:2diff1`.
@@ -110,7 +108,7 @@ For initial condition that satisfy {eq}`eq:2diff3`
110
108
equation {eq}`eq:2diff1` impllies that
111
109
112
110
$$
113
- y_0 = \left(a_1 + \frac{a_2}{\delta}\right) y_ {-1}
111
+ y_0 = \left(a_1 + \frac{a_2}{\delta}\right) y_ {-1}.
114
112
$$ (eq:2diff4)
115
113
116
114
We want
@@ -122,13 +120,13 @@ $$ (eq:2diff5)
122
120
which we can rewrite as the *characteristic equation*
123
121
124
122
$$
125
- \delta^2 - a_1 \delta - a_2 = 0
123
+ \delta^2 - a_1 \delta - a_2 = 0.
126
124
$$ (eq:2diff6)
127
125
128
126
Applying the quadratic formula to solve for the roots of {eq}`eq:2diff6` we find that
129
127
130
128
$$
131
- \delta = \frac{ a_1 \pm \sqrt{a_1^2 + 4 a_2}}{2}
129
+ \delta = \frac{ a_1 \pm \sqrt{a_1^2 + 4 a_2}}{2}.
132
130
$$ (eq:2diff7)
133
131
134
132
For either of the two $\delta$'s that satisfy equation {eq}`eq:2diff7`,
@@ -177,9 +175,9 @@ We'll turn to that after we describe how Ancient Greeks figured out how to compu
177
175
178
176
## Algorithm of the Ancient Greeks
179
177
180
- Let $\sigma$ be a positive integer greater than $1$
178
+ Let $\sigma$ be a positive integer greater than $1$.
181
179
182
- So $\sigma \in {\mathcal I} \equiv \{2, 3, \ldots \}$
180
+ So $\sigma \in {\mathcal I} \equiv \{2, 3, \ldots \}$.
183
181
184
182
We want an algorithm to compute the square root of $\sigma \in {\mathcal I}$.
185
183
195
193
y_ {t} = 2 y_ {t-1} - (1 - \sigma) y_ {t-2}, \quad t \geq 0
196
194
$$ (eq:second_order)
197
195
198
- together with a pair of integers that are initial conditions for $y_{-1}, y_{-2}$.
199
-
200
- First, we'll deploy some techniques for solving the difference equations that are also deployed in {doc}`dynam:samuelson`
201
-
196
+ together with a pair of integers that are initial conditions for $y_{-1}, y_{-2}$.
202
197
198
+ First, we'll deploy some techniques for solving the difference equations that are also deployed in {doc}`dynam:samuelson`.
203
199
204
200
The characteristic equation associated with difference equation {eq}`eq:second_order` is
205
201
206
202
$$
207
203
c(x) \equiv x^2 - 2 x + (1 - \sigma) = 0
208
204
$$ (eq:cha_eq0)
209
205
210
-
211
-
212
206
(Notice how this is an instance of equation {eq}`eq:2diff6` above.)
213
207
214
208
Factoring the right side of equation {eq}`eq:cha_eq0`, we obtain
@@ -233,11 +227,11 @@ By applying the quadratic formula to solve for the roots the characteristic equ
233
227
{eq}`eq:cha_eq0`, we find that
234
228
235
229
$$
236
- \lambda_1 = 1 + \sqrt{\sigma}, \quad \lambda_2 = 1 - \sqrt{\sigma}
230
+ \lambda_1 = 1 + \sqrt{\sigma}, \quad \lambda_2 = 1 - \sqrt{\sigma}.
237
231
$$ (eq:secretweapon)
238
232
239
233
Formulas {eq}`eq:secretweapon` indicate that $\lambda_1$ and $\lambda_2$ are each functions
240
- of a single variable, namely, $\sqrt{\sigma}$, the object that we along with some Ancient Greeks want to compute.
234
+ of a single variable, namely, $\sqrt{\sigma}$, the object that we along with some Ancient Greeks want to compute.
241
235
242
236
Ancient Greeks had an indirect way of exploiting this fact to compute square roots of a positive integer.
243
237
@@ -265,13 +259,13 @@ Since $\lambda_1 = 1 + \sqrt{\sigma} > 1 > \lambda_2 = 1 - \sqrt{\sigma} $,
265
259
it follows that for *almost all* (but not all) initial conditions
266
260
267
261
$$
268
- \lim_ {t \rightarrow \infty} \left(\frac{y_ {t+1}}{y_t}\right) = 1 + \sqrt{\sigma}
262
+ \lim_ {t \rightarrow \infty} \left(\frac{y_ {t+1}}{y_t}\right) = 1 + \sqrt{\sigma}.
269
263
$$
270
264
271
265
Thus,
272
266
273
267
$$
274
- \sqrt{\sigma} = \lim_ {t \rightarrow \infty} \left(\frac{y_ {t+1}}{y_t}\right) - 1
268
+ \sqrt{\sigma} = \lim_ {t \rightarrow \infty} \left(\frac{y_ {t+1}}{y_t}\right) - 1.
275
269
$$
276
270
277
271
However, notice that if $\eta_1 = 0$, then
283
277
so that
284
278
285
279
$$
286
- \sqrt{\sigma} = 1 - \lim_ {t \rightarrow \infty} \left(\frac{y_ {t+1}}{y_t}\right)
280
+ \sqrt{\sigma} = 1 - \lim_ {t \rightarrow \infty} \left(\frac{y_ {t+1}}{y_t}\right).
287
281
$$
288
282
289
283
Actually, if $\eta_1 =0$, it follows that
@@ -306,9 +300,9 @@ so again, convergence is immediate, and we have no need to compute a limit.
306
300
307
301
System {eq}`eq:leq_sq` of simultaneous linear equations can be used in various ways.
308
302
309
- * we can take $y_{-1}, y_{-2}$ as given initial conditions and solve for $\eta_1, \eta_2$
303
+ * we can take $y_{-1}, y_{-2}$ as given initial conditions and solve for $\eta_1, \eta_2$;
310
304
311
- * we can instead take $\eta_1, \eta_2$ as given and solve for initial conditions $y_{-1}, y_{-2}$
305
+ * we can instead take $\eta_1, \eta_2$ as given and solve for initial conditions $y_{-1}, y_{-2}$.
312
306
313
307
Notice how we used the second approach above when we set $\eta_1, \eta_2$ either to $(0, 1)$, for example, or $(1, 0)$, for example.
314
308
@@ -330,7 +324,6 @@ But first let's write some Python code to iterate on equation {eq}`eq:second_ord
330
324
331
325
We now implement the above algorithm to compute the square root of $\sigma$.
332
326
333
-
334
327
In this lecture, we use the following import:
335
328
336
329
```{code-cell} ipython3
594
587
595
588
that
596
589
597
-
598
-
599
590
$$
600
591
V^{2,1} V_ {1,1} + V^{2,2} V_ {2,1} = 0
601
592
$$
602
593
603
594
and
604
595
605
596
$$
606
- V^{1,1}V_ {1,2} + V^{1,2} V_ {2,2} = 0
597
+ V^{1,1}V_ {1,2} + V^{1,2} V_ {2,2} = 0.
607
598
$$
608
599
609
600
These equations will be very useful soon.
619
610
To deactivate $\lambda_1$ we want to set
620
611
621
612
$$
622
- x_ {1,0}^* = 0
613
+ x_ {1,0}^* = 0.
623
614
$$
624
615
625
616
638
629
This can be achieved by setting
639
630
640
631
$$
641
- x_ {2,0} = -(V^{2,2})^{-1} V^{2,1} x_ {1,0} = V_ {2,1} V_ {1,1}^{-1} x_ {1,0}
632
+ x_ {2,0} = -(V^{2,2})^{-1} V^{2,1} x_ {1,0} = V_ {2,1} V_ {1,1}^{-1} x_ {1,0}.
642
633
$$ (eq:deactivate2)
643
634
644
635
Let's verify {eq}`eq:deactivate1` and {eq}`eq:deactivate2` below
@@ -687,30 +678,30 @@ We find that the ratios converge to $\lambda_2$ in the first case and $\lambda_1
687
678
```{code-cell} ipython3
688
679
:tags: [hide-input]
689
680
690
- # Plot the ratios for y_t
691
- plt.figure( figsize=(14, 6))
692
-
693
- plt.subplot(1, 2, 1)
694
- plt .plot(np.round(ratios_λ1, 6),
695
- label=r'$\frac{y_t}{y_{t-1}}$', linewidth=3)
696
- plt .axhline(y=Λ[1], color='red',
697
- linestyle='--', label='$\lambda_2$', alpha=0.5)
698
- plt.xlabel ('t', size=18)
699
- plt.ylabel (r'$\frac{y_t}{y_{t-1}}$', size=18)
700
- plt.title (r'$\frac{y_t}{y_{t-1}}$ after Muting $\lambda_1$',
701
- size=13)
702
- plt .legend()
703
-
704
- plt.subplot(1, 2, 2)
705
- plt .plot(ratios_λ2,
706
- label=r'$\frac{y_t}{y_{t-1}}$', linewidth=3)
707
- plt .axhline(y=Λ[0], color='green',
708
- linestyle='--', label='$\lambda_1$', alpha=0.5)
709
- plt.xlabel ('t', size=18)
710
- plt.ylabel (r'$\frac{y_t}{y_{t-1}}$', size=18)
711
- plt.title (r'$\frac{y_t}{y_{t-1}}$ after Muting $\lambda_2$',
712
- size=13)
713
- plt .legend()
681
+ # Plot the ratios for y_t / y_{t-1}
682
+ fig, axs = plt.subplots(1, 2, figsize=(14, 6))
683
+
684
+ # First subplot
685
+ axs[0] .plot(np.round(ratios_λ1, 6),
686
+ label=r'$\frac{y_t}{y_{t-1}}$', linewidth=3)
687
+ axs[0] .axhline(y=Λ[1], color='red', linestyle='-- ',
688
+ label='$\lambda_2$', alpha=0.5)
689
+ axs[0].set_xlabel ('t', size=18)
690
+ axs[0].set_ylabel (r'$\frac{y_t}{y_{t-1}}$', size=18)
691
+ axs[0].set_title (r'$\frac{y_t}{y_{t-1}}$ after Muting $\lambda_1$',
692
+ size=13)
693
+ axs[0] .legend()
694
+
695
+ # Second subplot
696
+ axs[1] .plot(ratios_λ2, label=r'$\frac{y_t}{y_{t-1}}$' ,
697
+ linewidth=3)
698
+ axs[1] .axhline(y=Λ[0], color='green', linestyle='-- ',
699
+ label='$\lambda_1$', alpha=0.5)
700
+ axs[1].set_xlabel ('t', size=18)
701
+ axs[1].set_ylabel (r'$\frac{y_t}{y_{t-1}}$', size=18)
702
+ axs[1].set_title (r'$\frac{y_t}{y_{t-1}}$ after Muting $\lambda_2$',
703
+ size=13)
704
+ axs[1] .legend()
714
705
715
706
plt.tight_layout()
716
707
plt.show()
0 commit comments