commit 9419a6f6f31c19ef34666b1ac15371fc87fa9789
parent 962b6aae46913eb88f7f4d2cd790ea544f27ccd0
Author: miksa <milutin@popovic.xyz>
Date: Thu, 22 Dec 2022 18:52:39 +0000
done
Diffstat:
1 file changed, 36 insertions(+), 7 deletions(-)
diff --git a/num_ana/prog/prb6_p.ipynb b/num_ana/prog/prb6_p.ipynb
@@ -13,7 +13,7 @@
},
{
"cell_type": "code",
- "execution_count": 56,
+ "execution_count": 17,
"id": "1f94b10c",
"metadata": {},
"outputs": [
@@ -21,7 +21,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "[6488 6480]\t1.9987623950544455\n"
+ "[0.70678805 0.70742537]\t2.000899273263614\n"
]
}
],
@@ -34,14 +34,43 @@
" x_k = x_k1\n",
" return x_k, r_k\n",
"A = np.array([[1, 1], [2, 0]])\n",
- "x_0 = np.random.randint(10, size=len(A))\n",
+ "x_0 = np.random.randint(11, size=len(A))\n",
"x_k, r_k = power_iter(A, x_0)\n",
- "print(x_k, r_k, sep='\\t')"
+ "print(x_k/np.linalg.norm(x_k), r_k, sep='\\t')"
]
},
{
"cell_type": "code",
- "execution_count": 187,
+ "execution_count": 22,
+ "id": "c7f73c0c",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([10, 6])"
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "A@x_0"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ff0193ca",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
"id": "742e8c5e",
"metadata": {},
"outputs": [
@@ -174,7 +203,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3 (ipykernel)",
+ "display_name": "Python 3",
"language": "python",
"name": "python3"
},
@@ -188,7 +217,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.4"
+ "version": "3.10.8"
}
},
"nbformat": 4,