{
 "metadata": {
  "name": "",
  "signature": "sha256:61d9db5db58e478b9fe9a5d30d29d7e25c81e0f55f4212cd024ae335f00db037"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1- Differential Amplifiers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1 - Page 11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 9;#in V\n",
      "VEE= -9;# in V\n",
      "RC= 3.9;#in k\u03a9\n",
      "RE= 3.3;# in k\u03a9\n",
      "VBE= 0.7;# in V\n",
      "IE= (abs(VEE)-VBE)/(2*RE);# emitter current in mA\n",
      "IC= IE;# collector current in mA\n",
      "# Collector voltage,\n",
      "VC= VCC-IC*RC;# in V\n",
      "print \"The collector voltage = %0.3f volts\" %VC \n",
      "# Emitter voltage,\n",
      "VE= 0-VBE;# in V\n",
      "print \"The emitter voltage = %0.1f volts\" %VE\n",
      "# Collecctor-emitter voltage,\n",
      "VCE= VC-VE;# in V\n",
      "print \"The collector-emitter voltage = %0.3f volts\" %VCE\n",
      "\n",
      "# Note : There is some difference between coding output and the answer of the book \n",
      "#        because in the book the value of IE is used as 1.25mA while the calculated value of IE is 1.258"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The collector voltage = 4.095 volts\n",
        "The emitter voltage = -0.7 volts\n",
        "The collector-emitter voltage = 4.795 volts\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2 - Page 12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 10;#in V\n",
      "VEE= -10;# in V\n",
      "RC= 10;#in k\u03a9\n",
      "RE= 9.3;# in k\u03a9\n",
      "VBE= 0.7;# in V\n",
      "IE= (abs(VEE)-VBE)/(2*RE);# emitter current in mA\n",
      "ICQ= IE;#quiescent collector current in mA\n",
      "print \"The quiescent collector current = %0.1f mA\" %ICQ\n",
      "# Quiescent Collector-emitter voltage,\n",
      "VCEQ= VCC+VBE-ICQ*RC;# in V\n",
      "print \"The quiescent collector-emitter voltage = %0.1f volts\" %VCEQ"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The quiescent collector current = 0.5 mA\n",
        "The quiescent collector-emitter voltage = 5.7 volts\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3 - Page 12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "# Given data\n",
      "VCC= 12;#in V\n",
      "VEE= -12;# in V\n",
      "RC= 10;#in k\u03a9\n",
      "RE= 10;# in k\u03a9\n",
      "RB= 20;# in k\u03a9\n",
      "VBE= 0.7;# in V\n",
      "# Part (a)\n",
      "beta_dc= 75;\n",
      "# Tail current, IT= 2*IE= VEE/RE (ignoring VBE), hence\n",
      "IT= abs(VEE)/RE;# in mA\n",
      "IC= IT/2;#collector current in mA\n",
      "# output voltage,\n",
      "Vout1= VCC-(IC*RC);# in V\n",
      "IT= (abs(VEE)-VBE)/RE;# tail current in mA (on considering VBE)\n",
      "IC= IT/2;#collector current in mA\n",
      "Vout2= VCC-IC*RC;# in V\n",
      "# Tail current,\n",
      "IT= (abs(VEE)-VBE)/(RE+RB/(2*beta_dc));# in mA\n",
      "IC= IT/2;#collector current in mA\n",
      "# output voltage,\n",
      "Vout3= VCC-IC*RC;# in V\n",
      "print \"Part (a) : There are three different  values of output voltage \"\n",
      "print \"%0.f V\" %Vout1\n",
      "print \"%0.2f V\" %Vout2\n",
      "print \"%0.3f V\" %Vout3\n",
      "\n",
      "# Part (b)\n",
      "IT= abs(VEE)/RE;# in mA\n",
      "IC= IT/2;#collector current in mA\n",
      "IB= IC/(beta_dc);# base current in mA\n",
      "IB= IB*10**3;# in \u00b5A\n",
      "VB= -IB*RB;#base voltage  in mV\n",
      "VB= VB*10**-3;# in V\n",
      "print \"\\nPart (b) : \"\n",
      "print \"The value of base current = %0.f \u00b5A\" %IB\n",
      "print \"The value of base voltage = %0.2f V\" %VB\n",
      "\n",
      "# Part (c)\n",
      "beta_dc1= 60;\n",
      "beta_dc2= 80;\n",
      "IB1= IC/beta_dc1;#base current for transistor Q1, in mA\n",
      "IB1= IB1*10**3;# in \u00b5A\n",
      "print \"\\nPart (c)\"\n",
      "print \"The value of base current for transistor Q1 = %0.f \u00b5A \" %IB1\n",
      "VB1= -IB1*RB;# in mV\n",
      "VB1= VB1*10**-3;# in V\n",
      "print \"The value of base voltage for transistor Q1 = %0.1f V\" %VB1\n",
      "IB2= IC/beta_dc2;#base current for transistor Q2, in mA\n",
      "IB2= IB2*10**3;# in \u00b5A\n",
      "print \"The value of base current for transistor Q2 = %0.1f \u00b5A\" %IB2\n",
      "VB2= -IB2*RB;# in mV\n",
      "VB2= VB2*10**-3;# in V\n",
      "print \"The value of base voltage for transistor Q2 = %0.2f V\" %VB2\n",
      "\n",
      "# Note : In the part (c), the unit of base current for transistor Q2 in the book is wrong it will be \u00b5A\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (a) : There are three different  values of output voltage \n",
        "6 V\n",
        "6.35 V\n",
        "6.424 V\n",
        "\n",
        "Part (b) : \n",
        "The value of base current = 8 \u00b5A\n",
        "The value of base voltage = -0.16 V\n",
        "\n",
        "Part (c)\n",
        "The value of base current for transistor Q1 = 10 \u00b5A \n",
        "The value of base voltage for transistor Q1 = -0.2 V\n",
        "The value of base current for transistor Q2 = 7.5 \u00b5A\n",
        "The value of base voltage for transistor Q2 = -0.15 V\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4 - Page 13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "RC= 2.2;#in k\u03a9\n",
      "RE= 4.7;# in k\u03a9\n",
      "RE= RE*10**3;# in \u03a9\n",
      "Ri1= 50;# in \u03a9\n",
      "Ri2= 50;# in \u03a9\n",
      "VCC= 10;#in V\n",
      "VEE= 10;# in V\n",
      "VBE= 0.7;# in V\n",
      "beta_dc= 100;\n",
      "beta_ac= 100;\n",
      "\n",
      "# Part (a)\n",
      "# Formula Used : ICQ= IE= (VEE-VBE)/(2*RE+Ri/beta_dc)\n",
      "ICQ= (VEE-VBE)/(2*RE+Ri1/beta_dc);#quiescent collector current in A\n",
      "ICQ= ICQ*10**3;# in mA\n",
      "IE= ICQ;# in mA\n",
      "print \"Part (a)\"\n",
      "print \"The value of ICQ = %0.4f mA\" %ICQ\n",
      "# Quiescent collector-emitter voltage,\n",
      "VCEQ= VCC+VBE-ICQ*RC;# in V\n",
      "print \"The value of VCEQ = %0.4f V\" %VCEQ\n",
      "\n",
      "# Part (b)\n",
      "re_desh= 26/IE;# AC emitter resistance in \u03a9\n",
      "# Formula Used : Ad= Vout/Vind= RC/re_desh\n",
      "Ad= RC*10**3/re_desh;# voltage gain\n",
      "print \"Part (b)\"\n",
      "print \"The voltage gain = %0.2f \" %Ad\n",
      "\n",
      "# Part (c)\n",
      "Rin1= 2*beta_ac*re_desh;# input resistance in \u03a9\n",
      "Rin1= Rin1*10**-3;#in k\u03a9\n",
      "Rin2= Rin1;# in k\u03a9\n",
      "print \"Part (c)\"\n",
      "print \"The input resistance = %0.3f k\u03a9\" %Rin1\n",
      "\n",
      "# Part (d)\n",
      "Rout1= RC;# in k\u03a9\n",
      "print \"Part (d)\"\n",
      "print \"The output resistance = %0.1f k\u03a9\" %Rout1\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (a)\n",
        "The value of ICQ = 0.9893 mA\n",
        "The value of VCEQ = 8.5235 V\n",
        "Part (b)\n",
        "The voltage gain = 83.71 \n",
        "Part (c)\n",
        "The input resistance = 5.256 k\u03a9\n",
        "Part (d)\n",
        "The output resistance = 2.2 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5 - Page 14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 15;#in V\n",
      "VEE= 15;# in V\n",
      "RC= 1;#in M\u03a9\n",
      "RE= RC;# in M\u03a9\n",
      "beta_ac= 100;\n",
      "VBE= 0.7;# in V\n",
      "IE= (VEE-VBE)/(2*RE);#emitter current in \u00b5A\n",
      "IC= IE;# in collector current in \u00b5A\n",
      "re_desh= 26/IE;# ac resistance of each emitter diode in k\u03a9\n",
      "Ad= RC*10**3/re_desh;# Voltage gain \n",
      "print \"The voltage gain = %0.f\" %Ad\n",
      "Zin= 2*beta_ac*re_desh;# input impedance in k\u03a9\n",
      "Zin= Zin*10**-3;# in M\u03a9\n",
      "print \"The input impedance = %0.4f M\u03a9\" %Zin\n",
      "Zout= RC;#output impedance in M\u03a9\n",
      "print \"The output impedance = %0.f M\u03a9\" %Zout\n",
      "Acm= (RC*10**3)/(2*RE*10**3+re_desh);# common-mode gain\n",
      "CMRR= Ad/Acm;# common-mode rejection ratio\n",
      "print \"The common-mode rejection ratio = %0.f \" %CMRR \n",
      "# When v_in is zero\n",
      "Vout= VCC- IC*RC;# in V\n",
      "print \"When v_in is zero then the total output voltage at the quiescent value = %0.2f V\" %Vout\n",
      "# When v_in= 1mV,\n",
      "v_in= 1*10**-3;# in V\n",
      "Vout= Ad*v_in;# in V\n",
      "print \"When v_in is -1mV then the ac output voltage = %0.3f V\" %Vout\n",
      "\n",
      "# Note : The value of CMRR in the book is wrong because the correct value of Acm is \"0.4991\" and \n",
      "#       in the book it is taken as \"0.4225\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The voltage gain = 275\n",
        "The input impedance = 0.7273 M\u03a9\n",
        "The output impedance = 1 M\u03a9\n",
        "The common-mode rejection ratio = 551 \n",
        "When v_in is zero then the total output voltage at the quiescent value = 7.85 V\n",
        "When v_in is -1mV then the ac output voltage = 0.275 V\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6 - Page 16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VEE= 5;# supply voltage in V\n",
      "RC= 2*10**3;# collector resistance in \u03a9\n",
      "RE= 4.3;# emitter resistance in k\u03a9\n",
      "VBE= 0.7;# in V\n",
      "VT= 26;# in mV\n",
      "IE= (VEE-VBE)/(2*RE);#emitter current in mA\n",
      "re_desh= VT/IE;#dynamic emitter resistance in \u03a9\n",
      "Ad= RC/(2*re_desh);# differential mode gain\n",
      "print \"The differential mode gain = %0.2f\" %Ad\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The differential mode gain = 19.23\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.7 - Page 17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VEE= 5;# supply voltage in V\n",
      "RC= 2*10**3;# collector resistance in \u03a9\n",
      "RE= 4.3;# emitter resistance in k\u03a9\n",
      "VBE= 0.7;# in V\n",
      "VT= 26;# in mV\n",
      "IE= (VEE-VBE)/(2*RE);#emitter current in mA\n",
      "re_desh= VT/IE;#dynamic emitter resistance in \u03a9\n",
      "Ad= RC/(2*re_desh);# differential mode gain\n",
      "Acm= RC/(2*RE*10**3+re_desh);# common mode gain\n",
      "print \"The common mode gain = %0.4f\" %Acm\n",
      "CMRR= Ad/Acm;# common mode rejection ratio\n",
      "print \"The CMRR = %0.1f\" %CMRR\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The common mode gain = 0.2312\n",
        "The CMRR = 83.2\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.8 - Page 19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VEE= 9;#in V\n",
      "VCC= 9;#in V \n",
      "RC= 47*10**3;# collector resistance in \u03a9\n",
      "RE= 43*10**3;# emitter resistance in \u03a9\n",
      "vin1= 2.5*10**-3;# in V\n",
      "Ri1= 20*10**3;# in \u03a9\n",
      "Ri2= Ri1;# in \u03a9\n",
      "VBE= 0.7;# in V\n",
      "VT= 26*10**-3;# in V\n",
      "beta1= 75;\n",
      "beta2= 75;\n",
      "IE= (VEE-VBE)/(2*RE+Ri1/beta1);#emitter current in A\n",
      "ICQ= IE;# quiescent current in A\n",
      "VCEQ= VCC+VBE-ICQ*RC;# quiescent collector voltage in V\n",
      "re_desh= VT/IE;#AC emitter resistance in \u03a9\n",
      "Ad= RC/re_desh;# voltage gain\n",
      "vout= Ad*vin1;# output voltage in V\n",
      "print \"The output voltage = %0.3f V\" %vout"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output voltage = 0.435 V\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.9 - Page 20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "RC= 2.2;#in k\u03a9\n",
      "RE= 4.7;# in k\u03a9\n",
      "Ri1= 50*10**-3;# in k\u03a9\n",
      "Ri2= 50*10**-3;# in k\u03a9\n",
      "VCC= 10;#in V\n",
      "VEE= 10;# in V\n",
      "VBE= 0.7;# in V\n",
      "beta_dc= 100;\n",
      "beta_ac= 100;\n",
      "\n",
      "# Part (i)\n",
      "# Formula Used : ICQ= IE= (VEE-VBE)/(2*RE+Ri/beta_dc)\n",
      "ICQ= (VEE-VBE)/(2*RE+Ri1/beta_dc);#quiescent collector current in mA\n",
      "IE= ICQ;# in mA\n",
      "print \"Part (i) : Dual-input, unbalanced output\"\n",
      "print \"The value of ICQ = %0.4f mA\" %ICQ\n",
      "# Quiescent collector-emitter voltage,\n",
      "VCEQ= VCC+VBE-ICQ*RC;# in V\n",
      "print \"The value of VCEQ = %0.4f V\" %VCEQ\n",
      "re_desh= 26/IE;# AC emitter resistance in \u03a9\n",
      "Rin1= 2*beta_ac*re_desh;# input resistance in \u03a9\n",
      "Rin1= Rin1*10**-3;#in k\u03a9\n",
      "Rin2= Rin1;# in k\u03a9\n",
      "print \"The value of Rin1 = %0.3f k\u03a9 \" %Rin1\n",
      "print \"The value of Rin2 = %0.3f k\u03a9 \" %Rin1\n",
      "Rout= RC;# in k\u03a9\n",
      "print \"The value of Rout = %0.1f k\u03a9\" %Rout \n",
      "print \"The value of RC = %0.1f k\u03a9\" %RC\n",
      "# Formula Used : Ad= Vout/Vind= RC/re_desh\n",
      "Ad= RC*10**3/(re_desh*2);# voltage gain of dual input, unbalanced output\n",
      "print \"The value of Ad = %0.3f \" %Ad\n",
      "\n",
      "# Part (ii)\n",
      "print \"\\nPart (ii) : Single-output, balanced output\"\n",
      "print \"The value of ICQ = %0.4f mA\" %ICQ\n",
      "print \"The value of VCEQ = %0.4f V\" %VCEQ\n",
      "print \"The value of Rin = %0.3f k\u03a9\" %Rin1\n",
      "print \"The value of Rout1 = %0.1f k\u03a9\" %Rout\n",
      "print \"The value of Rout2 = %0.1f k\u03a9\" %Rout\n",
      "# Formula Used : Ad= Vout/Vind= RC/re_desh\n",
      "Ad= RC*10**3/(re_desh);# voltage gain of dual input, unbalanced output\n",
      "print \"The value of Ad = %0.2f\" %Ad\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (i) : Dual-input, unbalanced output\n",
        "The value of ICQ = 0.9893 mA\n",
        "The value of VCEQ = 8.5235 V\n",
        "The value of Rin1 = 5.256 k\u03a9 \n",
        "The value of Rin2 = 5.256 k\u03a9 \n",
        "The value of Rout = 2.2 k\u03a9\n",
        "The value of RC = 2.2 k\u03a9\n",
        "The value of Ad = 41.855 \n",
        "\n",
        "Part (ii) : Single-output, balanced output\n",
        "The value of ICQ = 0.9893 mA\n",
        "The value of VCEQ = 8.5235 V\n",
        "The value of Rin = 5.256 k\u03a9\n",
        "The value of Rout1 = 2.2 k\u03a9\n",
        "The value of Rout2 = 2.2 k\u03a9\n",
        "The value of Ad = 83.71\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.10 - Page 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VEE= 9;#in V\n",
      "VCC= 9;#in V \n",
      "RC= 47*10**3;# collector resistance in \u03a9\n",
      "RE= 43*10**3;# emitter resistance in \u03a9\n",
      "vin1= 2.5*10**-3;# in V\n",
      "Ri1= 20*10**3;# in \u03a9\n",
      "Ri2= Ri1;# in \u03a9\n",
      "VBE= 0.7;# in V\n",
      "VT= 26*10**-3;# in V\n",
      "beta1= 75;\n",
      "beta2= 75;\n",
      "IE= (VEE-VBE)/(2*RE+Ri1/beta1);#emitter current in A\n",
      "ICQ= IE;# quiescent current in A\n",
      "VCEQ= VCC+VBE-ICQ*RC;# quiescent collector voltage in V\n",
      "re_desh= VT/IE;#AC emitter resistance in \u03a9\n",
      "Ad= RC/(2*re_desh);# voltage gain\n",
      "vout= Ad*vin1;# output voltage in V\n",
      "print \"The output voltage = %0.3f V\" %vout"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output voltage = 0.217 V\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.11 - Page  26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VEE= 15 #in V\n",
      "VD1= 0.7 # in V\n",
      "VD2= 0.7 # in V\n",
      "VBE= 0.7 # in V\n",
      "Beta= 100 \n",
      "VT= 26 # in mV\n",
      "R3= 180 #in \u03a9\n",
      "RC= 470 # in \u03a9\n",
      "VB3= -VEE+VD1+VD2 #in V\n",
      "VE3= VB3-VBE #voltage at emitter terminal of transistor Q3 in V\n",
      "IE3= (VE3-(-VEE))/R3 #emitter current through transistor Q3 in A\n",
      "\n",
      "#Part  (i) \n",
      "ICQ= IE3/2 #quiescent current in A\n",
      "ICQ= round(ICQ*10**3) #in mA\n",
      "IE= ICQ #emitter current in mA\n",
      "print \"Part (i) : Quiescent current = %0.f mA \" %ICQ\n",
      "VCEQ= VEE+VBE-ICQ*10**-3*RC #quiescent collector-emitter voltage in V\n",
      "print \"The quiescent collector-emitter voltage = %0.2f V\" %VCEQ\n",
      "re_desh= VT/IE #AC emitter resistance in \u03a9\n",
      "\n",
      "# Part (ii)\n",
      "Ad= RC/re_desh # differential voltage gain\n",
      "print \"Part (ii) : Differential voltage gain = %0.2f \" %Ad\n",
      "\n",
      "# Part (iii)\n",
      "Rin1= 2*Beta*re_desh # in \u03a9\n",
      "Rin1= Rin1*10**-3 # in k\u03a9\n",
      "print \"Part (iii) : The input resistance = %0.1f k\u03a9\" %Rin1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (i) : Quiescent current = 2 mA \n",
        "The quiescent collector-emitter voltage = 14.76 V\n",
        "Part (ii) : Differential voltage gain = 36.15 \n",
        "Part (iii) : The input resistance = 2.6 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.12 - Page 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VEE= 10 #in V\n",
      "VCC=10 # in V\n",
      "VD1= 0.715 # in V\n",
      "Vz= 6.2# in V\n",
      "VBE= VD1 # in V\n",
      "Izt= 41 # in mA\n",
      "R3= 2.7 # in k\u03a9\n",
      "RC= 4.7 # in k\u03a9\n",
      "VT= 26 # in mV\n",
      "beta_ac= 100 \n",
      "beta_dc= 100 \n",
      "VB3= -VEE+Vz+VD1 #voltage at the base of transistor Q3 in V\n",
      "VE3= VB3-VBE # voltage at the emitter of transistor Q3 in V\n",
      "IE3= (VE3-(-VEE))/R3 #emitter current through transistor Q3 in mA\n",
      "ICQ= IE3/2 #quiescent current in mA\n",
      "VCEQ= VCC+VBE-ICQ*RC # in V\n",
      "print \"Part (c) : The Q-point values : \" \n",
      "print \"The value of ICQ = %0.3f mA\" %ICQ\n",
      "print \"The value of VCEQ = %0.2f V\" %VCEQ\n",
      "re_desh= VT/ICQ #dynamic emitter resistance in \u03a9\n",
      "Ad= RC*10**3/re_desh # voltage gain\n",
      "print \"Part (a) : The voltage gain = %0.1f\" %Ad\n",
      "Rin= 2*beta_ac*re_desh # differential input resistance in \u03a9\n",
      "Rin=Rin*10**-3 # in k\u03a9\n",
      "print \"Part (b) : The differential input resistance = %0.2f k\u03a9\" %Rin"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (c) : The Q-point values : \n",
        "The value of ICQ = 1.148 mA\n",
        "The value of VCEQ = 5.32 V\n",
        "Part (a) : The voltage gain = 207.5\n",
        "Part (b) : The differential input resistance = 4.53 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.13 - Page 31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 12 # in V\n",
      "VBE= 0.7 # in V\n",
      "R1= 25 # in k\u03a9\n",
      "# I= I_REF= (VCC-VBE)/R1\n",
      "I= (VCC-VBE)/R1 # mirrored current in mA\n",
      "print \"The mirrored current = %0.3f mA\" %I"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mirrored current = 0.452 mA\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14 - Page 31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 10 # in V\n",
      "VBE= 0.7 # in V\n",
      "R1= 15 # in k\u03a9\n",
      "Beta= 100 \n",
      "I_REF= (VCC-VBE)/R1 #reference current in mA\n",
      "print \"The reference current = %0.2f mA\" %I_REF\n",
      "Iout= I_REF*Beta/(Beta+2) # output current in mA\n",
      "print \"The output current = %0.3f mA\" %Iout"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reference current = 0.62 mA\n",
        "The output current = 0.608 mA\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15 - Page 32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 15 # in V\n",
      "VBE= 0.7 # in V\n",
      "R1= 2.2 # in k\u03a9\n",
      "Beta= 220 \n",
      "I_REF= (VCC-VBE)/R1 #reference current in mA\n",
      "# Formula : I= IC= I_REF*(Beta/(Beta+2))\n",
      "IC= I_REF*Beta/(Beta+2) # in mA\n",
      "print \"The value of current = %0.2f mA\" %IC"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of current = 6.44 mA\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.16 - Page 32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Vz= 1.8 # in V\n",
      "VBE= 0.7 # in V\n",
      "RE= 1 # in k\u03a9\n",
      "Beta= 180 \n",
      "VB= Vz-VBE # in V\n",
      "IE= VB/RE #emitter current in mA\n",
      "# Formula : I= IC= IE*(Beta/(Beta+1))\n",
      "IC= IE*Beta/(Beta+1) # in mA\n",
      "print \"The value of current = %0.3f mA\" %IC"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of current = 1.094 mA\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.17 - Page 33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 9 # in V\n",
      "R1= 12 # in k\u03a9\n",
      "VBE= 0.7 # in V\n",
      "Beta= 100 \n",
      "I_REF= (VCC-2*VBE)/R1 #reference current in mA\n",
      "print \"The reference current = %0.4f mA\" %I_REF\n",
      "Iout= I_REF/(1+2/(Beta*(1+Beta))) #output current in mA\n",
      "print \"The output current = %0.4f mA\" %Iout\n",
      "IC2= Iout #collector current in mA\n",
      "print \"The collector current = %0.4f mA\" %IC2\n",
      "# IB3= I_REF-IC1= I_REF-IC2  (since IC1= IC2)\n",
      "IB3= I_REF-IC2 #base current of transistor Q3 in mA\n",
      "IB3= IB3*10**3 # in \u00b5A\n",
      "print \"The base current of transistor Q3 = %0.1f \u00b5A\" %IB3\n",
      "IB3= 0.1 # in \u00b5A\n",
      "IE3= (1+Beta)*IB3 # emitter current of transistor Q3 in \u00b5A\n",
      "print \"The emitter current of transistor Q3 = %0.1f \u00b5A\" %IE3\n",
      "IB1= IE3/2 #base current in \u00b5A\n",
      "IB2= IB1 # in \u00b5A\n",
      "print \"The base current = %0.2f \u00b5A\" %IB1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reference current = 0.6333 mA\n",
        "The output current = 0.6332 mA\n",
        "The collector current = 0.6332 mA\n",
        "The base current of transistor Q3 = 0.1 \u00b5A\n",
        "The emitter current of transistor Q3 = 10.1 \u00b5A\n",
        "The base current = 5.05 \u00b5A\n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.18 - Page 33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VEE= 10 # in V\n",
      "VBE= 0.715 # in V\n",
      "beta_ac= 100 \n",
      "beta_dc= 100 \n",
      "R= 5.6 # in k\u03a9\n",
      "I_REF= (VEE-VBE)/R # in mA\n",
      "IC1= I_REF*beta_ac/(2+beta_ac) # in mA\n",
      "# IC1= IC2= IC3  (by symmetry)\n",
      "IC2= IC1 # in mA\n",
      "IC3= IC2 # in mA\n",
      "I_RC= IC1+IC2+IC3 # current through RC in mA\n",
      "print \"The current through RC = %0.2f mA\" %I_RC"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The current through RC = 4.88 mA\n"
       ]
      }
     ],
     "prompt_number": 51
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.19 - Page 34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 5 # in V\n",
      "VBE= 0.7 # in V\n",
      "VEE= -5 # in V\n",
      "VT= 26 # in mV\n",
      "R= 18.6 # in k\u03a9\n",
      "Beta= 100 \n",
      "I2= (VCC-VBE-VEE)/R # in mA\n",
      "IC3= I2 # in mA (due to current mirror action)\n",
      "IE= IC3/2 # emitter current of transistor Q1 and Q2\n",
      "re_desh= VT/IE #AC emitter resistance of transistor in \u03a9\n",
      "Rin1= 2*Beta*re_desh # in \u03a9\n",
      "Rin1= Rin1*10**-3 # in k\u03a9\n",
      "print \"The differential input resistance = %0.1f k\u03a9\" %Rin1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The differential input resistance = 20.8 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 52
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.20 - Page 42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "VCC= 18 # in V\n",
      "R1= 4.7 # in k\u03a9\n",
      "R2= 5.6 # in k\u03a9\n",
      "R3= 6.8 # in k\u03a9\n",
      "RE= 1.1 # in k\u03a9\n",
      "VBE= 0.7 # in V\n",
      "VT= 26 # in mV\n",
      "RC= 1.8*10**3 # in \u03a9\n",
      "IE1= (VCC*R1/(R1+R2+R3)-VBE)/RE # in mA\n",
      "re_desh= VT/IE1 #dynamic resistance of each transistor in \u03a9\n",
      "Av= -RC/re_desh # voltage gain of the cascode amplifier\n",
      "print \"The voltage gain of the cascode amplifier = %0.1f\" %Av"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The voltage gain of the cascode amplifier = -267.3\n"
       ]
      }
     ],
     "prompt_number": 55
    }
   ],
   "metadata": {}
  }
 ]
}