{ "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": [ "from numpy import array,identity\n", "from sympy import Symbol\n", "print 'C is the field of complex numbers'\n", "x = 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 = array([[1 ,0],[-1, 2]])\n", "print 'B = \\n',B\n", "print 2*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": [ "from sympy import Symbol\n", "x = 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": [ "from sympy import Symbol\n", "x = 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": [ "from sympy import Symbol\n", "x = 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": [ "from sympy import Symbol\n", "x = 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 }