{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter : 5 - Filters"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.1 : Page No - 204\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi\n",
      "#Given data\n",
      "R = 10 # in k ohm\n",
      "R = R * 10**3 # in ohm\n",
      "C = 0.001 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "f_c = 1/(2*pi*R*C) # Hz\n",
      "f_c = f_c * 10**-3 # in kHz\n",
      "print \"Cutoff frequency = %0.3f kHz\" %f_c \n",
      "R_F = 100 # in k ohm\n",
      "R1 = 10 # in k ohm\n",
      "A_F = 1+(R_F/R1) \n",
      "print \"The passband voltage gain = %0.f\" %A_F "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cutoff frequency = 15.915 kHz\n",
        "The passband voltage gain = 11\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2 : Page No - 204\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 10 # in k ohm\n",
      "R_F = R1 # in k ohm\n",
      "print \"The value of R_F = %0.f k\u03a9\" %R_F\n",
      "C = 0.001 # in \u00b5F\n",
      "C = C  *10**-6 # in F\n",
      "f_c = 10 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "R = 1/(2*pi*f_c*C) # in ohm\n",
      "R  = R * 10**-3 # in k ohm\n",
      "print \"The value of R = %0.1f k\u03a9\" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R_F = 10 k\u03a9\n",
        "The value of R = 15.9 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.3 : Page No - 204\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_c = 2 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R = 1/(2*pi*f_c*C) # in ohm\n",
      "R = R * 10**-3 # in k ohm\n",
      "R = 8.2 # in k ohm(Practical value)\n",
      "A_F = 2.5 \n",
      "R1 = (A_F*R)/1.5 # in k ohm\n",
      "R_F = 1.5*R1 # in k ohm\n",
      "print \"The value of R1 = %0.2f k\u03a9 (standard value 15 kohm)\" %R1\n",
      "print \"The value of R_F = %0.f k\u03a9\" %R_F"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 = 13.67 k\u03a9 (standard value 15 kohm)\n",
        "The value of R_F = 20 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.4 : Page No - 208\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_c = 1 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "C = 0.005*10**-6 # in F\n",
      "R3 = 1/(2*pi*f_c*C) # in ohm\n",
      "R3 = R3 * 10**-3 # in k ohm\n",
      "R2 = R3 # in k ohm\n",
      "R1 = 33 # in k ohm (standard value)\n",
      "R_F = 0.586*R1 # in k ohm\n",
      "print \"The value of R1  = %0.f k\u03a9\" %R1\n",
      "print \"The value of R2  = R3 = %0.2f k\u03a9\" %R3\n",
      "print \"The value of R_F = %0.3f k\u03a9\" %R_F\n",
      "print \"The value of C2  = C3 = %0.3f \u00b5F\" %(C*10**6)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1  = 33 k\u03a9\n",
        "The value of R2  = R3 = 31.83 k\u03a9\n",
        "The value of R_F = 19.338 k\u03a9\n",
        "The value of C2  = C3 = 0.005 \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.5 : Page No - 208\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#Given data\n",
      "R1 = 12 # in k ohm\n",
      "R_F = 7 # in k ohm\n",
      "R2 = 33 # in k ohm\n",
      "R3 = R2 # in k ohm\n",
      "R = R2 # in k ohm\n",
      "R = R * 10**3 # in ohm\n",
      "C1 = 0.002 # in \u00b5F\n",
      "C1 = C1 * 10**-6 # in F\n",
      "C2 = C1 # in F\n",
      "C = C1 # in F\n",
      "f_c = 1/(2*pi*R*C) # in Hz\n",
      "f_c = f_c * 10**-3 # in kHz\n",
      "print \"Cut off frequency = %0.3f kHz\" %f_c \n",
      "A_F = 1+(R_F/R1) \n",
      "print \"Pass band voltage gain = %0.3f\" %A_F\n",
      "\n",
      "#Note : The unit of cut off frequency in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cut off frequency = 2.411 kHz\n",
        "Pass band voltage gain = 1.583\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.6 : Page No - 209\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_c = 2 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "C2 = 0.033 # in \u00b5F\n",
      "C2 = C2 * 10**-6 # in F\n",
      "C3 = C2 # in F\n",
      "C = C2 # in F\n",
      "R2 = 1/(2*pi*f_c*C) # in ohm\n",
      "R2 = R2 * 10**-3 # in k ohm\n",
      "R3=R2 # in kohm\n",
      "print \"The value of R2 = R3 = %0.1f k\u03a9\" %R2 \n",
      "#R_F= 0.586*R1\n",
      "R1= 2*R2*(1+0.586)/0.586 # in k ohm\n",
      "print \"The value of R1 = %0.f k\u03a9\" %R1\n",
      "R1= 15 # in k ohm\n",
      "R_F = 0.586 * R1 # in k ohm\n",
      "print \"The value of R_F = %0.2f k\u03a9\" %R_F\n",
      "print \"R_F may be taken as a pot of 10 k\u03a9\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R2 = R3 = 2.4 k\u03a9\n",
        "The value of R1 = 13 k\u03a9\n",
        "The value of R_F = 8.79 k\u03a9\n",
        "R_F may be taken as a pot of 10 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.7 : Page No - 209\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Given data\n",
      "f_c = 1 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "C2 = 0.0047 # in \u00b5F\n",
      "C2 = C2 * 10**-6 # in F\n",
      "C3 = C2 # in F\n",
      "C = C2 # in F\n",
      "R2 = 1/(2*pi*f_c*C) # in ohm\n",
      "R2 = R2 * 10**-3 # in k ohm\n",
      "R3= R2 # in kohm\n",
      "# Let\n",
      "R1=30 # in kohm\n",
      "R_F= R1*0.586 # in kohm\n",
      "print \"The value of R2 = R3 = %0.f k\u03a9\" %math.floor(R2)\n",
      "print \"The value of C2 = C3 = %0.4f micro F\" %(C3*10**6)\n",
      "print \"The value of R1 = %0.f k\u03a9\" %R1\n",
      "print \"The value of R_F = %0.f k\u03a9\" %R_F\n",
      "print \"The standard value of R_F is 20 k\u03a9\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R2 = R3 = 33 k\u03a9\n",
        "The value of C2 = C3 = 0.0047 micro F\n",
        "The value of R1 = 30 k\u03a9\n",
        "The value of R_F = 18 k\u03a9\n",
        "The standard value of R_F is 20 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.8 : Page No - 215\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "#Given data\n",
      "f_c = 1.5 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "alpha = sqrt(2) \n",
      "R_F = (2-alpha) # in ohm\n",
      "print \"The value of R_F = %0.3f \u03a9\" %R_F \n",
      "R_i = 1 # in ohm\n",
      "A_F = 1+(R_F/R_i) \n",
      "print \"The pass band gain = %0.3f\" %A_F \n",
      "Omega_c = 2*pi*f_c # in rad/sec\n",
      "C = 1 # in F\n",
      "R = 1/Omega_c # in ohm\n",
      "R = R * 10**7 # in ohm\n",
      "R=R*10**-3 # in kohm\n",
      "R1 = R # in k ohm\n",
      "R2=R1 # in kohm\n",
      "print \"The value of R1 = R2 = %0.3f k\u03a9\" %R1  \n",
      "C = C/10**7 # in \u00b5F\n",
      "C = C * 10**9 # in nF\n",
      "C1=C # in nF\n",
      "C2= C1 # in nF\n",
      "print \"The value of C1 = C2 = %0.f nF\" %C1 \n",
      "\n",
      "#Note: The unit of R1 and R2 is wrong in the book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R_F = 0.586 \u03a9\n",
        "The pass band gain = 1.586\n",
        "The value of R1 = R2 = 1.061 k\u03a9\n",
        "The value of C1 = C2 = 100 nF\n"
       ]
      }
     ],
     "prompt_number": 47
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.9 : Page No - 216\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "alpha = 1.414 \n",
      "f_c = 1.5 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "C1 = 2/alpha # in F\n",
      "C2 = alpha/2 # in F\n",
      "R1 = 1 # in ohm\n",
      "R2 = R1 # in ohm \n",
      "R_F = 2 # in ohm\n",
      "Omega_c = 2*pi*f_c # in rad/sec\n",
      "R = 1/Omega_c # in ohm\n",
      "R = R * 10**7 # in ohm\n",
      "R1 = R # in ohm\n",
      "R2= R1 # in ohm\n",
      "R_F = 2*R # in ohm\n",
      "C1 = C1/10**7 # in F\n",
      "C2 = C2/10**7 # in F\n",
      "print \"The value of R1  = R2 = %0.3f kohm\" %(R1*10**-3) \n",
      "print \"The value of C1  = %0.1f nF\" %(C1*10**9) \n",
      "print \"The value of C2  = %0.1f nF\" %(C2*10**9) \n",
      "print \"The value of R_F = %0.3f kohm\" %(R_F*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1  = R2 = 1.061 kohm\n",
        "The value of C1  = 141.4 nF\n",
        "The value of C2  = 70.7 nF\n",
        "The value of R_F = 2.122 kohm\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.12 : Page No - 220\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from math import log10\n",
      "#Given data\n",
      "f_c = 10 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "omega_c= 2*pi*f_c # in rad/sec\n",
      "C = 0.01 # in \u00b5F\n",
      "C= C*10**-6 # in F\n",
      "Ri= 10*10**3 # in \u03a9\n",
      "n=2 \n",
      "Q= 1/1.414 \n",
      "R= 1/(2*pi*f_c*C) # in \u03a9\n",
      "Af= 3-1/Q \n",
      "Rf= (Af-1)*Ri # in \u03a9\n",
      "print \"The value of C = %0.2f \u00b5F\" %(C*10**6)\n",
      "print \"The value of R = %0.3f k\u03a9\" %(R*10**-3)\n",
      "print \"The value of Rf = %0.2f k\u03a9\" %(Rf*10**-3)\n",
      "print \"Frequency versus gain magnitude shown in following table:\"\n",
      "print \"-----------------------------------------------------------------------------------------\"\n",
      "print \"|      Frequency in Hz                                 Gain Magnitude in dB |H(s)|      |\"\n",
      "print \"-----------------------------------------------------------------------------------------\"\n",
      "f= 1000 # in Hz\n",
      "omega= 2*pi*f # in rad/sec\n",
      "HsdB= 20*log10(Af/sqrt(1+(omega/omega_c)**4))\n",
      "print \"|           \",int(f),\"                                               \",int(HsdB),\"                    |\"\n",
      "f= 2000 # in Hz\n",
      "omega= 2*pi*f # in rad/sec\n",
      "HsdB= 20*log10(Af/sqrt(1+(omega/omega_c)**4))\n",
      "print \"|           \",int(f),\"                                               \",round(HsdB,3),\"                |\"\n",
      "f= 5000 # in Hz\n",
      "omega= 2*pi*f # in rad/sec\n",
      "HsdB= 20*log10(Af/sqrt(1+(omega/omega_c)**4))\n",
      "print \"|           \",int(f),\"                                               \",round(HsdB,2),\"                 |\"\n",
      "f= 10000 # in Hz\n",
      "omega= 2*pi*f # in rad/sec\n",
      "HsdB= 20*log10(Af/sqrt(1+(omega/omega_c)**4))\n",
      "print \"|          \",int(f),\"                                               \",int(round(HsdB,2)),\"                    |\"\n",
      "f= 50000 # in Hz\n",
      "omega= 2*pi*f # in rad/sec\n",
      "HsdB= 20*log10(Af/sqrt(1+(omega/omega_c)**4))\n",
      "print \"|          \",int(f),\"                                              \",round(HsdB,2),\"                |\"\n",
      "f= 100000 # in Hz\n",
      "omega= 2*pi*f # in rad/sec\n",
      "HsdB= 20*log10(Af/sqrt(1+(omega/omega_c)**4))\n",
      "print \"|         \",int(f),\"                                              \",round(HsdB,2),\"                |\"\n",
      "print \"-----------------------------------------------------------------------------------------\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of C = 0.01 \u00b5F\n",
        "The value of R = 1.592 k\u03a9\n",
        "The value of Rf = 5.86 k\u03a9\n",
        "Frequency versus gain magnitude shown in following table:\n",
        "-----------------------------------------------------------------------------------------\n",
        "|      Frequency in Hz                                 Gain Magnitude in dB |H(s)|      |\n",
        "-----------------------------------------------------------------------------------------\n",
        "|            1000                                                 4                     |\n",
        "|            2000                                                 3.999                 |\n",
        "|            5000                                                 3.74                  |\n",
        "|           10000                                                 1                     |\n",
        "|           50000                                                -23.96                 |\n",
        "|          100000                                                -35.99                 |\n",
        "-----------------------------------------------------------------------------------------\n"
       ]
      }
     ],
     "prompt_number": 95
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.13 : Page No - 221\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_c = 1 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "C = 0.1 # in \u00b5F\n",
      "print \"The value of C = %0.1f \u00b5F\" %C \n",
      "C = C * 10**-6 # in F\n",
      "R = 1/(2*pi*f_c*C) # in ohm\n",
      "print \"The value of R = %0.3f k\u03a9\" %(R*10**-3) \n",
      "Q1 = 1/0.765 \n",
      "alpha1 = 1/Q1 \n",
      "Q2 = 1/1.848 \n",
      "alpha2 = 1/Q2 \n",
      "A_F1 = 3-alpha1 \n",
      "A_F2 = 3-alpha2 \n",
      "R_i =10*10**3 # in ohm\n",
      "R_F = (A_F1-1)*R_i # in ohm\n",
      "print \"For first stage the value of R_F = %0.2f k\u03a9\" %(R_F*10**-3) \n",
      "R_i = 100*10**3 # ohm\n",
      "R_F = (A_F2-1)*R_i # in ohm\n",
      "print \"For second stage the value of R_F = %0.1f k\u03a9\" %(R_F*10**-3) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of C = 0.1 \u00b5F\n",
        "The value of R = 1.592 k\u03a9\n",
        "For first stage the value of R_F = 12.35 k\u03a9\n",
        "For second stage the value of R_F = 15.2 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 97
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.14 : Page No - 225\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_c = 10 # in kHz\n",
      "f_c = f_c *10**3 # in Hz\n",
      "C = 0.0047 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R = 1/(2*pi*f_c*C) # in ohm\n",
      "R = R * 10**-3 # in k ohm\n",
      "print \"The value of R = %0.3f k\u03a9\" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R = 3.386 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 99
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.15 : Page No - 225\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R = 15 # in k ohm\n",
      "R = R *10**3 # in ohm\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "f_c = 1/(2*pi*R*C) # in Hz\n",
      "f_c= round(f_c) \n",
      "print \"Cut off frequency = %0.f Hz\" %f_c \n",
      "Omega_c = 2*pi*f_c # in rad/sec\n",
      "print \"The value of omega_c = %0.3f k rad/sec\" %(Omega_c*10**-3) \n",
      "\n",
      "# Note: There is calculation error to find the value of omega_c. So the answer in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cut off frequency = 1061 Hz\n",
        "The value of omega_c = 6.666 k rad/sec\n"
       ]
      }
     ],
     "prompt_number": 103
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.16 printed as 5.13 : Page No - 226\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 27 # in k ohm\n",
      "R1 = R1 * 10**3 # in ohm\n",
      "R2 = R1 # in ohm\n",
      "R3 = R2  # in ohm\n",
      "R = R1 # in ohm\n",
      "R_L = 10 # in k ohm\n",
      "R_F = 16 # in k ohm\n",
      "C2 = 0.005 # in \u00b5F\n",
      "C2 = C2 * 10**-6 # in F\n",
      "C3 = C2 # in F\n",
      "C = C3 # in F\n",
      "f_c = 1/(2*pi*R*C) # in Hz\n",
      "f_c = f_c * 10**-3 # in kHz\n",
      "R1= R1*10**-3 # in kohm\n",
      "print \"Cut off frequency = %0.2f kHz\" %f_c \n",
      "A_F = 1+(R_F/R1) \n",
      "print \"Voltage gain = %0.3f\" %A_F"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cut off frequency = 1.18 kHz\n",
        "Voltage gain = 1.593\n"
       ]
      }
     ],
     "prompt_number": 105
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.17 : Page No - 229\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "alpha = 1.732 \n",
      "k_f = 1.274 \n",
      "C1 = 1 # in F\n",
      "C2 = C1 # in F\n",
      "R1 = alpha/2 # in ohm\n",
      "R2 = 2/alpha # in ohm\n",
      "R_F = R2 # in ohm\n",
      "f_3dB = 2 # in kHz\n",
      "f_3dB = f_3dB * 10**3 # in Hz\n",
      "f_c = f_3dB/k_f # in Hz\n",
      "Omega_c = 2*pi*f_c # in rad/sec\n",
      "R1 = R1/Omega_c # in ohm\n",
      "R1 = R1 * 10**8 # in ohm\n",
      "R2 = R2/Omega_c # in ohm\n",
      "R2 = R2 * 10**8 # in ohm\n",
      "R_F = R2 # in ohm\n",
      "C1 = C1/10**8 # in F\n",
      "print \"The value of R1 = %0.4f k\u03a9\" %(R1*10**-3)\n",
      "print \"The value of R2 = R_F = %0.3f k\u03a9\" %(R2*10**-3)\n",
      "print \"The value of C1 = C2 = %0.f nF\" %(C1*10**9)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 = 8.7797 k\u03a9\n",
        "The value of R2 = R_F = 11.707 k\u03a9\n",
        "The value of C1 = C2 = 10 nF\n"
       ]
      }
     ],
     "prompt_number": 107
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.18 printed as 5.15 : Page No - 232\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "#Given data\n",
      "Cdesh = 0.01 # in \u00b5F\n",
      "Cdesh= Cdesh* 10**-6 # in F\n",
      "f_H = 1 # in kHz\n",
      "f_H = f_H * 10**3 # in Hz\n",
      "Rdesh= 1/(2*pi*f_H*Cdesh) # in ohm\n",
      "A_F2 = 2 \n",
      "R1desh = 10*10**3 # in ohm\n",
      "Rdesh_F= R1desh # in ohm\n",
      "print \"(i) Low-pass Filter Components : \"\n",
      "print \"The value of R1' = %0.f k\u03a9\" %(R1desh*10**-3) \n",
      "print \"The value of R'  = %0.1f k\u03a9\" %(Rdesh*10**-3) \n",
      "print \"The value of R'F = %0.f k\u03a9\" %(Rdesh_F*10**-3) \n",
      "print \"The value of C   = %0.2f \u00b5F\" %(Cdesh*10**6) \n",
      "C = 0.05 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "f_L = 100 # in Hz\n",
      "R = 1/(2*pi*f_L*C) # in ohm\n",
      "A_F1 = 2 \n",
      "R1 = 10*10**3 # in ohm\n",
      "R_F = R1 # in ohm\n",
      "print \"\\n(ii) High pass Filter Components\"\n",
      "print \"The value of R1  = %0.f k\u03a9\" %(R1*10**-3) \n",
      "print \"The value of R   = %0.3f k\u03a9\" %(R*10**-3) \n",
      "print \"The value of R_F = %0.f k\u03a9\" %(R_F*10**-3) \n",
      "print \"The value of C   = %0.2f \u00b5F\" %(C*10**6) \n",
      "Q = sqrt(f_H*f_L)/(f_H-f_L) \n",
      "print \"The quality factor = %0.3f\" %Q \n",
      "\n",
      "# Note : In High pass filter components, the value of R is calculated 31.83 k\u03a9 but at last it is writter as 3.183 k\u03a9 \n",
      "#       so the answer of R in High pass filter components is wrong.\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Low-pass Filter Components : \n",
        "The value of R1' = 10 k\u03a9\n",
        "The value of R'  = 15.9 k\u03a9\n",
        "The value of R'F = 10 k\u03a9\n",
        "The value of C   = 0.01 \u00b5F\n",
        "\n",
        "(ii) High pass Filter Components\n",
        "The value of R1  = 10 k\u03a9\n",
        "The value of R   = 31.831 k\u03a9\n",
        "The value of R_F = 10 k\u03a9\n",
        "The value of C   = 0.05 \u00b5F\n",
        "The quality factor = 0.351\n"
       ]
      }
     ],
     "prompt_number": 111
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.19 : Page No - 234\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_c = 2 # in kHz\n",
      "f_c = f_c * 10**3 # in Hz\n",
      "A_F = 10 \n",
      "Q = 4 \n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R1 = Q/(2*pi*f_c*C*A_F) # in ohm \n",
      "R1 = R1 * 10**-3 # in k ohm\n",
      "print \"The value of R1 =\",round(R1,3),\"k\u03a9 (standard value 3.3 k\u03a9)\" \n",
      "R2 = Q/(2*pi*f_c*C*(2*Q**2-A_F)) # in ohm\n",
      "R2 = R2 * 10**-3 # in k ohm\n",
      "print \"The value of R2 =\",round(R2,3),\"k\u03a9 (standard value 1.5 k\u03a9)\" \n",
      "R3 = Q/(pi*f_c*C) # in ohm\n",
      "R3 = R3 * 10**-3 # in k ohm\n",
      "print \"The value of R3 =\", round(R3,2),\"k\u03a9 (standard value 63 k\u03a9)\" \n",
      "f_c1 = 1 # in kHz\n",
      "Rdesh2 = R2*(((f_c*10**-3)/f_c1)**2) # in k ohm\n",
      "print \"The value of R'2 =\", round(Rdesh2,3),\"k\u03a9 (standard value 5.8 k\u03a9)\" \n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 = 3.183 k\u03a9 (standard value 3.3 k\u03a9)\n",
        "The value of R2 = 1.447 k\u03a9 (standard value 1.5 k\u03a9)\n",
        "The value of R3 = 63.66 k\u03a9 (standard value 63 k\u03a9)\n",
        "The value of R'2 = 5.787 k\u03a9 (standard value 5.8 k\u03a9)\n"
       ]
      }
     ],
     "prompt_number": 113
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.20 Printed as 5.17 : Page No - 236\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_H = 100 # in Hz\n",
      "f_L = 2 # in kHz\n",
      "f_L = f_L * 10**3 # in Hz\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R = 1/(2*pi*f_L*C) # in ohm\n",
      "R = R * 10**-3 # in k ohm\n",
      "A_F = 2 \n",
      "R1 = 10 # in k ohm\n",
      "# A_F= 1+R_F/R1 or\n",
      "R_F= (A_F-1)*R1 # in k ohm\n",
      "print \"(i) High-pass Section Components : \"\n",
      "print \"The value of C = %0.2f \u00b5F\" %(C*10**6)\n",
      "print \"The value of R = %0.2f k\u03a9\" %R \n",
      "print \"The value of R_F = R1 = %0.f k\u03a9\" %R_F \n",
      "Cdesh = 0.1 # in \u00b5F\n",
      "Cdesh= Cdesh* 10**-6 # in F\n",
      "Rdesh = 1/(2*pi*f_H*Cdesh) # in ohm\n",
      "Rdesh= Rdesh * 10**-3 # in k ohm\n",
      "Rdesh1 = 10 # in k ohm\n",
      "Rdesh_F= Rdesh1 # in k ohm\n",
      "print \"\\n(ii) Low-pass Section components : \"\n",
      "print \"The value of C' = %0.1f \u00b5F\" %(Cdesh*10**6)\n",
      "print \"The value of R' = %0.3f k\u03a9\" %Rdesh \n",
      "print \"The value of R'F = R'1 = %0.f k\u03a9\" %Rdesh_F \n",
      "R2 = 10 # in k ohm\n",
      "R3 = R2 # in k ohm\n",
      "R4 = R2 # in k ohm\n",
      "R_OM = (R2*R3*R4)/(R2*R3+R3*R4+R4*R2) # in k ohm\n",
      "print \"\\n(iii) Summing Amplifier component\"\n",
      "print \"The value of R_OM = %0.1f k\u03a9\" %R_OM \n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) High-pass Section Components : \n",
        "The value of C = 0.01 \u00b5F\n",
        "The value of R = 7.96 k\u03a9\n",
        "The value of R_F = R1 = 10 k\u03a9\n",
        "\n",
        "(ii) Low-pass Section components : \n",
        "The value of C' = 0.1 \u00b5F\n",
        "The value of R' = 15.915 k\u03a9\n",
        "The value of R'F = R'1 = 10 k\u03a9\n",
        "\n",
        "(iii) Summing Amplifier component\n",
        "The value of R_OM = 3.3 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 117
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.21 : Page No - 238\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_N = 50 # in Hz\n",
      "C = 0.47 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R = 1/(2*pi*f_N*C) # in ohm\n",
      "R = R * 10**-3 # in k ohm\n",
      "print \"The value of Resistance = %0.3f kohm\" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Resistance = 6.773 kohm\n"
       ]
      }
     ],
     "prompt_number": 119
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.22 : Page No - 240\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import atan\n",
      "#Given data\n",
      "R = 10 # in k ohm\n",
      "R = R * 10**3 # in ohm\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "f = 2 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "Phi = -2*atan(2*pi*R*C*f)*180/pi # in degree\n",
      "print \"The phase shift = %0.2f degree\" %Phi"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The phase shift = -102.98 degree\n"
       ]
      }
     ],
     "prompt_number": 140
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.23 : Page No - 241\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f_L = 200 # in Hz\n",
      "f_H = 1 # in kHz\n",
      "f_H = f_H * 10**3 # in Hz\n",
      "f_c = sqrt(f_H*f_L) # in Hz\n",
      "print \"The center frequency = %0.1f Hz\" %f_c \n",
      "Q = f_c/(f_H-f_L) \n",
      "print \"Quality factor = %0.3f\" %Q"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The center frequency = 447.2 Hz\n",
        "Quality factor = 0.559\n"
       ]
      }
     ],
     "prompt_number": 142
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.24 : Page No - 241\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f1 = 5 # in kHz\n",
      "f1 = f1 * 10**3 # in Hz\n",
      "f2 = 15 # in kHz\n",
      "f2 = f2 * 10**3 # in Hz\n",
      "Cdesh = 0.01 # in \u00b5F\n",
      "Cdesh= Cdesh * 10**-6 # in F\n",
      "Rdesh = 1/(2*pi*f2*Cdesh) # in ohm\n",
      "A_F1 = 1.414 \n",
      "A_F2 = A_F1 \n",
      "Rdesh1 = 10 # in k ohm\n",
      "Rdesh_F = (A_F1-1)*Rdesh1 # in k ohm\n",
      "print \"(i) Low pass Filter components : \"\n",
      "print \"The value of R'1 = %0.f k\u03a9\" %Rdesh1\n",
      "print \"The value of R'  = %0.3f k\u03a9\" %(Rdesh*10**-3)\n",
      "print \"The value of R'F = %0.2f k\u03a9\" %Rdesh_F\n",
      "print \"The value of C'  = %0.2f \u00b5F\" %(Cdesh*10**6) \n",
      "C = 0.05 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R = 1/(2*pi*f1*C) #in ohm\n",
      "R1 = 10 # in k ohm\n",
      "R_F = (A_F1-1)*R1 # in k ohm\n",
      "print \"\\n(ii) High pass Filter components : \"\n",
      "print \"The value of R1  = %0.f k\u03a9\" %R1\n",
      "print \"The value of R   = %0.2f \u03a9\" %R \n",
      "print \"The value of R_F = %0.2f k\u03a9\" %R_F \n",
      "print \"The value of C   = %0.2f \u00b5F\" %(C*10**6) \n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Low pass Filter components : \n",
        "The value of R'1 = 10 k\u03a9\n",
        "The value of R'  = 1.061 k\u03a9\n",
        "The value of R'F = 4.14 k\u03a9\n",
        "The value of C'  = 0.01 \u00b5F\n",
        "\n",
        "(ii) High pass Filter components : \n",
        "The value of R1  = 10 k\u03a9\n",
        "The value of R   = 636.62 \u03a9\n",
        "The value of R_F = 4.14 k\u03a9\n",
        "The value of C   = 0.05 \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 146
    }
   ],
   "metadata": {}
  }
 ]
}