Skip to content

Commit 79478e9

Browse files
committed
Remove rcparams
1 parent 901a940 commit 79478e9

File tree

2 files changed

+43
-47
lines changed

2 files changed

+43
-47
lines changed

lectures/linear_equations.md

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ We will use the following imports:
4848
```{code-cell} ipython3
4949
import numpy as np
5050
import matplotlib.pyplot as plt
51-
plt.rcParams["figure.figsize"] = (11, 5) # set default figure size
5251
```
5352

5453

@@ -65,10 +64,10 @@ The second method is more general, as we will see.
6564

6665
### Pencil and Paper Methods
6766

68-
Suppose that we have two related goods, such as
67+
Suppose that we have two related goods, such as
6968

70-
* propane and ethanol
71-
* rice and wheat, etc.
69+
* propane and ethanol
70+
* rice and wheat, etc.
7271

7372
To keep things simple, we label them as good 0 and good 1.
7473

@@ -78,20 +77,20 @@ The demand for each good depends on the price of both goods:
7877
:label: two_eq_demand
7978
\begin{aligned}
8079
q_0^d = 100 - 10 p_0 - 5 p_1 \\
81-
q_1^d = 50 - p_0 - 10 p_1
80+
q_1^d = 50 - p_0 - 10 p_1
8281
\end{aligned}
8382
```
8483

8584
(We are assuming demand decreases when the price of either good goes up, but
8685
other cases are also possible.)
8786

88-
Let's suppose that supply is given by
87+
Let's suppose that supply is given by
8988

9089
```{math}
9190
:label: two_eq_supply
9291
\begin{aligned}
9392
q_0^s = 10 p_0 + 5 p_1 \\
94-
q_1^s = 5 p_0 + 10 p_1
93+
q_1^s = 5 p_0 + 10 p_1
9594
\end{aligned}
9695
```
9796

@@ -103,18 +102,18 @@ This yields the linear system
103102
:label: two_equilibrium
104103
\begin{aligned}
105104
100 - 10 p_0 - 5 p_1 = 10 p_0 + 5 p_1 \\
106-
50 - p_0 - 10 p_1 = 5 p_0 + 10 p_1
105+
50 - p_0 - 10 p_1 = 5 p_0 + 10 p_1
107106
\end{aligned}
108107
```
109108

110109
We can solve this with pencil and paper to get
111110

112111
$$
113112
p_0 = 4.41 \quad \text{and} \quad p_1 = 1.18
114-
$$
113+
$$
115114

116115
Inserting these results into either {eq}`two_eq_demand` or {eq}`two_eq_supply` yields the
117-
equilibrium quantities
116+
equilibrium quantities
118117

119118
$$
120119
q_0 = 50 \quad \text{and} \quad q_1 = 33.82
@@ -148,7 +147,7 @@ column vectors.
148147

149148
The set of all $n$-vectors is denoted by $\mathbb R^n$.
150149

151-
For example,
150+
For example,
152151

