Skip to content

Commit 6151bfa

Browse files
committed
[scalar_dynamic] Update editorial suggestions
This updates the editorial suggestion in #426 (Delete %matplotlib inline) - If $n$ is an integer -> if $n$ is a positive integer - Change the duplicated heading for 22.2.3. Dynamic systems. - Capitalize the first letter in the section headings. - where $a, b$ are fixed constants -> where $a, b$ are constants. Sometimes they are referred to as parameters - $t \geq 0$ -> t = 0, 1, 2 - Arbitrary $t$ to non-negative integer $t$ - For example, recall how we [previously studied](https://python-programming.quantecon.org/python_oop.html#example-the-solow-growth-model) -> For example, in the simple Solow-Swan growth model. - $k$ is capital stock -> $k$ is capital stock per capita - a fixed dynamic system consisting -> a dynamic system consisting - Use commas instead of full stops below the sentence: "For example, for the linear model $x_{t+1} = a x_t + b$, you can use the definition to check that" - 45 degree -> 45-degree ## Code - Add labels to axis in `plot45` function x_t and x_{t+1} - Put the global variables into function $g$ - Missing full stop in 'study the trajectories' - Change the Solow model to Solow-Swan model
1 parent c879389 commit 6151bfa

File tree

1 file changed

+34
-43
lines changed

1 file changed

+34
-43
lines changed

lectures/scalar_dynam.md

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ and understand key concepts.
4040
Let's start with some standard imports:
4141

4242
```{code-cell} ipython
43-
%matplotlib inline
4443
import matplotlib.pyplot as plt
4544
import numpy as np
4645
```
@@ -79,7 +78,7 @@ $$
7978
f^2(x) = \sqrt{\sqrt{x}} = x^{1/4}
8079
$$
8180

82-
Similarly, if $n$ is an integer, then $f^n$ is $n$ compositions of $f$ with
81+
Similarly, if $n$ is a positive integer, then $f^n$ is $n$ compositions of $f$ with
8382
itself.
8483

8584
In the example above, $f^n(x) = x^{1/(2^n)}$.
@@ -104,10 +103,6 @@ form a dynamic system, since $g(1) = 2$.
104103

105104
* $g$ does not always send points in $S$ back into $S$.
106105

107-
108-
109-
### Dynamic systems
110-
111106
We care about dynamic systems because we can use them to study dynamics!
112107

113108
Given a dynamic system consisting of set $S$ and function $g$, we can create
@@ -138,7 +133,7 @@ Recalling that $g^n$ is the $n$ compositions of $g$ with itself,
138133
we can write the trajectory more simply as
139134

140135
$$
141-
x_t = g^t(x_0) \quad \text{ for } t \geq 0.
136+
x_t = g^t(x_0) \quad \text{ for } t = 0, 1, 2, \ldots
142137
$$
143138

144139
In all of what follows, we are going to assume that $S$ is a subset of
@@ -150,10 +145,10 @@ Equation {eq}`sdsod` is sometimes called a **first order difference equation**
150145

151146

152147

153-
### Example: A Linear Model
148+
### Example: a linear model
154149

155150
One simple example of a dynamic system is when $S=\mathbb R$ and $g(x)=ax +
156-
b$, where $a, b$ are fixed constants.
151+
b$, where $a, b$ are constants (sometimes they are referred as parameters).
157152

158153
This leads to the **linear difference equation**
159154

@@ -175,14 +170,14 @@ a^2 x_0 + a b + b, \quad \text{etc.}
175170
```
176171

177172
Continuing in this way, and using our knowledge of {doc}`geometric series
178-
<geom_series>`, we find that, for any $t \geq 0$,
173+
<geom_series>`, we find that, for any $t = 0, 1, 2, \ldots$,
179174

180175
```{math}
181176
:label: sdslinmod
182177
x_t = a^t x_0 + b \frac{1 - a^t}{1 - a}
183178
```
184179

185-
We have an exact expression for $x_t$ for all $t$ and hence a full
180+
We have an exact expression for $x_t$ for all non-negative integer $t$ and hence a full
186181
understanding of the dynamics.
187182

