{
 "metadata": {
  "name": "",
  "signature": "sha256:c5300e3088f971e53c15dd8fc5e0190bde02f3350126276135402bbe82ffef31"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 41: Attenuators</h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 1, page no. 763</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      " #ratio  of  output  power  to  input  power\n",
      "rp1  =  2;\n",
      "rp2  =  25;  \n",
      "rp3  =  1000;\n",
      "rp4  =  0.01;\n",
      "\n",
      "#calculation:\n",
      " #power  ratio  in  decibels\n",
      "rpd1  =  10*(1/2.303)*math.log(rp1)\n",
      "rpd2  =  10*(1/2.303)*math.log(rp2)\n",
      "rpd3  =  10*(1/2.303)*math.log(rp3)\n",
      "rpd4  =  10*(1/2.303)*math.log(rp4)\n",
      " #power  ratio  in  nepers\n",
      "rpn1  =  (math.log(rp1))/2\n",
      "rpn2  =  (math.log(rp2))/2\n",
      "rpn3  =  (math.log(rp3))/2\n",
      "rpn4  =  (math.log(rp4))/2\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  power  ratio  in  decibels  are  (a)\",round(rpd1,2),\"  dB  (b)\",round(rpd2,2),\"  dB \"\n",
      "print  \"(c)  \",round(rpd3,2),\"  dB  and  (d)  \",round(rpd4,2),\"  dB\"\n",
      "print  \"\\n  power  ratio  in  nepers  are  (a)\",round(rpn1,2),\"  Np  (b)\",round(rpn2,2),\"  Np\"\n",
      "print   \"(c)  \",round(rpn3,2),\"  Np  and  (d)  \",round(rpn4,2),\"  Np\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  power  ratio  in  decibels  are  (a) 3.01   dB  (b) 13.98   dB \n",
        "(c)   29.99   dB  and  (d)   -20.0   dB\n",
        "\n",
        "  power  ratio  in  nepers  are  (a) 0.35   Np  (b) 1.61   Np\n",
        "(c)   3.45   Np  and  (d)   -2.3   Np\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2, page no. 763</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "rp  =  0.05;#  power  ratio  P2/P1\n",
      "\n",
      " #calculation:\n",
      " #power  ratio  in  decibels\n",
      "rpd  =  10*(1/2.303)*math.log(rp)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\nthe  attenuation  is  \",round(abs(rpd),2),\"  dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "the  attenuation  is   13.01   dB"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3, page no. 764</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "gain  =  1.5;#  in  dB\n",
      "Pi  =  0.012;#  in  Watt\n",
      "\n",
      "#calculation:\n",
      " #output  power\n",
      "Po  =  Pi*10**gain\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\noutput  power  is  \",round(Po,2),\"  W\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "output  power  is   0.38   W"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 4, page no. 764</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "I2  =  0.05;#  in  Amperes\n",
      "rin  =  1.32;#  in  Np\n",
      "\n",
      " #calculation:\n",
      " #current  input,  I1\n",
      "I1  =  I2*math.e**(rin)\n",
      " #current  ratio  in  decibels\n",
      "rid  =  20*(1/2.303)*math.log(I2/I1)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\ncurrent  input,  I1  is  \",round(I1,2),\"  A\"\n",
      "print  \"\\ncurrent  ratio  in  decibels  is  \",round(rid,2),\"  dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "current  input,  I1  is   0.19   A\n",
        "\n",
        "current  ratio  in  decibels  is   -11.46   dB"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5, page no. 769</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Ra1 = 8; # in ohms\n",
      "Ra2 = 8; # in ohms\n",
      "Ra3 = 21; # in ohms\n",
      "Rb1 = 10; # in ohms\n",
      "Rb2 = 10; # in ohms\n",
      "Rb3 = 15; # in ohms\n",
      "Rc1 = 200; # in ohms\n",
      "Rc2 = 200; # in ohms\n",
      "Rc3 = 56.25; # in ohms\n",
      "\n",
      "#calculation:\n",
      "R01 = (Ra1**2 + 2*Ra2*Ra3)**0.5\n",
      "R02 = (Rb1**2 + 2*Rb2*Rb3)**0.5\n",
      "R03 = (Rc1**2 + 2*Rc2*Rc3)**0.5\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n(a) the characteristic impedance, R0  is  \",R01,\"  ohm\"\n",
      "print  \"\\n(b) the characteristic impedance, R0  is  \",R02,\"  ohm\"\n",
      "print  \"\\n(c) the characteristic impedance, R0  is  \",R03,\"  ohm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "(a) the characteristic impedance, R0  is   20.0   ohm\n",
        "\n",
        "(b) the characteristic impedance, R0  is   20.0   ohm\n",
        "\n",
        "(c) the characteristic impedance, R0  is   250.0   ohm"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 6, page no. 769</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "R1  =  500;#  in  ohm\n",
      "R2  =  1000;#  in  ohm\n",
      "I1  =  1;#  in  ampere  (lets  say)\n",
      "\n",
      "#calculation:\n",
      " #  for  symmetrical  pi-attenuator  section\n",
      " #characteristic  impedance,  R0\n",
      "R0  =  (R1*(R2**2)/(R1  +  2*R2))**0.5\n",
      " #current  Ix\n",
      "Ix  =  (R2/(R2  +  R1  +  (R2*R0/(R2  +  R0))))*I1\n",
      " #current  I2\n",
      "I2  =  (R2/(R2  +  R0))*Ix\n",
      "ri  =  I1/I2;#  retio  of  currents\n",
      " #attenuation\n",
      "attn  =  20*(1/2.303)*math.log(ri)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  the  characteristic  impedance  is  \",round(R0,2),\"  ohm\"\n",
      "print  \"\\n  attenuation  is  \",round(attn,2),\"  dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  the  characteristic  impedance  is   447.21   ohm\n",
        "\n",
        "  attenuation  is   8.36   dB"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 7, page no. 770</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Ra1  =  15;#  in  ohm\n",
      "Ra2  =  15;#  in  ohm\n",
      "Ra3  =  10;#  in  ohm\n",
      "Rb1  =  15;#  in  ohm\n",
      "Rb2  =  5;#  in  ohm\n",
      "Rb3  =  5;#  in  ohm\n",
      "\n",
      "#calculation:\n",
      "Roc1 = Ra1 + Ra3\n",
      "Rsc1 = Ra1 + Ra2*Ra3/(Ra2+Ra3)\n",
      "R01 = (Roc1*Rsc1)**0.5\n",
      "\n",
      "Roc2 = Rb2* (Rb1 + Rb3)/(Rb1 + Rb2 + Rb3)\n",
      "Rsc2 = Rb2*Rb1/(Rb2+Rb1)\n",
      "R02 = (Roc2*Rsc2)**0.5\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a) the input resistance when the output port is open-circuited  is\", Roc1,\" ohm for T-Network\"\n",
      "print   \"and \",Roc2,\" ohm for pi-Network \"\n",
      "print  \"\\n  (b) the input resistance when the output port is short-circuited  is,\", Rsc1,\" ohm for T-Network\"\n",
      "print   \"and \",Rsc2,\" ohm for pi-Network \"\n",
      "print  \"\\n  (c) the characteristic impedance.  is,\",round(R01,1),\" ohm for T-Network and ,\",round(R02,2),\" ohm for pi-Network \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a) the input resistance when the output port is open-circuited  is 25  ohm for T-Network\n",
        "and  4.0  ohm for pi-Network \n",
        "\n",
        "  (b) the input resistance when the output port is short-circuited  is, 21.0  ohm for T-Network\n",
        "and  3.75  ohm for pi-Network \n",
        "\n",
        "  (c) the characteristic impedance.  is, 22.9  ohm for T-Network and , 3.87  ohm for pi-Network \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8, page no. 770</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Vat = 20; # in db\n",
      "R0  =  600;#  in  ohm\n",
      "\n",
      "#calculation:\n",
      "N = math.e**(Vat*2.3/20)\n",
      "R1 = R0*(N-1)/(N+1)\n",
      "R2 = R0*2*N/(N**2 - 1)\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n For a T-section symmetrical attenuator pad, Resistance R1 is\",round(R1,0),\" ohm and Resistance R2 is\",round(R2,1),\" ohm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        " For a T-section symmetrical attenuator pad, Resistance R1 is 491.0  ohm and Resistance R2 is 121.5  ohm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 9, page no. 771</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Vat = 20; # in db\n",
      "R0  =  600;#  in  ohm\n",
      "\n",
      "#calculation:\n",
      "N = math.e**(Vat*2.303/20)\n",
      "R1 = R0*(N**2 - 1)/(2*N)\n",
      "R2 = R0*(N+1)/(N-1)\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n For a pi-section symmetrical attenuator pad, Resistance R1 is\",round(R1/1000,2),\" Kohm\"\n",
      "print   \"and Resistance R2 is\",round(R2,0),\" ohm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        " For a pi-section symmetrical attenuator pad, Resistance R1 is 2.97  Kohm\n",
        "and Resistance R2 is 733.0  ohm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 10, page no. 772</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "R1  =  300;#  in  ohm\n",
      "R2  =  450;#  in  ohm\n",
      "I1  =  1;#  in  ampere  (lets  say)\n",
      "\n",
      "#calculation:\n",
      " #the  characteristic  impedance  of  a  symmetric  T-pad  attenuator  is  given  by\n",
      "R0  =  (R1**2  +  2*R1*R2)**0.5\n",
      " #By  current  division\n",
      " #current  I2\n",
      "I2  =  (R2/(R2  +  R1+  R0))*I1\n",
      "ri  =  I1/I2;#  ratio  of  currents\n",
      " #insertion  loss\n",
      "il  =  20*(1/2.303)*math.log(ri)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  the  characteristic  impedance  is  \",R0,\"  ohm\"\n",
      "print  \"\\n  insertion  loss  is  \",round(il,2),\"  dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  the  characteristic  impedance  is   600.0   ohm\n",
        "\n",
        "  insertion  loss  is   9.54   dB"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 11, page no. 773</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "r  =  500;#  in  ohm\n",
      "Rhm  =  3000;#  in  ohm\n",
      "RL  =  2000;#  in  ohm\n",
      "r1  =  2000;#  in  ohm\n",
      "r2  =  1000;#  in  ohm\n",
      "E  =  1;#  in  volts  (lets  say)\n",
      "\n",
      " #calculation:\n",
      " #Without  the  rheostat  in  the  circuit  the  voltage  across  the  2  kohm\u0018  load,  VL\n",
      "VL  =  (RL/(RL  +  r))*E\n",
      " #voltage  V2  with  2kohm  tapping\n",
      "V2  =  ((RL*r1/(r1  +  RL))/((RL*r1/(r1  +  RL))  +  Rhm  -  r1  +  r))*E\n",
      "rv1  =  VL/V2;#  ratio  of  currents\n",
      " #insertion  loss  \n",
      "il1  =  20*(1/2.303)*math.log(rv1)\n",
      " #voltage  V1  with  1kohm  tapping\n",
      "V1  =  ((RL*r2/(r2  +  RL))/((RL*r2/(r2  +  RL))  +  Rhm  -  r2  +  r))*E\n",
      "rv2  =  VL/V1;#  ratio  of  currents\n",
      " #insertion  loss  \n",
      "il2  =  20*(1/2.303)*math.log(rv2)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  insertion  loss  for  2kohm  tap  is  \",round(il1,2),\"  dB\"\n",
      "print  \"\\n  insertion  loss  for  1kohm  tap  is  \",round(il2,2),\"  dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  insertion  loss  for  2kohm  tap  is   6.02   dB\n",
        "\n",
        "  insertion  loss  for  1kohm  tap  is   11.59   dB"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12, page no. 774</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "R1  =  1000;#  in  ohm\n",
      "R2  =  500;#  in  ohm\n",
      "I1  =  1;#  in  amperes  (lets  say)\n",
      "\n",
      "#calculation:\n",
      " #characteristic  impedance  of  a  symmetrical  attenuator\n",
      "R0  =  (R1*(R2**2)/(R1  +  2*R2))**0.5\n",
      " #current  Ix\n",
      "Ix  =  (R2/(R2  +  R1  +  (R2*R0/(R2  +  R0))))*I1\n",
      " #current  I2\n",
      "I2  =  (R2/(R2  +  R0))*Ix\n",
      "ri  =  I1/I2;#  retio  of  currents\n",
      " #insertion  loss  \n",
      "il  =  20*(1/2.303)*math.log(ri)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  characteristic  impedance  is  \",round(R0,2),\"  ohm\"\n",
      "print  \"\\n  insertion  loss  is  \",round(il,2),\"  dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  characteristic  impedance  is   353.55   ohm\n",
        "\n",
        "  insertion  loss  is   15.31   dB"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 13, page no. 776</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "R1  =  100;#  in  ohm\n",
      "R2  =  200;#  in  ohm\n",
      "R3  =  300;#  in  ohm\n",
      "I1  =  1;#  in  amperes  (lets  say)\n",
      "\n",
      "#calculation:\n",
      " #image  impedance  Roa\n",
      "Roa  =  ((R1  +  R2)*(R2  +  (R1*R3/(R1  +  R3))))**0.5\n",
      " #image  impedance  Rob\n",
      "Rob  =  ((R1  +  R3)*(R3  +  (R1*R2/(R1  +  R2))))**0.5\n",
      " #The  iterative  impedance  at  port  1\n",
      "Ri1  =  (-1*R1  +  (R1**2  -  (-1*4*((R2*(R1  +  R3))  +  (R3*R1))))**0.5)/2\n",
      " #The  iterative  impedance  at  port  2\n",
      "Ri2  =  (R1  +  (R1**2  -  (-1*4*((R3*(R1  +  R2))  +  (R2*R1))))**0.5)/2\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  image  impedance  are  \",round(Roa,2),\"  ohm  and  \",round(Rob,2),\"  ohm  \"\n",
      "print  \"\\n  iterative  impedances  are  \",round(Ri1,2),\"  ohm  and  \",round(Ri2,2),\"  ohm  \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  image  impedance  are   287.23   ohm  and   382.97   ohm  \n",
        "\n",
        "  iterative  impedances  are   285.41   ohm  and   385.41   ohm  "
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 14, page no. 777</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "R1  =  1000;#  in  ohm\n",
      "R2  =  2000;#  in  ohm\n",
      "R3  =  3000;#  in  ohm\n",
      "I1  =  1;#  in  amperes  (lets  say)\n",
      "\n",
      "#calculation:\n",
      " #image  impedance  Roa\n",
      "Roa  =  (((R3  +  R2)*R1/(R1  +  R2  +  R3))*(R1*R3/(R1  +  R3)))**0.5\n",
      " #image  impedance  Rob\n",
      "Rob  =  (((R3  +  R1)*R2/(R1  +  R2  +  R3))*(R2*R3/(R2  +  R3)))**0.5\n",
      " #The  iterative  impedance  at  port  1\n",
      "Ri1  =  (-1*R1  +  ((R1**2)  -  (-1*4*2*R2*R1))**0.5)/(2*2)\n",
      " #The  iterative  impedance  at  port  2\n",
      "Ri2  =  (R1  +  ((-1*R1)**2  -  (-1*4*2*R2*R1))**0.5)/(2*2)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  image  impedance  are  \",round(Roa,2),\"  ohm  and  \",round(Rob,2),\"  ohm  \"\n",
      "print  \"\\n  iterative  impedances  are  \",round(Ri1,2),\"  ohm  and  \",round(Ri2,2),\"  ohm  \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  image  impedance  are   790.57   ohm  and   1264.91   ohm  \n",
        "\n",
        "  iterative  impedances  are   780.78   ohm  and   1280.78   ohm  "
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 15, page no. 780</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "r  =  500;#  in  ohm\n",
      "RL  =  100;#  in  ohm\n",
      "E  =  1;#  in  volts  (lets  say)\n",
      "\n",
      "#calculation:\n",
      " #res.\n",
      "R1  =  (r*(r  -  RL))**0.5\n",
      "R2  =  (r*RL**2/(r  -  RL))**0.5\n",
      " #current  I1\n",
      "I1  =  E/(r  +  R1  +  R2*RL/(RL  +  R2))\n",
      " #current  I2\n",
      "I2  =  (R2/(R2  +  RL))*I1\n",
      " #input  power\n",
      "P1  =  r*I1**2\n",
      " #output  power\n",
      "P2  =  RL*I2**2\n",
      " #attenuation\n",
      "attn  =  10*(1/2.303)*math.log(P1/P2)\n",
      " #Load  current,  IL\n",
      "IL  =  E/(r  +  RL)\n",
      " #voltage,  VL\n",
      "VL  =  IL*RL\n",
      " #voltage,  V1\n",
      "V1  =  E  -  I1*r\n",
      " #voltage,  V2\n",
      "V2  =  V1  -  I1*R1\n",
      " #insertion  loss\n",
      "il  =  20*(1/2.303)*math.log(VL/V2)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  R1  =  \",round(R1,2),\"  ohm  and  R2  =  \",round(R2,2),\"  ohm  \"\n",
      "print  \"\\n  attenuation  is  \",round(attn,2),\"  dB  \"\n",
      "print  \"\\n  In  decibels,  the  insertion  loss  is  \",round(il,2),\"  dB  \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  R1  =   447.21   ohm  and  R2  =   111.8   ohm  \n",
        "\n",
        "  attenuation  is   12.54   dB  \n",
        "\n",
        "  In  decibels,  the  insertion  loss  is   9.98   dB  "
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 16, page no. 783</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "attnO  =  70;#  in  dB\n",
      "n  =  5;#  numbers  of  identical  atteneurs\n",
      "V1  =  0.02;#  in  Volts\n",
      "\n",
      "#calculation:\n",
      " #attenuation  of  each  section\n",
      "attn  =  attnO/n\n",
      " #output  of  the  final  stage\n",
      "Vo  =  V1/(10**(attnO/20))\n",
      " #voltage  output  of  the  third  stage\n",
      "V3  =  V1/(10**(3*attn/20))\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  attenuation  of  each  section  =  \",round(attn,2),\"  dB  \"\n",
      "print  \"\\n  output  of  the  final  stage  is  \",round(Vo*1E6,2),\"uV  \"\n",
      "print  \"\\n  voltage  output  of  the  third  stage  is  \",round(V3*1E3,3),\"mV  \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  attenuation  of  each  section  =   14.0   dB  \n",
        "\n",
        "  output  of  the  final  stage  is   6.32 uV  \n",
        "\n",
        "  voltage  output  of  the  third  stage  is   0.159 mV  "
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 17, page no. 784</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "r = 450; # in ohm\n",
      "R0 = 450; # in ohms\n",
      "x = 1/8\n",
      "\n",
      "#calculation:\n",
      "N = 1/x\n",
      "R1 = R0*(N-1)/(N+1)\n",
      "R2 = R0*2*N/(N**2 - 1)\n",
      "\n",
      "Io = x*x\n",
      "\n",
      "attn  =  20*math.log10(N)\n",
      "attnO = 4*attn\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)For a T-section symmetrical attenuator pad, Resistance R1 is\",round(R1,2),\" ohm \"\n",
      "print   \"and Resistance R2 is\",round(R2,0),\" ohm\"\n",
      "print  \"\\n  (b)current flows in the load =  \",round(Io,2),\"of the original current.\"\n",
      "print  \"\\n  (c)overall attenuation is  \",round(attnO,2),\"dB  \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)For a T-section symmetrical attenuator pad, Resistance R1 is 350.0  ohm \n",
        "and Resistance R2 is 114.0  ohm\n",
        "\n",
        "  (b)current flows in the load =   0.02 of the original current.\n",
        "\n",
        "  (c)overall attenuation is   72.25 dB  \n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}