153152
* $\mathbb R^2$ is the plane --- the set of pairs $(x_1, x_2)$
154153
* $\mathbb R^3$ is 3 dimensional space --- the set of vectors $(x_1, x_2, x_3)$
@@ -197,17 +196,17 @@ For example,
197196
$$
198197
\begin{bmatrix}
199198
4 \\
200-
-2
199+
-2
201200
\end{bmatrix}
202201
+
203202
\begin{bmatrix}
204203
3 \\
205-
3
204+
3
206205
\end{bmatrix}
207206
=
208207
\begin{bmatrix}
209208
4 & + & 3 \\
210-
-2 & + & 3
209+
-2 & + & 3
211210
\end{bmatrix}
212211
=
213212
\begin{bmatrix}
@@ -286,7 +285,7 @@ $$
286285
-2
287286
\begin{bmatrix}
288287
3 \\
289-
-7
288+
-7
290289
\end{bmatrix}
291290
=
292291
\begin{bmatrix}
@@ -347,10 +346,10 @@ for s in scalars:
347346
plt.show()
348347
```
349348

350-
In Python, a vector can be represented as a list or tuple,
349+
In Python, a vector can be represented as a list or tuple,
351350
such as `x = [2, 4, 6]` or `x = (2, 4, 6)`.
352351

353-
However, it is more common to represent vectors with
352+
However, it is more common to represent vectors with
354353
[NumPy arrays](https://python-programming.quantecon.org/numpy.html#numpy-arrays).
355354

356355
One advantage of NumPy arrays is that scalar multiplication and addition have
@@ -377,7 +376,7 @@ x + y # Add (element-by-element)
377376
The **inner product** of vectors $x,y \in \mathbb R^n$ is defined as
378377

379378
$$
380-
x' y =
379+
x' y =
381380
\begin{bmatrix}
382381
\color{red}{x_1} & \color{blue}{x_2} & \cdots & x_n
383382
\end{bmatrix}
@@ -407,7 +406,7 @@ np.sum(x*y) # Inner product of x and y
407406
```
408407

409408
```{code-cell} ipython3
410-
x @ y # Another way to compute the inner product
409+
x @ y # Another way to compute the inner product
411410
```
412411

413412
```{code-cell} ipython3
@@ -596,9 +595,9 @@ AB =
596595
\end{bmatrix}
597596
$$
598597

599-
There are many tutorials to help you further visualize this operation, such as
598+
There are many tutorials to help you further visualize this operation, such as
600599

601-
* [this one](http://www.mathsisfun.com/algebra/matrix-multiplying.html), or
600+
* [this one](http://www.mathsisfun.com/algebra/matrix-multiplying.html), or
602601
* the discussion on the [Wikipedia page](https://en.wikipedia.org/wiki/Matrix_multiplication).
603602

604603

@@ -609,7 +608,7 @@ Unlike number products, $A B$ and $B A$ are not generally the same thing.
609608
ONe important special case is the [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix), which has ones on the principal diagonal and zero elsewhere:
610609

611610
$$
612-
I =
611+
I =
613612
\begin{bmatrix}
614613
1 & \cdots & 0 \\
615614
\vdots & \ddots & \vdots \\
@@ -692,16 +691,16 @@ First we rewrite {eq}`two_eq_demand` as
692691
:label: two_eq_demand_mat
693692
q^d = D p + h
694693
\quad \text{where} \quad
695-
q^d =
694+
q^d =
696695
\begin{bmatrix}
697696
q_0^d \\
698697
q_1^d
699698
\end{bmatrix}
700699
\quad
701-
D =
700+
D =
702701
\begin{bmatrix}
703702
-10 & - 5 \\
704-
- 1 & - 10
703+
- 1 & - 10
705704
\end{bmatrix}
706705
\quad \text{and} \quad
707706
h =
@@ -717,18 +716,18 @@ We rewrite {eq}`two_eq_supply` as
717716

718717
```{math}
719718
:label: two_eq_supply_mat
720-
q^s = C p
719+
q^s = C p
721720
\quad \text{where} \quad
722-
q^s =
721+
q^s =
723722
\begin{bmatrix}
724723
q_0^s \\
725724
q_1^s
726725
\end{bmatrix}
727726
\quad \text{and} \quad
728-
C =
727+
C =
729728
\begin{bmatrix}
730729
10 & 5 \\
731-
5 & 10
730+
5 & 10
732731
\end{bmatrix}
733732
```
734733

@@ -738,7 +737,7 @@ $$
738737
C p = D p + h
739738
$$
740739

741-
We can rearrange the terms to get
740+
We can rearrange the terms to get
742741

743742
$$
744743
(C - D) p = h
@@ -789,13 +788,13 @@ To find an equilibrium, we solve $Dp + h = Cp + e$, or
789788

790789
```{math}
791790
:label: n_eq_sys_la
792-
(D- C)p = e - h
791+
(D- C)p = e - h
793792
```
794793

795794
The solution is
796795

797-
$$
798-
p = (D- C)^{-1}(e - h)
796+
$$
797+
p = (D- C)^{-1}(e - h)
799798
$$
800799

801800

@@ -813,7 +812,7 @@ A more general version of the problem described above looks as follows.
813812
\end{matrix}
814813
```
815814

