Skip to content

Commit 3d1ee76

Browse files
committed
algebra update
1 parent 851757e commit 3d1ee76

10 files changed

+1818
-67
lines changed

2a. Arange-Oscillation.ipynb

+14-40
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 1,
12+
"execution_count": 6,
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
@@ -23,12 +23,12 @@
2323
"cell_type": "markdown",
2424
"metadata": {},
2525
"source": [
26-
"$Y =Asin(\\omega t + \\phi)$"
26+
"$ Y = Asin(\\omega t + \\phi )$"
2727
]
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 2,
31+
"execution_count": 7,
3232
"metadata": {},
3333
"outputs": [
3434
{
@@ -38,7 +38,7 @@
3838
" 5.999e+01])"
3939
]
4040
},
41-
"execution_count": 2,
41+
"execution_count": 7,
4242
"metadata": {},
4343
"output_type": "execute_result"
4444
}
@@ -51,7 +51,7 @@
5151
},
5252
{
5353
"cell_type": "code",
54-
"execution_count": 3,
54+
"execution_count": 8,
5555
"metadata": {},
5656
"outputs": [
5757
{
@@ -61,7 +61,7 @@
6161
" -0.28570267, -0.29527141])"
6262
]
6363
},
64-
"execution_count": 3,
64+
"execution_count": 8,
6565
"metadata": {},
6666
"output_type": "execute_result"
6767
}
@@ -72,7 +72,7 @@
7272
},
7373
{
7474
"cell_type": "code",
75-
"execution_count": 4,
75+
"execution_count": 9,
7676
"metadata": {},
7777
"outputs": [
7878
{
@@ -82,7 +82,7 @@
8282
" 1.88401311e+02, 1.88432727e+02, 1.88464143e+02])"
8383
]
8484
},
85-
"execution_count": 4,
85+
"execution_count": 9,
8686
"metadata": {},
8787
"output_type": "execute_result"
8888
}
@@ -101,7 +101,7 @@
101101
},
102102
{
103103
"cell_type": "code",
104-
"execution_count": 5,
104+
"execution_count": 10,
105105
"metadata": {},
106106
"outputs": [
107107
{
@@ -129,12 +129,11 @@
129129
"'''create oscillation: Y = Asin(wt)| w = 2.pi.f'''\n",
130130
"ys = amp*np.sin(ts*(2*np.pi*freq))\n",
131131
"\n",
132-
"lb= \"amp: \"+str(amp) + \",freq:\"+str(freq) \n",
132+
"lb = \"amp: \" + str(amp) + \",freq:\" + str(freq) \n",
133133
"plt.plot(ts,ys, label = lb)\n",
134134
" \n",
135135
"plt.xlabel(\"Time in seconds\") \n",
136136
"plt.ylabel(\"Displacement\")\n",
137-
"plt.axis()\n",
138137
"plt.legend()\n",
139138
"plt.show()"
140139
]
@@ -148,7 +147,7 @@
148147
},
149148
{
150149
"cell_type": "code",
151-
"execution_count": 9,
150+
"execution_count": 11,
152151
"metadata": {},
153152
"outputs": [
154153
{
@@ -198,7 +197,7 @@
198197
},
199198
{
200199
"cell_type": "code",
201-
"execution_count": 7,
200+
"execution_count": 15,
202201
"metadata": {},
203202
"outputs": [
204203
{
@@ -231,7 +230,7 @@
231230
"'''create a plot'''\n",
232231
"plt.plot(ts,ys, label= \"Superposed oscillation\")\n",
233232
"plt.legend()\n",
234-
"plt.show() "
233+
"plt.show()"
235234
]
236235
},
237236
{
@@ -248,31 +247,6 @@
248247
"-----------"
249248
]
250249
},
251-
{
252-
"cell_type": "code",
253-
"execution_count": null,
254-
"metadata": {},
255-
"outputs": [],
256-
"source": [
257-
"fourierTransform = np.fft.fft(ys)/len(ys) # Normalize amplitude\n",
258-
"fourierTransform = fourierTransform[range(int(len(ys)/2))] # Exclude sampling frequency\n",
259-
"\n",
260-
"tpCount = len(ys)\n",
261-
"values = np.arange(int(tpCount/2))\n",
262-
"timePeriod = tpCount/fs\n",
263-
"frequencies = values/timePeriod\n",
264-
"\n",
265-
" \n",
266-
"\n",
267-
"# Frequency domain representation\n",
268-
"plt.title('Fourier transform depicting the frequency components')\n",
269-
"plt.scatter(frequencies, abs(fourierTransform))\n",
270-
"plt.xlabel('Frequency')\n",
271-
"plt.ylabel('Amplitude')\n",
272-
"plt.xlim(0.1,0.4)\n",
273-
"plt.show()"
274-
]
275-
},
276250
{
277251
"cell_type": "markdown",
278252
"metadata": {},
@@ -284,7 +258,7 @@
284258
},
285259
{
286260
"cell_type": "code",
287-
"execution_count": 28,
261+
"execution_count": 14,
288262
"metadata": {},
289263
"outputs": [],
290264
"source": [

2c. Arange-FourierSeries.ipynb

+5-2
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,20 @@
340340
"plt.figure(figsize = [15,4])\n",
341341
"\n",
342342
"k = 1\n",
343-
"for n in [i for i in range(10) if i%2 !=0]:\n",
343+
"for n in [i for i in range(10) if i%2 != 0]:\n",
344344
" if n == 1:\n",
345345
" '''taking care of first term'''\n",
346346
" fi = (4/np.pi)*(1/n)*np.sin(n*np.pi*thetas/float(L))\n",
347347
" plt.plot(thetas,fi, label = \"first term\")\n",
348348
" ff = fi\n",
349+
" \n",
349350
" else:\n",
350351
" '''terms following first term'''\n",
351352
" fi = ff + (4/np.pi)*(1/n)*np.sin(n*np.pi*thetas/float(L))\n",
352353
" plt.plot(thetas,fi, label = \"sum of \"+str(k)+\" terms\")\n",
354+
" \n",
353355
" ff = fi\n",
356+
" \n",
354357
" k = k+1\n",
355358
" \n",
356359
"plt.legend()\n",
@@ -363,7 +366,7 @@
363366
"cell_type": "markdown",
364367
"metadata": {},
365368
"source": [
366-
"#### Sum of all n-terms"
369+
"#### 3. Sum of all n-terms"
367370
]
368371
},
369372
{

3.Meshgrid.ipynb renamed to 3. Meshgrid.ipynb

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"source": [
3535
"xs = np.arange(10)\n",
3636
"ys = np.arange(10)\n",
37+
"\n",
3738
"XG,YG = np.meshgrid(xs,ys)"
3839
]
3940
},
@@ -184,7 +185,7 @@
184185
"xs = np.arange(-3,3,1/ns)\n",
185186
"ys = np.arange(-3,3,1/ns)\n",
186187
"\n",
187-
"XG, YG = np.meshgrid(xs, ys, sparse=True) "
188+
"XG,YG = np.meshgrid(xs, ys, sparse=True) "
188189
]
189190
},
190191
{
@@ -304,6 +305,7 @@
304305
"source": [
305306
"from matplotlib import cm\n",
306307
"from mpl_toolkits.mplot3d import Axes3D\n",
308+
"\n",
307309
"fig = plt.figure(figsize = [8,6])\n",
308310
"ax = fig.gca(projection='3d')\n",
309311
"\n",

3a. Meshgrid-SphericalHrmonics.ipynb

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"## Meshgrid : ```mgrid```"
7+
"## Meshgrid : Spherical Harmonics"
88
]
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 66,
12+
"execution_count": 6,
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
@@ -38,7 +38,7 @@
3838
},
3939
{
4040
"cell_type": "code",
41-
"execution_count": 84,
41+
"execution_count": 7,
4242
"metadata": {},
4343
"outputs": [],
4444
"source": [
@@ -49,7 +49,7 @@
4949
},
5050
{
5151
"cell_type": "code",
52-
"execution_count": 85,
52+
"execution_count": 8,
5353
"metadata": {},
5454
"outputs": [],
5555
"source": [
@@ -65,7 +65,7 @@
6565
},
6666
{
6767
"cell_type": "code",
68-
"execution_count": 86,
68+
"execution_count": 9,
6969
"metadata": {},
7070
"outputs": [
7171
{
@@ -91,7 +91,7 @@
9191
"ZG = RG * np.cos(thetas)\n",
9292
"\n",
9393
"'''normalization with maximum value'''\n",
94-
"NG = R/R.max()\n",
94+
"NG = RG/RG.max()\n",
9595
"\n",
9696
"'''plot figure'''\n",
9797
"fig = plt.figure(figsize = [8,8])\n",
@@ -114,7 +114,7 @@
114114
},
115115
{
116116
"cell_type": "code",
117-
"execution_count": 87,
117+
"execution_count": 10,
118118
"metadata": {},
119119
"outputs": [
120120
{
@@ -140,7 +140,7 @@
140140
"ZG = RG * np.cos(thetas)\n",
141141
"\n",
142142
"'''normalization with maximum value'''\n",
143-
"NG = R/R.max()\n",
143+
"NG = RG/RG.max()\n",
144144
"\n",
145145
"'''plot figure'''\n",
146146
"fig = plt.figure(figsize = [8,8])\n",
@@ -163,7 +163,7 @@
163163
},
164164
{
165165
"cell_type": "code",
166-
"execution_count": 88,
166+
"execution_count": 11,
167167
"metadata": {},
168168
"outputs": [
169169
{
@@ -189,7 +189,7 @@
189189
"ZG = RG * np.cos(thetas)\n",
190190
"\n",
191191
"'''normalization with maximum value'''\n",
192-
"NG = R/R.max()\n",
192+
"NG = RG/RG.max()\n",
193193
"\n",
194194
"'''plot figure'''\n",
195195
"fig = plt.figure(figsize = [8,8])\n",
@@ -212,7 +212,7 @@
212212
},
213213
{
214214
"cell_type": "code",
215-
"execution_count": 89,
215+
"execution_count": 19,
216216
"metadata": {},
217217
"outputs": [
218218
{
@@ -238,7 +238,7 @@
238238
"ZG = RG * np.cos(thetas)\n",
239239
"\n",
240240
"'''normalization with maximum value'''\n",
241-
"NG = R/R.max()\n",
241+
"NG = RG/RG.max()\n",
242242
"\n",
243243
"'''plot figure'''\n",
244244
"fig = plt.figure(figsize = [8,8])\n",

5. Algebra.ipynb renamed to 4. Algebra.ipynb

+4-12
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,14 @@
1717
},
1818
{
1919
"cell_type": "code",
20-
"execution_count": 1,
20+
"execution_count": 3,
2121
"metadata": {},
22-
"outputs": [
23-
{
24-
"name": "stderr",
25-
"output_type": "stream",
26-
"text": [
27-
"UsageError: Line magic function `%` not found.\n"
28-
]
29-
}
30-
],
22+
"outputs": [],
3123
"source": [
3224
"import numpy as np\n",
3325
"import seaborn as sns\n",
3426
"import matplotlib.pyplot as plt\n",
35-
"% matplotlib inline\n",
27+
"%matplotlib inline\n",
3628
"sns.set()"
3729
]
3830
},
@@ -382,7 +374,7 @@
382374
"name": "python",
383375
"nbconvert_exporter": "python",
384376
"pygments_lexer": "ipython3",
385-
"version": "3.7.1"
377+
"version": "3.7.3"
386378
},
387379
"widgets": {
388380
"state": {},

0 commit comments

Comments
 (0)