1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chapter 4 - Polynomials"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Page 121 Example 4.3"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"C is the field of complex numbers\n",
"f = x**2 + 2\n",
"if a = C and z belongs to C, then f(z) = z**2 + 2\n",
"f(2) = 6\n",
"f(1+1J/1-1J) = (1+0j)\n",
"----------------------------------------\n",
"If a is the algebra of all 2*2 matrices over C and\n",
"B = \n",
"[[ 1 0]\n",
" [-1 2]]\n",
"[[ 3. 0.]\n",
" [ 1. 6.]] then, f(B) = \n",
"----------------------------------------\n",
"If a is algebra of all linear operators on C**3\n",
"And T is element of a as:\n",
"T(c1,c2,c3) = (i*2**1/2*c1,c2,i*2**1/2*c3)\n",
"Then, f(T)(c1,c2,c3) = (0,3*c2,0)\n",
"----------------------------------------\n",
"If a is the algebra of all polynomials over C\n",
"And, g = x**4 + 3.0*I\n",
"Then f(g) = (16+3j)\n"
]
}
],
"source": [
"import numpy as np\n",
"import sympy as sp\n",
"from sympy.polys.polyfuncs import horner\n",
"print 'C is the field of complex numbers'\n",
"x = sp.Symbol(\"x\")\n",
"def f(x):\n",
" ff= x**2 + 2\n",
" return ff\n",
"print 'f = ',f(x)\n",
"#part a\n",
"print 'if a = C and z belongs to C, then f(z) = z**2 + 2'\n",
"print 'f(2) = ',f(2)\n",
"\n",
"\n",
"print 'f(1+1J/1-1J) = ',f((1+1J)/(1-1J))\n",
"print '----------------------------------------'\n",
"\n",
"\n",
"#part b\n",
"print 'If a is the algebra of all 2*2 matrices over C and'\n",
"B = np.array([[1 ,0],[-1, 2]])\n",
"print 'B = \\n',B\n",
"print 2*np.identity(2) + B**2,'then, f(B) = '\n",
"print '----------------------------------------'\n",
"\n",
"#part c\n",
"print 'If a is algebra of all linear operators on C**3'\n",
"print 'And T is element of a as:'\n",
"print 'T(c1,c2,c3) = (i*2**1/2*c1,c2,i*2**1/2*c3)'\n",
"print 'Then, f(T)(c1,c2,c3) = (0,3*c2,0)'\n",
"print '----------------------------------------'\n",
"#part d\n",
"print 'If a is the algebra of all polynomials over C'\n",
"def g(x):\n",
" gg= x**4 + 3*1J\n",
" return gg\n",
"print 'And, g = ',g(x)\n",
"print 'Then f(g) = ',g(2)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Page 131 Example 4.7"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"M = (x+2)F[x] + (x**2 + 8x + 16)F[x]\n",
"We assert, M = F[x]\n",
"M contains: x**2 - x*(x + 2) + 8*x + 16\n",
"And hence M contains: x**2 - x*(x + 2) + 2*x + 4\n",
"Thus the scalar polynomial 1 belongs to M as well all its multiples.\n"
]
}
],
"source": [
"import sympy as sp\n",
"x = sp.Symbol('x')\n",
"p1 = x + 2#\n",
"p2 = x**2 + 8*x + 16#\n",
"print 'M = (x+2)F[x] + (x**2 + 8x + 16)F[x]'\n",
"print 'We assert, M = F[x]'\n",
"print 'M contains:',\n",
"t = p2 - x*p1#\n",
"print t\n",
"print 'And hence M contains:',\n",
"print t - 6*p1\n",
"print 'Thus the scalar polynomial 1 belongs to M as well all its multiples.'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Page 133 Example 4.8"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"p1 = x + 2\n",
"p2 = x**2 + 8*x + 16\n",
"M = (x+2)F[x] + (x**2 + 8x + 16)F[x]\n",
"We assert, M = F[x]\n",
"M contains: x**2 - x*(x + 2) + 8*x + 16\n",
"And hence M contains: x**2 - x*(x + 2) + 2*x + 4\n",
"Thus the scalar polynomial 1 belongs to M as well all its multiples\n",
"So, gcd(p1,p2) = 1\n",
"----------------------------------------------\n",
"p1 = (x - 2)**2*(x + 1.0*I)\n",
"p2 = (x - 2)*(x**2 + 1)\n",
"M = (x - 2)**2*(x+1J)F[x] + (x-2)*(x**2 + 1\n",
"The ideal M contains p1 - p2 i.e., (x - 2)**2*(x + 1.0*I) - (x - 2)*(x**2 + 1)\n",
"Hence it contains (x-2)(x+i), which is monic and divides both,\n",
"So, gcd(p1,p2) = (x-2)(x+i)\n",
"----------------------------------------------\n"
]
}
],
"source": [
"import sympy as sp\n",
"x = sp.Symbol('x')\n",
"\n",
"#part a\n",
"p1 = x + 2#\n",
"p2 = x**2 + 8*x + 16#\n",
"print 'p1 = ',p1\n",
"print 'p2 = ',p2\n",
"print 'M = (x+2)F[x] + (x**2 + 8x + 16)F[x]'\n",
"print 'We assert, M = F[x]'\n",
"print 'M contains:',\n",
"t = p2 - x*p1#\n",
"print t\n",
"print 'And hence M contains:',\n",
"print t - 6*p1\n",
"print 'Thus the scalar polynomial 1 belongs to M as well all its multiples'\n",
"print 'So, gcd(p1,p2) = 1'\n",
"print '----------------------------------------------'\n",
"#part b\n",
"p1 = (x - 2)**2*(x+1J)#\n",
"p2 = (x-2)*(x**2 + 1)#\n",
"print 'p1 = ',p1\n",
"print 'p2 = ',p2\n",
"print 'M = (x - 2)**2*(x+1J)F[x] + (x-2)*(x**2 + 1'\n",
"print 'The ideal M contains p1 - p2 i.e.,',\n",
"print p1 - p2\n",
"print 'Hence it contains (x-2)(x+i), which is monic and divides both,'\n",
"print 'So, gcd(p1,p2) = (x-2)(x+i)'\n",
"print '----------------------------------------------'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Page 133 Example 4.9"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"M is the ideal in F[x] generated by:\n",
"(x-1)*(x+2)**2\n",
"(x+2)**2*(x+3)\n",
"(x-3) and\n",
"M = (x-1)*(x+2)**2 F[x] + (x+2)**2*(x-3) + (x-3)\n",
"Then M contains: 0\n",
"i.e., M contains (x+2)**2\n",
"and since, (x+2)**2 = (x-3)(x-7) - 17\n",
"So M contains the scalar polynomial 1.\n",
"So, M = F[x] and given polynomials are relatively prime.\n"
]
}
],
"source": [
"import sympy as sp\n",
"x = sp.Symbol('x')\n",
"\n",
"print 'M is the ideal in F[x] generated by:'\n",
"print '(x-1)*(x+2)**2'\n",
"print '(x+2)**2*(x+3)'\n",
"print '(x-3)','and'\n",
"p1 = (x-1)*(x+2)**2#\n",
"p2 = (x+2)**2*(x-3)#\n",
"p3 = (x-3)#\n",
"print 'M = (x-1)*(x+2)**2 F[x] + (x+2)**2*(x-3) + (x-3)'\n",
"print 'Then M contains:',\n",
"t = 1/2*(x+2)**2*((x-1) - (x-3))#\n",
"print t\n",
"print 'i.e., M contains (x+2)**2'\n",
"print 'and since, (x+2)**2 = (x-3)(x-7) - 17'\n",
"print 'So M contains the scalar polynomial 1.'\n",
"print 'So, M = F[x] and given polynomials are relatively prime.'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Page 135 Example 4.10"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x**2 + 1 P = \n",
"P is reducible over complex numbers as: = x**2 + 1\n",
"(x-i)(x+i)\n",
"Whereas, P is irreducible over real numbers as: = x**2 + 1\n",
"(ax + b)(ax + b)\n",
"For, a,a,b,b to be in R,\n",
"aa = 1\n",
"ab + ba = 0\n",
"bb = 1\n",
"=> a**2 + b**2 = 0\n",
"=> a = b = 0\n"
]
}
],
"source": [
"import sympy as sp\n",
"x = sp.Symbol('x')\n",
"P = x**2 + 1#\n",
"print P,'P = '\n",
"print 'P is reducible over complex numbers as: ',\n",
"print '=',P\n",
"print '(x-i)(x+i)'\n",
"print 'Whereas, P is irreducible over real numbers as:',\n",
"print '=',P\n",
"print '(ax + b)(a''x + b'')'\n",
"print 'For, a,a'',b,b'' to be in R,'\n",
"print 'aa'' = 1'\n",
"print 'ab'' + ba'' = 0'\n",
"print 'bb'' = 1'\n",
"print '=> a**2 + b**2 = 0'\n",
"print '=> a = b = 0'"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|