{
 "metadata": {
  "name": "",
  "signature": "sha256:22eee2ba9d1da7cc9449ec91cc33a421ca03a319ba4cd73132a5cc29034c4568"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter12-Network Synthesis"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg12.2"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Network Synthesis : example 12.2 : (pg 12.2)\n",
      "import numpy\n",
      "p1 = numpy.array([1,0,5,0,4])\n",
      "p2 = numpy.array([1,0,3,0])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "[q3,r3]=numpy.polydiv(r1,r2);\n",
      "print \"\\nEven part of P(s) = (s^4)+(5s^3)+4\"\n",
      "print \"\\nOdd part of P(s) = (s^3)+(3s)\"\n",
      "print \"\\nQ(s)= m(s)/n(s)\"\n",
      "# values of quotients in continued fraction expansion\n",
      "print (q);\n",
      "print (q1);\n",
      "print (q2);\n",
      "print (q3);\n",
      "print \"Since all the quotient terms are positive, P(s) is hurwitz\";\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Even part of P(s) = (s^4)+(5s^3)+4\n",
        "\n",
        "Odd part of P(s) = (s^3)+(3s)\n",
        "\n",
        "Q(s)= m(s)/n(s)\n",
        "[ 1.  0.]\n",
        "[ 0.5  0. ]\n",
        "[ 2.  0.]\n",
        "[ 0.25  0.  ]\n",
        "Since all the quotient terms are positive, P(s) is hurwitz\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg12.2"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Network Synthesis : example 12.3 : (pg 12.2 & 12.3)\n",
      "import numpy\n",
      "p1=numpy.array([1,0,5,0])     \n",
      "p2=numpy.array([4,0,2])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "print(\"\\nEven part of P(s) = ((4*s^2)+(2))\");\n",
      "print(\"\\nOdd part of P(s) = ((s^3)+(5*(s)))\");\n",
      "print(\"\\nQ(s)= n(s)/m(s)\");\n",
      "# values of quotients in continued fraction expansion\n",
      "print(q);\n",
      "print(q1);\n",
      "print(q2);\n",
      "print(\"\\nSince all the quotient terms are positive, P(s) is hurwitz\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Even part of P(s) = ((4*s^2)+(2))\n",
        "\n",
        "Odd part of P(s) = ((s^3)+(5*(s)))\n",
        "\n",
        "Q(s)= n(s)/m(s)\n",
        "[ 0.25  0.  ]\n",
        "[ 0.88888889  0.        ]\n",
        "[ 2.25  0.  ]\n",
        "\n",
        "Since all the quotient terms are positive, P(s) is hurwitz\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg12.3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Network Synthesis : example 12.4 : (pg 12.3)\n",
      "import numpy\n",
      "p1=numpy.array([1,0,3,0,12])\n",
      "p2=numpy.array([1,0,2,0])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "[q3,r3]=numpy.polydiv(r1,r2);\n",
      "print(\"\\nEven part of P(s) = ((s^4)+(3*(s)^2)+12)\");\n",
      "print(\"\\nOdd part of P(s) = ((s^3)+(2*s))\");\n",
      "print(\"\\nQ(s)= m(s)/n(s)\");\n",
      "## values of quotients in continued fraction expansion\n",
      "print(q);\n",
      "print(q1);\n",
      "print(q2);\n",
      "print(q3);\n",
      "print(\"\\nSince two quotient terms are negative, P(s) is  not hurwitz\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Even part of P(s) = ((s^4)+(3*(s)^2)+12)\n",
        "\n",
        "Odd part of P(s) = ((s^3)+(2*s))\n",
        "\n",
        "Q(s)= m(s)/n(s)\n",
        "[ 1.  0.]\n",
        "[ 1.  0.]\n",
        "[-0.1 -0. ]\n",
        "[-0.83333333  0.        ]\n",
        "\n",
        "Since two quotient terms are negative, P(s) is  not hurwitz\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg12.3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Network Synthesis : example 12.5 : (pg 12.3 & 12.4)\n",
      "import numpy\n",
      "p1=numpy.array([1,0,2,0,2])\n",
      "p2=numpy.array([1,0,3,0])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "[q3,r3]=numpy.polydiv(r1,r2);\n",
      "print(\"\\nEven part of P(s) = ((s^4)+(2*(s)^2)+2)\");\n",
      "print(\"\\nOdd part of P(s) = (s^3)+(3s)\");\n",
      "print(\"\\nQ(s)= m(s)/n(s)\");\n",
      "## values of quotients in continued fraction expansion\n",
      "print(q);\n",
      "print(q1);\n",
      "print(q2);\n",
      "print(q3);\n",
      "print(\"\\nSince two terms are negative, P(s) is  not hurwitz\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Even part of P(s) = ((s^4)+(2*(s)^2)+2)\n",
        "\n",
        "Odd part of P(s) = (s^3)+(3s)\n",
        "\n",
        "Q(s)= m(s)/n(s)\n",
        "[ 1.  0.]\n",
        "[-1. -0.]\n",
        "[-0.2  0. ]\n",
        "[ 2.5  0. ]\n",
        "\n",
        "Since two terms are negative, P(s) is  not hurwitz\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg12.4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Network Synthesis : example 12.6 : (pg 12.4)\n",
      "import numpy\n",
      "p1=numpy.array([2,0,6,0,1])\n",
      "p2=numpy.array([5,0,3,0])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "[q3,r3]=numpy.polydiv(r1,r2);\n",
      "print(\"\\nEven part of P(s) = ((2*s^4)+(6*(s)^2)+1)\");\n",
      "print(\"\\nOdd part of P(s) = ((5*s^3)+(3*s))\");\n",
      "print(\"\\nQ(s)= m(s)/n(s)\");\n",
      "## values of quotients in continued fraction expansion\n",
      "print(q);\n",
      "print(q1);\n",
      "print(q2);\n",
      "print(q3);\n",
      "print(\"\\nSince all the quotient terms are positive, P(s) is hurwitz\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Even part of P(s) = ((2*s^4)+(6*(s)^2)+1)\n",
        "\n",
        "Odd part of P(s) = ((5*s^3)+(3*s))\n",
        "\n",
        "Q(s)= m(s)/n(s)\n",
        "[ 0.4  0. ]\n",
        "[ 1.04166667  0.        ]\n",
        "[ 2.45106383  0.        ]\n",
        "[ 1.95833333  0.        ]\n",
        "\n",
        "Since all the quotient terms are positive, P(s) is hurwitz\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg12.4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Network Synthesis : example 12.7 : (pg 12.4 & 12.5)\n",
      "import numpy\n",
      "p1=numpy.array([1,0,6,0,8])\n",
      "\n",
      "p2=numpy.array([7,0,21,0])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "[q3,r3]=numpy.polydiv(r1,r2);\n",
      "print(\"\\nEven part of P(s) = ((s^4)+(6*(s)^2)+8)\");\n",
      "print(\"\\nOdd part of P(s) = (7*(s^3)+(21*s))\");\n",
      "print(\"\\nQ(s)= m(s)/n(s)\");\n",
      "## values of quotients in continued fraction expansion\n",
      "print(q);\n",
      "print(q1);\n",
      "print(q2);\n",
      "print(q3);\n",
      "print(\"\\nSince all the quotient terms are positive, P(s) is hurwitz\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Even part of P(s) = ((s^4)+(6*(s)^2)+8)\n",
        "\n",
        "Odd part of P(s) = (7*(s^3)+(21*s))\n",
        "\n",
        "Q(s)= m(s)/n(s)\n",
        "[ 0.14285714  0.        ]\n",
        "[ 2.33333333  0.        ]\n",
        "[ 1.28571429  0.        ]\n",
        "[ 0.29166667  0.        ]\n",
        "\n",
        "Since all the quotient terms are positive, P(s) is hurwitz\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex8-pg12.5"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Network Synthesis : example 12.8 : (pg 12.5)\n",
      "import numpy\n",
      "p1=numpy.array([1,0,5,0,10])\n",
      "\n",
      "p2=numpy.array([5,0,4,0])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "[q3,r3]=numpy.polydiv(r1,r2);\n",
      "print(\"\\nEven part of P(s) = ((s^4)+(5*(s)^2)+10)\");\n",
      "print(\"\\nOdd part of P(s) = (5*(s^3)+(4*s))\");\n",
      "print(\"\\nQ(s)= m(s)/n(s)\");\n",
      "## values of quotients in continued fraction expansion\n",
      "print(q);\n",
      "print(q1);\n",
      "print(q2);\n",
      "print(q3);\n",
      "print(\"\\nSince two terms are negative, P(s) is not hurwitz\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Even part of P(s) = ((s^4)+(5*(s)^2)+10)\n",
        "\n",
        "Odd part of P(s) = (5*(s^3)+(4*s))\n",
        "\n",
        "Q(s)= m(s)/n(s)\n",
        "[ 0.2  0. ]\n",
        "[ 1.19047619  0.        ]\n",
        "[-0.5313253 -0.       ]\n",
        "[-0.79047619  0.        ]\n",
        "\n",
        "Since two terms are negative, P(s) is not hurwitz\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex9-pg12.6"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Network Synthesis : example 12.9 : (pg 12.6)\n",
      "import numpy\n",
      "p1=numpy.array([1,0,3,0,2,0])\n",
      "p2=numpy.array([5,0,9,0,2])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "[q3,r3]=numpy.polydiv(r1,r2);\n",
      "[q4,r4]=numpy.polydiv(r2,r3);\n",
      "print(\"\\n P(s) = ((s^5)+(3*(s^3))+(2*s))\");\n",
      "print(\"\\n d/ds.P(s)= ((5*(s^4))+9*(s^2)+2)\");\n",
      "print(\"\\nQ(s)=P(s)/d/ds.P(s)\");\n",
      "## values of quotients in continued fraction expansion\n",
      "print(q);\n",
      "print(q1);\n",
      "print(q2);\n",
      "print(q3);\n",
      "print(q4);\n",
      "print(\"\\nSince all the quotient terms are positive, P(s) is hurwitz\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " P(s) = ((s^5)+(3*(s^3))+(2*s))\n",
        "\n",
        " d/ds.P(s)= ((5*(s^4))+9*(s^2)+2)\n",
        "\n",
        "Q(s)=P(s)/d/ds.P(s)\n",
        "[ 0.2  0. ]\n",
        "[ 4.16666667  0.        ]\n",
        "[ 0.51428571  0.        ]\n",
        "[ 4.08333333  0.        ]\n",
        "[ 0.28571429  0.        ]\n",
        "\n",
        "Since all the quotient terms are positive, P(s) is hurwitz\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex10-pg12.6"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Network Synthesis : example 12.10 : (pg 12.6 & 12.7)\n",
      "import numpy\n",
      "p1=numpy.array([1,0,1,0,1,0])\n",
      "p2=numpy.array([5,0,3,0,1])\n",
      "[q,r]=numpy.polydiv(p1,p2);\n",
      "[q1,r1]=numpy.polydiv(p2,r);\n",
      "[q2,r2]=numpy.polydiv(r,r1);\n",
      "[q3,r3]=numpy.polydiv(r1,r2);\n",
      "[q4,r4]=numpy.polydiv(r2,r3);\n",
      "print(\"\\n P(s) = ((s^5)+((s^3))+(s))\");\n",
      "print(\"\\n d/ds.P(s)= ((5*(s^4))+3*(s^2)+1)\");\n",
      "print(\"\\nQ(s)=P(s)/d/ds.P(s)\");\n",
      "## values of quotients in continued fraction expansion\n",
      "print(q);\n",
      "print(q1);\n",
      "print(q2);\n",
      "print(q3);\n",
      "print(q4);\n",
      "print(\"\\nSince two quotient terms are negative, P(s) is not hurwitz\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " P(s) = ((s^5)+((s^3))+(s))\n",
        "\n",
        " d/ds.P(s)= ((5*(s^4))+3*(s^2)+1)\n",
        "\n",
        "Q(s)=P(s)/d/ds.P(s)\n",
        "[ 0.2  0. ]\n",
        "[ 12.5   0. ]\n",
        "[-0.05714286 -0.        ]\n",
        "[-8.16666667  0.        ]\n",
        "[ 0.85714286  0.        ]\n",
        "\n",
        "Since two quotient terms are negative, P(s) is not hurwitz\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}