Skip to content

MAINT: update anaconda=2025.06 and python=3.13 #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Build Cache [using jupyter-book]
on:
push:
branches:
- main
schedule:
# Execute cache weekly at 3am on Monday
- cron: '0 3 * * 1'
workflow_dispatch:
jobs:
tests:
runs-on: ubuntu-latest
Expand All @@ -15,7 +16,7 @@ jobs:
auto-update-conda: true
auto-activate-base: true
miniconda-version: 'latest'
python-version: "3.12"
python-version: "3.13"
environment-file: environment.yml
activate-environment: quantecon
- name: graphviz Support # TODO: required?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
auto-update-conda: true
auto-activate-base: true
miniconda-version: 'latest'
python-version: "3.12"
python-version: "3.13"
environment-file: environment.yml
activate-environment: quantecon
- name: Graphics Support #TODO: Review if graphviz is needed
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
auto-update-conda: true
auto-activate-base: true
miniconda-version: 'latest'
python-version: "3.12"
python-version: "3.13"
environment-file: environment.yml
activate-environment: quantecon
- name: Install latex dependencies
Expand Down
20 changes: 10 additions & 10 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: quantecon
channels:
- default
- conda-forge
dependencies:
- python=3.12
- anaconda=2024.10
- python=3.13
- anaconda=2025.06
- pip
- pip:
- jupyter-book==1.0.3
- quantecon-book-theme==0.8.2
- sphinx-tojupyter==0.3.0
- jupyter-book==1.0.4post1
- quantecon-book-theme==0.8.3
- sphinx-tojupyter==0.3.1
- sphinxext-rediraffe==0.2.7
- sphinx-exercise==1.0.1
- ghp-import==2.1.0
- sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5
- sphinx-proof==0.2.0
- sphinx-proof==0.2.1
- sphinxcontrib-youtube==1.4.1
- sphinx-togglebutton==0.3.2
- sphinx-reredirects==0.1.4 #Version 0.1.5 requires sphinx>=7.1
- sphinx-reredirects==1.0.0


54 changes: 11 additions & 43 deletions lectures/eigen_I.md
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,6 @@ Here is one solution.
We start by looking into the distance between the eigenvector approximation and the true eigenvector.

```{code-cell} ipython3
---
mystnb:
figure:
caption: Power iteration
name: pow-dist
---
# Define a matrix A
A = np.array([[1, 0, 3],
[0, 2, 0],
Expand Down Expand Up @@ -1040,20 +1034,14 @@ print('The real eigenvalue is', np.linalg.eig(A)[0])
plt.figure(figsize=(10, 6))
plt.xlabel('iterations')
plt.ylabel('error')
plt.title('Power iteration')
_ = plt.plot(errors)
```

+++ {"user_expressions": []}

Then we can look at the trajectory of the eigenvector approximation.

```{code-cell} ipython3
---
mystnb:
figure:
caption: Power iteration trajectory
name: pow-trajectory
---

# Set up the figure and axis for 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
Expand Down Expand Up @@ -1081,11 +1069,11 @@ ax.legend(points, ['actual eigenvector',
r'approximated eigenvector ($b_k$)'])
ax.set_box_aspect(aspect=None, zoom=0.8)

ax.set_title('Power iteration trajectory')

plt.show()
```

+++ {"user_expressions": []}

```{solution-end}
```

Expand Down Expand Up @@ -1119,21 +1107,14 @@ print(f'eigenvectors:\n {eigenvectors}')
plot_series(A, v, n)
```

+++ {"user_expressions": []}

The result seems to converge to the eigenvector of $A$ with the largest eigenvalue.

Let's use a [vector field](https://en.wikipedia.org/wiki/Vector_field) to visualize the transformation brought by A.

(This is a more advanced topic in linear algebra, please step ahead if you are comfortable with the math.)

```{code-cell} ipython3
---
mystnb:
figure:
caption: Convergence towards eigenvectors
name: eigen-conv
---

# Create a grid of points
x, y = np.meshgrid(np.linspace(-5, 5, 15),
np.linspace(-5, 5, 20))
Expand Down Expand Up @@ -1165,13 +1146,12 @@ plt.legend(lines, labels, loc='center left',

plt.xlabel("x")
plt.ylabel("y")
plt.title("Convergence towards eigenvectors")
plt.grid()
plt.gca().set_aspect('equal', adjustable='box')
plt.show()
```

+++ {"user_expressions": []}

Note that the vector field converges to the eigenvector of $A$ with the largest eigenvalue and diverges from the eigenvector of $A$ with the smallest eigenvalue.

In fact, the eigenvectors are also the directions in which the matrix $A$ stretches or shrinks the space.
Expand Down Expand Up @@ -1200,13 +1180,8 @@ Use the visualization in the previous exercise to explain the trajectory of the
Here is one solution

```{code-cell} ipython3
---
mystnb:
figure:
caption: Vector fields of the three matrices
name: vector-field
---
figure, ax = plt.subplots(1, 3, figsize=(15, 5))

fig, ax = plt.subplots(1, 3, figsize=(15, 5))
A = np.array([[sqrt(3) + 1, -2],
[1, sqrt(3) - 1]])
A = (1/(2*sqrt(2))) * A
Expand Down Expand Up @@ -1264,24 +1239,18 @@ for i, example in enumerate(examples):
ax[i].grid()
ax[i].set_aspect('equal', adjustable='box')

fig.suptitle("Vector fields of the three matrices")
plt.show()
```

+++ {"user_expressions": []}

The vector fields explain why we observed the trajectories of the vector $v$ multiplied by $A$ iteratively before.

The pattern demonstrated here is because we have complex eigenvalues and eigenvectors.

We can plot the complex plane for one of the matrices using `Arrow3D` class retrieved from [stackoverflow](https://stackoverflow.com/questions/22867620/putting-arrowheads-on-vectors-in-a-3d-plot).

```{code-cell} ipython3
---
mystnb:
figure:
caption: 3D plot of the vector field
name: 3d-vector-field
---

class Arrow3D(FancyArrowPatch):
def __init__(self, xs, ys, zs, *args, **kwargs):
super().__init__((0, 0), (0, 0), *args, **kwargs)
Expand Down Expand Up @@ -1334,11 +1303,10 @@ ax.set_ylabel('y')
ax.set_zlabel('Im')
ax.set_box_aspect(aspect=None, zoom=0.8)

plt.title("3D plot of the vector field")
plt.draw()
plt.show()
```

+++ {"user_expressions": []}

```{solution-end}
```
Loading
Loading