{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "chapter 5: Feed Back"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.1, Page No.192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Percentage of output which is fed back\n",
      "import math\n",
      "#variable declaration\n",
      "A=50.0                         #gain(unitless)\n",
      "Af=10.0                        #gain(unitless)\n",
      "\n",
      "#calculation\n",
      "\n",
      "#Formula : Af=A/(1+A*Beta)\n",
      "Beta=(A/Af-1)/A               #feedback ratio (unitless)\n",
      "\n",
      "#Result\n",
      "print(\"Percentage of output feed back : %.0f%%\"%(Beta*100))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage of output feed back : 8%\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.2, Page No.192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Voltage gain and reduction in voltage\n",
      "import math\n",
      "#variable declaration\n",
      "A=1000.0                     #gainWithoutFeedback(unitless)\n",
      "Adash=800                    #gainWithoutFeedback(unitless) \n",
      "g_reduce=0.40                #factor by which gain reduced\n",
      "#Calculations\n",
      "\n",
      "#Part (i) : \n",
      "Af=A-A*g_reduce              #gainWithFeedback(unitless)\n",
      "#Formula : Af=A/(1+A*Beta)\n",
      "Beta=(A/Af-1)/A           #feedback factor (unitless)\n",
      "\n",
      "Af_dash=Adash/(1+Adash*Beta)\n",
      "\n",
      "#Part (ii)\n",
      "Reduction=((A-Adash)/A)*100  #% reduction without feedback\n",
      "Reduction1=((Af-Af_dash)/Af)*100 #% reduction without feedback\n",
      "\n",
      "#Result\n",
      "print(\"At normal collector supply :\")\n",
      "print(\"with feedback gain reduces by a factor %.2f\"%g_reduce)\n",
      "print(\"At normal collector supply, Gain with feedback :%.0f \"%Af)\n",
      "print(\"\\nAt reduced power supply :\")\n",
      "print(\"At Reduced collector supply, Gain with feedback : %.0f\"%(math.ceil(Af_dash)))\n",
      "print(\"%% reduction in gain without feedback :%.0f%%\"%Reduction)\n",
      "print(\"%% reduction in gain with feedback :%.0f%%\"%Reduction1)\n",
      "#Note : answer of Af is wrong in the book."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At normal collector supply :\n",
        "with feedback gain reduces by a factor 0.40\n",
        "At normal collector supply, Gain with feedback :600 \n",
        "\n",
        "At reduced power supply :\n",
        "At Reduced collector supply, Gain with feedback : 522\n",
        "% reduction in gain without feedback :20%\n",
        "% reduction in gain with feedback :13%\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.3, Page No.192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Gain with feedback factor and feedback voltage\n",
      "import math\n",
      "#Variable declaration\n",
      "\n",
      "A=100.0                           #gain without feedback(unitless)\n",
      "Beta=1.0/25.0                     #feedback ratio (unitless)\n",
      "Vi=50.0                           #in mV\n",
      "\n",
      "\n",
      "#Calculations\n",
      "\n",
      "#Part (i) :\n",
      "Af=A/(1+A*Beta)                   #gain with feedback(unitless)\n",
      "\n",
      "\n",
      "#Part (ii) :\n",
      "FeedbackFactor=Beta*A            #unitless\n",
      "\n",
      "\n",
      "#Part (iii) :\n",
      "Vo_dash=Af*Vi*10**-3             #in volt\n",
      "\n",
      "\n",
      "#Part (iv) :\n",
      "FeedbackVoltage=Beta*Vo_dash     #in volt\n",
      "\n",
      "\n",
      "#Part (v) :\n",
      "Vi_dash=Vi*(1+Beta*A)            #in mv\n",
      "\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"(i)\\n Gain with feedback :%.0f\"%Af)\n",
      "print(\"(ii)\\n Feedback Factor :%.0f\"%FeedbackFactor)\n",
      "print(\"(iii)\\n Output Voltage in volts :%.0f\"%Vo_dash)\n",
      "print(\"(iv)\\n Feedback Voltage in volts :%.2f\"%FeedbackVoltage)\n",
      "print(\"(v)\\n New Increased Input Voltage in milli volts :%.0f\"%Vi_dash)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)\n",
        " Gain with feedback :20\n",
        "(ii)\n",
        " Feedback Factor :4\n",
        "(iii)\n",
        " Output Voltage in volts :1\n",
        "(iv)\n",
        " Feedback Voltage in volts :0.04\n",
        "(v)\n",
        " New Increased Input Voltage in milli volts :250\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.4, Page no.193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Bandwidth with negative feedback\n",
      "import math\n",
      "#variable declaration\n",
      "BW=200.0                              #in kHz\n",
      "A=40.0                                #gain without feedback(in dB)\n",
      "Beta=5.0                              #negative feedback in %\n",
      "Beta=Beta/100.0                       #feedback factor\n",
      "\n",
      "#calculation\n",
      "\n",
      "#Formula : Af=A/(1+A*Beta)\n",
      "Af=A/(1+A*Beta)                    #gain with feedback(in dB)\n",
      "BW_dash=A*BW/Af                    #in kHz\n",
      "\n",
      "#Result\n",
      "print(\"Since gain bandwidth product remains constant, A*BW=Af*BW_dash\")\n",
      "print(\"New Bandwidth in kHz : %.0f\"%BW_dash)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Since gain bandwidth product remains constant, A*BW=Af*BW_dash\n",
        "New Bandwidth in kHz : 600\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.5, Page No.193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Fraction of output fed back\n",
      "import math\n",
      "#variable declaration\n",
      "A=140.0                     #gain without feedback(unitless)\n",
      "Af=17.5                     #gain with feedback(unitless)\n",
      "\n",
      "#Calculations\n",
      "#Formula : Af=A/(1+A*Beta)\n",
      "Beta=(A/Af-1)/A             #feedback ratio (unitless)\n",
      "\n",
      "#Result\n",
      "print(\"Fraction of output fed back to input : %.2f or 1/20\"%Beta)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fraction of output fed back to input : 0.05 or 1/20\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.6, Page No.205"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Small Change in gain\n",
      "import math\n",
      "#variable declaration\n",
      "A=200.0                           #gain without feedback(unitless)\n",
      "Beta=0.25                         #fraction ratio(unitless)\n",
      "\n",
      "#CAlculations\n",
      "#Given : Normal gain changes by 10 %, it means dA/A=10/100\n",
      "dABYA=10.0/100.0                  #change in gain\n",
      "dAfBYAf=(1/(1+Beta*A))*(dABYA)    #change in gain\n",
      "\n",
      "#Result\n",
      "print(\"We have, Af=A/(1+Beta*A).................eqn(1)\")\n",
      "print(\"\\nDifferentiating it with respect to A, we get\")\n",
      "print(\"\\ndAf/dA=((1+Beta*A)-Beta*A)/(1+Beta*A)^2=1/(1+Beta*A)^2\")\n",
      "print(\"\\ndAf=dA/(1+Beta*A)^2.......................eqn(2)\")\n",
      "print(\"\\nDividing eqn(2) by eqn(1),\")\n",
      "print(\"\\ndAf/Af=(dA/((1+Beta*A)^2))*((1+Beta*A)/A)=(1/(1+Beta*A))*(dA/A)\")\n",
      "print(\"\\n\\nChange in gain : %.4f\"%((math.floor(dAfBYAf*10**4))/10**4))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "We have, Af=A/(1+Beta*A).................eqn(1)\n",
        "\n",
        "Differentiating it with respect to A, we get\n",
        "\n",
        "dAf/dA=((1+Beta*A)-Beta*A)/(1+Beta*A)^2=1/(1+Beta*A)^2\n",
        "\n",
        "dAf=dA/(1+Beta*A)^2.......................eqn(2)\n",
        "\n",
        "Dividing eqn(2) by eqn(1),\n",
        "\n",
        "dAf/Af=(dA/((1+Beta*A)^2))*((1+Beta*A)/A)=(1/(1+Beta*A))*(dA/A)\n",
        "\n",
        "\n",
        "Change in gain : 0.0019\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.7, Page No.206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#New gain distortion and input voltage\n",
      "import math\n",
      "#Variable declaration\n",
      "A=200.0                               #gain without feedback(unitless)\n",
      "Dn=10.0                               #Distortion in %\n",
      "Vi=0.5                                #Initial input voltage in volt\n",
      "Beta=0.05                             #feedback ratio (unitless)\n",
      "\n",
      "#Calculations\n",
      "#Formula : Af=A/(1+A*Beta)\n",
      "Af=A/(1+A*Beta)                       #gain with feedback(unitless)\n",
      "Dn_dash=Dn/(1+A*Beta)                 #new distortion in %\n",
      "InitialOutputVoltage=A*Vi             #in Volt\n",
      "NewInputVoltage=InitialOutputVoltage/Af\n",
      "\n",
      "print(\"New gain :%.3f\"%Af)\n",
      "print(\"Distortion with negative feedback : %.3f%%\"%Dn_dash)\n",
      "print(\"Initial Output Voltage in volt:%.0f\"%InitialOutputVoltage)\n",
      "print(\"New Input Voltage in volts :%.2f\"%NewInputVoltage)\n",
      "#Note :Ans of Af and  NewInputVoltage is not acurate in the book."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "New gain :18.182\n",
        "Distortion with negative feedback : 0.909%\n",
        "Initial Output Voltage in volt:100\n",
        "New Input Voltage in volts :5.50\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.8, Page No. 206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Feedback rction voltage and impedence\n",
      "import math\n",
      "\n",
      "#variable declaration\n",
      "A=10000.0                             #gain without feedback(unitless)\n",
      "Zi=10.0                               #in kOhm\n",
      "Zo=100.0                              #in Ohm\n",
      "R1=2.0                                #in Ohm\n",
      "R2=18.0                               #in Ohm\n",
      "\n",
      "#calculations\n",
      "\n",
      "#Part (i) :\n",
      "Beta=R1/(R1+R2)                     #feedback fraction(unitless)\n",
      "\n",
      "#Part (ii) :\n",
      "Af=A/(1+A*Beta)                     #Gain with negative feedback(unitless)\n",
      "\n",
      "#Part (iii) :\n",
      "inputVoltge=0.5                     #in mV\n",
      "outputVoltge=Af*inputVoltge         #in mV\n",
      "\n",
      "#Part (iv) :\n",
      "Zif=Zi*(1+Beta*A)                   #in kOhm\n",
      "\n",
      "#Part (v) :\n",
      "Zof=Zo/(1+Beta*A)                   #in kOhm\n",
      "\n",
      "print(\"(i)\\nFeedback Fraction :%.1f\"%Beta)\n",
      "print(\"\\n(ii)\\nGain with negative feedback :%.0f\"%(math.ceil(Af)))\n",
      "print(\"\\n(iii)\\nOutput Voltage in milli volts :%.0f\"%(math.ceil(outputVoltge)))\n",
      "print(\"\\n(iv)\\nInput impedance of feedback amplifier in Mohm : %.2f\"%(Zif*10**-3))\n",
      "print(\"\\n(v)\\nOutput impedance with feedback in Ohm : %.1f\"%Zof)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)\n",
        "Feedback Fraction :0.1\n",
        "\n",
        "(ii)\n",
        "Gain with negative feedback :10\n",
        "\n",
        "(iii)\n",
        "Output Voltage in milli volts :5\n",
        "\n",
        "(iv)\n",
        "Input impedance of feedback amplifier in Mohm : 10.01\n",
        "\n",
        "(v)\n",
        "Output impedance with feedback in Ohm : 0.1\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.9, Page No.207"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Voltage gain input and output resistance\n",
      "import math\n",
      "#variable declaration\n",
      "A=200                                #gain without feedback(unitless)\n",
      "Ri=2                                 #in kOhm\n",
      "Ro=12                                #in kOhm\n",
      "Beta=0.02                            #feedbak ratio(unitless)\n",
      "\n",
      "#Calculation\n",
      "\n",
      "#Part (i) :\n",
      "Af=A/(1+A*Beta)                      #gain with feedback(unitless)\n",
      "\n",
      "#Part (ii) :\n",
      "Rif=Ri*(1+A*Beta)                    #in kOhm\n",
      "\n",
      "#Part (ii) :\n",
      "Rof=Ro/(1+A*Beta)                    #in kOhm\n",
      "\n",
      "#Result\n",
      "print(\"(i)\\nGain with Negative Feedback :%.0f\"%Af)\n",
      "print(\"\\n(ii)\\nInput resistance with feedback in kOhm :%.0f\"%Rif)\n",
      "print(\"\\n(iii)\\nOutput resistance with feedback in kOhm :%.1f\"%Rof)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)\n",
        "Gain with Negative Feedback :40\n",
        "\n",
        "(ii)\n",
        "Input resistance with feedback in kOhm :10\n",
        "\n",
        "(iii)\n",
        "Output resistance with feedback in kOhm :2.4\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.10, Page No.207"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Gain wih feedbck in dB\n",
      "import math\n",
      "#variable declaration\n",
      "A=1000.0                       #gain(unitless)\n",
      "Beta=1.0/20.0                  #feedback ratio (unitless)\n",
      "\n",
      "#Calculation\n",
      "#Formula : Af=A/(1+A*Beta)\n",
      "Af=A/(1+A*Beta)                #gain with feedback(unitless)\n",
      "Af=20*math.log10(Af)           #in dB\n",
      "\n",
      "#Result\n",
      "print(\"Gain with feedback in dB : %.1f\"%Af)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gain with feedback in dB : 25.8\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      " example 5.11, page No.208"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Bandwidth after feedback\n",
      "import math\n",
      "#Variable declarations\n",
      "\n",
      "A=800.0                               #gain(unitless)\n",
      "f1=40.0                               #in Hz\n",
      "f2=16.0                               #in kHz\n",
      "Beta=2.0/100.0                        #feedback fator (unitless)\n",
      "\n",
      "#caalculations\n",
      "\n",
      "#Formula : Af=A/(1+A*Beta)\n",
      "Af=A/(1+A*Beta)                       #gain with feedback(unitless)\n",
      "BW=f2*10**3-f1                        #Bandwidth of amplifier in Hz\n",
      "f1_f=f1/(1+A*Beta)                    #in Hz\n",
      "f2_f=f2*(1+A*Beta)                    #in kHz\n",
      "BW_f=f2_f*10**3-f1_f                  #Bandwith after feedback in Hz\n",
      "\n",
      "#result\n",
      "print(\"Voltage gin with feedback : %.0f\"%Af)\n",
      "print(\"Bandwidth of amplifier in kHz : %.2f\"%(BW*10**-3))\n",
      "print(\"Bandwith after feedback in KHz : %.0f\"%(BW_f*10**-3))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage gin with feedback : 47\n",
        "Bandwidth of amplifier in kHz : 15.96\n",
        "Bandwith after feedback in KHz : 272\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      " example 5.12, Page No.208"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Gain and new bandwidth\n",
      "import math\n",
      "#Variable declaration\n",
      "A=100.0                           #gain(unitless)\n",
      "BW=10.0                           #in Hz\n",
      "Beta=5.0                          #in %\n",
      "\n",
      "#Calculations\n",
      "\n",
      "#Part (i) :\n",
      "#Formula : Af=A/(1+A*Beta)\n",
      "Af=A/(1+A*Beta/100.0)            #gain with feedback(unitless)\n",
      "\n",
      "#Part (ii)\n",
      "BW_f=BW*(1+A*Beta/100.0)         #Bandwith after feedback in Hz\n",
      "\n",
      "#Result\n",
      "print(\"Voltage gain with feedback :%.2f \"%Af)\n",
      "print(\"Bandwith with negative feedback in KHz : %.0f\"%BW_f)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage gain with feedback :16.67 \n",
        "Bandwith with negative feedback in KHz : 60\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 5.13, Page No.208"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Input resistance and voltage gain\n",
      "import math\n",
      "#variable decclaration\n",
      "hfe=50.0                                #unitless\n",
      "hie=1.1                                 #in kOhm\n",
      "hoe=0.0                                 #unitless\n",
      "hre=0.0                                 #unitless\n",
      "RL=4.0                                  #in kOhm\n",
      "Rs=10.0                                 #in kOhm\n",
      "RB=40.0                                 #in kOhm\n",
      "\n",
      "#calculation\n",
      "\n",
      "RLdash=RB*RL/(RB+RL)                    #in Kohm\n",
      "AV=-hfe*RLdash/hie                      #unitless\n",
      "\n",
      "#Part (i) ;\n",
      "Rif=hie*(RB/(1-AV))/(hie+(RB/(1-AV)))   #in kOhm\n",
      "print(\"Input resistance with feedback in Ohm : %.0f\"%(Rif*1000))\n",
      "#Part (ii) :\n",
      "AVf=AV*(Rif/(Rs+Rif))                   #unitless\n",
      "print(\"Voltage gain with feedback : %.2f\"%((math.ceil(AVf*100))/100))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Input resistance with feedback in Ohm : 197\n",
        "Voltage gain with feedback : -3.19\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}