Skip to content

Commit abbf029

Browse files
committed
60 / 200 : narrow random rotation angle to avoid degenerate cases
`nr.randint(-180, 180)` could land on near-zero or near-±180° angles, producing rotations close to identity or to a 180° flip. In both cases the power-iteration example becomes ambiguous (no clearly dominant eigendirection over a single rotation). Replace with a random choice from `[-170, -10] ∪ [10, 170]` and import `random` accordingly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Clean ipynb 62019ec
1 parent 2f308fa commit abbf029

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

60_linear_algebra_2/200_Eigenvalues_of_a_Matrix_PowerMethod.ipynb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,18 @@
626626
"metadata": {},
627627
"outputs": [],
628628
"source": [
629-
"theta_rad = np.deg2rad(nr.randint(-180, 180))\n",
629+
"import random\n",
630+
"\n"
631+
]
632+
},
633+
{
634+
"cell_type": "code",
635+
"execution_count": null,
636+
"metadata": {},
637+
"outputs": [],
638+
"source": [
639+
"deg_list = list(range(-170, -10)) + list(range(10, 170+1))\n",
640+
"theta_rad = np.deg2rad(random.choice(deg_list))\n",
630641
"\n",
631642
"matA = np.array(\n",
632643
" [\n",
@@ -727,8 +738,8 @@
727738
],
728739
"metadata": {
729740
"colab": {
730-
"provenance": [],
731-
"include_colab_link": true
741+
"include_colab_link": true,
742+
"provenance": []
732743
},
733744
"kernelspec": {
734745
"display_name": "Python 3 (ipykernel)",
@@ -745,9 +756,9 @@
745756
"name": "python",
746757
"nbconvert_exporter": "python",
747758
"pygments_lexer": "ipython3",
748-
"version": "3.10.9"
759+
"version": "3.13.12"
749760
}
750761
},
751762
"nbformat": 4,
752-
"nbformat_minor": 0
763+
"nbformat_minor": 4
753764
}

0 commit comments

Comments
 (0)