{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Chapter 8 , Hybrid Parameteres and Transistor Amplifiers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.1 , Page Number 285"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hie :  1.1 kilo-ohm.\n",
      "hfe :  50.0 .\n",
      "hre :  0.00025 .\n",
      "hoe :  30.0 micro-S.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "IB1 = 20.0 *10**-6                  #Base current with ac o/p shorted (in Ampere)\n",
    "IC1 = 1.0 *10**-3                   #Collector current with ac o/p shorted (in Ampere)\n",
    "VBC1 = 22.0 * 10**-3                #Base-collector voltage with ac o/p shorted (in volts)\n",
    "VCE1 = 0                            #Collector-emitter voltage wwith ac o/p shorted (in volts)\n",
    "\n",
    "IB2 = 0                             #Base current with ac i/p open-circuited (in Ampere)\n",
    "VBE2 = 0.25 *10**-3                 #Base-emitter voltage with ac i/p open-circuited (in volts)\n",
    "IC2 = 30.0 * 10**-6                 #Collector current with ac i/p open-circuited (in Ampere)              \n",
    "VCE2 = 1                            #Collector-emitter voltage with ac i/p open-circuited (in volts)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "hie = VBC1/IB1                      #hie (in ohm)\n",
    "hfe = IC1/IB1                       #Current gain in CE\n",
    "hre = VBE2/VCE2                     #hre \n",
    "hoe = IC2/VCE2                      #hoe (in Siemen)\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"hie : \",hie*10**-3,\"kilo-ohm.\"\n",
    "print \"hfe : \",hfe,\".\"\n",
    "print \"hre : \",hre,\".\"\n",
    "print \"hoe : \",hoe * 10**6,\"micro-S.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.2 , Page Number 290"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hfb :  -0.98 .\n",
      "hib :  16.27 ohm.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hfe = 50.0                    #hfe\n",
    "hie = 0.83 * 10**3            #hie (in ohm)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "hfb =  -hfe/(1 + hfe)         #Current gain\n",
    "hib = hie/(1 + hfe)           #Input impedance (in ohm)    \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"hfb : \",round(hfb,2),\".\\nhib : \",round(hib,2),\"ohm.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.3 , Page Number 290"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hic : 2600.0 ohm.\n",
      "hfc : -101 .\n",
      "hrc : 1.0 .\n",
      "hoc : 5e-06 S.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hfe = 100                          #hfe\n",
    "hre = 0.02 * 10**-2                #hre\n",
    "hoe = 5 * 10**-6                   #hoe (in Siemens) \n",
    "hic = hie = 2600.0                 #hie (in ohm) \n",
    "\n",
    "#Calculation\n",
    "\n",
    "hfc = -(1 + hfe)                   #hfc                   \n",
    "hrc = 1 - hre                      #hrc\n",
    "hoc = hoe                          #hoe (in Siemens) \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"hic :\",hic,\"ohm.\"\n",
    "print \"hfc :\",hfc,\".\"\n",
    "print \"hrc :\",round(hrc),\".\"\n",
    "print \"hoc :\",hoc,\"S.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.4 , Page Number 294  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current gain : -19.6 .\n",
      "Input resistance : 1905.92 ohm.\n",
      "Voltage gain : -308.5 .\n",
      "Overall voltage gain : -235.0 .\n",
      "Overall current gain : -4.7 .\n",
      "Output conductance : 4.69846153846e-05 S.\n",
      "Output resistance : 21284.0 ohm.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hie = 2000.0                    #hie (in ohm)\n",
    "hre = 1.6 * 10**-4              #hre\n",
    "hfe = 49                        #Current gain \n",
    "hoe = 50 * 10**-6               #hoe (in Ampere per volt)\n",
    "RL = 30.0 * 10**3               #Load resistance (in ohm)\n",
    "RS = 600.0                      #Source resistance (in ohm)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "Ai = - hfe/(1 + hoe*RL)         #Current gain\n",
    "Rin = hie - hre*hfe/(hoe + 1/RL)#Input resistance (in ohm)\n",
    "Av = -hfe/((hoe + 1/RL)*Rin)    #Voltage gain \n",
    "Avs = Av*Rin/(Rin + RS)         #Overall voltage gain \n",
    "Ais = Ai*RS/(Rin + RS)          #Overall current gain\n",
    "Gout = hoe - hfe*hre/(hie + RS) #Output conductance (in Siemens)\n",
    "Rout = 1/Gout                   #Output resistance (in ohm)\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Current gain :\",Ai,\".\"\n",
    "print \"Input resistance :\",Rin,\"ohm.\"\n",
    "print \"Voltage gain :\",round(Av,1),\".\"\n",
    "print \"Overall voltage gain :\",round(Avs),\".\"\n",
    "print \"Overall current gain :\",round(Ais,1),\".\"\n",
    "print \"Output conductance :\",Gout,\"S.\"\n",
    "print \"Output resistance :\",round(Rout),\"ohm.\"\n",
    "\n",
    "#Slight variations due to higher precision."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.5 , Page Number 294 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current gain : -48.78 .\n",
      "Input resistance : 1087.8 ohm.\n",
      "Voltage gain : -44.84 .\n",
      "Overall voltage gain : -23.36 .\n",
      "Overall current gain : -23.364 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hie = 1.1 * 10**3              #hie (in ohm)\n",
    "hre = 0.25 * 10**-3            #hre\n",
    "hfe = 50                       #Current gain\n",
    "hoe = 25.0 * 10**-6            #hoe (in Siemens)\n",
    "RL = 1.0 * 10**3               #Load resistance (in ohm)\n",
    "RS = 1.0 * 10**3               #Series resistance (in ohm) \n",
    "\n",
    "#Calculation\n",
    "\n",
    "Ai = - hfe/(1 + hoe*RL)         #Current gain\n",
    "Rin = hie - hre*hfe/(hoe + 1/RL)#Input resistance (in ohm)\n",
    "Av = -hfe/((hoe + 1/RL)*Rin)    #Voltage gain \n",
    "Avs = Av*Rin/(Rin + RS)         #Overall voltage gain \n",
    "Ais = Ai*RS/(Rin + RS)          #Overall current gain\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Current gain :\",round(Ai,2),\".\"\n",
    "print \"Input resistance :\",round(Rin,1),\"ohm.\"\n",
    "print \"Voltage gain :\",round(Av,2),\".\"\n",
    "print \"Overall voltage gain :\",round(Avs,2),\".\"\n",
    "print \"Overall current gain :\",round(Ais,3),\".\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.6 , Page Number 295 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current gain : -100.0 .\n",
      "Input resistance : 1000.0 ohm.\n",
      "Voltage gain : -200.0 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hie = 1.0 * 10**3            #hie (in ohm)\n",
    "hfe = 100                    #Current gain\n",
    "RL = 2.0 * 10**3             #Load resistance (in ohm)\n",
    "hre = hoe = 0                #hre \n",
    "\n",
    "#Calculation\n",
    "\n",
    "Ai = - hfe/(1 + hoe*RL)         #Current gain\n",
    "Rin = hie - hre*hfe/(hoe + 1/RL)#Input resistance (in ohm)\n",
    "Av = -hfe/((hoe + 1/RL)*Rin)    #Voltage gain \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Current gain :\",round(Ai,2),\".\"\n",
    "print \"Input resistance :\",round(Rin,1),\"ohm.\"\n",
    "print \"Voltage gain :\",round(Av,2),\".\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.7 , Page Number 295 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current gain : 0.979 .\n",
      "Input resistance : 24.47 ohm.\n",
      "Voltage gain : 48.02 .\n",
      "Overall voltage gain : 5.24 .\n",
      "Overall current gain : 0.873 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "RS = 200.0                  #internal resistance (in ohm)\n",
    "RL = 1200.0                 #Load resistance (in ohm)\n",
    "hib = 24.0                  #hib (in ohm)\n",
    "hrb = 4.0 * 10**-4          #hrb\n",
    "hfb = -0.98                 #hfb\n",
    "hob = 0.6 * 10**-6          #hob (in Ampere per volt)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "Ai = - hfb/(1 + hob*RL)         #Current gain\n",
    "Rin = hib + hrb*Ai*RL           #Input resistance (in ohm)\n",
    "Av = Ai*RL/Rin                  #Voltage gain \n",
    "Avs = Av*Rin/(Rin + RS)         #Overall voltage gain \n",
    "Ais = Ai*RS/(Rin + RS)          #Overall current gain\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Current gain :\",round(Ai,3),\".\"\n",
    "print \"Input resistance :\",round(Rin,2),\"ohm.\"\n",
    "print \"Voltage gain :\",round(Av,2),\".\"\n",
    "print \"Overall voltage gain :\",round(Avs,2),\".\"\n",
    "print \"Overall current gain :\",round(Ais,3),\".\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.8 , Page Number 296 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hfe : 120.0 .\n",
      "hoe : 2.5e-05 S.\n",
      "hie : 2.5 kilo-ohm.\n",
      "Current amplification factor : 0.99 .\n",
      "hob : 2.06611570248e-07 .\n",
      "hib : 20.83 ohm.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "IE = 1.2 * 10**-3          #Emitter current (in Ampere)\n",
    "beta = 120.0               #Current gain\n",
    "ro = 40.0 * 10**3          #O/p resistance (in ohm)\n",
    "hre = 0                    #hre  \n",
    "\n",
    "#Calculation\n",
    "\n",
    "hfe = beta                 #hfe\n",
    "hoe = 1/ro                 #hoe (in Siemen)\n",
    "hie = 25.0*10**-3/IE*beta  #hie (in ohm)\n",
    "alpha = beta/(1 + beta)    #Current gain in CB\n",
    "hob = hoe/(1 + beta)       #hob (in Siemen)  \n",
    "hib = 25 * 10**-3/IE       #hib (in ohm)\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"hfe :\",hfe,\".\"\n",
    "print \"hoe :\",hoe,\"S.\"\n",
    "print \"hie :\",hie*10**-3,\"kilo-ohm.\"\n",
    "print \"Current amplification factor :\",round(alpha,2),\".\"\n",
    "print \"hob :\",hob,\".\"\n",
    "print \"hib :\",round(hib,2),\"ohm.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.9 , Page Number 296 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current gain : 99.75 .\n",
      "Input resistance : 51864.074 ohm.\n",
      "Voltage gain : 0.9617 .\n",
      "Overall voltage gain : 0.9435 .\n",
      "Overall current gain : 1.887 .\n",
      "Output resistance : 29.69 ohm.\n",
      "Output conductance : 0.0337 Siemen.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hic = hie = 2.0 * 10**3            #hic (in ohm)\n",
    "hfe = 100.0                        #Current gain in CE\n",
    "hre = 2.5 * 10**-4                 #hre\n",
    "hoe = 25.0 * 10**-6                #hoe (in Ampere per volt)\n",
    "RS = 1.0 * 10**3                   #Source resistance (in ohm)\n",
    "RL = 500.0                         #Load resistance (in ohm)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "hfc = -(1 + hfe)                   #hfc\n",
    "hrc = 1 - hre                      #hrc\n",
    "hoc = hoe                          #hoc (in Siemens)\n",
    "Ai = -hfc/(1 + hoc*RL)             #Current gain\n",
    "Rin = hic - hrc*hfc/(hoc + 1/RL)   #Input resistance (in ohm)\n",
    "Av = -hfc/((hoc + 1/RL)*Rin)       #Voltage gain\n",
    "Avs = Av*Rin/(Rin + RS)            #Overall voltage gain\n",
    "Ais = Ai*RS/(Rin + RS)             #Overall current gain\n",
    "Go = hoc  -(hfc*hrc/(hic + RS))    #O/P conductance (in Siemens)\n",
    "Ro = 1/Go                          #O/P resistance (in ohm)\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Current gain :\",round(Ai,2),\".\"\n",
    "print \"Input resistance :\",round(Rin,3),\"ohm.\"\n",
    "print \"Voltage gain :\",round(Av,4),\".\"\n",
    "print \"Overall voltage gain :\",round(Avs,4),\".\"\n",
    "print \"Overall current gain :\",round(Ais,3),\".\"\n",
    "print \"Output resistance :\",round(Ro,2),\"ohm.\"\n",
    "print \"Output conductance :\",round(Go,4),\"Siemen.\"\n",
    "\n",
    "#Slight variations due to higher precision."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.10 , Page Number 300"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power gain :  826.0 .\n",
      "EMF E :  0.29 V.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hie = 2.0 * 10**3              #hie (in ohm)\n",
    "hoe = 25.0 * 10**-6            #hoe (in Siemens)\n",
    "hfe = 55.0                     #Current gain in CE\n",
    "Pin = 10.0 * 10**-3             #Output power (in watt)\n",
    "RB = 80.0 * 10**3              #Base resistance (in ohm)\n",
    "RC = 10.0 * 10**3              #Collector resitance (in ohm)\n",
    "RL = 10.0 * 10**3              #Load resistance (in ohm)\n",
    "RS = 5.0 * 10**3               #Source resistance (in ohm)  \n",
    "\n",
    "#Calculation\n",
    "\n",
    "Zb = hie                       #Zb (in ohm)\n",
    "Zin = RB                       #Impedance (in ohm)\n",
    "ZS = RS + Zin                  #Imput impedance (in ohm)\n",
    "Zout = RC/hoe*(1/(RC + 1/hoe)) #Output impedance (in ohm)\n",
    "Rac = Zout*RL/(Zout + RL)      #AC load resistance (in ohm)\n",
    "Vout = -34.3*0.29              #Output voltage (in volts)\n",
    "Pout = Vout**2/RL              #Output power (in watt) \n",
    "E = 0.29                       #EMF (in volts)\n",
    "Ap = Pin/0.29**2*6.95*10**3    #Power gain\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Power gain : \",round(Ap),\".\"\n",
    "print \"EMF E : \",E,\"V.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.11 , Page Number 301 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Input impedance :  0.87 kilo-ohm.\n",
      "Output impedance :  1.9 kilo-ohm\n",
      "Current gain :  -43.5 .\n",
      "Voltage gain :  -100.0 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hie = 1.0 * 10**3            #hie (in ohm)\n",
    "hfe = 100.0                  #Current gain   \n",
    "R1 = 20.0 * 10**3            #Resistance1 (in ohm)\n",
    "R2 = 10 * 10**3              #Resistance2 (in ohm)\n",
    "hoe = 25.0 * 10**-6          #hoe (in Siemens)\n",
    "RC = 2* 10**3                #Collector resistance (in ohm)\n",
    "RL = 2* 10**3                #Load resistance (in ohm)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "Zb = hie                                   #Zb (in ohm)   \n",
    "Zin = Zb*R1*R2/(Zb*R1 + Zb*R2 + R1*R2)     #Input impedance (in ohm)\n",
    "Zout = 1/hoe*RC/(RC + 1/hoe)               #Output impedance (in ohm)\n",
    "Av = -(RC*RL)/(RC + RL)*hfe/hie            #Voltage gain\n",
    "RB = R1*R2/(R1 + R2)                       #Base resistance (in ohm)\n",
    "Ai = -hfe*RB*RC/((RC + RL)*(RB + Zb))      #Current gain\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Input impedance : \",round(Zin * 10**-3,2),\"kilo-ohm.\"\n",
    "print \"Output impedance : \",round(Zout * 10**-3,1),\"kilo-ohm\"\n",
    "print \"Current gain : \",round(Ai,1),\".\"\n",
    "print \"Voltage gain : \",Av,\".\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.12 , Page Number 302 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ai :  -100.0 .\n",
      "Av :  -9.597 .\n",
      "Avs :  -4.19 .\n",
      "Rin :  7.74 kilo-ohm.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hie = 1100.0                          #hie (in ohm)\n",
    "hre = 0                               #hre\n",
    "hfe = 50.0                            #Current gain \n",
    "hoe = 100.0                           #hoe  \n",
    "R1 = 100.0 * 10**3                    #Resistance1 (in ohm)\n",
    "R2 = 10.0 * 10**3                     #Resistance2 (n ohm)\n",
    "RE = 1.0 * 10**3                      #Emitter resistance (in ohm)\n",
    "RL = 5.0 * 10**3                      #Load resistance (in ohm) \n",
    "RS = 10.0 * 10**3                     #Source resistance (in ohm)  \n",
    "\n",
    "#Calculation\n",
    "\n",
    "RB = hie + (1 + hfe)*RE                   #Base resistance (in ohm)\n",
    "Rin = RB*R1*R2/((RB*R1 + RB*R2 + R1*R2))  #Input resistance (in ohm)\n",
    "Ai = -hoe                                 #Current gain\n",
    "Av = -hoe*RL/(hie + (1 + hfe)*RE)         #Voltage gain\n",
    "Avs = Av * Rin/(Rin + RS)                 #Overall voltage gain\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Ai : \",Ai,\".\"\n",
    "print \"Av : \",round(Av,3),\".\"\n",
    "print \"Avs : \",round(Avs,2),\".\"\n",
    "print \"Rin : \",round(Rin*10**-3,2),\"kilo-ohm.\"\n",
    "\n",
    "#Slight variation due to higher precision."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.13 , Page Number 302 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Quiescent collector current :  1.0 mA.\n",
      "Small signal voltage gain :  -40.63 .\n",
      "Maximum possible swing of collector current :  4.55 mA.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "RE = 100.0                #Emitter resistance (in ohm) \n",
    "RC = 1.0 * 10**3          #Collector resistance (in ohm)\n",
    "VBE = 0.7                 #Base-emitter voltage (in volts)\n",
    "RB = 420.0 * 10**3        #Base resistance (in ohm)\n",
    "beta = 100                #Current gain in CE\n",
    "VCC = 5.0                 #Collector supply voltage (in volts)  \n",
    "\n",
    "#Calculation\n",
    "\n",
    "IB = (VCC -VBE)/(RB + (beta + 1)*RE)      #Base current (in Ampere)\n",
    "ICQ = beta * IB                           #Q-point collector current (in Ampere)\n",
    "IE = (beta + 1)*IB                        #Emitter current (in Ampere)\n",
    "r1e = 25.0*10**-3/IE                      #Resistance (in ohm)  \n",
    "Rin = RB*(beta*r1e)/(RB + beta*r1e)       #Input resistance (in ohm)\n",
    "Rout = RC                                 #Output resistance (in ohm)\n",
    "Av = -ICQ/IB*Rout/Rin                     #Small signal voltage gain \n",
    "swing = VCC/(RC + RE)                     #Max. possible swing (in Ampere) \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Quiescent collector current : \",round(ICQ*10**3,3),\"mA.\"\n",
    "print \"Small signal voltage gain : \",round(Av,2),\".\"\n",
    "print \"Maximum possible swing of collector current : \",round(swing*10**3,2),\"mA.\"\n",
    "\n",
    "#Slight variation due to high precision."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.14 , Page Number 303 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.20603015075e-05 0.00156783919598 0.00156783919598 0.00157989949749\n",
      "ICQ :  0.945 mA and VCEQ :  2.251 V.\n",
      "VCE when R2 is open circuited :  -8.117 V.\n",
      "AV :  -455.0 .\n",
      "Rin :  1.0 kilo-ohm.\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "beta = hfe = 130                  #Current gain in CE\n",
    "R1 = 510.0 * 10**3                #Resistance1 (in ohm)\n",
    "R2 = 510.0 * 10**3                #Resistance2 (n ohm)\n",
    "RE = 7.5 * 10**3                  #Emitter resistance (in ohm)\n",
    "RC = 9.1 * 10**3                  #Collector resistance (in ohm)\n",
    "VCC = 18.0                        #Collector supply voltage (in volts)\n",
    "VBE = 0                           #Base-Emitter voltage (in volts)\n",
    "hie = 1.0 * 10**3                 #hie (in ohm)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "Rth = R1*R2/(R1 + R2)             #Thevenin's eq. resistance (in ohm)\n",
    "Vth = VCC * R2/(R1 + R2)          #Thevenin's eq. voltage (in volts)\n",
    "IB = (Vth - VBE)/(Rth + (beta + 1)*RE)           #Base current (in Ampere)\n",
    "IC = beta*IB                      #Collector current (in Ampere)\n",
    "ICQ = IC                          #Q-point IC (in Ampere)\n",
    "IE = (beta + 1)*IB                #Emitter current (in Ampere)\n",
    "VCEQ = VCC - ICQ*RC - IE*RE       #Q-point VCE (in Ampere)    \n",
    "\n",
    "IB1 = (VCC - VBE)/(R1 + (beta + 1)*RE)           #Base current1 (in Ampere)\n",
    "IC1 = beta*IB1                    #Collector current1 (in Ampere) \n",
    "ICQ1 = IC1                        #Q-point IC (in Ampere)\n",
    "IE1 = (beta + 1)*IB1              #Emitter current1 (in Ampere)\n",
    "VCEQ1 = VCC - ICQ1*RC - IE1*RE    #Q-point VCE (in Ampere)    \n",
    "\n",
    "Rin = (R1*R2*hie)/(R1*R2 + hie*R2 + hie*R1)      #Input resistance (in ohm)\n",
    "Av = -50/hie*RC                  #Voltage gain        \n",
    "\n",
    "#Result\n",
    "print IB1,IC1,ICQ1,IE1\n",
    "print \"ICQ : \",round(ICQ*10**3,3),\"mA and VCEQ : \",round(VCEQ,3),\"V.\"\n",
    "print \"VCE when R2 is open circuited : \",round(VCEQ1,3),\"V.\"\n",
    "print \"AV : \",round(Av,3),\".\"\n",
    "print \"Rin : \",round(Rin*10**-3,2),\"kilo-ohm.\"\n",
    "\n",
    "#Mistake in book for the value of hfe in calculation of Av."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.15 , Page Number 304 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Zin :  1.595  kilo-ohm.\n",
      "Zout :  4.296  kilo-ohm.\n",
      "Av :  -323.125 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hfe = 110                     #Current gain in CE\n",
    "hie = 1.6 * 10**3             #hie (in ohm)\n",
    "hre = 2 * 10**-4              #hre\n",
    "hoe = 20.0 * 10**-6           #hoe (in Ampere per volt)      \n",
    "RB = 470.0 * 10**3            #Base resistance (in ohm)\n",
    "RC = 4.7 * 10**3              #Collector resistance (in ohm)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "Zin = RB*hie/(RB + hie)       #Input impedance (in ohm)\n",
    "Zout = RC*1/hoe/(RC + 1/hoe)  #Output impedance (in ohm)\n",
    "Av = -RC*hfe/hie              #Voltage gain  \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Zin : \",round(Zin*10**-3,3),\" kilo-ohm.\"\n",
    "print \"Zout : \",round(Zout*10**-3,3),\" kilo-ohm.\"\n",
    "print \"Av : \",round(Av,3),\".\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.16 , Page Number 307 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Zin :  24.84  ohm.\n",
      "Zout :  7.97  kilo-ohm.\n",
      "Av :  134.4 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hib = 25.0                            #hie (in ohm)\n",
    "hfb = -0.98                           #Current gain in CB \n",
    "hob = 0.5 * 10**-6                    #hob (in Siemens)  \n",
    "R1 = 20.0 * 10**3                     #Resistance1 (in ohm)\n",
    "R2 = 5.0 * 10**3                      #Resistance2 (n ohm)\n",
    "RE = 4.0 * 10**3                      #Emitter resistance (in ohm)\n",
    "RL = 6.0 * 10**3                      #Load resistance (in ohm) \n",
    "RC = 8.0 * 10**3                      #Collector resistance (in ohm)  \n",
    "\n",
    "#Calculation\n",
    "\n",
    "Zin = hib*RE/(hib + RE)               #Input impedance (in ohm)\n",
    "Zout = RC*1/hob/(RC + 1/hob)          #Output impedance (in ohm)\n",
    "Av = -(RC*RL)/(RC+RL)*hfb/hib         #Voltage gain  \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Zin : \",round(Zin,2),\" ohm.\"\n",
    "print \"Zout : \",round(Zout*10**-3,2),\" kilo-ohm.\"\n",
    "print \"Av : \",round(Av,3),\".\"\n",
    "\n",
    "#Slight variation due to higher precision."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.17 , Page Number 309 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Input impedance :  4.9 kilo-ohm.\n",
      "Outpur impedance :  28.0 ohm.\n",
      "Voltage gain :  1 .\n",
      "Current gain :  101.0 .\n",
      "Power gain :  101.0 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hie = 2000.0                          #hie (in ohm)\n",
    "hfe = 100.0                           #Current gain  \n",
    "R1 = 10.0 * 10**3                     #Resistance1 (in ohm)\n",
    "R2 = 10.0 * 10**3                     #Resistance2 (n ohm)\n",
    "RE = 5.0 * 10**3                      #Emitter resistance (in ohm)\n",
    "RL = 5.0 * 10**3                      #Load resistance (in ohm) \n",
    "RS = 1.0 * 10**3                      #Source resistance (in ohm)  \n",
    "\n",
    "#Calculation\n",
    "\n",
    "hic = hie                             #hic\n",
    "hfc = -(1 + hfe)                      #hfc\n",
    "Zb = hic - hfc*(RE*RL)/(RE + RL)      #ZB (in ohm)\n",
    "Zin = Zb*R1*R2/(Zb*R1 + R1*R2 + Zb*R2)#Input impedance (in ohm)\n",
    "Ze = -(hic + (R1*R2*RS/(R1*R2 + R2*RS + R1*RS)))/hfc    #Ze (in ohm)\n",
    "Zout = Ze*RE/(Ze + RE)                #Output impedance (in ohm)  \n",
    "Av = 1                                #Coltage gain\n",
    "RB = R1*R2/(R1 + R2)                  #Base resistance (in ohm)\n",
    "Ai = -hfc                             #Current gain\n",
    "Ap = Ai                               #Power gain\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Input impedance : \",round(Zin * 10**-3,1),\"kilo-ohm.\"\n",
    "print \"Outpur impedance : \",round(Zout),\"ohm.\"\n",
    "print \"Voltage gain : \",Av,\".\"\n",
    "print \"Current gain : \",Ai,\".\"\n",
    "print \"Power gain : \",Ap,\".\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.18 , Page Number 310 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Input impedance :  227.667 kilo-ohm.\n",
      "Voltage gain :  0.9956 .\n",
      "Current gain :  45.33 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "RL = 5.0 * 10**3                      #Load resistance (in ohm) \n",
    "RS = 0.5 * 10**3                      #Source resistance (in ohm)  \n",
    "hie = 1000.0                          #hie (in ohm)\n",
    "hfe = 50.0                            #Current gain  \n",
    "hoe = 25.0 * 10**-6                   #hor (in Siemens)  \n",
    "\n",
    "#Calculation\n",
    "\n",
    "hic = hie                             #hie (in ohm)\n",
    "hrc = 1                               #hrc\n",
    "hfc = -(1 + hfe)                      #hfc \n",
    "hoc = hoe                             #hoe (in Siemens)\n",
    "Ai = -hfc/(1 + hoc*RL)                #Current gain\n",
    "Ri = hic - hrc*hfc/(hoc + 1/RL)       #Input resistance (in ohm)\n",
    "Av = Ai*RL/Ri                         #Voltage gain\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Input impedance : \",round(Ri * 10**-3,3),\"kilo-ohm.\"\n",
    "print \"Voltage gain : \",round(Av,4),\".\"\n",
    "print \"Current gain : \",round(Ai,2),\".\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.19 , Page Number 310"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Input impedance :  34.254 kilo-ohm.\n",
      "Outpur impedance :  21.1 ohm.\n",
      "Voltage gain :  0.9789 .\n",
      "Current gain :  33.53 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "VCC = 15.0               #Collector supply voltage (in volts)\n",
    "RB = 100.0 * 10**3       #Base resistance (in ohm)\n",
    "RE = 1.0 * 10**3         #Emitter resistance (in ohm)\n",
    "hie = 1100.0             #hie (in ohm)\n",
    "hfe = 50                 #hfe\n",
    "\n",
    "#Calculation\n",
    "\n",
    "hic = hie                #hic (in ohm)\n",
    "hfc = -(1 + hfe)         #hfc\n",
    "Zin = (hic - hfc*RE)*RB/((hic - hfc*RE) + RB)     #Input impedance (in ohm)\n",
    "\n",
    "Zout = RE*(-hic/hfc)/(RE - hic/hfc)               #Output impedance (in ohm)\n",
    "Av = -hfc*RE/(hic - hfc*RE)                       #Voltage gain\n",
    "Ai = Av*Zin/RE                                    #Current gain \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Input impedance : \",round(Zin * 10**-3,3),\"kilo-ohm.\"\n",
    "print \"Outpur impedance : \",round(Zout,1),\"ohm.\"\n",
    "print \"Voltage gain : \",round(Av,4),\".\"\n",
    "print \"Current gain : \",round(Ai,2),\".\"\n",
    "\n",
    "#Calculation mistake in the value of Zout in the book."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 8.20 , Page Number 311 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Zin :  1.0883 kilo-ohm.\n",
      "Av :  0.99 .\n"
     ]
    }
   ],
   "source": [
    "#Variables\n",
    "\n",
    "hre = hoe = 0                   #hre\n",
    "hie = 1.0 * 10**3               #hie (in ohm)\n",
    "hfe = 100.0                     #hfe\n",
    "VCC = 5.0                       #Collector supply voltage (in volts) \n",
    "R1 = 2.2 * 10**3                #Resistance1 (in ohm)\n",
    "R2 = 2.2 * 10**3                #Resistance2 (in ohm)\n",
    "RE = 1.0 * 10**3                #Emitter resistance (in ohm)\n",
    "\n",
    "#Calculation\n",
    "\n",
    "hic = hie                       #hic (in ohm)\n",
    "hfc = -(1 + hfe)                #hfc  \n",
    "hrc = 1 - hre                   #hrc\n",
    "hoc = hoe = 0                   #hoc\n",
    "Zin = (hic - hfc*RE)*R1*R2/(((hic - hfc*RE)*(R1+R2))+R1*R2)     #Input impedance (in ohm)\n",
    "Av = -hfc*RE/(hic - hfc*RE)     #Voltage gain \n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Zin : \",round(Zin*10**-3,4),\"kilo-ohm.\"\n",
    "print \"Av : \",round(Av,2),\".\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}