188183
Notice in particular that $|a| < 1$, then, by {eq}`sdslinmod`, we have
@@ -193,32 +188,32 @@ Notice in particular that $|a| < 1$, then, by {eq}`sdslinmod`, we have
193188
x_t \to \frac{b}{1 - a} \text{ as } t \to \infty
194189
```
195190

196-
regardless of $x_0$
191+
regardless of $x_0$.
197192

198193
This is an example of what is called global stability, a topic we return to
199194
below.
200195

201196

202197

203198

204-
### Example: A Nonlinear Model
199+
### Example: a nonlinear model
205200

206201
In the linear example above, we obtained an exact analytical expression for
207-
$x_t$ in terms of arbitrary $t$ and $x_0$.
202+
$x_t$ in terms of arbitrary non-negative integer $t$ and $x_0$.
208203

209204
This made analysis of dynamics very easy.
210205

211206
When models are nonlinear, however, the situation can be quite different.
212207

213-
For example, recall how we [previously studied](https://python-programming.quantecon.org/python_oop.html#example-the-solow-growth-model) the law of motion for the Solow growth model, a simplified version of which is
208+
For example, the law of motion for the Solow-Swan growth model, a simplified version of which is
214209

215210
```{math}
216211
:label: solow_lom2
217212
218213
k_{t+1} = s z k_t^{\alpha} + (1 - \delta) k_t
219214
```
220215

221-
Here $k$ is capital stock and $s, z, \alpha, \delta$ are positive
216+
Here $k$ is the per capita capital stock and $s, z, \alpha, \delta$ are positive
222217
parameters with $0 < \alpha, \delta < 1$.
223218

224219
If you try to iterate like we did in {eq}`sdslinmodpath`, you will find that
@@ -233,7 +228,7 @@ Analyzing the dynamics of this model requires a different method (see below).
233228

234229
## Stability
235230

236-
Consider a fixed dynamic system consisting of set $S \subset \mathbb R$ and
231+
Consider a dynamic system consisting of set $S \subset \mathbb R$ and
237232
$g$ mapping $S$ to $S$.
238233

239234
### Steady states
@@ -247,9 +242,9 @@ $S$.
247242
For example, for the linear model $x_{t+1} = a x_t + b$, you can use the
248243
definition to check that
249244

250-
* $x^* := b/(1-a)$ is a steady state whenever $a \not= 1$.
245+
* $x^* := b/(1-a)$ is a steady state whenever $a \not= 1$,
251246
* if $a = 1$ and $b=0$, then every $x \in \mathbb R$ is a
252-
steady state.
247+
steady state,
253248
* if $a = 1$ and $b \not= 0$, then the linear model has no steady
254249
state in $\mathbb R$.
255250

@@ -303,13 +298,13 @@ There is no single way to tackle all nonlinear models.
303298
However, there is one technique for one-dimensional models that provides a
304299
great deal of intuition.
305300

306-
This is a graphical approach based on **45 degree diagrams**.
301+
This is a graphical approach based on **45-degree diagrams**.
307302

308-
Let's look at an example: the Solow model with dynamics given in {eq}`solow_lom2`.
303+
Let's look at an example: the Solow-Swan model with dynamics given in {eq}`solow_lom2`.
309304

310305
We begin with some plotting code that you can ignore at first reading.
311306

312-
The function of the code is to produce 45 degree diagrams and time series
307+
The function of the code is to produce 45-degree diagrams and time series
313308
plots.
314309

315310

@@ -340,6 +335,8 @@ def plot45(g, xmin, xmax, x0, num_arrows=6, var='x'):
340335
fig, ax = subplots()
341336
ax.set_xlim(xmin, xmax)
342337
ax.set_ylim(xmin, xmax)
338+
ax.set_xlabel(r'${}_t$'.format(var), fontsize=14)
339+
ax.set_ylabel(r'${}_{t+1}$'.format(var), fontsize=14)
343340
344341
hw = (xmax - xmin) * 0.01
345342
hl = 2 * hw
@@ -403,29 +400,23 @@ def ts_plot(g, xmin, xmax, x0, ts_length=6, var='x'):
403400
plt.show()
404401
```
405402

406-
Let's create a 45 degree diagram for the Solow model with a fixed set of
407-
parameters
408-
409-
```{code-cell} ipython
410-
A, s, alpha, delta = 2, 0.3, 0.3, 0.4
411-
```
412-
413-
Here's the update function corresponding to the model.
403+
Let's create a 45-degree diagram for the Solow-Swan model with a fixed set of
404+
parameters. Here's the update function corresponding to the model.
414405

