{
 "metadata": {
  "name": "",
  "signature": "sha256:38e4b5c5a213abfd3f2257eb6ecdfd3c14d4e997b4c58b00b3484c2a059038e7"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "\n",
      "Chapter 3:           SMALL SIGNAL MODELS,AMPLIFICATION AND BIASING"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1,Page number 136"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=100            #current gain\n",
      "Ic=2.5               #collector current(mA)\n",
      "Io=-0.5              #output current(mA) \n",
      "Rl=2.5               #load resistance(kohm)\n",
      "\n",
      "#Calculations\n",
      "rpi=beeta*(25/Ic)   #dynamic resistance(ohms)\n",
      "Ib=Io/(-beeta)      #as Io=-beeta*Ib\n",
      "Vs=rpi*Ib           #signal voltage(V)\n",
      "Vo=Rl*Io            #output voltage(V)\n",
      "Av=Vo/Vs            #voltage gain\n",
      "Ai=Io/Ib            #current gain\n",
      "\n",
      "#Results\n",
      "print\"signal voltage is\",Vs,\"mV\"\n",
      "print\"current gain is\",Ai\n",
      "print\"voltage gain is\",round(Av/1E-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "signal voltage is 5.0 mV\n",
        "current gain is -100.0\n",
        "voltage gain is -250.0\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2,Page number 139"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Id=1.6               #drain current(mA)\n",
      "Vgs=-3               #gate to source voltage(V)\n",
      "Id1=.4               #drain current(mA)\n",
      "Vgs1=-4              #gate to source voltage(V)   \n",
      "Vp=-5                #peak voltage(V) by solving equations 1.6=Idss(1+3/Vp)^2 and .4=Idss(1+4/Vp)^2\n",
      "Idss=10              #small signal drain current(mA) by solving equations 1.6=Idss(1+3/Vp)^2 and .4=Idss(1+4/Vp)^2\n",
      "                      \n",
      "#Calculations\n",
      "gmo=-(2*Idss)/Vp                #transconductance(mS)\n",
      "gm=gmo*(math.sqrt(Id/Idss))     #transconductance(uS)\n",
      "gm1=gmo*(math.sqrt(Id1/Idss))   #transconductance(uS) \n",
      "\n",
      "#Results\n",
      "print\"Idss and Vp are\",Idss,\"mA and\",Vp,\"V\"\n",
      "print\"gmo is\",gmo,\"mS\"\n",
      "print\"gm at Id is\",round(gm/1E-3),\"and gm at Id1 is\",round(gm1/1E-3),\"uS\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Idss and Vp are 10 mA and -5 V\n",
        "gmo is 4 mS\n",
        "gm at Id is 1600.0 and gm at Id1 is 800.0 uS\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3,Page number 140"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "gm=1600             #gm(us)\n",
      "rd=50               #resistance(kohms)\n",
      "Rl=5                #load resistance(kohms)\n",
      "\n",
      "#Calculations\n",
      "Av=-gm*Rl           #Vgs=Vs from circuit model\n",
      "                    #Vo=-(gm*Vgs)*Rl\n",
      "                    #as Av=Vo/Vs=-gm*Rl     \n",
      "\n",
      "#Result\n",
      "print\"voltage gain of the circuit is\",round(Av/1E+3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "voltage gain of the circuit is -8.0\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4,Page number 145"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beta=100.       #current gain\n",
      "rpi=2*10**3     #dynamic resistance(ohms)\n",
      "rx=500          #resistance(ohms)\n",
      "ro=250*10**3    #output resistance(ohms)\n",
      "R1=50*10**3     #resistance(k ohms)   \n",
      "R2=10*10**3     #resistance(k ohms)\n",
      "Rc=5*10**3      #collector current(k ohms) \n",
      "Rl=5*10**3.     #load current(k ohms)\n",
      "Rs=1*10**3      #source resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "Rb=(R1*R2)/(R1+R2)               #equivalent resistance of R1 and R2(kohms)\n",
      "r=rpi+rx                         #series resistance of rpi and rx(k ohms) \n",
      "gm=beta/rpi                      #transconductance(mS)\n",
      "Vo=-gm*((Rc*Rl)/(Rc+Rl))*.526    #output voltage(V) as \n",
      "Av=Vo                            #voltage gain\n",
      "Ai=Av*((Rs+((Rb*r)/(Rb+r)))/Rl)  #current gain \n",
      "\n",
      "#Results\n",
      "print\"source to load voltage gain is\",Av\n",
      "print\"source to load current gain is\",Ai,\"(Solution given in the textbook is incorrect)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "source to load voltage gain is -65.75\n",
        "source to load current gain is -38.43745 (Solution given in the textbook is incorrect)\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5,Page number 148"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beta=100.       #current gain\n",
      "rd=50*10**3     #internal dynamic resistance(ohms\n",
      "gm=5*10**-3     #transconductance(mS)\n",
      "R1=50*10**3     #resistance(ohms)   \n",
      "R2=10*10**3      #resistance(ohms)\n",
      "Rs=10*10**3      #source current(ohms) \n",
      "Rg=1*10**6.      #gate resistance(ohms)\n",
      "Rd=10*10**3      #drain resistance(ohms)\n",
      "\n",
      "#Calculations                      \n",
      "Vgs=(Rg/(Rs+Rg))                 #gate to source voltage (V) as Vgs=Vs((Rg/(Rs+Rg))   \n",
      "Av=-Vgs*gm*((rd*Rd)/(rd+Rd))      #voltage gain,Av=Vo/Vs and Vo=-gmVgs(rd||Rd)\n",
      "Ai=Av*((Rs+Rg)/Rd)               #current gain\n",
      "\n",
      "#Results\n",
      "print\"source to load voltage gain is\",round(Av)\n",
      "print\"source to load current gain is\",round(Ai)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "source to load voltage gain is -41.0\n",
        "source to load current gain is -4167.0\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6,Page number 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Rs=500           #collector current(k ohms) \n",
      "Io=-1*10**-3     #output current(mA) \n",
      "Rc=5*10**3.       #collector resistance(ohms)\n",
      "hie=2*10**3\n",
      "hoe=10*10**-6.    \n",
      "hfe=100.\n",
      "hre=5*10**-4\n",
      "Rb=50*10**3.     #base resistance(ohms)\n",
      "\n",
      "#Calculations                      \n",
      "Io1=-1/(1+Rc*hoe)*hfe   #as Io=-1/(1+Rc*hoe)*hfe*Ib \n",
      "Ib=-1/Io1               #base current(uA)\n",
      "Vo=Io*Rc                #output voltage(V)\n",
      "Vi=hie*Ib+Vo*hre        #input voltage(V)\n",
      "Is=Ib+Vi/Rb             #source current(ohms)\n",
      "Ai=Io/Is                #current gain\n",
      "Vs=(Is*Rs)+Vi           #source voltage(V)\n",
      "Av=Vo/Vs                #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"source to load voltage gain is\",round(Av/1E-3)\n",
      "print\"source to load current gain is\",round(Ai/1E-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "source to load voltage gain is -189.0\n",
        "source to load current gain is -92.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7,Page number 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=100.      #current gain  \n",
      "Ic=4.           #collector current(mA)\n",
      "Vbe=0.7         #base to emitter voltage(V)  \n",
      "Re=2.           #emitter resistance(ohms)\n",
      "Vcc=32.         #supply voltage(V)\n",
      "abeeta=40.      #actual current gain\n",
      "\n",
      "#Calculations\n",
      "Ib=Ic/beeta                        #base current(mA)\n",
      "Rb=(Vcc-Vbe-((Ib+Ic)*Re))/Ib       #as Vcc=(Ib*Rb)+Vbe+(Ib+Ic)*Re              \n",
      "Ib=(Vcc-Vbe-8)/(Rb+Re)             #as Vcc=Rb*Ib+Vbe+(Ib+Ic)*Re\n",
      "Ic1=abeeta*Ib                      #collector current(mA)\n",
      "deltaIc=Ic-Ic1                     #change in collector current(mA)\n",
      "\n",
      "#Result\n",
      "print\"change in Ic when beeta=40 is\",deltaIc,\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "change in Ic when beeta=40 is 2.4 mA\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8,Page number 155"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Rb1=36                   #base resistance 1(kohms)\n",
      "Rb2=12                   #base resistance 2(kohms)\n",
      "Rc=4                     #emitter resistancce(kohms) \n",
      "Re=1.8                   #emitter resistance(kohms)    \n",
      "Vcc=12                   #supply voltage(V)\n",
      "Vbe=0.7                  #base to emitter voltage(V)\n",
      "\n",
      "#Calculations\n",
      "Rb=(Rb1*Rb2)/(Rb1+Rb2)   #base resistance(ohms)\n",
      "Vbb=Vcc*(Rb2/(Rb1+Rb2))  #voltage supply to base(V)\n",
      "                         #(10.8*Ib)+(1.8*Ic)=2.3    equation 1...solving -Vbb+RbIb+Vbe+(Ib+IC)Re\n",
      "                          #(1.8*Ib)+(5.8*Ic)+Vce=12  equation 2  solving -Vcc+RcIc+Vce+(Ob+Ic)Re\n",
      "#Part a\n",
      "beeta=50              #current gain  \n",
      "Ib=2.3/100.8          #(10.8*Ib)+(90*Ib)=2.3 ,using -Vbb+Rb*Ib+Vbe+(Ib+Ic)*Re  \n",
      "                      #as Ic=50Ib and putting this in equation 1      \n",
      "Icq=Ib*beeta\n",
      "Vceq=Vcc-(1.8*Ib)-(5.8*Icq) #from equation 2\n",
      "\n",
      "#Part b\n",
      "beeta=150           #current gain  \n",
      "Ib=2.3/280.8        # (10.8*Ib)+(270*Ib)=2.3,using -Vcc+Rc*Ic+Vce+(Ib+Ic)*Re   \n",
      "                    #as Ic=150Ib and putting this in equation 1      \n",
      "Icq1=Ib*beeta                           \n",
      "Vceq1=Vcc-(1.8*Ib)-(5.8*Icq1)         #from equation 2\n",
      "\n",
      "#Results\n",
      "print\"when beeta increases by 300%,Icq increases by\",round((((Icq1-Icq)/Icq1)*100),1),\"%\"\n",
      "print\"when beeta increases by 300%, Vceq increases by\",round(((Vceq-Vceq1)/Vceq)*100),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "when beeta increases by 300%,Icq increases by 7.1 %\n",
        "when beeta increases by 300%, Vceq increases by 9.0 %\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.9,Page number 156"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ic=4                      #collector current(mA)\n",
      "Vce=8                     #collector emitter voltage(V) \n",
      "beeta=100                 #current gain   \n",
      "Rb2=24                    #base resistance(kohms)\n",
      "Vbe=0.7                   #base to emitter voltage(V)\n",
      "Rc=4                     #collector current(kohm)\n",
      "Re=2                     #emitter resistance(kohms) \n",
      "Ib=0.04                  #base current(mA) \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vcc=(Ic*Rc)+Vce+Ic*Re         #from formula Vcc=IcRc+Vce+(Ic+Ib)Re..eq 1\n",
      "\n",
      "#Part b\n",
      "Rb1=Rb2*(Vcc-(Vbe+Ic*Re))/((Vbe+Ic*Re)+Ib)  #from eq 1 and also from Vbb= Vcc(Rb2/(Rb1+Rb2))\n",
      "Rb=(Rb1*Rb2)/(Rb1+Rb2)                      #base resistance(ohms)\n",
      "Vbb=(Vcc*Rb2)/(Rb1+Rb2)                     #supply to base(V)\n",
      "\n",
      "#Part c\n",
      "abeeta=40                                 #actual current gain\n",
      "Ib1=((Vbe+Re*Ic)-Vbe)/((1+abeeta)*2+Rb)   #from equation Vbb=IbRb+Vbe+(Ic+Ib)Re\n",
      "Ic1=abeeta*Ib1                            #collector gain\n",
      "\n",
      "#Results\n",
      "print\"a)Vcc is\",Vcc,\"V\"\n",
      "print\"b)values are Rb1:\",round(Rb1,2),\"KOhms,Rb:\",round(Rb,2),\"kohm and Vbb:\",round(Vbb,2),\"V\" \n",
      "print\"c)actual value of Ic1\",round(Ic1,2),\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)Vcc is 32 V\n",
        "b)values are Rb1: 63.98 KOhms,Rb: 17.45 kohm and Vbb: 8.73 V\n",
        "c)actual value of Ic1 3.22 mA\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.10,Page number 158"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vcc=10       #supply voltage(V)\n",
      "Rc=4.7       #collector current(kohms)\n",
      "Rb=250       #base resistance(kohms)\n",
      "Re=1.2       #emitter resistance(kohms)\n",
      "beeta=100    #current gain\n",
      "Vbe=0.7      #base to emitter voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Ib=(Vcc-Vbe)/(Rb+(beeta*(Rc+Re)))   #base current(uA)\n",
      "Ic=beeta*Ib                         #collector current(mA)\n",
      "Vce=Vcc-Ic*(Rc+Re)                  #collector to emitter voltage(V)\n",
      "#Part b\n",
      "beeta1=150                          #current gain\n",
      "Ib1=(Vcc-Vbe)/(Rb+(beeta1*(Rc+Re))) #base current(mA)\n",
      "Ic1=beeta1*Ib1                      #collector current(mA)\n",
      "Vce1=Vcc-Ic1*(Rc+Re)                #collector to emitter voltage(V)\n",
      "deltaIc=((Ic1-Ic)/Ic)*100           #small change in Ic(mA)\n",
      "deltaVce=((Vce-Vce1)/Vce)*100       #small change in Vce(V)\n",
      "\n",
      "#Results\n",
      "print\"values of Ic is\",round(Ic,2),\"mA and Vce:\",round(Vce,2),\"V\"\n",
      "print\"values of Ic1 is\",round(Ic1,2),\"mA and Vce1 is\",round(Vce1,2),\"V\"\n",
      "print\"% change in Ic is\",round(deltaIc,2),\"% and in Vce is\",round(deltaVce,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "values of Ic is 1.11 mA and Vce: 3.47 V\n",
        "values of Ic1 is 1.23 mA and Vce1 is 2.75 V\n",
        "% change in Ic is 11.01 % and in Vce is 20.74 %\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.11,Page number 160"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Id=3              #drain current(mA)\n",
      "Vds=12            #drain source voltage(V)\n",
      "Vgs=-3            #gate source voltage(V)\n",
      "Vdd=36            #drain voltage(V)\n",
      "Vgg=12            #gate voltage(V)\n",
      "Rg=12             #gate resistance(Mohms)\n",
      "\n",
      "#Calculations\n",
      "R1=(Rg*Vdd)/Vgg             #resistance(Mohms)\n",
      "R2=(Rg*R1)/(R1-Rg)          #resistance(kohms)\n",
      "Rs=(Vgg-Vgs)/Id             #resistance(kohms)\n",
      "Rd=(Vdd-Vds-Id*Rs)/Id       #as Vdd-IdRd-Vds-IdRs\n",
      "Vgs=-3.6                    #consider Vgs increases by 20%\n",
      "Idnew=(Vgg-Vgs)/Rs          #new drain current(mA)\n",
      "\n",
      "#Results\n",
      "print\"value of R1:\",R1,\"MOhm,R2:\",R2,\"Mohms,Rs:\",Rs,\"KOhm and Rd:\",Rd,\"kohms\"\n",
      "print\"new Id is\",Idnew,\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of R1: 36 MOhm,R2: 18 Mohms,Rs: 5 KOhm and Rd: 3 kohms\n",
        "new Id is 3.12 mA\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.12,Page number 161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import*\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "k=0.0002                    #device parameter\n",
      "Vt=4                        #thevinin voltage(V)   \n",
      "Vdd=24                      #drain voltage(V)\n",
      "Id0=3                        #drain current(mA)  \n",
      "\n",
      "#Calculations\n",
      "Vgs=(math.sqrt(Id0/k))+4   #as Id=k(Vgs-Vt)^2\n",
      "Rd=-(Vgs-Vdd)/Id0         #as Vds=Vdd-IdRd and Vgs=Vds=7.87                        \n",
      "k=0.0003                  #device parameter \n",
      "\n",
      "Id=symbols('Id')\n",
      "expr=solve(Id**2-7.5*Id+13.7,Id)\n",
      "print\"equation has 2 solutions\",expr                                    # putting value of k=0.0003 in eq of Id,\n",
      "Id1=3.15                                    # we get Vgs=Vds=24-5.4Id and putting Vgs again in Id we get,\n",
      "                                    # Id^2-7.5Id+13.7=0\n",
      "                                    \n",
      "Idchange=((Id1-Id0)/Id0)*100                                                    #changed Id(mA)\n",
      "\n",
      "#Result\n",
      "print\"change in Id is\",Idchange,\"% increase\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "equation has 2 solutions [3.14792027106039, 4.35207972893962]\n",
        "change in Id is 5.0 % increase\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.13,Page number 162"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration \n",
      "Vt=2                        #threshold voltage(V)\n",
      "Id=8                        #drain current(mA)\n",
      "Vgs=6.                       #gate to source voltage(V)\n",
      "k=0.5                       #device parameter\n",
      "Vdd=24                      #drain voltage(V)\n",
      "Vds=10                       #drain to source voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vgs1=4                                            #gate to source voltage(V) \n",
      "Id1=k*(Vgs1-Vt)**2                                 #drain current(mA)\n",
      "\n",
      "#Part b\n",
      "Vgg=3*Vgs1                                         #gate voltage(V)\n",
      "R2=(Vdd/Vgg)-1                                    #resistance(Mohms)\n",
      "Rs=(Vgg-Vgs1)/2                                    #source resistance(k ohms)\n",
      "Rd=(Vdd-Vds-Id1*Rs)/2\n",
      "\n",
      "#part c\n",
      "K=1.5*k                   #increased by 50%\n",
      "Vgs2=3.67                 #solving 12=Vgs+4Id and Id=0.75(Vgs-2)^2 \n",
      "Id2=2.08                   #drain current when k is increased(mA)\n",
      "Vds1=Vdd-Id2*(Rd+Rs)      #drain to source voltage(V)\n",
      "\n",
      "#Results\n",
      "print\"drain current defined by Vgs=4 and Vds=10 is\",Id1,\"mA\"\n",
      "print\"value of Rs,Rd,R2 are\",Rs,\"k ohms,\", Rd,\"k ohms,\",R2,\"Mohms resp.\"\n",
      "print\"actual value of Id and Vds are\",Id2,\"mA,\",Vds1,\"mA and\",Vds,\" V resp.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "drain current defined by Vgs=4 and Vds=10 is 2.0 mA\n",
        "value of Rs,Rd,R2 are 4 k ohms, 3.0 k ohms, 1 Mohms resp.\n",
        "actual value of Id and Vds are 2.08 mA, 9.44 mA and 10  V resp.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.14,Page number 166"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ic=10                       #collector current(mA)\n",
      "beeta=100                   #current gain\n",
      "Vbe=0.7                     #base to emitter voltage(V)\n",
      "Vcc=10                      #supply voltage(V) \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "R=(beeta*(Vcc-Vbe))/((beeta+2)*Ic)               #resistance(k ohms)  \n",
      "beeta1=200                                       #current gain\n",
      "Ic1=(beeta1/(beeta1+2))*((Vcc-Vbe)/R)            #collector current(mA)\n",
      "Icchange=((Ic-Ic1)/Ic)                           #change in collector current(mA)  \n",
      "\n",
      "#Part b\n",
      "Ic2=0.1                                          #collector current(mA)\n",
      "R1=(beeta*(Vcc-Vbe))/((beeta+2)*Ic)              #resistance(k ohms)\n",
      "Ic3=(beeta1/(beeta1+2))*((Vcc-Vbe)/R1)           #collector current(mA)\n",
      "Icchange1=((Ic2-Ic3)/Ic2)                        #change in collector current(mA)\n",
      "\n",
      "#Results\n",
      "print\"% change in Ic is\",round(Icchange,1),\"% increase\"\n",
      "print\"% change in Ic is\",round(Icchange1,1),\"% increase\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "% change in Ic is 1.0 % increase\n",
        "% change in Ic is 1.0 % increase\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.15,Page number 167"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vcc=6                      #supply voltage(V)\n",
      "R=1.2                      #resistance(k ohms)\n",
      "Vbe=0.7                    #base to emitter voltage(V) \n",
      "beeta=100.                 #current gain\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Ir=(Vcc-Vbe)/R             #current(mA)\n",
      "I=(beeta/(beeta+3))*Ir     #current(mA)as transistors are identiical,I=Ie\n",
      "\n",
      "#Result\n",
      "print\"load current I is\",round(I,2),\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "load current I is 4.29 mA\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.16,Page number 171"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "Idss=10              #drain current for zero bias(mA)\n",
      "Vp=-4                #peak voltage(V)\n",
      "Idq=Id=2.5           #quienscent drain current(mA)\n",
      "Vdd=24               #voltage drain drain(V)\n",
      "Vgg=4                #gate voltage(V)\n",
      "R1=22                #resistance(Mohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vgs=Vp*(1-(math.sqrt(Id/Idss)))         #solving Id=Idss(1-Vgs/Vp)^2\n",
      "Rs=(Vgg-Vgs)/Id                         #as Vgg-Vgs-IdRs=0 ,Id=Is \n",
      "Rd=2.5*Rs                               #given\n",
      "R2=(Vgg*R1)/(R1-Vgg)                    #from Vgg=(R1*R2)/(R1+R2)\n",
      "\n",
      "#Part b\n",
      "gmo=-(2*Idss)/Vp                       #transconductance(mS)\n",
      "gm=gmo*(math.sqrt(Id/Idss))            #transconductance(mS)\n",
      "\n",
      "#Part c\n",
      "Av=-gm*Rd                              #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"values of Rs:\",Rs,\"Kohms,Rd:\",Rd,\"k ohms and R2 is\",round(R2,1),\"M ohms\"\n",
      "print\"value of gm is\",gm,\"mS and gmo is\",gmo,\"mS\"\n",
      "print\"voltage amplification is\",Av"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "values of Rs: 2.4 Kohms,Rd: 6.0 k ohms and R2 is 4.0 M ohms\n",
        "value of gm is 2.5 mS and gmo is 5 mS\n",
        "voltage amplification is -15.0\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.17,Page number 174"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "beeta=98.                          #current gain\n",
      "rpi=1.275                          #dynamic resistance(k ohms)\n",
      "Rb=220.                            #base resistance(k ohms)\n",
      "Re=3.3                             #emitter resistance(k ohms)\n",
      "Vcc=12.                            #supply voltage(V)\n",
      "Vbe=0.7                            #base to emitter voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "x=rpi/(1+beeta)\n",
      "Av=Re/(Re+x)                     #voltage gain\n",
      "\n",
      "#Part b\n",
      "Zb=rpi+(1+beeta)*Re            #impedance(k ohms)\n",
      "Zi=(Zb*Rb)/(Zb+Rb)             #input impedance(k ohms)\n",
      "Zo=(Re*x)/(Re+x)               #output impedance(k ohms)\n",
      "\n",
      "#Part c\n",
      "Ib=(Vcc-Vbe)/(Rb+(Re*(1+beeta)))     #as Ie=(1+beeta)*Ib\n",
      "Ic=beeta*Ib                         #collector current(mA)\n",
      "rpi=beeta*(25/Ic)                   #dynamic resistance(k ohms)\n",
      "\n",
      "#Results\n",
      "print\"voltage gain is\",round(Av,3)\n",
      "print\"input impedance is\",round(Zi,1),\"KOhm and output impedance is\",round((Zo/1E-3),1),\"ohms\"\n",
      "print\"value of Ic is\",round(Ic,3),\"mA\"\n",
      "print\"value of rpi is\",round((rpi/1E+3),3),\"k ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "voltage gain is 0.996\n",
        "input impedance is 131.7 KOhm and output impedance is 12.8 ohms\n",
        "value of Ic is 2.026 mA\n",
        "value of rpi is 1.21 k ohms\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.18,Page number 176"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import*\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Idss=16                           #drain current bias to zero(mA) \n",
      "Vp=-4                             #pinch off voltage(V)  \n",
      "Rg=1                              #gate resistance(ohms)\n",
      "Rs=2.2                            #sourse resistance(ohm)\n",
      "Vdd=9                             #drain drain voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "#Id=Idss*(1-(Vgs/Vp))**2\n",
      "# putting value of Vgs=2.2*Id inequation of Id,we get\n",
      "#Id**2-3.84Id+3.31   \n",
      "\n",
      "Id=symbols('Id')\n",
      "expr=solve(Id**2-3.84*Id+3.31,Id)\n",
      "print expr\n",
      "Id1=1.3    \n",
      "Vgs=-Id1*Rs                                         #gate to source voltage(V)\n",
      "gm0=-(2*Idss)/Vp                                    #transconductance(mS)\n",
      "gm=gm0*(1-(Vgs/Vp))                                 #transconductance(mS)  \n",
      "rm=1/gm                                             #transresistance(k ohms) \n",
      "Av=(Rs*gm)/(1+(Rs*gm))                              #voltage gain\n",
      "\n",
      "#Part b\n",
      "Zi=Rg                                               #input impedance(Mohms)\n",
      "Zo=(Rs*rm)/(Rs+rm)                                  #output impedance(ohms)\n",
      "\n",
      "#Results\n",
      "print\"voltage gain is\",round(Av,3)\n",
      "print\"input and output impedences are\",Zi,\"Mohms and\",round((Zo/1E-3),1),\"ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " [1.30648553399288, 2.53351446600712]\n",
        "voltage gain is 0.834\n",
        "input and output impedences are 1 Mohms and 365.7 ohms\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.19,Page number 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Re=0.56                          #emitter resistance(k ohms)\n",
      "beta=1600                        #current gain\n",
      "R1=110                           #resistance(k ohms)\n",
      "R2=330                           #resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Av1=Re*(beta+1)               #voltage gain\n",
      "\n",
      "#part b\n",
      "Rb=(R1*R2)/(R1+R2)             #base resistance(k ohms)\n",
      "Vs=(1.56/(Re*(beta+1)))+1       #source voltage(V) \n",
      "Avs=1/Vs\n",
      "\n",
      "#part c\n",
      "R=1+(1+beta)*Re                                    #resistance presented to Ib\n",
      "I=Rb/(Rb+R)                                        #I=Ib/Ii \n",
      "Ai=(1+beta)*I                                      #current gain\n",
      "\n",
      "#part d\n",
      "Rl=10*10**3                             #load resistance(ohm)\n",
      "Re1=(Re*Rl)/(Re+Rl)                     #emitter resistance(k ohms)\n",
      "R1=1+(1+beta)*Re1                       #resistance presented to Ib(k ohms)\n",
      "I1=Rb/(Rb+R1)                           #I1=Ib/Ii\n",
      "Ai1=(beta+1)*I1                         #current gain\n",
      "Av2=Re1*(1+beta)                        #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"a)voltage gain is\",Av1\n",
      "print\"b)Avs is\",round(Avs,2)\n",
      "print\"c)Ai is\",round(Ai,2)\n",
      "print\"when output Vo1 feeds a load of 10 k ohms Ai is\",round(Ai1),\"and Av2 is\",round(Av2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)voltage gain is 896.56\n",
        "b)Avs is 1.0\n",
        "c)Ai is 134.02\n",
        "when output Vo1 feeds a load of 10 k ohms Ai is 134.0 and Av2 is 897.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.20,Page number 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta1=120.                       #current gain\n",
      "beeta2=160.                      #current gain\n",
      "Vcc=18                           #supply voltage(V)\n",
      "Rc=0.1                           #collector resistance(ohms)\n",
      "Rb=2*10**3.                       #base resistance(ohms)\n",
      "Vbe=0.7                          #base to emitter voltage(V)\n",
      "\n",
      "#Calculations\n",
      "Ib1=(Vcc-Vbe)/(Rb+(beeta1*beeta2*Rc))#base current(uA)\n",
      "Ib2=beeta1*Ib1                      #base current(mA)\n",
      "Ie1=(beeta1+1)*Ib1                  #emitter current(mA)\n",
      "Ic=Ie1+(beeta2*Ib2)                 #collector current(mA)\n",
      "Vo=Vcc-(Ic*Rc)                      #output voltage(V)\n",
      "Vi=Vo-Vbe                           #input voltage(V)\n",
      "\n",
      "#Results\n",
      "print\"dc biased current is\",round(Ic,1),\"mA\"\n",
      "print\"output voltage\",round(Vo,2),\"V\"\n",
      "print\"input voltage\",round(Vi,2),\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "dc biased current is 85.3 mA\n",
        "output voltage 9.47 V\n",
        "input voltage 8.77 V\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.21,Page number 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "deltaId=2.                         #change in Id(mA)\n",
      "deltaVgs=1.                        #change in Vgs(V)\n",
      "deltaVds=5.                        #change in Vds(V)\n",
      "Idss=10.                           #drain current biased to zero(mA)\n",
      "Id=5.                              #drain current(mA)\n",
      "Vp=-6.                             #pinch off voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "gm=(deltaId)/(deltaVgs)            #transconductance(mS)\n",
      "rds=(deltaVds)/(deltaId)           #resistance(k ohms)\n",
      "gm0=-(2*Idss)/Vp                   #transconductance(mS)\n",
      "gm=gm0*(math.sqrt(Id/Idss))        #transconductance(mS)\n",
      "\n",
      "#Part b\n",
      "R1=4.5                             #resistance(k ohms)\n",
      "R2=2                               #resistance(k ohms)\n",
      "Av=gm*((R1*R2)/(R1+R2))            #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"drain current biased to zero is\",Idss,\"mA and pinch off voltage is\",Vp,\"V\"\n",
      "print\"value of gm and rds are\",round(gm,2),\"mS and\",rds,\"k ohms\"\n",
      "print\"small signal amplifier gain is\",round(Av,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "drain current biased to zero is 10.0 mA and pinch off voltage is -6.0 V\n",
        "value of gm and rds are 2.36 mS and 2.5 k ohms\n",
        "small signal amplifier gain is 3.26\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.22,Page number 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Idson=0.2\n",
      "Vgs=5                      #gate to source voltage(V)\n",
      "Vdd=12                     #drain voltage(V)\n",
      "Vt=2                       #thevinine voltage(V)\n",
      "R1=100.                    #resistance(k ohms)                               \n",
      "R2=100.                    #resistance(k ohms)   \n",
      "Rd=30                      #drain resistance(K ohms)\n",
      "Rs=6                       #source resistance(k ohms)\n",
      "deltaVdd=0.3               #change in Vdd(V)\n",
      "rds=50                     #internal drain to source resistance()\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "k=Idson/((Vgs-Vt)**2)              #device parameter\n",
      "Vgg=Vdd*(R1/(R1+R2))               #gate voltage(V)\n",
      "Vgs=4.89                           #gate to source voltage(V)\n",
      "Id=k*(Vgs-Vt)**2                   #drain current(mA)\n",
      "Vds=Vdd-((Rd+Rs)*Id)               #drain to source voltage(V)\n",
      "gm=2*(math.sqrt(k*Id))             #transconductance(mS)\n",
      "deltaVgg=deltaVdd*(R2/(R1+R2))     #change in Vgg(V)\n",
      "\n",
      "vgs=0.105                          #as vgs=0.15-6id where id=u*vgs/(rds+Rs+Rd)=0.74vgs after solving\n",
      "id= 0.074*vgs*10**3\n",
      "\n",
      "#Results\n",
      "print\"id is\",id,\"uA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "id is 7.77 uA\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.23,Page number 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "deltaId=1                         #change in Id(mA)\n",
      "deltaVgs=0.75                     #change in Vgs(V) \n",
      "rd=100                            #internal drain resistance(k ohms)\n",
      "Rd=100                            #drain resistance(k ohms)\n",
      "Vgs=2                             #as Vgs= 2sinwt                \n",
      "\n",
      "#Calculations\n",
      "gm=(deltaId)/(deltaVgs)           #transconductance(m)  \n",
      "Vo=-gm*Vgs*((rd*Rd)/(rd+Rd))      # as Vi=2sin(w*t)\n",
      "\n",
      "#Results\n",
      "print\"value of Vo is\",round(Vo),\"*sinwt mV\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Vo is -133.0 *sinwt mV\n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.24,Page number 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Finding resistance\n",
      "\n",
      "#Variable declaration\n",
      "Rd=4                 #drain resistance(ohms)\n",
      "Rs=2.5               #ource resistance(ohms)      \n",
      "R1=200*10**3         #resistance(ohms)\n",
      "R2=100*10**3         #resistance(ohms)\n",
      "gm=2.5               #transconductance(mS)\n",
      "rd=60                #internal drain resistance(ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part b\n",
      "Ro=Rs/(1+(((1+gm*rd)*Rs)/(rd+Rd)))   #output resistance(ohms)\n",
      "\n",
      "#Part c\n",
      "Rd1=0                              #drain resistance\n",
      "Ro1=Rs/(1+(((1+gm*rd)*Rs)/rd))     #output resistance(ohms)\n",
      "\n",
      "#Results\n",
      "print\"value of Ro is\",round(Ro/1E-3),\"ohms\"\n",
      "print\"value of Ro1 is\",round(Ro1/1E-3),\"ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Ro is 362.0 ohms\n",
        "value of Ro1 is 343.0 ohms\n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.25,Page number 196"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=100                      #current gain factor\n",
      "Vbe=0.7                        #base to emitter voltage(V)\n",
      "Rb=250                         #base resistance(k ohms)\n",
      "Vee=10                         #emitter voltage(V)\n",
      "Re=1                           #emitter resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "Ib=(Vee-Vbe)/(Rb+1+beeta)       # solving Rb*Ib+Vbe+(Ic+Ib)=Vee and putting Ic+Ib=(1+beeta)Ib\n",
      "Ic=beeta*Ib                     #collector current(mA)\n",
      "rpi=beeta*(25/Ic)               #dynamic resistance(ohms)    \n",
      "Vi=(rpi*Ib)+(1+beeta)*Re*Ib     #input voltage(V)\n",
      "Ri=Vi/Ib                        #input resistance(k ohms)\n",
      "\n",
      "#Results\n",
      "print\"value of Ri is\",round((Ri/1E+1),1),\"K ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Ri is 104.5 K ohms\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.26,Page number 197"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "beeta=125                       #current gain\n",
      "gm=35                           #transconductance(mS)\n",
      "Re=4                            #emitter resistance(k ohms)\n",
      "Rb=1.5                          #base resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "rpi=beeta/gm                   #dynamic resistance(k ohms)\n",
      "Ri=rpi+((1+beeta)*Re)          #input resistance(k ohms) \n",
      "Ro=((Rb+rpi)*Re)/((Rb+rpi)+((1+beeta)*Re))  #output resistance(ohms) as Ro=Vo/Isc\n",
      "\n",
      "#Part b                                 \n",
      "f=((1+beeta)*Re)/(Rb+rpi+((1+beeta)*Re))  #transfer function\n",
      "\n",
      "#Results\n",
      "print\"value of Ri is\",Ri,\"K ohms and Ro is\",round(Ro,4),\"k\"\n",
      "print\"transfer function is\",round(f,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of Ri is 507 K ohms and Ro is 0.0354 k\n",
        "transfer function is 0.99\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.28,Page number 199"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration \n",
      "Vcc=16               #supply voltage(V)\n",
      "Vc=12                 #collector voltage(V)\n",
      "Ic=8                  #collector current(mA)\n",
      "Ic1=12                \n",
      "deltaIc=2000          #collector current(uA)\n",
      "deltaVce=4            #collector emitter voltage(Vce) \n",
      "deltaIb=20            #base current(mA)       \n",
      "Rl=2.                 #load reistance(k ohms)      \n",
      "\n",
      "#Calculations\n",
      "hfe=(deltaIc)/(deltaIb)\n",
      "hoe=(deltaIc)/(deltaVce)\n",
      "Rdc=Vcc/Ic                       #dc resistance(k ohms)\n",
      "Rac=Vc/Ic1                       #ac resistance(k ohms)\n",
      "Re=Rdc-Rac                       #emitter resistance(k ohms)\n",
      "Rac1=(Rac*Rl)/(Rac+Rl)           #for load of 2kohms, Rc=Rac\n",
      "Icq=Vcc/(Rac1+Rdc)               #Ic at operatingpoint(mA) \n",
      "Vceq=Vcc-(Icq*Rdc)               #Vc at operating point(V)\n",
      "\n",
      "#Results\n",
      "print\"value of hfe and hoe are\",hfe,\"uS and\",hoe,\"uS\"\n",
      "print\"value Rc and Re are\",Rac,\"k ohms and\",Re,\"k ohms resp.\"\n",
      "print\"value of Icq and Vce\",Icq,\"mA and\",Vceq,\"V resp.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " value of hfe and hoe are 100 uS and 500 uS\n",
        "value Rc and Re are 1 k ohms and 1 k ohms resp.\n",
        "value of Icq and Vce 6.0 mA and 4.0 V resp.\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.29,Page number 200"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "hfe=120              #current gain\n",
      "r1=1.5               #resistance(k ohms)\n",
      "Vi=1                 #input voltage(V) \n",
      "hoe=50*10**-3        #output conductance with input open circuited\n",
      "Rs=2                 #source resistance(k ohms)\n",
      "Vbe=0.7              #base to emitter voltage(V)\n",
      "Vcc=10               #supply voltage(V)\n",
      "r3=0.33              #resistance(k ohms)\n",
      "r4=5.8               #rsistance(k ohms) \n",
      "r5=27                #rsistance(k ohms) \n",
      "hoe=50*10**-3        #output conductance with input open circuited\n",
      "    \n",
      "#Calculations\n",
      "#Part a\n",
      "Vbb=Vcc*(r4/(r4+r5))          #voltage to bae(V)\n",
      "Rb=(r5*r4)/(r5+r4)            # as Vbb-Vbe=RbIb+(hfe+1)Ib*R,here hfe=beeta\n",
      "ib=(Vbb-Vbe)/(Rb+(hfe+1)*r3)  #instantaneous base current(mA)\n",
      "hie=(0.02/ib)*10**3           \n",
      "Ib=Vi/hie                    #base current(mA)\n",
      "h=hfe*Ib\n",
      "Avo=-h*r1                    #voltage gain\n",
      "\n",
      "#Part b\n",
      "r=1/hoe                #resistance(k ohms)\n",
      "R1=(r*r1)/(r+r1)       #resitance(k ohms)\n",
      "R=(R1*Rs)/(R1+Rs)      #resistance(k ohms)\n",
      "Ib1=1/(Rs+R)          #base current(mA)\n",
      "h1=hfe*Ib1\n",
      "Avl=-h1*R             #voltage gain\n",
      "\n",
      "#Results\n",
      "print\"hie and Avo are\",round(hie),\"and\",round((Avo/1E-3),1)\n",
      "print\"Avl is\",round(Avl,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "hie and Avo are 837.0 and -215.1\n",
        "Avl is -34.95\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.30,Page number 201"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Rl=20              #load resistance(ohms)\n",
      "Vcc=30             #supply voltage(V)\n",
      "beeta=150          #current gain \n",
      "Re=2200            #emitter resistance(ohms)  \n",
      "Rb=350             #base resistance(k ohms) \n",
      "Vbe=0.7            #base to emitter voltage(V)\n",
      "Is=10**-3          #source current(A) \n",
      "r1=2000            #resistance(ohms)\n",
      "\n",
      "#Calculations\n",
      "Ib=(Vcc-Vbe)/(Rb+(1+beeta)*Re)#base current(uA)\n",
      "Ic=beeta*Ib                   #collector current(mA)\n",
      "rpi=beeta*(25/Ic)             #dynamic resistance(ohms)   \n",
      "R=(Re*Rl)/(Re+Rl)             #resistance(ohms)  \n",
      "Ib1=17.95                     #round the base emitter(as Rb>>2 kohms,it it ignored)\n",
      "Vl=(beeta+1)*Ib1*R            #load voltage(V)\n",
      "Avl=Vl                              #Voltage gain\n",
      "Il=Vl/Rl                            #load current(A)\n",
      "Ail=Il/Is                           #current gain\n",
      "\n",
      "#Results\n",
      "print\"overall voltage gain is\",round((Avl/1E+3),2)\n",
      "print\"overall current gain is\",round(Ail/1E+3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "overall voltage gain is 51.5\n",
        "overall current gain is 2575.0\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.31,Page number 202"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vcc=15             #supply voltage(V)\n",
      "beeta=30           #current gain \n",
      "R=.47            #emitter resistance(ohms)  \n",
      "Vbe=0.7            #base to emitter voltage(V)\n",
      "Vo=5               #output voltage(V)\n",
      "\n",
      "#Calculations\n",
      "Vbb=Vcc/2                                   #base voltage(V)\n",
      "'''\n",
      "Vbb=(R1/2)*Ib+Vbe*2+(30Ib+Ic2)*R\n",
      "Ic2=beeta*30Ib,so\n",
      "Ic2=30*30Ib=900Ib\n",
      "Vbb=(R1/2)*Ib+Vbe*2+(30+900)*R*Ib....(i)\n",
      "(R1/2)*Ib+437*Ib=6.1.......(ii)\n",
      "0.47*930Ib=5         #output voltage is given like this\n",
      "\n",
      "'''\n",
      "Ib=Vo/(R*930)    #from equation(i)\n",
      "\n",
      "'''\n",
      "substituting value of Ibin eq(ii) we get\n",
      "\n",
      "'''\n",
      "R1=((6.1-4.98)/0.0114)*2                     #resistance(k ohms)  \n",
      "#Results\n",
      "print\"value of R1 is\",round(R1),\"K ohms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of R1 is 196.0 K ohms\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}