add a few lectures

This commit is contained in:
Frank Xu
2025-05-02 21:54:52 -04:00
parent 02953d8608
commit ac1c788fe9
22 changed files with 260097 additions and 201 deletions

View File

@@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 62,
"id": "323b62e8",
"metadata": {},
"outputs": [
@@ -29,7 +29,7 @@
"6"
]
},
"execution_count": 2,
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
@@ -40,7 +40,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 63,
"id": "6cdd612e",
"metadata": {},
"outputs": [
@@ -50,7 +50,7 @@
"8"
]
},
"execution_count": 3,
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
@@ -61,7 +61,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 64,
"id": "5e7c9a36",
"metadata": {},
"outputs": [
@@ -71,7 +71,7 @@
"1"
]
},
"execution_count": 4,
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
@@ -82,7 +82,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 65,
"id": "c497160d",
"metadata": {},
"outputs": [
@@ -101,7 +101,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 66,
"id": "e81329e5",
"metadata": {},
"outputs": [
@@ -111,7 +111,7 @@
"[1, 2, 3]"
]
},
"execution_count": 6,
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
@@ -123,7 +123,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 67,
"id": "0f886f3a",
"metadata": {},
"outputs": [
@@ -133,7 +133,7 @@
"1"
]
},
"execution_count": 7,
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
@@ -144,7 +144,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 68,
"id": "bd694c5c",
"metadata": {},
"outputs": [
@@ -154,7 +154,7 @@
"[1, 2, 3, 4]"
]
},
"execution_count": 8,
"execution_count": 68,
"metadata": {},
"output_type": "execute_result"
}
@@ -166,7 +166,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 69,
"id": "f47c854d",
"metadata": {},
"outputs": [
@@ -176,7 +176,7 @@
"4"
]
},
"execution_count": 9,
"execution_count": 69,
"metadata": {},
"output_type": "execute_result"
}
@@ -187,7 +187,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 70,
"id": "e2d7b456",
"metadata": {},
"outputs": [
@@ -197,7 +197,7 @@
"(1, 2, 3)"
]
},
"execution_count": 10,
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
@@ -209,7 +209,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 71,
"id": "4e37998a",
"metadata": {},
"outputs": [
@@ -219,7 +219,7 @@
"1"
]
},
"execution_count": 11,
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
@@ -238,7 +238,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 72,
"id": "d9c0f925",
"metadata": {},
"outputs": [
@@ -248,7 +248,7 @@
"[1, 4, 9]"
]
},
"execution_count": 1,
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
@@ -259,7 +259,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 73,
"id": "799c1063",
"metadata": {},
"outputs": [
@@ -269,7 +269,7 @@
"[1, 4, 9, 16, 25]"
]
},
"execution_count": 4,
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
@@ -282,7 +282,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 74,
"id": "7a9d00ab",
"metadata": {},
"outputs": [
@@ -292,7 +292,7 @@
"[0, 2, 4, 6, 8]"
]
},
"execution_count": 6,
"execution_count": 74,
"metadata": {},
"output_type": "execute_result"
}
@@ -305,7 +305,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 75,
"id": "0b3a893b",
"metadata": {},
"outputs": [
@@ -315,7 +315,7 @@
"[1, 2]"
]
},
"execution_count": 8,
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
}
@@ -337,7 +337,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 76,
"id": "0df3abc9",
"metadata": {},
"outputs": [],
@@ -347,7 +347,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 77,
"id": "2a7a1daf",
"metadata": {},
"outputs": [
@@ -357,7 +357,7 @@
"array([1, 2, 3, 4, 5, 6])"
]
},
"execution_count": 13,
"execution_count": 77,
"metadata": {},
"output_type": "execute_result"
}
@@ -369,7 +369,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 78,
"id": "1f8e61c2",
"metadata": {},
"outputs": [
@@ -379,7 +379,7 @@
"np.int64(1)"
]
},
"execution_count": 14,
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
@@ -390,7 +390,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 79,
"id": "61e20947",
"metadata": {},
"outputs": [],
@@ -400,7 +400,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 80,
"id": "18251de4",
"metadata": {},
"outputs": [
@@ -410,7 +410,7 @@
"np.float32(2.0)"
]
},
"execution_count": 16,
"execution_count": 80,
"metadata": {},
"output_type": "execute_result"
}
@@ -421,7 +421,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 81,
"id": "11f35a16",
"metadata": {},
"outputs": [
@@ -431,7 +431,7 @@
"array([1, 2, 3])"
]
},
"execution_count": 17,
"execution_count": 81,
"metadata": {},
"output_type": "execute_result"
}
@@ -442,7 +442,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 82,
"id": "57ef6d6c",
"metadata": {},
"outputs": [
@@ -452,7 +452,7 @@
"array([4, 5, 6])"
]
},
"execution_count": 18,
"execution_count": 82,
"metadata": {},
"output_type": "execute_result"
}
@@ -463,7 +463,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 83,
"id": "db3cc4e7",
"metadata": {},
"outputs": [
@@ -475,7 +475,7 @@
" [ 9, 10, 11, 12]])"
]
},
"execution_count": 19,
"execution_count": 83,
"metadata": {},
"output_type": "execute_result"
}
@@ -487,7 +487,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 84,
"id": "7ca7a696",
"metadata": {},
"outputs": [
@@ -497,7 +497,7 @@
"np.int64(8)"
]
},
"execution_count": 20,
"execution_count": 84,
"metadata": {},
"output_type": "execute_result"
}
@@ -506,6 +506,39 @@
"a[1, 3]"
]
},
{
"cell_type": "markdown",
"id": "3d2d0b6f",
"metadata": {},
"source": [
"The function calculates the step size as:\n",
"\n",
"step = (stop - start) / (num - 1) = (10 - (-10)) / (11 - 1) = 20/10 ≈ 2"
]
},
{
"cell_type": "code",
"execution_count": 85,
"id": "53d75c62",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-10., -8., -6., -4., -2., 0., 2., 4., 6., 8., 10.])"
]
},
"execution_count": 85,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Range of z values\n",
"# np.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)\n",
"np.linspace(-10, 10, 11)"
]
},
{
"cell_type": "markdown",
"id": "0580eca2",
@@ -519,7 +552,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 86,
"id": "25a9b316",
"metadata": {},
"outputs": [
@@ -559,7 +592,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 87,
"id": "d86d32ee",
"metadata": {},
"outputs": [
@@ -615,7 +648,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 88,
"id": "ba1d7074",
"metadata": {},
"outputs": [
@@ -625,7 +658,7 @@
"True"
]
},
"execution_count": 23,
"execution_count": 88,
"metadata": {},
"output_type": "execute_result"
}
@@ -636,7 +669,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 89,
"id": "124e1812",
"metadata": {},
"outputs": [
@@ -646,7 +679,7 @@
"4"
]
},
"execution_count": 24,
"execution_count": 89,
"metadata": {},
"output_type": "execute_result"
}
@@ -658,7 +691,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 90,
"id": "f300cebf",
"metadata": {},
"outputs": [
@@ -668,7 +701,7 @@
"3"
]
},
"execution_count": 25,
"execution_count": 90,
"metadata": {},
"output_type": "execute_result"
}
@@ -686,7 +719,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 91,
"id": "6e9dceae",
"metadata": {},
"outputs": [
@@ -696,7 +729,7 @@
"(3, 2, 4)"
]
},
"execution_count": 26,
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
@@ -707,7 +740,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 92,
"id": "a5ee181d",
"metadata": {},
"outputs": [
@@ -717,7 +750,7 @@
"24"
]
},
"execution_count": 27,
"execution_count": 92,
"metadata": {},
"output_type": "execute_result"
}
@@ -728,7 +761,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 93,
"id": "b251a416",
"metadata": {},
"outputs": [
@@ -738,7 +771,7 @@
"dtype('int64')"
]
},
"execution_count": 28,
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
@@ -750,7 +783,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 94,
"id": "a043cd1c",
"metadata": {},
"outputs": [
@@ -760,7 +793,7 @@
"dtype('float32')"
]
},
"execution_count": 29,
"execution_count": 94,
"metadata": {},
"output_type": "execute_result"
}
@@ -780,7 +813,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 95,
"id": "75b22e31",
"metadata": {},
"outputs": [
@@ -790,7 +823,7 @@
"array([0., 0.])"
]
},
"execution_count": 30,
"execution_count": 95,
"metadata": {},
"output_type": "execute_result"
}
@@ -801,7 +834,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 96,
"id": "4b542c1f",
"metadata": {},
"outputs": [
@@ -811,7 +844,7 @@
"array([1., 1.])"
]
},
"execution_count": 31,
"execution_count": 96,
"metadata": {},
"output_type": "execute_result"
}
@@ -822,7 +855,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 97,
"id": "c22cdd54",
"metadata": {},
"outputs": [
@@ -832,7 +865,7 @@
"array([0, 1, 2, 3])"
]
},
"execution_count": 32,
"execution_count": 97,
"metadata": {},
"output_type": "execute_result"
}
@@ -843,7 +876,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 98,
"id": "367eacd6",
"metadata": {},
"outputs": [
@@ -853,7 +886,7 @@
"array([2, 4, 6, 8])"
]
},
"execution_count": 33,
"execution_count": 98,
"metadata": {},
"output_type": "execute_result"
}
@@ -864,19 +897,19 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 99,
"id": "0fa059e6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.01135293, 0.54482248, 0.33628695, 0.81612888],\n",
" [0.00168462, 0.97332481, 0.86424808, 0.01566007],\n",
" [0.32076747, 0.3997841 , 0.24520416, 0.00826635]])"
"array([[0.84849457, 0.2408882 , 0.26897315, 0.88789736],\n",
" [0.17325996, 0.06966163, 0.81198917, 0.24941808],\n",
" [0.70722305, 0.64643472, 0.07015388, 0.19063198]])"
]
},
"execution_count": 34,
"execution_count": 99,
"metadata": {},
"output_type": "execute_result"
}
@@ -887,19 +920,19 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 100,
"id": "eae03b14",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[6, 6, 4, 5],\n",
" [8, 4, 1, 3],\n",
" [3, 4, 9, 6]], dtype=int32)"
"array([[ 1, 1, 10, 1],\n",
" [ 8, 10, 1, 1],\n",
" [ 8, 1, 4, 8]], dtype=int32)"
]
},
"execution_count": 35,
"execution_count": 100,
"metadata": {},
"output_type": "execute_result"
}
@@ -910,18 +943,18 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 101,
"id": "86c88e48",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1.61548569, -1.27751798, 2.23823677, 1.87533372],\n",
" [ 1.88733913, 0.59567694, -0.74642328, 0.29124792]])"
"array([[-0.06960131, 0.94400631, -0.05980746, -0.81806564],\n",
" [-0.06661582, -0.71274669, 0.9149406 , 0.63540989]])"
]
},
"execution_count": 36,
"execution_count": 101,
"metadata": {},
"output_type": "execute_result"
}
@@ -944,7 +977,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 102,
"id": "b26242be",
"metadata": {},
"outputs": [
@@ -954,7 +987,7 @@
"(6,)"
]
},
"execution_count": 37,
"execution_count": 102,
"metadata": {},
"output_type": "execute_result"
}
@@ -966,7 +999,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 103,
"id": "18db087b",
"metadata": {},
"outputs": [
@@ -976,7 +1009,7 @@
"(1, 6)"
]
},
"execution_count": 38,
"execution_count": 103,
"metadata": {},
"output_type": "execute_result"
}
@@ -988,7 +1021,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 104,
"id": "f213bce6",
"metadata": {},
"outputs": [
@@ -998,7 +1031,7 @@
"array([[1, 2, 3, 4, 5, 6]])"
]
},
"execution_count": 39,
"execution_count": 104,
"metadata": {},
"output_type": "execute_result"
}
@@ -1009,7 +1042,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 105,
"id": "25c7b822",
"metadata": {},
"outputs": [
@@ -1024,7 +1057,7 @@
" [6]])"
]
},
"execution_count": 40,
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
@@ -1035,7 +1068,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 106,
"id": "bbd43b79",
"metadata": {},
"outputs": [
@@ -1046,7 +1079,7 @@
" [4, 5, 6]])"
]
},
"execution_count": 41,
"execution_count": 106,
"metadata": {},
"output_type": "execute_result"
}
@@ -1071,7 +1104,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 107,
"id": "9af72192",
"metadata": {},
"outputs": [
@@ -1082,7 +1115,7 @@
" [4, 5]])"
]
},
"execution_count": 42,
"execution_count": 107,
"metadata": {},
"output_type": "execute_result"
}
@@ -1098,7 +1131,7 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 108,
"id": "4216c512",
"metadata": {},
"outputs": [
@@ -1109,7 +1142,7 @@
" [ 4, 14]])"
]
},
"execution_count": 43,
"execution_count": 108,
"metadata": {},
"output_type": "execute_result"
}
@@ -1124,7 +1157,7 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 109,
"id": "0eec244e",
"metadata": {},
"outputs": [
@@ -1136,7 +1169,7 @@
" [6, 6]])"
]
},
"execution_count": 44,
"execution_count": 109,
"metadata": {},
"output_type": "execute_result"
}
@@ -1152,7 +1185,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 110,
"id": "bb8d128a",
"metadata": {},
"outputs": [
@@ -1162,7 +1195,7 @@
"array([1.6, 3.2])"
]
},
"execution_count": 45,
"execution_count": 110,
"metadata": {},
"output_type": "execute_result"
}
@@ -1179,7 +1212,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 111,
"id": "af55cce3",
"metadata": {},
"outputs": [
@@ -1191,7 +1224,7 @@
" [10, 20, 30]])"
]
},
"execution_count": 46,
"execution_count": 111,
"metadata": {},
"output_type": "execute_result"
}
@@ -1244,7 +1277,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 112,
"id": "0194c4b4",
"metadata": {},
"outputs": [
@@ -1254,7 +1287,7 @@
"np.int64(1)"
]
},
"execution_count": 47,
"execution_count": 112,
"metadata": {},
"output_type": "execute_result"
}
@@ -1267,7 +1300,7 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 113,
"id": "5b201131",
"metadata": {},
"outputs": [
@@ -1277,7 +1310,7 @@
"6"
]
},
"execution_count": 48,
"execution_count": 113,
"metadata": {},
"output_type": "execute_result"
}
@@ -1290,7 +1323,7 @@
},
{
"cell_type": "code",
"execution_count": 49,
"execution_count": 114,
"id": "e73fbd22",
"metadata": {},
"outputs": [
@@ -1300,7 +1333,7 @@
"array([5, 7])"
]
},
"execution_count": 49,
"execution_count": 114,
"metadata": {},
"output_type": "execute_result"
}
@@ -1314,7 +1347,7 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 115,
"id": "01229cfb",
"metadata": {},
"outputs": [],
@@ -1326,7 +1359,7 @@
},
{
"cell_type": "code",
"execution_count": 51,
"execution_count": 116,
"id": "fd882d6c",
"metadata": {},
"outputs": [
@@ -1336,7 +1369,7 @@
"np.float64(2.5)"
]
},
"execution_count": 51,
"execution_count": 116,
"metadata": {},
"output_type": "execute_result"
}
@@ -1348,7 +1381,7 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 117,
"id": "ba88c2f7",
"metadata": {},
"outputs": [
@@ -1358,7 +1391,7 @@
"array([2., 3.])"
]
},
"execution_count": 52,
"execution_count": 117,
"metadata": {},
"output_type": "execute_result"
}
@@ -1370,7 +1403,7 @@
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 118,
"id": "b49ff53c",
"metadata": {},
"outputs": [
@@ -1380,7 +1413,7 @@
"array([1.5, 3.5])"
]
},
"execution_count": 53,
"execution_count": 118,
"metadata": {},
"output_type": "execute_result"
}
@@ -1392,7 +1425,7 @@
},
{
"cell_type": "code",
"execution_count": 54,
"execution_count": 119,
"id": "fa48f9a5",
"metadata": {},
"outputs": [
@@ -1402,7 +1435,7 @@
"array([1.5, 3.5])"
]
},
"execution_count": 54,
"execution_count": 119,
"metadata": {},
"output_type": "execute_result"
}
@@ -1415,7 +1448,7 @@
},
{
"cell_type": "code",
"execution_count": 55,
"execution_count": 120,
"id": "3ee7e4c9",
"metadata": {},
"outputs": [],
@@ -1440,7 +1473,7 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": 121,
"id": "6d37c412",
"metadata": {},
"outputs": [
@@ -1476,7 +1509,7 @@
},
{
"cell_type": "code",
"execution_count": 57,
"execution_count": 122,
"id": "b0a7a95f",
"metadata": {},
"outputs": [
@@ -1510,7 +1543,7 @@
},
{
"cell_type": "code",
"execution_count": 58,
"execution_count": 123,
"id": "713cbe61",
"metadata": {},
"outputs": [
@@ -1553,7 +1586,7 @@
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": 124,
"id": "0ef952bd",
"metadata": {},
"outputs": [
@@ -1601,7 +1634,7 @@
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": 125,
"id": "5afe68f8",
"metadata": {},
"outputs": [
@@ -1634,7 +1667,7 @@
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": 126,
"id": "a1c381ad",
"metadata": {},
"outputs": [
@@ -1670,7 +1703,7 @@
},
{
"cell_type": "code",
"execution_count": 62,
"execution_count": 127,
"id": "5085fc72",
"metadata": {},
"outputs": [
@@ -1710,7 +1743,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 128,
"id": "37870aa6",
"metadata": {},
"outputs": [