{
 "metadata": {
  "name": "",
  "signature": "sha256:ddb3981597525229ad0e3a4e8d351738f910ed199ce10833b7bffa5c5e341de3"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter11-Two-Port Networks"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex16-pg11.29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.16 :(pg11.39 )\n",
      "V1s=25.;\n",
      "import math\n",
      "I1s=1.;\n",
      "I2s=2.;\n",
      "V1o=10.;\n",
      "V2o=50.;\n",
      "I2o=2.;\n",
      "h11=(V1s/I1s);\n",
      "h21=(I2s/I1s);\n",
      "h12=(V1o/V2o);\n",
      "h22=(I2o/V2o);\n",
      "print\"%s %.2f %s\"%(\"\\nh11 = V1/I1 = \",h11,\" Ohm\");##when V2=0\n",
      "print\"%s %.2f %s\"%(\"\\nh21= I2/I1 = \",h21,\"\");##when V2=0\n",
      "print\"%s %.2f %s\"%(\"\\nh12 = V1/V2 =\",h12,\"\");##when I1=0\n",
      "print\"%s %.2f %s\"%(\"\\nh22 = I2/V2 = \",h22,\" mho\");##when I1=0\n",
      "print(\"\\nth h-parameters are\");\n",
      "print([[h11 ,h12],[h21, h22]]);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "h11 = V1/I1 =  25.00  Ohm\n",
        "\n",
        "h21= I2/I1 =  2.00 \n",
        "\n",
        "h12 = V1/V2 = 0.20 \n",
        "\n",
        "h22 = I2/V2 =  0.04  mho\n",
        "\n",
        "th h-parameters are\n",
        "[[25.0, 0.2], [2.0, 0.04]]\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex19-pg11.49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.19 :(pg11.49 & 11.50)\n",
      "Z11=20.;\n",
      "import math\n",
      "Z22=30.;\n",
      "Z12=10.;\n",
      "Z21=10.;\n",
      "dZ=((Z11*Z22)-(Z12*Z21));\n",
      "Y11=(Z22/dZ);\n",
      "Y12=(-Z12/dZ);\n",
      "Y21=(-Z21/dZ);\n",
      "Y22=(Z11/dZ);\n",
      "A=(Z11/Z21);\n",
      "B=(dZ/Z21);\n",
      "C=(1./Z21);\n",
      "D=(Z22/Z21);\n",
      "print(\"\\nY-parameters\");\n",
      "print\"%s %.2f %s\"%(\"\\nY11 = Z22/dZ = \",Y11,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY12 = -Z12/dZ = \",Y12,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY21 = -Z21/dZ = \",Y21,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY22 = Z11/dZ = \",Y22,\" mho\");\n",
      "print(\"\\n Y-parameters are:\");\n",
      "print([[Y11, Y12],[Y21, Y22]]);##Y-parameters in matrix form\n",
      "print(\"\\nABCD parameters\");\n",
      "print\"%s %.2f %s\"%(\"\\nA = Z11/Z21 = \",A,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nB = dZ/Z21 = \",B,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nC = 1/Z21 = \",C,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nD = Z22/Z21 = \",D,\"\");\n",
      "print(\"\\n ABCD parameters are:\");\n",
      "print([[A ,B],[C ,D]]);##ABCD parameters in matrix form\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Y-parameters\n",
        "\n",
        "Y11 = Z22/dZ =  0.06  mho\n",
        "\n",
        "Y12 = -Z12/dZ =  -0.02  mho\n",
        "\n",
        "Y21 = -Z21/dZ =  -0.02  mho\n",
        "\n",
        "Y22 = Z11/dZ =  0.04  mho\n",
        "\n",
        " Y-parameters are:\n",
        "[[0.06, -0.02], [-0.02, 0.04]]\n",
        "\n",
        "ABCD parameters\n",
        "\n",
        "A = Z11/Z21 =  2.00 \n",
        "\n",
        "B = dZ/Z21 =  50.00 \n",
        "\n",
        "C = 1/Z21 =  0.10 \n",
        "\n",
        "D = Z22/Z21 =  3.00 \n",
        "\n",
        " ABCD parameters are:\n",
        "[[2.0, 50.0], [0.1, 3.0]]\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex20-pg11.50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.20 :(pg11.50 & 11.51)\n",
      "a=0.5;\n",
      "import math\n",
      "b=-0.2;\n",
      "d=1.\n",
      "print(\"\\nI1 =0.5V1-0.2V2 \\nI2=-0.2V1+V2\");\n",
      "print\"%s %.2f %s\"%(\"\\n Y11 =I1/V1 = \",a,\"mho\");##when V2 is 0 in the 1st eqn\n",
      "print\"%s %.2f %s\"%(\"\\n Y21 =I2/V1 = \",b,\" mho\");##when V2 is 0 in the 1st eqn\n",
      "print\"%s %.2f %s\"%(\"\\n Y12 =I1/V2 = \",b,\" mho\");##when V1 is 0 in the 2nd eqn\n",
      "print\"%s %.2f %s\"%(\"\\n Y22 =I2/V2 = \",d,\" mho\");##when V1 is 0 in the 2nd eqn\n",
      "print(\"\\nY-parameters are\");\n",
      "print([[a, b],[b ,d]]);\n",
      "dY=((a*d)-(b*b));\n",
      "Z11=(d/dY);\n",
      "Z12=(-b/dY);\n",
      "Z21=(-b/dY);\n",
      "Z22=(a/dY);\n",
      "A=(-d/b);\n",
      "C=(-dY/b);\n",
      "D=(-a/b);\n",
      "print\"%s %.2f %s\"%(\"\\ndY=Y11.Y22-Y12.Y21 =\",dY,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ11 = Y22/dY = \",Z11,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ12 = -Y12/dY = \",Z12,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ21 = -Y21/-dY = \",Z21,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ22 = Y11/dY = \",Z22,\" Ohm\");\n",
      "print(\"\\nZ-parameters :\");\n",
      "\n",
      "x=([[Z11, Z12],[Z21, Z22]])\n",
      "\n",
      "print(x)\n",
      "print\"%s %.2f %s\"%(\"\\nA =-Y22/Y21 =\",A,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nB = -1/Y21 =\",A,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nC = -dY/Y21 =\",C,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nD = -Y11/Y21 =\",D,\"\");\n",
      "print(\"\\nABCD parameters :\");\n",
      "print([[A, A],[C ,D]]);\n",
      "\n",
      "\n",
      "\n",
      "#due to round off error\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "I1 =0.5V1-0.2V2 \n",
        "I2=-0.2V1+V2\n",
        "\n",
        " Y11 =I1/V1 =  0.50 mho\n",
        "\n",
        " Y21 =I2/V1 =  -0.20  mho\n",
        "\n",
        " Y12 =I1/V2 =  -0.20  mho\n",
        "\n",
        " Y22 =I2/V2 =  1.00  mho\n",
        "\n",
        "Y-parameters are\n",
        "[[0.5, -0.2], [-0.2, 1.0]]\n",
        "\n",
        "dY=Y11.Y22-Y12.Y21 = 0.46 \n",
        "\n",
        "Z11 = Y22/dY =  2.17  Ohm\n",
        "\n",
        "Z12 = -Y12/dY =  0.43  Ohm\n",
        "\n",
        "Z21 = -Y21/-dY =  0.43  Ohm\n",
        "\n",
        "Z22 = Y11/dY =  1.09  Ohm\n",
        "\n",
        "Z-parameters :\n",
        "[[2.173913043478261, 0.4347826086956522], [0.4347826086956522, 1.0869565217391306]]\n",
        "\n",
        "A =-Y22/Y21 = 5.00 \n",
        "\n",
        "B = -1/Y21 = 5.00 \n",
        "\n",
        "C = -dY/Y21 = 2.30 \n",
        "\n",
        "D = -Y11/Y21 = 2.50 \n",
        "\n",
        "ABCD parameters :\n",
        "[[5.0, 5.0], [2.3, 2.5]]\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex22-pg11.52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.22 :(pg11.52 & 11.53)\n",
      "print(\"\\nApplying KVL to Mesh 1 \\nV1 = I1 - I3 - - - -(i)\");\n",
      "print(\"\\nApplying KVL to Mesh 2 \\nV2 = -4I2 + 2I3 - - - -(ii)\");\n",
      "print(\"\\nApplying KVL to Mesh 3 \\nI3 = (1/5)I1 + (4/5)I2 - - - -(iii)\");\n",
      "##substituting (iii) in (i) & (ii),we get\n",
      "print(\"\\nV1 = (4/5)I1 - (4/5)I2 \\nV2 = (2/5)I1 - (12/5)I2\");\n",
      "print(\"\\nZ-parameters:\");\n",
      "a=4./5.;b=-4/5.;c=2/5.;d=-12/5.;\n",
      "print([[a, b],[c, d]]);\n",
      "dZ=(a*d)-(b*c);\n",
      "Y11=(d/dZ);\n",
      "Y12=(-b/dZ);\n",
      "Y21=(-c/dZ);\n",
      "Y22=(a/dZ);\n",
      "print(\"\\nY-parameters are:\");\n",
      "print\"%s %.2f %s\"%(\"\\ndZ = Z11.Z22 - Z12.Z21 = \",dZ,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nY11 = Z22/dZ = \",Y11,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY12 = -Z12/dY = \",Y12,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY21 = -Z21/-dY = \",Y21,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY22 = Z11/dY = \",Y22,\" mho\");\n",
      "print([[Y11, Y12],[Y21, Y22]]); \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KVL to Mesh 1 \n",
        "V1 = I1 - I3 - - - -(i)\n",
        "\n",
        "Applying KVL to Mesh 2 \n",
        "V2 = -4I2 + 2I3 - - - -(ii)\n",
        "\n",
        "Applying KVL to Mesh 3 \n",
        "I3 = (1/5)I1 + (4/5)I2 - - - -(iii)\n",
        "\n",
        "V1 = (4/5)I1 - (4/5)I2 \n",
        "V2 = (2/5)I1 - (12/5)I2\n",
        "\n",
        "Z-parameters:\n",
        "[[0.8, -0.8], [0.4, -2.4]]\n",
        "\n",
        "Y-parameters are:\n",
        "\n",
        "dZ = Z11.Z22 - Z12.Z21 =  -1.60 \n",
        "\n",
        "Y11 = Z22/dZ =  1.50  mho\n",
        "\n",
        "Y12 = -Z12/dY =  -0.50  mho\n",
        "\n",
        "Y21 = -Z21/-dY =  0.25  mho\n",
        "\n",
        "Y22 = Z11/dY =  -0.50  mho\n",
        "[[1.5, -0.5000000000000001], [0.25000000000000006, -0.5000000000000001]]\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex23-pg11.53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.23 :(pg11.53 & 11.54)\n",
      "print(\"\\nApplying KVL to Mesh 1 \\nV1 = 4I1 - 2I3 - - - -(i)\");\n",
      "print(\"\\nApplying KVL to Mesh 2 \\nV2 = 4I2 + 2I3 - - - -(ii)\");\n",
      "print(\"\\nApplying KVL to Mesh 3 \\n-2I3 = I1 + I2 - - - -(iii)\");\n",
      "##substituting (iii) in (i) & (ii),we get\n",
      "print(\"\\nV1 = 5I1 + I2 \\nV2 = -I1 + 3I2\");\n",
      "print(\"\\nZ-parameters:\");\n",
      "a=5.;b=1.;c=-1.;d=3.;\n",
      "print([[a, b],[c ,d]]);\n",
      "dZ=(a*d)-(b*c);\n",
      "h11=(dZ/d);\n",
      "h12=(b/d);\n",
      "h21=(-c/d);\n",
      "h22=(.1/d);\n",
      "print\"%s %.2f %s\"%(\"\\ndZ = Z11.Z22 - Z12.Z21 =\",dZ,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nh11 = dZ/Z22 =  \",h11,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nh12 = Z12/Z22 = \",h12,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nh21 = -Z21/Z22 = \",h21,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nh22 = 1/Z22 = \",h22,\"\");\n",
      "print(\"\\nh-parameters are:\");\n",
      "print([[h11 ,h12],[h21 ,h22]]); "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KVL to Mesh 1 \n",
        "V1 = 4I1 - 2I3 - - - -(i)\n",
        "\n",
        "Applying KVL to Mesh 2 \n",
        "V2 = 4I2 + 2I3 - - - -(ii)\n",
        "\n",
        "Applying KVL to Mesh 3 \n",
        "-2I3 = I1 + I2 - - - -(iii)\n",
        "\n",
        "V1 = 5I1 + I2 \n",
        "V2 = -I1 + 3I2\n",
        "\n",
        "Z-parameters:\n",
        "[[5.0, 1.0], [-1.0, 3.0]]\n",
        "\n",
        "dZ = Z11.Z22 - Z12.Z21 = 16.00 \n",
        "\n",
        "h11 = dZ/Z22 =   5.33 \n",
        "\n",
        "h12 = Z12/Z22 =  0.33 \n",
        "\n",
        "h21 = -Z21/Z22 =  0.33 \n",
        "\n",
        "h22 = 1/Z22 =  0.03 \n",
        "\n",
        "h-parameters are:\n",
        "[[5.333333333333333, 0.3333333333333333], [0.3333333333333333, 0.03333333333333333]]\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex24-pg11.54"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.24 :(pg11.54 & 11.55)\n",
      "print(\"\\nApplying KCL to Node 3 \\nV3 = V2/3 - - - -(i)\");\n",
      "print(\"\\nI1 = 2V1 - (2/3)V2 - - - -(ii)\");\n",
      "print(\"\\nI2 = 3V2 - (V2/3) = (8/3)V2 - - - -(iii)\");\n",
      "##Comparing (iii) & (ii) ,we get\n",
      "print(\"\\nY-parameters:\");\n",
      "a=2;b=(-2/3.);c=0;d=(8/3.);\n",
      "print([[a, b],[b ,d]]);\n",
      "dY=((a*d)-(b*c));\n",
      "Z11=(d/dY);\n",
      "Z12=(-b/dY);\n",
      "Z21=(c/dY);\n",
      "Z22=(a/dY);\n",
      "print\"%s %.2f %s\"%(\"\\ndY=Y11.Y22-Y12.Y21 =\",dY,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ11 = Y22/dY =\",Z11,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ12 = -Y12/dY = \",Z12,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ21 = -Y21/-dY = \",Z21,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ22 = Y11/dY = \",Z22,\" Ohm\");\n",
      "print(\"\\nZ-parameters :\");\n",
      "print([[Z11, Z12],[Z21, Z22]]);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KCL to Node 3 \n",
        "V3 = V2/3 - - - -(i)\n",
        "\n",
        "I1 = 2V1 - (2/3)V2 - - - -(ii)\n",
        "\n",
        "I2 = 3V2 - (V2/3) = (8/3)V2 - - - -(iii)\n",
        "\n",
        "Y-parameters:\n",
        "[[2, -0.6666666666666666], [-0.6666666666666666, 2.6666666666666665]]\n",
        "\n",
        "dY=Y11.Y22-Y12.Y21 = 5.33 \n",
        "\n",
        "Z11 = Y22/dY = 0.50  Ohm\n",
        "\n",
        "Z12 = -Y12/dY =  0.12  Ohm\n",
        "\n",
        "Z21 = -Y21/-dY =  0.00  Ohm\n",
        "\n",
        "Z22 = Y11/dY =  0.38  Ohm\n",
        "\n",
        "Z-parameters :\n",
        "[[0.5, 0.125], [0.0, 0.375]]\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex25-pg11.55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.25 :(pg11.55 & 11.56)\n",
      "print(\"\\nApplying KCL to Node 1 \\nI1 = (-3/2)V1 - V2- - -(i)\");\n",
      "print(\"\\nApplying KCL to Node 2 \\nI2 = 2V1 + 2V2 - - - -(ii)\");\n",
      "##observing (i) & (ii)\n",
      "print(\"\\nY-parameters:\");\n",
      "a=(-3/2.);b=(-1);c=2.;d=2.;\n",
      "print([[a, b],[c ,d]]);\n",
      "dY=((a*d)-(b*c));\n",
      "Z11=(d/dY);\n",
      "Z12=(-b/dY);\n",
      "Z21=(-c/dY);\n",
      "Z22=(a/dY);\n",
      "print\"%s %.2f %s\"%(\"\\ndY=Y11.Y22-Y12.Y21 =\",dY,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ11 = Y22/dY = \",Z11,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ12 = -Y12/dY =\",Z12,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ21 = -Y21/-dY = \",Z21,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ22 = Y11/dY = \",Z22,\" Ohm\");\n",
      "print(\"\\nZ-parameters :\");\n",
      "print([[Z11 ,Z12],[Z21, Z22]]);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KCL to Node 1 \n",
        "I1 = (-3/2)V1 - V2- - -(i)\n",
        "\n",
        "Applying KCL to Node 2 \n",
        "I2 = 2V1 + 2V2 - - - -(ii)\n",
        "\n",
        "Y-parameters:\n",
        "[[-1.5, -1], [2.0, 2.0]]\n",
        "\n",
        "dY=Y11.Y22-Y12.Y21 = -1.00 \n",
        "\n",
        "Z11 = Y22/dY =  -2.00  Ohm\n",
        "\n",
        "Z12 = -Y12/dY = -1.00  Ohm\n",
        "\n",
        "Z21 = -Y21/-dY =  2.00  Ohm\n",
        "\n",
        "Z22 = Y11/dY =  1.50  Ohm\n",
        "\n",
        "Z-parameters :\n",
        "[[-2.0, -1.0], [2.0, 1.5]]\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex26-pg11.56"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.22 :(pg11.52 & 11.53)\n",
      "print(\"\\nApplying KVL to Mesh 1 \\nV1 = 2I1 + I2 - - - -(i)\");\n",
      "print(\"\\nApplying KVL to Mesh 2 \\nV2 = 10I1 + 11I2 - - - -(ii)\");\n",
      "##observing (i) & (ii)\n",
      "print(\"\\nV1 = (4/5)I1 - (4/5)I2 \\nV2 = (2/5)I1 - (12/5)I2\");\n",
      "print(\"\\nZ-parameters:\");\n",
      "a=2.;b=1.;c=10.;d=11.;\n",
      "print([[a, b],[c ,d]]);\n",
      "dZ=(a*d)-(b*c);\n",
      "Y11=(d/dZ);\n",
      "Y12=(-b/dZ);\n",
      "Y21=(-c/dZ);\n",
      "Y22=(a/dZ);\n",
      "print(\"\\nY-parameters are:\");\n",
      "print\"%s %.2f %s\"%(\"\\ndZ = Z11.Z22 - Z12.Z21 = \",dZ,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nY11 = Z22/dZ = \",Y11,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY12 = -Z12/dY = \",Y12,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY21 = -Z21/-dY = \",Y21,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY22 = Z11/dY = \",Y22,\" mho\");\n",
      "print([[Y11, Y12],[Y21, Y22]]); \n",
      "\n",
      "h11=(dZ/d);\n",
      "h12=(b/d);\n",
      "h21=(-c/d);\n",
      "h22=(1/d);\n",
      "\n",
      "print\"%s %.2e %s\"%(\"\\ndZ = Z11.Z22 - Z12.Z21 =\",dZ,\"\");\n",
      "print\"%s %.2e %s\"%(\"\\nh11 = dZ/Z22 =  \",h11,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nh12 = Z12/Z22 = \",h12,\"\");\n",
      "print\"%s %.2e %s\"%(\"\\nh21 = -Z21/Z22 = \",h21,\"\");\n",
      "print\"%s %.2e %s\"%(\"\\nh22 = 1/Z22 = \",h22,\"\");\n",
      "print(\"\\nh-parameters are:\");\n",
      "print([[h11 ,h12],[h21 ,h22]]); "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KVL to Mesh 1 \n",
        "V1 = 2I1 + I2 - - - -(i)\n",
        "\n",
        "Applying KVL to Mesh 2 \n",
        "V2 = 10I1 + 11I2 - - - -(ii)\n",
        "\n",
        "V1 = (4/5)I1 - (4/5)I2 \n",
        "V2 = (2/5)I1 - (12/5)I2\n",
        "\n",
        "Z-parameters:\n",
        "[[2.0, 1.0], [10.0, 11.0]]\n",
        "\n",
        "Y-parameters are:\n",
        "\n",
        "dZ = Z11.Z22 - Z12.Z21 =  12.00 \n",
        "\n",
        "Y11 = Z22/dZ =  0.92  mho\n",
        "\n",
        "Y12 = -Z12/dY =  -0.08  mho\n",
        "\n",
        "Y21 = -Z21/-dY =  -0.83  mho\n",
        "\n",
        "Y22 = Z11/dY =  0.17  mho\n",
        "[[0.9166666666666666, -0.08333333333333333], [-0.8333333333333334, 0.16666666666666666]]\n",
        "\n",
        "dZ = Z11.Z22 - Z12.Z21 = 1.20e+01 \n",
        "\n",
        "h11 = dZ/Z22 =   1.09e+00 \n",
        "\n",
        "h12 = Z12/Z22 =  0.09 \n",
        "\n",
        "h21 = -Z21/Z22 =  -9.09e-01 \n",
        "\n",
        "h22 = 1/Z22 =  9.09e-02 \n",
        "\n",
        "h-parameters are:\n",
        "[[1.0909090909090908, 0.09090909090909091], [-0.9090909090909091, 0.09090909090909091]]\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex27-pg11.58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.27 :(pg11.58)\n",
      "print(\"\\nApplying KCL to Node 1 \\nI1 = 4V1 - 3V2- - -(i)\");\n",
      "print(\"\\nApplying KCL to Node 2 \\nI2 = -3V1 + 1.5V2 - - - -(ii)\");\n",
      "##observing (i) & (ii)\n",
      "print(\"\\nY-parameters:\");\n",
      "a=4.;b=(-3);c=(-3);d=1.5;\n",
      "print([[a ,b],[c ,d]]);\n",
      "dY=((a*d)-(b*c));\n",
      "Z11=(d/dY);\n",
      "Z12=(-b/dY);\n",
      "Z21=(-c/dY);\n",
      "Z22=(a/dY);\n",
      "print\"%s %.2f %s\"%(\"\\ndY=Y11.Y22-Y12.Y21 =\",dY,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ11 = Y22/dY = \",Z11,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ12 = -Y12/dY =\",Z12,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ21 = -Y21/-dY = \",Z21,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ22 = Y11/dY = \",Z22,\" Ohm\");\n",
      "print(\"\\nZ-parameters :\");\n",
      "print([[Z11 ,Z12],[Z21, Z22]]);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KCL to Node 1 \n",
        "I1 = 4V1 - 3V2- - -(i)\n",
        "\n",
        "Applying KCL to Node 2 \n",
        "I2 = -3V1 + 1.5V2 - - - -(ii)\n",
        "\n",
        "Y-parameters:\n",
        "[[4.0, -3], [-3, 1.5]]\n",
        "\n",
        "dY=Y11.Y22-Y12.Y21 = -3.00 \n",
        "\n",
        "Z11 = Y22/dY =  -0.50  Ohm\n",
        "\n",
        "Z12 = -Y12/dY = -1.00  Ohm\n",
        "\n",
        "Z21 = -Y21/-dY =  -1.00  Ohm\n",
        "\n",
        "Z22 = Y11/dY =  -1.33  Ohm\n",
        "\n",
        "Z-parameters :\n",
        "[[-0.5, -1.0], [-1.0, -1.3333333333333333]]\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex28-pg11.58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.28 :(pg11.58 & 11.59)\n",
      "(\"\\nApplying KCL to Node 1 \\nI1 = 1.5V1 - 0.5V2- - -(i)\");\n",
      "print(\"\\nApplying KCL to Node 2 \\nI2 = 4V1 - 0.5V2 - - - -(ii)\");\n",
      "##observing (i) & (ii)\n",
      "print(\"\\nY-parameters:\");\n",
      "a=1.5;b=(-0.5);c=(4);d=(-0.5);\n",
      "print([[a ,b],[c ,d]]);\n",
      "dY=((a*d)-(b*c));\n",
      "Z11=(d/dY);\n",
      "Z12=(-b/dY);\n",
      "Z21=(-c/dY);\n",
      "Z22=(a/dY);\n",
      "print\"%s %.2f %s\"%(\"\\ndY=Y11.Y22-Y12.Y21 =\",dY,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ11 = Y22/dY = \",Z11,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ12 = -Y12/dY =\",Z12,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ21 = -Y21/-dY = \",Z21,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ22 = Y11/dY = \",Z22,\" Ohm\");\n",
      "print(\"\\nZ-parameters :\");\n",
      "print([[Z11 ,Z12],[Z21, Z22]]);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KCL to Node 2 \n",
        "I2 = 4V1 - 0.5V2 - - - -(ii)\n",
        "\n",
        "Y-parameters:\n",
        "[[1.5, -0.5], [4, -0.5]]\n",
        "\n",
        "dY=Y11.Y22-Y12.Y21 = 1.25 \n",
        "\n",
        "Z11 = Y22/dY =  -0.40  Ohm\n",
        "\n",
        "Z12 = -Y12/dY = 0.40  Ohm\n",
        "\n",
        "Z21 = -Y21/-dY =  -3.20  Ohm\n",
        "\n",
        "Z22 = Y11/dY =  1.20  Ohm\n",
        "\n",
        "Z-parameters :\n",
        "[[-0.4, 0.4], [-3.2, 1.2]]\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex29-pg11.59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.29 :(pg11.59 & 11.60)\n",
      "print(\"\\nApplying KCL to Node 1 \\nI1 = 3V1 - 2V2- - -(i)\");\n",
      "print(\"\\nApplying KCL to Node 2 \\nI2 = 3V2 - V3 - - - -(ii)\");\n",
      "print(\"\\nApplying KCL to Node 3 \\nV3 = (1/3)V2 - - - -(ii)\");\n",
      "##substituting (iii) in (i) & (ii),we get\n",
      "print(\"\\nI1 = 3V1 - (2/3)V2 \\nI2 = 0V1 + (8/3)V2\");\n",
      "print(\"\\nY-parameters:\");\n",
      "a=3.;b=(-2/3.);c=(0.);d=(8/3.);\n",
      "print([[a ,b],[c ,d]]);\n",
      "\n",
      "dY=((a*d)-(b*c));\n",
      "Z11=(d/dY);\n",
      "Z12=(-b/dY);\n",
      "Z21=(c/dY);\n",
      "Z22=(a/dY);\n",
      "\n",
      "\n",
      "\n",
      "print\"%s %.2f %s\"%(\"\\ndY=Y11.Y22-Y12.Y21 =\",dY,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ11 = Y22/dY = \",Z11,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ12 = -Y12/dY =\",Z12,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ21 = -Y21/-dY = \",Z21,\" Ohm\");\n",
      "print\"%s %.2f %s\"%(\"\\nZ22 = Y11/dY = \",Z22,\" Ohm\");\n",
      "print(\"\\nZ-parameters :\");\n",
      "print([[Z11 ,Z12],[Z21, Z22]]);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KCL to Node 1 \n",
        "I1 = 3V1 - 2V2- - -(i)\n",
        "\n",
        "Applying KCL to Node 2 \n",
        "I2 = 3V2 - V3 - - - -(ii)\n",
        "\n",
        "Applying KCL to Node 3 \n",
        "V3 = (1/3)V2 - - - -(ii)\n",
        "\n",
        "I1 = 3V1 - (2/3)V2 \n",
        "I2 = 0V1 + (8/3)V2\n",
        "\n",
        "Y-parameters:\n",
        "[[3.0, -0.6666666666666666], [0.0, 2.6666666666666665]]\n",
        "\n",
        "dY=Y11.Y22-Y12.Y21 = 8.00 \n",
        "\n",
        "Z11 = Y22/dY =  0.33  Ohm\n",
        "\n",
        "Z12 = -Y12/dY = 0.08  Ohm\n",
        "\n",
        "Z21 = -Y21/-dY =  0.00  Ohm\n",
        "\n",
        "Z22 = Y11/dY =  0.38  Ohm\n",
        "\n",
        "Z-parameters :\n",
        "[[0.3333333333333333, 0.08333333333333333], [0.0, 0.375]]\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex30-pg11.60"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.30 :(pg11.60 & 11.561)\n",
      "print(\"\\nApplying KVL to Mesh 1 \\nV1 = 4I1 + (0.05)I2 - - - -(i)\");\n",
      "print(\"\\nApplying KVL to Mesh 2 \\nV2 = 2I1 - 10I2 - - - -(ii)\");\n",
      "##substituting (i) in (ii),\n",
      "print(\"\\nV2 = -40I1 + (1.5)I2\");\n",
      "print(\"\\nZ-parameters:\");\n",
      "a=4;b=0.05;c=-40;d=1.5;\n",
      "print([[a ,b],[c ,d]]);\n",
      "dZ=(a*d)-(b*c);\n",
      "Y11=(d/dZ);\n",
      "Y12=(b/dZ);\n",
      "Y21=(-c/dZ);\n",
      "Y22=(a/dZ);\n",
      "print(\"\\nY-parameters are:\");\n",
      "print\"%s %.2f %s\"%(\"\\ndZ = Z11.Z22 - Z12.Z21 = \",dZ,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nY11 = Z22/dZ = \",Y11,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY12 = -Z12/dY = \",Y12,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY21 = -Z21/-dY = \",Y21,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY22 = Z11/dY = \",Y22,\" mho\");\n",
      "print([[Y11, Y12],[Y21, Y22]]); \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KVL to Mesh 1 \n",
        "V1 = 4I1 + (0.05)I2 - - - -(i)\n",
        "\n",
        "Applying KVL to Mesh 2 \n",
        "V2 = 2I1 - 10I2 - - - -(ii)\n",
        "\n",
        "V2 = -40I1 + (1.5)I2\n",
        "\n",
        "Z-parameters:\n",
        "[[4, 0.05], [-40, 1.5]]\n",
        "\n",
        "Y-parameters are:\n",
        "\n",
        "dZ = Z11.Z22 - Z12.Z21 =  8.00 \n",
        "\n",
        "Y11 = Z22/dZ =  0.19  mho\n",
        "\n",
        "Y12 = -Z12/dY =  0.01  mho\n",
        "\n",
        "Y21 = -Z21/-dY =  5.00  mho\n",
        "\n",
        "Y22 = Z11/dY =  0.50  mho\n",
        "[[0.1875, 0.00625], [5.0, 0.5]]\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex31-pg11.61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Two-Port Networks : example 11.31 :(pg11.61 & 11.62)\n",
      "print(\"\\nApplying KVL to Mesh 1 \\nV1 = 3I1 + 5I2 - - - -(i)\");\n",
      "print(\"\\nApplying KVL to Mesh 2 \\nV2 = 2I1 + 4I2 - 2I3 - - - -(ii)\");\n",
      "print(\"\\nApplying KVL to Mesh 3 \\nI3 = 2V3 - - - -(iii)\");\n",
      "##substituting (iii) in (i) & (ii),we get\n",
      "print(\"\\n2V3 = 4I1 + 4I2 \\nV2 = -6I1 + 4I2\");\n",
      "print(\"\\nZ-parameters:\");\n",
      "a=3.;b=5.;c=-6.;d=-4.;\n",
      "print([[a ,b],[c ,d]]);\n",
      "dZ=(a*d)-(b*c);\n",
      "Y11=(d/dZ);\n",
      "Y12=(-b/dZ);\n",
      "Y21=(-c/dZ);\n",
      "Y22=(a/dZ);\n",
      "print(\"\\nY-parameters are:\");\n",
      "print\"%s %.2f %s\"%(\"\\ndZ = Z11.Z22 - Z12.Z21 = \",dZ,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nY11 = Z22/dZ = \",Y11,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY12 = -Z12/dY = \",Y12,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY21 = -Z21/-dY = \",Y21,\" mho\");\n",
      "print\"%s %.2f %s\"%(\"\\nY22 = Z11/dY = \",Y22,\" mho\");\n",
      "print([[Y11, Y12],[Y21, Y22]]);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KVL to Mesh 1 \n",
        "V1 = 3I1 + 5I2 - - - -(i)\n",
        "\n",
        "Applying KVL to Mesh 2 \n",
        "V2 = 2I1 + 4I2 - 2I3 - - - -(ii)\n",
        "\n",
        "Applying KVL to Mesh 3 \n",
        "I3 = 2V3 - - - -(iii)\n",
        "\n",
        "2V3 = 4I1 + 4I2 \n",
        "V2 = -6I1 + 4I2\n",
        "\n",
        "Z-parameters:\n",
        "[[3.0, 5.0], [-6.0, -4.0]]\n",
        "\n",
        "Y-parameters are:\n",
        "\n",
        "dZ = Z11.Z22 - Z12.Z21 =  18.00 \n",
        "\n",
        "Y11 = Z22/dZ =  -0.22  mho\n",
        "\n",
        "Y12 = -Z12/dY =  -0.28  mho\n",
        "\n",
        "Y21 = -Z21/-dY =  0.33  mho\n",
        "\n",
        "Y22 = Z11/dY =  0.17  mho\n",
        "[[-0.2222222222222222, -0.2777777777777778], [0.3333333333333333, 0.16666666666666666]]\n"
       ]
      }
     ],
     "prompt_number": 18
    }
   ],
   "metadata": {}
  }
 ]
}