{
 "metadata": {
  "name": "",
  "signature": "sha256:09753e7a346739f82308cf509d88fc83ed902094a78212d77e77c7b8bb5b6fee"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter01 : Differential Amplifiers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.1 : page 9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#given data\n",
      "Icq=100 #in uA\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "Ad=100 #unitless\n",
      "CMRRdB=60 #in dB\n",
      "#part (a)\n",
      "IE=2*Icq #in UA\n",
      "VT=25 #in mV\n",
      "re=2*VT/IE #in ohm\n",
      "RC=Ad*re #in Kohm\n",
      "CMRR=10**(CMRRdB/20) #using formula CMRRdB=20log10(CMRR)\n",
      "#calculate RE using formula CMRR=1+2*RE/re\n",
      "RE=((CMRR-1)*re)/2 #in Kohm\n",
      "print \"Value of RC is\",RC,\"kohm and value of RE is\",round(RE,1),\"kohm\" \n",
      "#part (b)\n",
      "Ri1=2*BETAac*re #in kohm\n",
      "Ri2=2*BETAac*re #in kohm\n",
      "print \"Value of Ri1 = Ri2 =\",Ri1,\"kohm\"\n",
      "#part (c)\n",
      "Ric=BETAac*(re+2*RE) #in kohm\n",
      "print \"Value of Ric is\",Ric/1000,\"Mohm.\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of RC is 25.0 kohm and value of RE is 124.9 kohm\n",
        "Value of Ri1 = Ri2 = 50.0 kohm\n",
        "Value of Ric is 25.0 Mohm.\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.2 : page 13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "#given data\n",
      "V1=50 #in uV\n",
      "V2=-50 #in uV\n",
      "Ad=2000 #unitless\n",
      "Ac=0.5 #unitless\n",
      "Vid=V1-V2 #in uV\n",
      "Vc=(V1+V2)/2 #in uV\n",
      "#output voltage\n",
      "Vo=Ad*Vid+Ac*Vc #in uV\n",
      "Vo=Vo*10**(-6) #in Volts\n",
      "CMRRdB=20*np.log10(Ad/Ac) \n",
      "print \"Output voltage = %0.2f V\" %(Vo)\n",
      "print \"CMRR = %0.1f dB\" %CMRRdB"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage = 0.20 V\n",
        "CMRR = 72.0 dB\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.3 : page 13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "#given data\n",
      "V1=5 #in mV\n",
      "V2=6 #in mV\n",
      "Ad=70 #in dB\n",
      "CMRR=90 #in dB\n",
      "Vid=V2-V1 #in mV\n",
      "Vc=(V1+V2)/2 #in mV\n",
      "Ad=10**(Ad/20) #unitless\n",
      "Ad=np.floor(Ad) \n",
      "CMRR=10**(CMRR/20) #unitless\n",
      "#output voltage\n",
      "Vo=Ad*(Vid+Vc/CMRR) #in mV\n",
      "Vo=round(Vo) \n",
      "Vo=Vo*10**(-3) #in Volts\n",
      "Vid=Vid*10**(-3) #in Volts\n",
      "ErrorVotage=Vo-Ad*Vid \n",
      "PercentageError=(ErrorVotage*100)/Vo \n",
      "print \"Output voltage = %0.3f Volts\"%Vo\n",
      "print \"ErrorVotage = %0.3f Volts\" %ErrorVotage \n",
      "print \"PercentageError = %0.3f %%\"%PercentageError"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output voltage = 3.163 Volts\n",
        "ErrorVotage = 0.001 Volts\n",
        "PercentageError = 0.032 %\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.4 : page 14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "V1=5 #in uV\n",
      "V2=4 #in uV\n",
      "Ad=80 #in dB\n",
      "CMRR=100 #in dB\n",
      "Ad=10**(Ad/20) #unitless\n",
      "CMRR=10**(CMRR/20) #unitless\n",
      "#differential mode output voltage \n",
      "Vid=V1-V2 #in uV\n",
      "Vod=Ad*Vid #in uV\n",
      "Vod=Vod*10**(-3) #in mV\n",
      "#common mode output voltage \n",
      "Vc=(V1+V2)/2 #in uV\n",
      "Ac=Ad/CMRR #unitless\n",
      "Voc=Ac*Vc #in uV\n",
      "print \"Differential mode output voltage = %0.2f mV\" %Vod\n",
      "print \"common mode output voltage = %0.2f uV\" %Voc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Differential mode output voltage = 10.00 mV\n",
        "common mode output voltage = 0.45 uV\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.5 : page 17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Rc=2 #in kohm\n",
      "VE=-5 #in volts\n",
      "VT=25 #in mVolts\n",
      "RE=4.3*1000 #in ohm\n",
      "IE=(-0.7-VE)/RE #in mA\n",
      "re=(2*VT*10**(-3))/IE #in ohm\n",
      "Rc=Rc*1000 #in ohms\n",
      "Ad=(Rc)/(2*re)\n",
      "Ac=-(Rc/(2*RE+re))\n",
      "CMRR=-Ad/Ac \n",
      "#CMRR is always positive\n",
      "print \"Differential mode gain = %0.2f \"%Ad\n",
      "print \"Common mode gain = %0.2f\"%Ac\n",
      "print \"CMRR = %0.2f\"%CMRR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Differential mode gain = 20.00 \n",
        "Common mode gain = -0.23\n",
        "CMRR = 86.50\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.6 : page 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Ad=50 #unitless\n",
      "I=5 #in mA\n",
      "VEE=15 #in Volts\n",
      "VD=0.7 #in Volts\n",
      "VT=25 #in mVolt\n",
      "#desired value of emitter current is 5 mA\n",
      "IE3=5 #in mA\n",
      "RE=VD/(IE3*10**(-3)) #in ohm\n",
      "VB3=VEE-2*VD #in volts\n",
      "I2=IE3 #in mA\n",
      "R2=VB3/I2 #in kohm\n",
      "IE1=IE3/2 #in mA\n",
      "IE2=IE1 #in mA\n",
      "re=(2*VT)/IE3 #in ohm\n",
      "RC=Ad*re #in ohm\n",
      "print \"Design values are :\"\n",
      "print \"Value of Rc = %0.f ohm\" %RC\n",
      "print \"Value of RE = %0.f ohm\" %RE\n",
      "print \"Value of R2 = %0.2f kohm\" %R2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Design values are :\n",
        "Value of Rc = 500 ohm\n",
        "Value of RE = 140 ohm\n",
        "Value of R2 = 2.72 kohm\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.7 : page 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Ri=600 #in kohm\n",
      "Vopp=5 #in volts\n",
      "VEE=15 #in volts\n",
      "VT=25 #in mVolts\n",
      "VD=0.7 #in Volts\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VBE=0.7 #in volts\n",
      "BETAact=BETAac*BETAdc #unitless\n",
      "#formula : Ri=2*BETAact*(2*re1)\n",
      "re1=Ri/(4*BETAact) #in ohm\n",
      "#formula : re1=VT/IE1\n",
      "IE1=(VT*10**(-3))/re1 #in mA\n",
      "IE3=2*IE1 #in mA\n",
      "RE=VD/(IE3*10**(-3)) #in ohm\n",
      "R2=(VEE-2*VD)/IE3 #in kohm\n",
      "IC=IE1 #in mA\n",
      "RC=1.25/(IC*10**(-3)) #in ohm\n",
      "print \"Thus the Design components values are :\"\n",
      "print \"Value of Rc = %0.f ohm\" %RC\n",
      "print \"Value of RE = %0.f ohm\" %RE\n",
      "print \"Value of R2 = %0.2f kohm\" %R2\n",
      "#Answer in the book is not as much accurate as calculated by Python."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thus the Design components values are :\n",
        "Value of Rc = 750 ohm\n",
        "Value of RE = 210 ohm\n",
        "Value of R2 = 4.08 kohm\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.8 : page 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VBE3=0.715 #in volts\n",
      "VD1=0.715 #in Volts\n",
      "VZ=6.2 #in Volts\n",
      "VT=25 #in mVolts\n",
      "IZt=41 #in mA \n",
      "VCC=10 #in Volts\n",
      "VEE=-10 #in Volts\n",
      "RC1=2.7 #in kohm\n",
      "RC=4.7 #in kohm\n",
      "#Part (a)\n",
      "VB3=VEE+VZ+VD1 #in volts\n",
      "VE3=VB3-VBE3\n",
      "IE3=(VE3-VEE)/RC1 #in mA\n",
      "#ICQ1=IE1=ICQ2=IE2\" \n",
      "IE2=IE3/2 #in mA\n",
      "ICQ1=IE2 #in mA\n",
      "ICQ2=IE2 #in mA\n",
      "IE1=IE2 #in mA\n",
      "VCEQ=VCC+VBE3-RC*ICQ1# formula for VCEQ \n",
      "print \"Operating point for Q1 and Q2 are : \"\n",
      "print \"VCEQ = %0.2f Volts\" %VCEQ\n",
      "print \"ICQ = %0.2f mA \" %ICQ1\n",
      "print \"and the operating point for Q3 :\"\n",
      "VCE3=-VBE3-VE3 #in Volts\n",
      "print \"VCE3 = %0.3f Volts\" %VCE3\n",
      "IC3=IE3 #in mA\n",
      "print \"IE3 = %0.2f mA \"%IE3\n",
      "#Part (b)\n",
      "re=(2*VT)/IC3 #in ohm\n",
      "Ad=(RC*1000)/re #unitless\n",
      "print \"Differential voltage gain = %0.2f  \"%Ad\n",
      "#Part (c)\n",
      "Ri=2*BETAac*re #in ohm\n",
      "print \"Input resistance = %0.2f kohm\"%(Ri/1000)\n",
      "#Answer in the book is not as much accurate as calculated by Python."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Operating point for Q1 and Q2 are : \n",
        "VCEQ = 5.32 Volts\n",
        "ICQ = 1.15 mA \n",
        "and the operating point for Q3 :\n",
        "VCE3 = 3.085 Volts\n",
        "IE3 = 2.30 mA \n",
        "Differential voltage gain = 215.85  \n",
        "Input resistance = 4.35 kohm\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.9 : page 35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Io=180 #in uA\n",
      "Vcc=20 #in Volts\n",
      "VBE=0.7 #in Volts\n",
      "BETA=120 #unitless\n",
      "IR=Io*(1+2/BETA) #in uA\n",
      "R=(Vcc-VBE)/(IR*10**-3) #in kohm\n",
      "print \"Value of IR = %0.2f uA\" %IR\n",
      "print \"Value of R = %0.1f kohm\"%R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of IR = 183.00 uA\n",
        "Value of R = 105.5 kohm\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.10 : page 35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "VBE=0.7 #in Volts\n",
      "BETA=120 #unitless\n",
      "IR=(VCC-VBE)/(3.6) #in mA\n",
      "IC=IR/2 #in mA\n",
      "Iload=IC #in mA\n",
      "print \"Load current in the circuit = %0.2f mA\"%Iload\n",
      "# Note : Derivation skip"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Load current in the circuit = 1.29 mA\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.11 : page 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Iload=0.5 #in mA\n",
      "BETA=150 #unitless\n",
      "VEB=0.7 #in Volts\n",
      "VCC=10 #in Volts\n",
      "IR=Iload*(1+2/BETA) #in mA\n",
      "R=(VCC-VEB)/IR #in kohm\n",
      "print \"Value of IR = %0.2f mA\"%IR\n",
      "print \"Value of R = %0.2f kohm\"%R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of IR = 0.51 mA\n",
        "Value of R = 18.36 kohm\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.12 : page 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=110 #unitless\n",
      "BETAdc=110 #unitless\n",
      "VBE=0.7 #in volts\n",
      "VEE=15 #in volts\n",
      "VT=25 #in mvolts\n",
      "R=2.7 #in kohm\n",
      "Rc=3.3 #in kohm\n",
      "IR=(VEE-VBE)/R #in mA\n",
      "IC3=IR #in mA\n",
      "IC1=IC3/2 #in mA\n",
      "IC2=IC3/2 #in mA\n",
      "re1=VT/IC1 #in ohm\n",
      "re2=re1 #in ohm\n",
      "#  part (i)\n",
      "Ad=(Rc*1000)/re1 #unitless\n",
      "#  part (ii)\n",
      "Ri1=2*BETAac*re1*10**(-3) #in kohm\n",
      "Ri2=2*BETAac*re2*10**(-3) #in kohm\n",
      "print \"Differential mode voltage gain = %0.2f\"%Ad\n",
      "print \"Input resistances are :\"\n",
      "print \"Ri1 = Ri2 = %0.2f kohm\"%Ri1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Differential mode voltage gain = 349.56\n",
        "Input resistances are :\n",
        "Ri1 = Ri2 = 2.08 kohm\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.13 : page 39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Ad=200 #unitless\n",
      "Ri=3#in kohm\n",
      "BETAac=110 #unitless\n",
      "BETAdc=110 #unitless\n",
      "VBE=0.7 #in volts\n",
      "VEE=15 #in volts\n",
      "VT=25 #in mvolts\n",
      "re=Ri/(2*BETAac) #in ohm\n",
      "RC=Ad*re #in kohm\n",
      "IC1=VT/re #in mA\n",
      "IR=2*IC1 #in mA\n",
      "IC3=IR #in mA\n",
      "R=(VEE-VBE)/(IR*10**(-3)) #in kohm\n",
      "print \"Value of resistance Rc = %0.2f kohm\"%RC\n",
      "print \"Value of resistance R = %0.2f kohm\"%R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of resistance Rc = 2.73 kohm\n",
        "Value of resistance R = 3.90 kohm\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.14 : page 39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Ad=400 #unitless\n",
      "Ri=3#in kohm\n",
      "BETAac=110 #unitless\n",
      "BETAdc=110 #unitless\n",
      "VBE=0.7 #in volts\n",
      "VEE=15 #in volts\n",
      "VT=25 #in mvolts\n",
      "#circuit bias current IR\n",
      "IR=3 #in mA\n",
      "R=(VEE-VBE)/(IR) #in kohm\n",
      "re=(2*VT)/IR #in ohm\n",
      "RC=Ad*re*10**-3 #in kohm\n",
      "Ri=2*BETAac*re*10**-3 #in kohm\n",
      "print \"Value of resistance R = %0.2f kohm\"%R\n",
      "print \"Value of resistance RC = %0.2f kohm\"%RC\n",
      "print \"Value of resistance Ri = %0.2f kohm\"%Ri"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of resistance R = 4.77 kohm\n",
        "Value of resistance RC = 6.67 kohm\n",
        "Value of resistance Ri = 3.67 kohm\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.15 : page 39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VBEon=0.7 #in volts\n",
      "VCC=5 #in volts\n",
      "VEE=-5 #in volts\n",
      "VT=25 #in mVolts\n",
      "R=18.6 #in kohm\n",
      "IR=(VCC-VBEon -VEE)/R #in mA\n",
      "IC1=IR/2 #in mA\n",
      "IC2=IC1 #in mA\n",
      "re1=(2*VT)/IR #in ohm\n",
      "re2=re1 #in ohm\n",
      "Ri1=2*BETAac*re1*10**-3 #in kohm\n",
      "Ri2=Ri1 #in kohm\n",
      "print \"Differential input resistances are :\"\n",
      "print \"Ri1 = Ri2 = %0.2f kohm\" %Ri1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Differential input resistances are :\n",
        "Ri1 = Ri2 = 20.00 kohm\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.16 : page 40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VBEon=0.7 #in volts\n",
      "VCC=5 #in volts\n",
      "VEE=-5 #in volts\n",
      "VT=25 #in mVolts\n",
      "R=18.6 #in kohm\n",
      "Ad=200 #unitless\n",
      "IR=(VCC-VBEon -VEE)/R #in mA\n",
      "IC1=IR/2 #in mA\n",
      "IC2=IC1 #in mA\n",
      "re1=(2*VT)/IR #in ohm\n",
      "re2=re1 #in ohm\n",
      "RC=Ad*re1*10**-3 #in kohm\n",
      "print \"Rc = %0.2f kohm\"%RC"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rc = 20.00 kohm\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.17 : page 41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VBE=0.7 #in volts\n",
      "VCC=10 #in volts\n",
      "VEE=-10 #in volts\n",
      "VT=25 #in mVolts\n",
      "R=3.6 #in kohm\n",
      "RC=2.2 #in kohm\n",
      "# part (i) #\n",
      "IR=(VCC-VBE-VEE)/R #in mA\n",
      "ICQ=IR/2 #in mA\n",
      "VE=-2*VBE #in Volts\n",
      "VC=VCC-ICQ*RC #in Volts\n",
      "VCEQ=VC-VE #in Volts\n",
      "print \"Operating point VCEQ = %0.2f Volt\"%VCEQ\n",
      "# part (ii) #\n",
      "re=VT/ICQ #in ohm\n",
      "re1=re #in ohm\n",
      "re2=re #in ohm\n",
      "reT=re1+re2 #in ohm\n",
      "Ad=(RC*1000)/reT # unitless\n",
      "print \"Differential voltage gain = %0.2f\" %Ad\n",
      "# part (iii) #\n",
      "BETAT=BETAac*BETAdc #unitless\n",
      "Rid=2*BETAT*reT*10**-3 #in kohm\n",
      "print \"Differential input resistance = %0.f kohm\"%Rid"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Operating point VCEQ = 5.50 Volt\n",
        "Differential voltage gain = 117.94\n",
        "Differential input resistance = 373 kohm\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.18 : page 43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Iload=20 #in uA\n",
      "VBE=0.7 #in volts\n",
      "VCC=10 #in Volts\n",
      "IR=Iload #in mA\n",
      "R=(VCC-2*VBE)/(IR*10**-3) #in kohm\n",
      "print \"R= %0.f kohm\"%R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "R= 430 kohm\n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.19 : page 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "#given data\n",
      "Io=10 #in uA\n",
      "IR=1 #in mA\n",
      "VBE2=0.7 #in volts\n",
      "VT=25 #in mVolts\n",
      "VCC=20 #in volts\n",
      "R=(VCC-VBE2)/IR #in kohm\n",
      "RE=((VT*10**-3)/(Io*10**-6))*np.log((IR*10**-3)/(Io*10**-6)) #in ohm\n",
      "RE=RE/1000 #in kohm\n",
      "print \"R = %0.2f kohm\"%R\n",
      "print \"RE = %0.2f kohm\"%RE\n",
      "#note : answer in the book of RE is wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "R = 19.30 kohm\n",
        "RE = 11.51 kohm\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.20 : 48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "#given data\n",
      "IR=2 #in mA\n",
      "I2=10 #in uA\n",
      "I3=20 #in uA\n",
      "VBE1=0.7 #in volts\n",
      "VT=25 #in mVolts\n",
      "VCC=10 #in volts\n",
      "VEE=-10 #in volts\n",
      "R=(VCC-VBE1-VEE)/IR #in kohm\n",
      "RE2=(VT/(I2*10**-3))*np.log(IR/(I2*10**-3)) #in kohm\n",
      "RE3=(VT/(I3*10**-3))*np.log(IR/(I3*10**-3)) #in kohm\n",
      "VBE2=VBE1-RE2*I2*10**-6 #in volts\n",
      "VBE3=VBE1-RE3*I3*10**-6 #in volts\n",
      "RE2=RE2/1000 #in kohm\n",
      "RE3=RE3/1000 #in kohm\n",
      "print \"Value of R = %0.2f kohm\"%R\n",
      "print \"Value of RE2 = %0.2f kohm\"%RE2\n",
      "print \"Value of RE3 = %0.2f kohm\"%RE3\n",
      "print \"Value of VBE2 = %0.3f Volt\"%VBE2\n",
      "print \"Value of VBE3 = %0.3f Volt\"%VBE3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of R = 9.65 kohm\n",
        "Value of RE2 = 13.25 kohm\n",
        "Value of RE3 = 5.76 kohm\n",
        "Value of VBE2 = 0.568 Volt\n",
        "Value of VBE3 = 0.585 Volt\n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.21 : page 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VBE=0.715 #in volts\n",
      "VEE=10 #in volts\n",
      "VT=25 #in mvolts\n",
      "R=5.6 #in kohm\n",
      "N=3 # as three transistors here\n",
      "IR=(VEE-VBE)/(R) #in mA\n",
      "IC1=IR/(1+(1+N)/BETAac) #in mA\n",
      "IC2=IR/(1+(1+N)/BETAac) #in mA\n",
      "IC3=IR/(1+(1+N)/BETAac) #in mA\n",
      "IRC=3*IC1 #in mA\n",
      "print \"Current through resistor Rc, I_RC = %0.2f mA\" %IRC\n",
      "print \"Collector Current for each transistor : \"\n",
      "print \"IC1 = IC2 = IC3 = %0.2f mA\" %IC1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current through resistor Rc, I_RC = 4.78 mA\n",
        "Collector Current for each transistor : \n",
        "IC1 = IC2 = IC3 = 1.59 mA\n"
       ]
      }
     ],
     "prompt_number": 53
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.22 : page 51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "I4=600 #in uA\n",
      "I2=10 #in uA\n",
      "I3=20 #in uA\n",
      "VCC=10 #in volts\n",
      "VEE=-10 #in volts\n",
      "VBE=0.7 #in volts\n",
      "VEB=0.7 #in volts\n",
      "IR=I4/3 #in uA\n",
      "I2=2*IR #in uA\n",
      "I1=IR #in uA\n",
      "I3=IR #in uA\n",
      "R=(VCC-VEB-VBE-VEE)/(IR*10**(-3)) #in kohm\n",
      "print \"IR = %0.f uA \" %IR\n",
      "print \"I1 = %0.f uA\"%I1\n",
      "print \"I2 = %0.f uA \" %I2\n",
      "print \"I3 = %0.f uA\" %I3\n",
      "print \"R = %0.f kohm\"%R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "IR = 200 uA \n",
        "I1 = 200 uA\n",
        "I2 = 400 uA \n",
        "I3 = 200 uA\n",
        "R = 93 kohm\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.23 : page 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Vo=5 #in volts\n",
      "BETAac=150 #unitless\n",
      "BETAdc=150 #unitless\n",
      "VT=25 #in mvolts\n",
      "VCC=10 #in volts\n",
      "VD=0.7 #in volts\n",
      "R1=2.7 #in kohm\n",
      "R2=1.5 #in kohm\n",
      "# part (i) #\n",
      "IR=(VCC-VD)/R1 #in mA\n",
      "IC=(IR-VD/R2)/(1+2/BETAac) #in mA\n",
      "IC1=IC #in mA\n",
      "IC2=IC #in mA\n",
      "RC=(VCC-Vo)/IC #in kohm\n",
      "print \"IC1 = %0.2f mA\" %IC1\n",
      "print \"IC2 = %0.2f mA\" %IC2\n",
      "print \"RC = %0.2f kohm\" %RC"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "IC1 = 2.94 mA\n",
        "IC2 = 2.94 mA\n",
        "RC = 1.70 kohm\n"
       ]
      }
     ],
     "prompt_number": 57
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.24 : page 53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VT=25 #in mvolts\n",
      "VEE=15 #in volts\n",
      "VCC=15 #in volts\n",
      "VBE=0.7 #in volts\n",
      "VEB=-0.7 #in volts\n",
      "R2=2.2 #in kohm\n",
      "RC1=2.5 #in kohm\n",
      "RC6=1.2 #in kohm\n",
      "RE8=1.2 #in kohm\n",
      "I2=(VEE-VBE)/R2 #in mA\n",
      "IC3=I2 #in mA\n",
      "IC7=I2 #in mA\n",
      "IC9=I2 #in mA\n",
      "IC1=I2/2 #in mA\n",
      "IC2=IC1 #in mA\n",
      "IC5=IC1 #in mA\n",
      "IC6=IC1 #in mA\n",
      "IC8=I2 #in mA\n",
      "IC9=I2 #in mA\n",
      "# calculation of collector to emitter voltages \n",
      "VC1=VCC-IC1*RC1 #in Volts\n",
      "VC2=VC1 #in Volts\n",
      "VCE1=VC1-VEB #in Volts\n",
      "VCE2=VCE1 #in Volts\n",
      "VE5=VC1-VBE #in Volts\n",
      "VE6=VE5 #in Volts\n",
      "VC6=VCC-RC6*IC6\n",
      "VCE5=VCC-VE5 \n",
      "VCE6=VCC-VE6 \n",
      "VE8=VC6-VBE \n",
      "VCE8=VCC-VE8 \n",
      "# calculation of ac emitter resistances \n",
      "re1=VT/IC1 #in ohm\n",
      "re2=re1 #in ohm\n",
      "re5=re1 #in ohm\n",
      "re6=re1 #in ohm\n",
      "re8=VT/IC8 #in ohm\n",
      "#input resistance of second stage is\n",
      "Ri2=2*BETAac*re6*10**(-3) #in kohm\n",
      "# voltage gain of first stage\n",
      "Ad1=(((RC1*Ri2)/(RC1+Ri2)))/(re1*10**(-3)) \n",
      "#input resistance of third stage is\n",
      "Ri3=BETAac*(re8+RE8) #in kohm\n",
      "# voltage gain of second stage\n",
      "Ad2=(((RC6*Ri3)/(RC6+Ri3)))/(2*re6*10**(-3)) \n",
      "Ad3=1 \n",
      "#Overall gain of the circuit\n",
      "Ad=Ad1*Ad2*Ad3 \n",
      "#voltage drop across collector resistor\n",
      "VRC6=IC1*RC6 #in volts\n",
      "#Maximum peak to peak output voltage swing\n",
      "Vopp=3.9 # in volt\n",
      "## part (i)\n",
      "print \"The operating point for each transistor :\" \n",
      "print \"For transistor 1:\" \n",
      "print \"IC1 = %0.2f mA\"%IC1, \n",
      "print \"& VCE1 = %0.3f Volt\" %VCE1\n",
      "print \"For transistor 2:\" \n",
      "print \"IC2 = %0.2f mA\"%IC2, \n",
      "print \"& VCE2 = %0.3f Volt\" %VCE2\n",
      "print \"For transistor 5:\"\n",
      "print \"IC5 = %0.2f mA\"%IC5, \n",
      "print \"& VCE5 = %0.3f Volt\" %VCE5\n",
      "print \"For transistor 6:\" \n",
      "print \"IC6 = %0.2f mA\"%IC6, \n",
      "print \"& VCE6 = %0.3f Volt\" %VCE6\n",
      "print \"For transistor 8:\" \n",
      "print \"IC8 = %0.2f mA\"%IC8, \n",
      "print \"& VCE8 = %0.2f Volt\" %VCE8\n",
      "## part (ii)\n",
      "print \"Overall voltage gain of the circuit = %0.2f \"%Ad \n",
      "## part (iii)\n",
      "print \"Maximum peak to peak output voltage swing = %0.2f \"%Vopp\n",
      "#note :answer in the book is not as much accurate as calculated by Python"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The operating point for each transistor :\n",
        "For transistor 1:\n",
        "IC1 = 3.25 mA & VCE1 = 7.575 Volt\n",
        "For transistor 2:\n",
        "IC2 = 3.25 mA & VCE2 = 7.575 Volt\n",
        "For transistor 5:\n",
        "IC5 = 3.25 mA & VCE5 = 8.825 Volt\n",
        "For transistor 6:\n",
        "IC6 = 3.25 mA & VCE6 = 8.825 Volt\n",
        "For transistor 8:\n",
        "IC8 = 6.50 mA & VCE8 = 4.60 Volt\n",
        "Overall voltage gain of the circuit = 9634.23 \n",
        "Maximum peak to peak output voltage swing = 3.90 \n"
       ]
      }
     ],
     "prompt_number": 63
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.25 : page 55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAmin=80 #unitless\n",
      "BETAmax=120 #unitless\n",
      "IE=400 #in uA\n",
      "VT=25 #in mvolts\n",
      "VEE=15 #in volts\n",
      "VCC=15 #in volts\n",
      "VBE=0.7 #in volts\n",
      "VEB=-0.7 #in vol\n",
      "IE1=IE/2 #in uA\n",
      "IE2=IE1 #in uA\n",
      "IBmax=IE1/(1+BETAmin) #in uA\n",
      "IBmin=IE1/(1+BETAmax) #in uA\n",
      "Iiomax=IBmax-IBmin #in uA\n",
      "print \"Largest possible input bias current = %0.3f uA\"%IBmax\n",
      "print \"smallest possible input bias current = %0.3f uA \" %IBmin\n",
      "print \"Largest possible input offset current = %0.3f uA\"%Iiomax"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Largest possible input bias current = 2.469 uA\n",
        "smallest possible input bias current = 1.653 uA \n",
        "Largest possible input offset current = 0.816 uA\n"
       ]
      }
     ],
     "prompt_number": 67
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.26 : page 58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VT=25 #in mvolts\n",
      "VEE=10 #in volts\n",
      "VCC=10 #in volts\n",
      "VBE=0.7 #in volts\n",
      "VEB=-0.7 #in volts\n",
      "RC2=2.7 #in kohm\n",
      "RC1=2.7 #in kohm\n",
      "RC3=1.5 #in kohm\n",
      "RC4=1.5 #in kohm\n",
      "RE1=5 #in kohm\n",
      "RE2=10 #in kohm\n",
      "RE3=10 #in kohm\n",
      "IE1=(VEE-VBE)/(2*RE1) #in mA\n",
      "IC1=IE1 \n",
      "#as Q1 and Q2 are identical\n",
      "IC2=IC1 \n",
      "VC1=VCC-RC1*IC1 \n",
      "VE1=-0.7 #in Volts\n",
      "VE2=0.7 #in Volts\n",
      "VCE1=VC1-VE1 \n",
      "VCE2=VCE1 \n",
      "IE3=(VCC-RC2*IC2-VBE+VEE)/(2*RE3) #in mA \n",
      "IE4=IE3 #in mA\n",
      "VC3=VCC-RC3*IE3 #in Volts\n",
      "VC4=VC3 #in Volts\n",
      "VE3=VC1-VBE #in Volts\n",
      "VCE3=VC3-VE3 #in Volts\n",
      "VCE4=VCE3 #in Volts\n",
      "print \"Operating point for Q1 & Q2 becomes : \"\n",
      "print \"ICQ = %0.2f mA & VCEQ = %0.2f Volts \"%(IC1,VCE1 )\n",
      "print \"And operating point for Q3 & Q4 becomes : \"\n",
      "print \"ICQ = %0.2f mA & VCEQ = %0.2f Volts\"%(IE3,VCE3)\n",
      "\n",
      "re1=VT/IC1 #in ohm\n",
      "re2=re1 #in ohm\n",
      "re3=VT/IE3 #in ohm\n",
      "re4=re3 #in ohm\n",
      "Ri2=2*BETAac*re3 #in ohm\n",
      "Ri2=Ri2*10**-3 #in kohm\n",
      "Ad1=((RC1*Ri2)/(RC1+Ri2))/(re1*10**-3) \n",
      "Ad2=RC4/(2*re4*10**-3) \n",
      "Ad=Ad1*Ad2 \n",
      "print \"Overall voltage gain = %0.2f\" %Ad\n",
      "Ri1=2*BETAac*re1 #in ohm\n",
      "Ri1=Ri1/1000 #in kohm\n",
      "print \"Input resistance of the cascaded differential amplifier = %0.2f kohm\" %Ri1\n",
      "Ro2=RC4 #in kohm\n",
      "print \"Output resistance of the cascaded differential amplifier = %0.2f kohm  \" % Ro2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Operating point for Q1 & Q2 becomes : \n",
        "ICQ = 0.93 mA & VCEQ = 8.19 Volts \n",
        "And operating point for Q3 & Q4 becomes : \n",
        "ICQ = 0.84 mA & VCEQ = 1.95 Volts\n",
        "Overall voltage gain = 1740.47\n",
        "Input resistance of the cascaded differential amplifier = 5.38 kohm\n",
        "Output resistance of the cascaded differential amplifier = 1.50 kohm  \n"
       ]
      }
     ],
     "prompt_number": 69
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exa 1.27 : page 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "BETAac=100 #unitless\n",
      "BETAdc=100 #unitless\n",
      "VT=25 #in mvolts\n",
      "VEE=10 #in volts\n",
      "VCC=10 #in volts\n",
      "VBE=0.7 #in volts\n",
      "VD=0.7 #in volts\n",
      "IE6=2 #in mA\n",
      "IE1=3.25 #in mA \n",
      "Ri2=1.538 #in kohm\n",
      "RC1=2.5 #in kohm\n",
      "re8=3.85 #in kohm\n",
      "RE8=1.2 #in kohm\n",
      "RC6=1.2 #in kohm\n",
      "RE=VD/(IE6*10**-3) #in ohm\n",
      "R=(VEE-2*VD)/IE6 #in kohm\n",
      "VB5=8.74 #in Volts\n",
      "VE5=VB5-VBE \n",
      "R1=VE5/IE6 #in kohm\n",
      "re1=VT/IE1 #in ohm\n",
      "re2=re1; re5=re1; re6=re1 #in ohm\n",
      "re8=VT/6.5 #in ohm\n",
      "Ri2=2*BETAac*re6*10**-3 #in kohm\n",
      "Ad1=(1000*(RC1*Ri2)/((RC1+Ri2)))/re1 \n",
      "Ri3=BETAac*(re8*10**-3+RE8) #in kohm\n",
      "Ad2=(1000*(RC6*Ri3)/(RC6+Ri3))/(2*re6) \n",
      "Ad=Ad1*Ad2 \n",
      "VRC6=RC6*IE1 #in Volts\n",
      "Vopp=VRC6 #in Volts\n",
      "print \"Value of RE = %0.2f ohm\"%RE\n",
      "print \"Value of R = %0.2f kohm\"%R\n",
      "print \"Value of VE5 = %0.2f Volt\"%VE5\n",
      "print \"Value of R1 = %0.2f kohm\"% R1\n",
      "print \"AC emitter resistances re1 = re2 = re5 = re6 = %0.2f ohm\" %re1\n",
      "print \"Abd re8 = %0.2f ohm\"%re8\n",
      "print \"Input resistance of 2nd stage Ri2 = %0.3f kohm \"%Ri2\n",
      "print \"Voltage gain of 1st stage = %0.2f\"%Ad1 \n",
      "print \"Voltage gain of 2nd stage = %0.2f\"%Ad2 \n",
      "Ad3=1 \n",
      "print \"Voltage gain of 3rd stage = %0.2f\" %Ad3 \n",
      "print \"Overall Voltage gain of the circuit = %0.2f\" %Ad \n",
      "print \"Voltage drop across collector resistor = %0.2f Volt\"%VRC6\n",
      "print \"Maximum peak to peak output voltage swing = %0.2f Volt\"%Vopp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of RE = 350.00 ohm\n",
        "Value of R = 4.30 kohm\n",
        "Value of VE5 = 8.04 Volt\n",
        "Value of R1 = 4.02 kohm\n",
        "AC emitter resistances re1 = re2 = re5 = re6 = 7.69 ohm\n",
        "Abd re8 = 3.85 ohm\n",
        "Input resistance of 2nd stage Ri2 = 1.538 kohm \n",
        "Voltage gain of 1st stage = 123.81\n",
        "Voltage gain of 2nd stage = 77.23\n",
        "Voltage gain of 3rd stage = 1.00\n",
        "Overall Voltage gain of the circuit = 9561.83\n",
        "Voltage drop across collector resistor = 3.90 Volt\n",
        "Maximum peak to peak output voltage swing = 3.90 Volt\n"
       ]
      }
     ],
     "prompt_number": 72
    }
   ],
   "metadata": {}
  }
 ]
}