415406
```{code-cell} ipython
416-
def g(k):
407+
def g(k, A = 2, s = 0.3, alpha = 0.3, delta = 0.4):
417408
return A * s * k**alpha + (1 - delta) * k
418409
```
419410

420-
Here is the 45 degree plot.
411+
Here is the 45-degree plot.
421412

422413
```{code-cell} ipython
423414
xmin, xmax = 0, 4 # Suitable plotting region.
424415
425416
plot45(g, xmin, xmax, 0, num_arrows=0)
426417
```
427418

428-
The plot shows the function $g$ and the 45 degree line.
419+
The plot shows the function $g$ and the 45-degree line.
429420

430421
Think of $k_t$ as a value on the horizontal axis.
431422

@@ -434,11 +425,11 @@ value on the vertical axis.
434425

435426
Clearly,
436427

437-
* If $g$ lies above the 45 degree line at this point, then we have $k_{t+1} > k_t$.
438-
* If $g$ lies below the 45 degree line at this point, then we have $k_{t+1} < k_t$.
439-
* If $g$ hits the 45 degree line at this point, then we have $k_{t+1} = k_t$, so $k_t$ is a steady state.
428+
* If $g$ lies above the 45-degree line at this point, then we have $k_{t+1} > k_t$.
429+
* If $g$ lies below the 45-degree line at this point, then we have $k_{t+1} < k_t$.
430+
* If $g$ hits the 45-degree line at this point, then we have $k_{t+1} = k_t$, so $k_t$ is a steady state.
440431

441-
For the Solow model, there are two steady states when $S = \mathbb R_+ =
432+
For the Solow-Swan model, there are two steady states when $S = \mathbb R_+ =
442433
[0, \infty)$.
443434

444435
* the origin $k=0$
@@ -452,7 +443,7 @@ $$
452443

453444
### Trajectories
454445

455-
By the preceding discussion, in regions where $g$ lies above the 45 degree line, we know that the trajectory is increasing.
446+
By the preceding discussion, in regions where $g$ lies above the 45-degree line, we know that the trajectory is increasing.
456447

457448
The next figure traces out a trajectory in such a region so we can see this more clearly.
458449

@@ -464,7 +455,7 @@ k0 = 0.25
464455
plot45(g, xmin, xmax, k0, num_arrows=5, var='k')
465456
```
466457

467-
We can plot the time series of capital corresponding to the figure above as
458+
We can plot the time series of per capita capital corresponding to the figure above as
468459
follows:
469460

470461
```{code-cell} ipython
@@ -477,7 +468,7 @@ Here's a somewhat longer view:
477468
ts_plot(g, xmin, xmax, k0, ts_length=20, var='k')
478469
```
479470

480-
When capital stock is higher than the unique positive steady state, we see that
471+
When per capita capital stock is higher than the unique positive steady state, we see that
481472
it declines:
482473

483474
```{code-cell} ipython
@@ -494,7 +485,7 @@ ts_plot(g, xmin, xmax, k0, var='k')
494485

495486
### Complex dynamics
496487

497-
The Solow model is nonlinear but still generates very regular dynamics.
488+
The Solow-Swan model is nonlinear but still generates very regular dynamics.
498489

499490
One model that generates irregular dynamics is the **quadratic map**
500491

@@ -503,7 +494,7 @@ g(x) = 4 x (1 - x),
503494
\qquad x \in [0, 1]
504495
$$
505496

506-
Let's have a look at the 45 degree diagram.
497+
Let's have a look at the 45-degree diagram.
507498

508499
```{code-cell} ipython
509500
xmin, xmax = 0, 1
@@ -550,7 +541,7 @@ Try to illustrate this graphically by looking at a range of initial conditions.
550541
What differences do you notice in the cases $a \in (-1, 0)$ and $a
551542
\in (0, 1)$?
552543
553-
Use $a=0.5$ and then $a=-0.5$ and study the trajectories
544+
Use $a=0.5$ and then $a=-0.5$ and study the trajectories.
554545
555546
Set $b=1$ throughout.
556547
```

0 commit comments

Comments
 (0)