816-
The objective here is to solve for the "unknowns" $x_1, \ldots, x_n$
815+
The objective here is to solve for the "unknowns" $x_1, \ldots, x_n$
817816

818817
We take as given the coefficients $a_{11}, \ldots, a_{nn}$ and constants $b_1, \ldots, b_n$.
819818

@@ -831,7 +830,7 @@ In matrix form, the system {eq}`la_se` becomes
831830
:label: la_gf
832831
A x = b
833832
\quad \text{where} \quad
834-
A =
833+
A =
835834
\begin{bmatrix}
836835
a_{11} & \cdots & a_{1n} \\
837836
\vdots & \vdots & \vdots \\
@@ -846,10 +845,10 @@ In matrix form, the system {eq}`la_se` becomes
846845
\end{bmatrix}
847846
```
848847

849-
For example, {eq}`n_eq_sys_la` has this form with
848+
For example, {eq}`n_eq_sys_la` has this form with
850849

851-
$$
852-
A = D - C,
850+
$$
851+
A = D - C,
853852
\quad
854853
b = e - h
855854
\quad \text{and} \quad
@@ -924,7 +923,7 @@ We can rewrite this system in matrix form as
924923
A =
925924
\begin{bmatrix}
926925
1 & 3 \\
927-
2 & 6
926+
2 & 6
928927
\end{bmatrix}
929928
\quad \text{and} \quad
930929
b =
@@ -965,7 +964,7 @@ Any vector $v = (x,y)$ such that $x = 2y - 4$ will solve the above system.
965964

966965
Since we can find infinite such vectors this system has infinitely many solutions.
967966

968-
This is because the rows of the corresponding matrix
967+
This is because the rows of the corresponding matrix
969968

970969
```{math}
971970
:label: many_solns
@@ -1177,7 +1176,7 @@ A =
11771176
p_2
11781177
\end{bmatrix}
11791178
\quad \text{and} \quad
1180-
b =
1179+
b =
11811180
\begin{bmatrix}
11821181
100 \\
11831182
75 \\
@@ -1235,7 +1234,7 @@ When faced with an inconsistent system we try to find the best "approximate" sol
12351234

12361235
There are various methods to do this, one such method is the **method of least squares.**
12371236

1238-
Suppose we have an inconsistent system
1237+
Suppose we have an inconsistent system
12391238

12401239
```{math}
12411240
:label: inconsistent
@@ -1249,11 +1248,11 @@ is less than the distance from $Ax$ to $b$.
12491248
That is,
12501249

12511250
$$
1252-
\|A\hat{x} - b\| \leq \|Ax - b\|
1251+
\|A\hat{x} - b\| \leq \|Ax - b\|
12531252
$$
12541253

12551254
It can be shown that, for the system of equations $Ax = b$, the least squares
1256-
solution $\hat{x}$ is
1255+
solution $\hat{x}$ is
12571256

12581257
```{math}
12591258
:label: least_squares
@@ -1367,5 +1366,3 @@ plt.show()
13671366
The documentation of the `numpy.linalg` submodule can be found [here](https://numpy.org/devdocs/reference/routines.linalg.html).
13681367

13691368
More advanced topics in linear algebra can be found [here](https://python.quantecon.org/linear_algebra.html#id5).
1370-
1371-

lectures/time_series_with_matrices.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ We will use the following imports:
5252
import numpy as np
5353
import matplotlib.pyplot as plt
5454
from matplotlib import cm
55-
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
5655
```
5756

5857
## Samuelson's model

0 commit comments

Comments
 (0)