{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 6 - Power Amplifiers [Large Signal Amplifiers]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.1 Page No. 6-64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) I_BQ = V_CC-V_BE / R_B =12.87 mA\n",
      "I_CQ = beta * I_BQ =643.50 mA\n",
      "(ii) V_CC = I_CQ*R_L + V_CEQ\n",
      "Therefore,  V_CEQ(in V) = V_CC - I_CQ*R_L =9.70 V\n",
      "(iii) P_DC = V_CC * I_CQ =12.87 W\n",
      "(iv) P_ac Peak current i_b = 9 mA\n",
      "i_c = beta * i_b =450.00 mA\n",
      "Therefore,  i_c(rms) = I_rms(in mA) = i_c(peak) / sqrt(2) =318.20\n",
      "Therefore,  P_ac = (I_rms)**2 * R_L =1.62 W\n",
      "(v) Efficiency eta(in percentage) = P_ac/P_DC * 100 =12.58\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "from __future__ import division  \n",
    "ibq=(20-0.7)/1.5\n",
    "print \"(i) I_BQ = V_CC-V_BE / R_B =%0.2f mA\"%ibq\n",
    "icq=50*12.87\n",
    "print \"I_CQ = beta * I_BQ =%0.2f mA\"%icq\n",
    "print \"(ii) V_CC = I_CQ*R_L + V_CEQ\"\n",
    "vceq=20-(643.5*16*10**-3)\n",
    "print \"Therefore,  V_CEQ(in V) = V_CC - I_CQ*R_L =%0.2f V\"%vceq\n",
    "pdc=20*643.5*10**-3\n",
    "print \"(iii) P_DC = V_CC * I_CQ =%0.2f W\"%pdc\n",
    "print \"(iv) P_ac Peak current i_b = 9 mA\"\n",
    "ic=50*9\n",
    "print \"i_c = beta * i_b =%0.2f mA\"%ic\n",
    "icm=450/sqrt(2)\n",
    "print \"Therefore,  i_c(rms) = I_rms(in mA) = i_c(peak) / sqrt(2) =%0.2f\"%icm\n",
    "pac=318.19**2*16*10**-6\n",
    "print \"Therefore,  P_ac = (I_rms)**2 * R_L =%0.2f W\"%pac\n",
    "n=(1.619*100)/12.87\n",
    "print \"(v) Efficiency eta(in percentage) = P_ac/P_DC * 100 =%0.2f\"%n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.2 Page No. 6-64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_L = 4 ohm,  N1 = 200,  N2 = 20\n",
      "Therefore,  n = N2 / N1 =0.10\n",
      "Therefore,  R''_L = R1 / n**2 =400.00 ohm\n",
      "As N2 < N1, the transformer is step down and hence R''_L > R_L, as the primary winding is high voltage winding.\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "print \"R_L = 4 ohm,  N1 = 200,  N2 = 20\"\n",
    "n=20/200\n",
    "print \"Therefore,  n = N2 / N1 =%0.2f\"%n\n",
    "rl=4/(0.1**2)\n",
    "print \"Therefore,  R''_L = R1 / n**2 =%0.2f ohm\"%rl\n",
    "print \"As N2 < N1, the transformer is step down and hence R''_L > R_L, as the primary winding is high voltage winding.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.3 Page No. 6-65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_L = 8 ohm, R''_L = 648 ohm\n",
      "Now  R''_L = R_L / n**2\n",
      "Therefore,  n**2 = R_L / R''_L =0.01\n",
      "Therefore,  n = 0.1111 = Turn ratio\n",
      "But,  n = N2 / N1 = 0.1111\n",
      "Therefore,  N1/N2 = 9\n",
      "Generally the turns ratio is specified as Ni/N2 : 1 i.e. for this transformer it is 9:1\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "print \"R_L = 8 ohm, R''_L = 648 ohm\"\n",
    "print \"Now  R''_L = R_L / n**2\"\n",
    "n=8/648\n",
    "print \"Therefore,  n**2 = R_L / R''_L =%0.2f\"%n\n",
    "print \"Therefore,  n = 0.1111 = Turn ratio\"\n",
    "print \"But,  n = N2 / N1 = 0.1111\"\n",
    "print \"Therefore,  N1/N2 = 9\"\n",
    "print \"Generally the turns ratio is specified as Ni/N2 : 1 i.e. for this transformer it is 9:1\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example6.4 Page No. 6-66"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_L=8ohm, I_CQ=140 mA, V_CC=10V\n",
      "P_ac= 0.48 W\n",
      "The turns ratio are specified as N1/N2:1 i.e 3:1\n",
      "Therefore N1/N2=3\n",
      "n=N2/N1=1/3=0.33\n",
      "Therefore R''_L=R_L/n**2=72.14\n",
      "1. As the transformer is ideal, whatever is the power delivered to the load,same is the power developed across primary.\n",
      "Therefore P_ac(across primary)=0.48W\n",
      "2. Using equation (9),\n",
      "we get, P_ac=(V_1rms**2)/(R''_L)\n",
      "Therefore 0.48=(V_1rms**2)/72\n",
      "Therefore V_1rms(in V)=5.88 But rms value of the load voltage is V_2rms\n",
      "So (V1_rms)/(V2_rms)=N1/N2=3/1\n",
      "Therefore (V2_rms)(in V)=(V1_rms)/3=1.96\n",
      "This is the rms value of the load voltage.\n",
      "3. The rms value of the primary voltage is (V1_rms) as calculated above.\n",
      "Therefore (V1_rms)=5.8787 V\n",
      "4. The power delivered to the load = (I_2rms**2)*R_L       ..Refer equation 13.\n",
      "0.48=(I_2rms**2)*8\n",
      "(I_2rms)[in A]=0.24\n",
      "This is the rms value of the load current as the resistance value used is R_L and not R''_L\n",
      "5. The rms values of primary and secondary are related through the transformation ratio.\n",
      "Therefore (I_1rms)/(I_2rms)=N2/N1=n=0.333\n",
      "Thererfore (I_1rms)[in A]=0.2449*0.333= 0.08\n",
      "6. The dc power input is,\n",
      "P_DC =(V_CC)*(I_CQ)=1.40 W\n",
      "7. %eta=(P_ac *100)/(P_dc)=34.29\n",
      "P_d = 0.92 W\n",
      "This is the power dissipation.\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "from __future__ import division  \n",
    "print \"R_L=8ohm, I_CQ=140 mA, V_CC=10V\"\n",
    "print \"P_ac= 0.48 W\"\n",
    "print \"The turns ratio are specified as N1/N2:1 i.e 3:1\"\n",
    "print \"Therefore N1/N2=3\"\n",
    "n=1/3\n",
    "print \"n=N2/N1=1/3=%0.2f\"%n\n",
    "r=8/(0.333)**2\n",
    "print \"Therefore R''_L=R_L/n**2=%0.2f\"%r\n",
    "print \"1. As the transformer is ideal, whatever is the power delivered to the load,same is the power developed across primary.\"\n",
    "print \"Therefore P_ac(across primary)=0.48W\"\n",
    "print \"2. Using equation (9),\"\n",
    "print \"we get, P_ac=(V_1rms**2)/(R''_L)\"\n",
    "print \"Therefore 0.48=(V_1rms**2)/72\"\n",
    "v=sqrt(34.56)\n",
    "print \"Therefore V_1rms(in V)=%0.2f\"%v,\n",
    "print \"But rms value of the load voltage is V_2rms\"\n",
    "print \"So (V1_rms)/(V2_rms)=N1/N2=3/1\"\n",
    "v=5.8787/3\n",
    "print \"Therefore (V2_rms)(in V)=(V1_rms)/3=%0.2f\"%v\n",
    "print \"This is the rms value of the load voltage.\"\n",
    "print \"3. The rms value of the primary voltage is (V1_rms) as calculated above.\"\n",
    "print \"Therefore (V1_rms)=5.8787 V\"\n",
    "print \"4. The power delivered to the load = (I_2rms**2)*R_L       ..Refer equation 13.\"\n",
    "print \"0.48=(I_2rms**2)*8\"\n",
    "i=sqrt(0.06)\n",
    "print \"(I_2rms)[in A]=%0.2f\"%i\n",
    "print \"This is the rms value of the load current as the resistance value used is R_L and not R''_L\"\n",
    "print \"5. The rms values of primary and secondary are related through the transformation ratio.\"\n",
    "print \"Therefore (I_1rms)/(I_2rms)=N2/N1=n=0.333\"\n",
    "i=0.2449*0.333\n",
    "print \"Thererfore (I_1rms)[in A]=0.2449*0.333= %0.2f\"%i\n",
    "print \"6. The dc power input is,\"\n",
    "p=140*10**-2\n",
    "print \"P_DC =(V_CC)*(I_CQ)=%0.2f W\"%p\n",
    "n=(0.48*100)/1.4\n",
    "print \"7. %%eta=(P_ac *100)/(P_dc)=%0.2f\"%n\n",
    "d=1.4-0.48\n",
    "print \"P_d = %0.2f W\"%d\n",
    "print \"This is the power dissipation.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.6 Page No. 6-67"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_L = 4 k-ohm,  (P_ac)_D = 0.85 W\n",
      "The current without signal is I_CQ = 31 mA\n",
      "The current with signal is I_CQ + B0 = 34 mA\n",
      "The increase is due to harmonic content in the signal\n",
      "Therefore,  B0 = 34 - 31 = 3 mA\n",
      "But,  B2 = B0 = 3 mA\n",
      "Now  (P_ac)_D = P_ac * [1+D2**2]      ... Assuming only second harmonic\n",
      "Therefore,  (P_ac)_D = 1/2*B1**2*R_L * [1 + B2**2/B1**2]\n",
      "Therefore,  (P_ac)_D = 1/2*B1**2*R_L + 1/2*B2**2*R_L\n",
      "0.85 = 1/2*B1**2*(4*10**3) + 1/2*(9*10**-6)*(4*10**3)\n",
      "Therefore,  B1 = 20.396 mA\n",
      "Therefore,  D2(in percentage) = |B2|/|B1| * 100 =14.71\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "print \"R_L = 4 k-ohm,  (P_ac)_D = 0.85 W\"\n",
    "print \"The current without signal is I_CQ = 31 mA\"\n",
    "print \"The current with signal is I_CQ + B0 = 34 mA\"\n",
    "print \"The increase is due to harmonic content in the signal\"\n",
    "print \"Therefore,  B0 = 34 - 31 = 3 mA\"\n",
    "print \"But,  B2 = B0 = 3 mA\"\n",
    "print \"Now  (P_ac)_D = P_ac * [1+D2**2]      ... Assuming only second harmonic\"\n",
    "print \"Therefore,  (P_ac)_D = 1/2*B1**2*R_L * [1 + B2**2/B1**2]\"\n",
    "print \"Therefore,  (P_ac)_D = 1/2*B1**2*R_L + 1/2*B2**2*R_L\"\n",
    "print \"0.85 = 1/2*B1**2*(4*10**3) + 1/2*(9*10**-6)*(4*10**3)\"\n",
    "print \"Therefore,  B1 = 20.396 mA\"\n",
    "d2=300/20.396\n",
    "print \"Therefore,  D2(in percentage) = |B2|/|B1| * 100 =%0.2f\"%d2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.8 Page No. 6-68"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_L = 12 ohm,  n = N2/N1 = 1/3 = 0.333, eta_trans = 78.5%\n",
      "Therefore,  R''_L = R_L / n**2 =108.22\n",
      "(i) For P_max, V_m = V_CC\n",
      "Threfore,  (P_ac)_max = 1/2 * V_CC**2/R''_L =1.85 W\n",
      "But  eta_trans = 78.5%\n",
      "Therefore,  P_L = eta_trans * (P_ac)_max =1.45 W\n",
      "(ii) Condition for (P_d)_max is V_m(in V) = 2*V_CC/pi =12.73\n",
      "Therefore,  (P_d)_max(in W) = 2*V_CC**2 / pi**2*R''_L =0.75 W\n",
      "Therefore,  (P_d)_max per transistor =0.38 W\n",
      "(iii) (P_ac)_max = V_rms * I_rms = V_m/sqrt(2) * I_m/sqrt(2) = V_m*I_m / 2  and  V_m = V_CC\n",
      "Therefore,  1.8518 = 20*I_m / 2\n",
      "Therefore,  I_m = (I_c)_max =0.19 A\n",
      "and  (i_b)_max = (i_c))max / h_fe =7.40 mA\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "from __future__ import division  \n",
    "print \"R_L = 12 ohm,  n = N2/N1 = 1/3 = 0.333, eta_trans = 78.5%\"\n",
    "rl=12/(0.333**2)\n",
    "print \"Therefore,  R''_L = R_L / n**2 =%0.2f\"%rl\n",
    "pac=(0.5*20**2)/108\n",
    "print \"(i) For P_max, V_m = V_CC\"\n",
    "print \"Threfore,  (P_ac)_max = 1/2 * V_CC**2/R''_L =%0.2f W\"%pac\n",
    "print \"But  eta_trans = 78.5%\"\n",
    "pl=0.785*1.8518\n",
    "print \"Therefore,  P_L = eta_trans * (P_ac)_max =%0.2f W\"%pl\n",
    "vm=(2*20)/pi\n",
    "print \"(ii) Condition for (P_d)_max is V_m(in V) = 2*V_CC/pi =%0.2f\"%vm\n",
    "pd=(2*20**2)/(108*pi**2)\n",
    "print \"Therefore,  (P_d)_max(in W) = 2*V_CC**2 / pi**2*R''_L =%0.2f W\"%pd\n",
    "pdm=0.7505/2\n",
    "print \"Therefore,  (P_d)_max per transistor =%0.2f W\"%pdm\n",
    "print \"(iii) (P_ac)_max = V_rms * I_rms = V_m/sqrt(2) * I_m/sqrt(2) = V_m*I_m / 2  and  V_m = V_CC\"\n",
    "print \"Therefore,  1.8518 = 20*I_m / 2\"\n",
    "im=(2*1.8518)/20\n",
    "print \"Therefore,  I_m = (I_c)_max =%0.2f A\"%im\n",
    "ibm=(0.1851/25)*10**3\n",
    "print \"and  (i_b)_max = (i_c))max / h_fe =%0.2f mA\"%ibm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example6.9 Page No. 6-69"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_L=16 ohm, V_CC=25 V\n",
      "Now 2N1=200, N2=50\n",
      "Therefore N1=100.00\n",
      "Therefore n=N2/N1=0.50\n",
      "Therefore R''_L =(R_L)/(n**2)=64.00\n",
      "For maximum power output, V_m=V_CC\n",
      "i) (P_ac)_max  =(V_CC**2)/(2*R_L)=4.88 W\n",
      "ii) (P_dc)=(2*V_CC*I_m)/pi\n",
      "Now  (V_m)/(I_m)=(R''_L)\n",
      "and V_m=V_CC\n",
      "Therefore (I_m)=(V_CC)/(R''_L)=0.39\n",
      "Therefore (P_DC) = 6.22 W\n",
      "iii) %eta=(P_ac*100)/(P_DC)=78.57\n",
      "iv) (P_d)_max[in W]=(2*(P_ac)_max)/(pi**2)=0.99 W\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"R_L=16 ohm, V_CC=25 V\"\n",
    "print \"Now 2N1=200, N2=50\"\n",
    "n=200/2\n",
    "print \"Therefore N1=%0.2f\"%n\n",
    "n=50/100\n",
    "print \"Therefore n=N2/N1=%0.2f\"%n\n",
    "r=16/(0.5**2)\n",
    "print \"Therefore R''_L =(R_L)/(n**2)=%0.2f\"%r\n",
    "print \"For maximum power output, V_m=V_CC\"\n",
    "p=(25**2)/(2*64)\n",
    "print \"i) (P_ac)_max  =(V_CC**2)/(2*R_L)=%0.2f W\"%p\n",
    "print \"ii) (P_dc)=(2*V_CC*I_m)/pi\"\n",
    "print \"Now  (V_m)/(I_m)=(R''_L)\"\n",
    "print \"and V_m=V_CC\"\n",
    "i=25/64\n",
    "print \"Therefore (I_m)=(V_CC)/(R''_L)=%0.2f\"%i\n",
    "p=(2*25*0.3906)/(pi)\n",
    "print \"Therefore (P_DC) = %0.2f W\"%p\n",
    "n=(4.8848*100)/6.2169\n",
    "print \"iii) %%eta=(P_ac*100)/(P_DC)=%0.2f\"%n\n",
    "p=(2*4.8828)/(pi**2)\n",
    "print \"iv) (P_d)_max[in W]=(2*(P_ac)_max)/(pi**2)=%0.2f W\"%p"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.12 Page No. 6-70"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_L = 8 ohm, V_CC = +-12 V hence dual supply version\n",
      "(1)  (P_ac)_max = 1/2 * V_CC**2/R_L =9.00 W\n",
      "(2)  P_DC = V_CC*I_DC  but I_DC = 2*I_m / pi\n",
      "          = V_CC * (2*I_m/pi)\n",
      "Now  R_L = V_m/I_m i.e. I_m = V_m/R_L and V_m = V_CC\n",
      "Therefore,  P_DC = V_CC * 2 * V_CC/R_L * 1/pi =11.46 W\n",
      "Therefore,  Total P_D = P_DC - P_ac =2.46 W\n",
      "Therefore,  P_D per transistor =1.23 W\n",
      "(3)  %eta(in percentage) = P_ac/P_DC * 100 =78.54\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"R_L = 8 ohm, V_CC = +-12 V hence dual supply version\"\n",
    "pac=0.5*(12**2/8)\n",
    "print \"(1)  (P_ac)_max = 1/2 * V_CC**2/R_L =%0.2f W\"%pac\n",
    "print \"(2)  P_DC = V_CC*I_DC  but I_DC = 2*I_m / pi\"\n",
    "print \"          = V_CC * (2*I_m/pi)\"\n",
    "print \"Now  R_L = V_m/I_m i.e. I_m = V_m/R_L and V_m = V_CC\"\n",
    "pdc=(12**2*2)/(8*pi)\n",
    "print \"Therefore,  P_DC = V_CC * 2 * V_CC/R_L * 1/pi =%0.2f W\"%pdc\n",
    "pdt=11.4591-9\n",
    "print \"Therefore,  Total P_D = P_DC - P_ac =%0.2f W\"%pdt\n",
    "pd=2.4591/2\n",
    "print \"Therefore,  P_D per transistor =%0.2f W\"%pd\n",
    "n=900/11.4591\n",
    "print \"(3)  %%eta(in percentage) = P_ac/P_DC * 100 =%0.2f\"%n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example6.13 Page No. 6-71"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "V_CC=10V ,R_L=5 ohm\n",
      "i) (P_ac)_max = (V_CC**2)/(2*R_L)=(10**2)/(2*5)=10.00 W\n",
      "ii) To decide Power rating of transistors means to find (P_D)_max\n",
      "V_m = 6.37 V\n",
      "Now, R_L=(V_m)/(I_m)\n",
      "Therefore (I_m) = 1.27 A\n",
      "Therefore (P_DC)=(V_CC)*(I_DC)=(V_CC)*(2*I_m)/pi    (I_DC)=(2*I_m)/pi\n",
      " =(10*2*1.2732)/(pi) =8.11\n",
      "and  (P_ac)[in W]=(V_m*I_m)/2=4.05 W\n",
      "(P_D)_max = (P_DC)-(P_ac)=3.60 W\n",
      "Therefore P_D rating fora each transistor =(P_D)_max/2=2.03\n",
      "iii) For (P_ac)_max, V_m=V_CC=10 V\n",
      "I_m = (V_m)/R_L=2.00 A\n",
      "P_DC = 12.73 W\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "from __future__ import division  \n",
    "print \"V_CC=10V ,R_L=5 ohm\"\n",
    "p=100/10\n",
    "print \"i) (P_ac)_max = (V_CC**2)/(2*R_L)=(10**2)/(2*5)=%0.2f W\"%p\n",
    "print \"ii) To decide Power rating of transistors means to find (P_D)_max\"\n",
    "v=(2*10)/(pi)\n",
    "print \"V_m = %0.2f V\"%v\n",
    "print \"Now, R_L=(V_m)/(I_m)\"\n",
    "i=6.3662/5 \n",
    "print \"Therefore (I_m) = %0.2f A\"%i\n",
    "print \"Therefore (P_DC)=(V_CC)*(I_DC)=(V_CC)*(2*I_m)/pi    (I_DC)=(2*I_m)/pi\"\n",
    "p=(10*2*1.2732)/(pi)\n",
    "print \" =(10*2*1.2732)/(pi) =%0.2f\"%p\n",
    "p=(6.3662*1.2732)/2\n",
    "print \"and  (P_ac)[in W]=(V_m*I_m)/2=%0.2f W\"%p\n",
    "p=8.1056-4.5027\n",
    "print \"(P_D)_max = (P_DC)-(P_ac)=%0.2f W\"%p\n",
    "p=4.0528/2\n",
    "print \"Therefore P_D rating fora each transistor =(P_D)_max/2=%0.2f\"%p\n",
    "print \"iii) For (P_ac)_max, V_m=V_CC=10 V\"\n",
    "i=10/5\n",
    "print \"I_m = (V_m)/R_L=%0.2f A\"%i\n",
    "p=(10*2*2)/pi\n",
    "print \"P_DC = %0.2f W\"%p"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.15 Page No. 6-72"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "V_CC = 20 V,  R_L = 4 ohm\n",
      "For (P_d)max,  V_m(in V) = 2/pi * V_CC = 12.73\n",
      "R_L = V_m / I_m\n",
      "Therefore,  I_m = V_m / R_L =3.18 A\n",
      "Therefore,  I_dc = 2*I_m / pi =2.03 A\n",
      "Therefore,  P_ac = 1/2 * V_m**2/R_L =20.26 W\n",
      "and  P_dc = V_CC * I_DC =40.51 W\n",
      "Therefore,  Total (P_d)max = P_dc - P_ac =20.25 W\n",
      "Therefore,  (P_d)max per transistor =10.13 W\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "from __future__ import division  \n",
    "print \"V_CC = 20 V,  R_L = 4 ohm\"\n",
    "vm=(2*20)/pi\n",
    "print \"For (P_d)max,  V_m(in V) = 2/pi * V_CC = %0.2f\"%vm\n",
    "print \"R_L = V_m / I_m\"\n",
    "im=12.7324/4\n",
    "print \"Therefore,  I_m = V_m / R_L =%0.2f A\"%im\n",
    "idc=(2*3.183)/pi\n",
    "print \"Therefore,  I_dc = 2*I_m / pi =%0.2f A\"%idc\n",
    "pac=(0.5*12.7324**2)/4\n",
    "print \"Therefore,  P_ac = 1/2 * V_m**2/R_L =%0.2f W\"%pac\n",
    "pdc=20*2.0254\n",
    "print \"and  P_dc = V_CC * I_DC =%0.2f W\"%pdc\n",
    "pdm=40.508-20.2542\n",
    "print \"Therefore,  Total (P_d)max = P_dc - P_ac =%0.2f W\"%pdm\n",
    "pdma=20.2538/2\n",
    "print \"Therefore,  (P_d)max per transistor =%0.2f W\"%pdma"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example6.16 Page No. 6-73"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For a given transistor,\n",
      "Maximum collector current =I_cm =1A\n",
      "Maximum power dissipation =P_d=10W\n",
      "Maximum V_CEO =40V\n",
      "For maximum output power,\n",
      "I_cm=2*I_CQ\n",
      "I_CQ=1/2=0.50\n",
      "and V_CEO=2*V_CC\n",
      "V_CC = V_CEO/2= 20.00 V\n",
      "and  V_cc=V_m=20V for (P_ac)_max\n",
      "(P_ac)_max=(V_cc**2)/(2*R_L)\n",
      "R''_L=(V_m)/I_m and I_m=I_CQ=0.5 A\n",
      "R''_L =40.00 ohm\n",
      "(P_ac)_max = (20**2)/(2*40)=5.00 W\n",
      "Now, R''_L=R_L/n**2\n",
      "n=N2/N1=0.25\n",
      "Therefore N1/N2=1/n=4.00\n",
      "Hence the turns ratio of output transformer is 4:1\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "from __future__ import division  \n",
    "print \"For a given transistor,\"\n",
    "print \"Maximum collector current =I_cm =1A\"\n",
    "print \"Maximum power dissipation =P_d=10W\"\n",
    "print \"Maximum V_CEO =40V\"\n",
    "print \"For maximum output power,\"\n",
    "print \"I_cm=2*I_CQ\"\n",
    "i=1/2\n",
    "print \"I_CQ=1/2=%0.2f\"%i\n",
    "print \"and V_CEO=2*V_CC\"\n",
    "v=40/2\n",
    "print \"V_CC = V_CEO/2= %0.2f V\"%v\n",
    "print \"and  V_cc=V_m=20V for (P_ac)_max\"\n",
    "print \"(P_ac)_max=(V_cc**2)/(2*R_L)\"\n",
    "print \"R''_L=(V_m)/I_m and I_m=I_CQ=0.5 A\"\n",
    "r=20/0.5\n",
    "print \"R''_L =%0.2f ohm\"%r\n",
    "p=(20**2)/80\n",
    "print \"(P_ac)_max = (20**2)/(2*40)=%0.2f W\"%p\n",
    "print \"Now, R''_L=R_L/n**2\"\n",
    "n=sqrt(0.0625)\n",
    "print \"n=N2/N1=%0.2f\"%n\n",
    "n=1/0.25\n",
    "print \"Therefore N1/N2=1/n=%0.2f\"%n\n",
    "print \"Hence the turns ratio of output transformer is 4:1\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.19 Page No. 6-76"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using equation (2) from section 6.7, we can determine I_BQ.\n",
      "I_BQ = 0.01 A\n",
      "Now (I_CQ) =(beta*I_BQ)=576.67 mA\n",
      "And (V_CEQ) = (V_CC)-(I_CQ*R_L)=8.77 V\n",
      "So  P_dc =(V_CC)*(I_CQ)=10380.06 W\n",
      "This is the input power.\n",
      "Now input a.c. voltage causes a base current of 5mA rms\n",
      "Therefore (I_b)_rms=5 mA\n",
      "Therefore i_c_rms = 40*5= 200.00 mA\n",
      "This is nothing but the output collector current,rms value I_rms\n",
      "Therefore I_rms = 200mA\n",
      "Using equation (13) from section 6.8, we can write,\n",
      "P_ac = (I_rms**2)**R_L=0.64 W\n",
      "This is the power delivered to the load.\n",
      "Hence the efficiency of the amplifier is,\n",
      "%eta=(P_ac*100)/P_dc= 6.17\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "from __future__ import division  \n",
    "print \"Using equation (2) from section 6.7, we can determine I_BQ.\"\n",
    "i=(18-0.7)/(1.2*10**3)\n",
    "print \"I_BQ = %0.2f A\"%i\n",
    "i=40*14.4167\n",
    "print \"Now (I_CQ) =(beta*I_BQ)=%0.2f mA\"%i\n",
    "v=18-(576.67*16*10**-3)\n",
    "print \"And (V_CEQ) = (V_CC)-(I_CQ*R_L)=%.2f V\"%v\n",
    "p=18*576.67\n",
    "print \"So  P_dc =(V_CC)*(I_CQ)=%0.2f W\"%p\n",
    "print \"This is the input power.\"\n",
    "print \"Now input a.c. voltage causes a base current of 5mA rms\"\n",
    "print \"Therefore (I_b)_rms=5 mA\"\n",
    "i=40*5\n",
    "print \"Therefore i_c_rms = 40*5= %0.2f mA\"%i\n",
    "print \"This is nothing but the output collector current,rms value I_rms\"\n",
    "print \"Therefore I_rms = 200mA\"\n",
    "print \"Using equation (13) from section 6.8, we can write,\"\n",
    "p=16*(200*10**-3)**2\n",
    "print \"P_ac = (I_rms**2)**R_L=%0.2f W\"%p\n",
    "print \"This is the power delivered to the load.\"\n",
    "print \"Hence the efficiency of the amplifier is,\"\n",
    "n=(64000*10**-3)/10.38\n",
    "print \"%%eta=(P_ac*100)/P_dc= %0.2f\"%n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.20 Page No. 6-77"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "V_CC = 20 V,  R_L = 20 ohm, turns ratio 1.58:1\n",
      "  n = 1/1.58 = 0.63\n",
      "Therefore,  R''_L = R_L / n**2 =49.93 ohm\n",
      "(i) For maximum possible peak to peak output voltage, the power output is also maximum possible. For this condition the slope of the a.c. load line can be expressed as\n",
      "R''_L = V_m/I_m = V_CC/I_CQ\n",
      "Therefore,  I_CQ =0.40 A\n",
      "Therefore,  I_BQ = I_CQ/beta =0.01 A\n",
      "This is the required value of the base current\n",
      "(ii)  P_ac = I_Irms**2 * R''_L\n",
      "But for maximum power output condition,\n",
      "I_Irms = I_Im/sqrt(2) = I_CQ/sqrt(2) =0.28 A\n",
      "Therefore,  P_ac = 3.99 W\n",
      "(iii)  %eta = P_ac/P_DC * 100\n",
      "Now  P_DC = V_CC * I_CQ =8.00 W\n",
      "%eta(in percentage) =50.00\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "from __future__ import division  \n",
    "print \"V_CC = 20 V,  R_L = 20 ohm, turns ratio 1.58:1\"\n",
    "n=1/1.58\n",
    "print \"  n = 1/1.58 = %0.2f\"%n\n",
    "rl=20/0.6329**2\n",
    "print \"Therefore,  R''_L = R_L / n**2 =%0.2f ohm\"%rl\n",
    "print \"(i) For maximum possible peak to peak output voltage, the power output is also maximum possible. For this condition the slope of the a.c. load line can be expressed as\"\n",
    "print \"R''_L = V_m/I_m = V_CC/I_CQ\"\n",
    "icq=20/49.928\n",
    "print \"Therefore,  I_CQ =%0.2f A\"%icq\n",
    "ibq=0.4/40\n",
    "print \"Therefore,  I_BQ = I_CQ/beta =%0.2f A\"%ibq\n",
    "print \"This is the required value of the base current\"\n",
    "print \"(ii)  P_ac = I_Irms**2 * R''_L\"\n",
    "print \"But for maximum power output condition,\"\n",
    "irms=0.4/sqrt(2)\n",
    "print \"I_Irms = I_Im/sqrt(2) = I_CQ/sqrt(2) =%0.2f A\"%irms\n",
    "pac=49.928*0.2828**2\n",
    "print \"Therefore,  P_ac = %0.2f W\"%pac\n",
    "print \"(iii)  %eta = P_ac/P_DC * 100\"\n",
    "pdc=20*0.4\n",
    "print \"Now  P_DC = V_CC * I_CQ =%0.2f W\"%pdc\n",
    "eta=400/8\n",
    "print \"%%eta(in percentage) =%0.2f\"%eta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.21 Page No. 6-78"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_L = 8 ohm,  P_ac(max) = 40 W\n",
      "2*N1 = 160,  N2 = 40\n",
      "N1 = 80\n",
      "n = N2/N1 =0.50\n",
      "Therefore,  R''_L = R_L / n**2 =32.00 ohm\n",
      "Under maximum condition, V_CC = V_m\n",
      "Therefore,  P_ac(max) = 1/2 * V_CC**2/R''_L\n",
      "Therefore,  V_CC = 50.60 V\n",
      "This is the required value of V_CC\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"R_L = 8 ohm,  P_ac(max) = 40 W\"\n",
    "print \"2*N1 = 160,  N2 = 40\"\n",
    "print \"N1 = 80\"\n",
    "n=40/80\n",
    "print \"n = N2/N1 =%0.2f\"%n\n",
    "rl=8/0.5**2\n",
    "print \"Therefore,  R''_L = R_L / n**2 =%0.2f ohm\"%rl\n",
    "print \"Under maximum condition, V_CC = V_m\"\n",
    "print \"Therefore,  P_ac(max) = 1/2 * V_CC**2/R''_L\"\n",
    "vcc=sqrt(40*2*32)\n",
    "print \"Therefore,  V_CC = %0.2f V\"%vcc\n",
    "print \"This is the required value of V_CC\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.22 Page No. 6-79"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For a common collector configuration the voltage gain is 1\n",
      "Therefore,  V_in(peak) = V_out(peak) = 20 V\n",
      "i.e.  V_m = 20 V\n",
      "Now  V_m/I_m = R_L\n",
      "Therefore,  I_m = V_m/R_L =1.25 A\n",
      "while  V_CC = 25 V\n",
      "Now  P_DC = 2*V_CC*I_m / pi =19.89 W\n",
      "P_ac = V_m*I_m / 2 =12.50 W\n",
      "Therefore,  %eta(in percentage) = P_ac*100 / P_DC =62.83\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"For a common collector configuration the voltage gain is 1\"\n",
    "print \"Therefore,  V_in(peak) = V_out(peak) = 20 V\"\n",
    "print \"i.e.  V_m = 20 V\"\n",
    "print \"Now  V_m/I_m = R_L\"\n",
    "im=20/16\n",
    "print \"Therefore,  I_m = V_m/R_L =%0.2f A\"%im\n",
    "print \"while  V_CC = 25 V\"\n",
    "pdc=(2*25*1.25)/pi\n",
    "print \"Now  P_DC = 2*V_CC*I_m / pi =%0.2f W\"%pdc\n",
    "pac=(20*1.25)/2\n",
    "print \"P_ac = V_m*I_m / 2 =%0.2f W\"%pac\n",
    "eta=1250/19.8943\n",
    "print \"Therefore,  %%eta(in percentage) = P_ac*100 / P_DC =%0.2f\"%eta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.26 Page No. 6-81"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) As single transistor is used, even harmonic components will not get eliminated\n",
      "  D2 = |B2| / |B1| =8.33 %\n",
      "  D3 = |B3| / |B1| =3.33 %\n",
      "  D4 = |B4| / |B1| =1.67 %\n",
      "  D5 = |B5| / |B1| =0.83 %\n",
      "The total harmonic distortion is,\n",
      "%D = sqrt(D2**2 + D3**2 + D4**2 + D5**2) * 100\n",
      "Therefore,  %D =9.16 %\n",
      "(ii) When identical second transistor is used, then all even harmonics get eliminated. So only D3 and D5 will present\n",
      "Therefore,  %D = sqrt(D3**2 + D5**2)*100 =3.40 %\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"(i) As single transistor is used, even harmonic components will not get eliminated\"\n",
    "d2=1000/120\n",
    "d3=400/120\n",
    "d4=200/120\n",
    "d5=100/120\n",
    "print \"  D2 = |B2| / |B1| =%0.2f %%\"%d2\n",
    "print \"  D3 = |B3| / |B1| =%0.2f %%\"%d3\n",
    "print \"  D4 = |B4| / |B1| =%0.2f %%\"%d4\n",
    "print \"  D5 = |B5| / |B1| =%0.2f %%\"%d5\n",
    "print \"The total harmonic distortion is,\"\n",
    "print \"%D = sqrt(D2**2 + D3**2 + D4**2 + D5**2) * 100\"\n",
    "d=sqrt((0.0833**2)+(0.0333**2)+(0.01667**2)+(0.00833**2))*100\n",
    "print \"Therefore,  %%D =%0.2f %%\"%d\n",
    "print \"(ii) When identical second transistor is used, then all even harmonics get eliminated. So only D3 and D5 will present\"\n",
    "dp=sqrt((0.033**2)+(0.00833**2))*100\n",
    "print \"Therefore,  %%D = sqrt(D3**2 + D5**2)*100 =%0.2f %%\"%dp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.27 Page No. 6-82"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "From the fig 6.50 we can write,\n",
      "V_CC=20V and R_L=12 ohm\n",
      "i) The maximum ac power that can be delivered to the load is,\n",
      "(P_ac)_max = 16.67 W\n",
      "Let new power delivered to load be (P_ac)''.\n",
      "The corresponding new supply voltage be (V''_cc)\n",
      "(P_ac)''[in W]=1.36(P_ac)_max     ..36% more\n",
      "= 1.36*16.67=22.67\n",
      "And (P_ac)''=(V''_cc**2)/R_L\n",
      "Therefore 22.67=(V''_cc**2)/(2*12)\n",
      "V''_cc = 23.33 V\n",
      "Hence the percentage increase in supply voltage is,\n",
      "= ((V''_cc-V_cc)*100)/V_cc= 16.63\n",
      "The mimimum breakdown voltage per transistor this condition is,\n",
      "=2*V''_cc=2*23.326=46.65\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"From the fig 6.50 we can write,\"\n",
    "print \"V_CC=20V and R_L=12 ohm\"\n",
    "print \"i) The maximum ac power that can be delivered to the load is,\"\n",
    "p=(20**2)/24\n",
    "print \"(P_ac)_max = %0.2f W\"%p\n",
    "print \"Let new power delivered to load be (P_ac)''.\"\n",
    "print \"The corresponding new supply voltage be (V''_cc)\"\n",
    "print \"(P_ac)''[in W]=1.36(P_ac)_max     ..36% more\"\n",
    "p=1.36*16.67\n",
    "print \"= 1.36*16.67=%0.2f\"%p\n",
    "print \"And (P_ac)''=(V''_cc**2)/R_L\"\n",
    "print \"Therefore 22.67=(V''_cc**2)/(2*12)\"\n",
    "v=sqrt(544.1088)\n",
    "print \"V''_cc = %0.2f V\"%v\n",
    "print \"Hence the percentage increase in supply voltage is,\"\n",
    "p=(23.326-20)/0.2\n",
    "print \"= ((V''_cc-V_cc)*100)/V_cc= %0.2f\"%p\n",
    "print \"The mimimum breakdown voltage per transistor this condition is,\"\n",
    "v=2*23.326\n",
    "print \"=2*V''_cc=2*23.326=%0.2f\"%v"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.30 Page No. 6-83"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The circuit used for providing proper biasing is self bias, for which the various currents can be shown in the fig 6.52\n",
      "Applying KVL to base emiter loop,\n",
      "(-V_BE)-(I_E*R_E)+(I*R2)=0\n",
      "Theredfore (I*100)-(1+beta)*I_B*10=V_BE\n",
      "100I-210(I_B)=0.5     ..(1)\n",
      "Applying KVL through R1 and R2,\n",
      "(-R1(I+I_B))-(R2*I)+V_cc=0\n",
      "-1000(I+I_B)-100I=-V_cc\n",
      "1100I+1000(I_B)=25    ..(2)\n",
      "Multiplying equation (1) by 11 and subtracting from equation (2) we get,\n",
      "3310(I_B)=19.5\n",
      "Therefore I_B = 0.01 A\n",
      "Thereofore I_C=(beta*I_B)=117.82 mA=I_CQ\n",
      "Now n=N2/N1=1/8\n",
      "Therefore (R''_L)=(R_L)/(n**2) : \n",
      "i) For maximum power delivered to load,\n",
      "V_1m=V_CEQ\n",
      "Apply KVL to collector-emitter loop,\n",
      "(-10I_C)-(V_CEQ)-(10*I_E)+V_CC=0\n",
      "V_CEQ=V_cc-20*I_C=22.64     ...I_C=I_E\n",
      "(P_ac)_pri = (V_CEQ**2)/(2*R''_L)=0.80 W\n",
      "(P_ac)_max = 0.9*0.8011= 0.72 W\n",
      "This is maximum power delivered to the load.\n",
      "ii) Now (P_DC)[in W]=V_CC*I_CQ:\n",
      "%eta=(P_ac*100)/(P_dc)=24.48 %\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"The circuit used for providing proper biasing is self bias, for which the various currents can be shown in the fig 6.52\"\n",
    "print \"Applying KVL to base emiter loop,\"\n",
    "print \"(-V_BE)-(I_E*R_E)+(I*R2)=0\"\n",
    "print \"Theredfore (I*100)-(1+beta)*I_B*10=V_BE\"\n",
    "print \"100I-210(I_B)=0.5     ..(1)\"\n",
    "print \"Applying KVL through R1 and R2,\"\n",
    "print \"(-R1(I+I_B))-(R2*I)+V_cc=0\"\n",
    "print \"-1000(I+I_B)-100I=-V_cc\"\n",
    "print \"1100I+1000(I_B)=25    ..(2)\"\n",
    "print \"Multiplying equation (1) by 11 and subtracting from equation (2) we get,\"\n",
    "print \"3310(I_B)=19.5\"\n",
    "i=19.5/3310\n",
    "print \"Therefore I_B = %0.2f A\"%i\n",
    "print \"Thereofore I_C=(beta*I_B)=117.82 mA=I_CQ\"\n",
    "print \"Now n=N2/N1=1/8\"\n",
    "r=5*(8**2)\n",
    "print \"Therefore (R''_L)=(R_L)/(n**2) : \"\n",
    "print \"i) For maximum power delivered to load,\"\n",
    "print \"V_1m=V_CEQ\"\n",
    "print \"Apply KVL to collector-emitter loop,\"\n",
    "print \"(-10I_C)-(V_CEQ)-(10*I_E)+V_CC=0\"\n",
    "v=25-(20*(117.82*10**-3))\n",
    "print \"V_CEQ=V_cc-20*I_C=%0.2f     ...I_C=I_E\"%v\n",
    "p=(22.643**2)/640\n",
    "print \"(P_ac)_pri = (V_CEQ**2)/(2*R''_L)=%0.2f W\"%p\n",
    "p=0.9*0.8011\n",
    "print \"(P_ac)_max = 0.9*0.8011= %0.2f W\"%p\n",
    "print \"This is maximum power delivered to the load.\"\n",
    "p=25*117.82*10**-3\n",
    "print \"ii) Now (P_DC)[in W]=V_CC*I_CQ:\"\n",
    "n=(0.721*100)/2.9455\n",
    "print \"%%eta=(P_ac*100)/(P_dc)=%0.2f %%\"%n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.32 Page No. 3-85"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "When no signal is applied, current drawn is\n",
      "I_CQ =200mA from V_cc= 10V\n",
      "P_DC(in W)=V_CC*I_CQ:\n",
      "For maximum power output,\n",
      "V_1m=V_cc=10V and I_1m=I_CQ=200mA\n",
      "P_ac = (V_1rms*I_1rms)=(V_1m*I_1m)/2=(10*200*10**-3)/2=1.00 W\n",
      "i) P_ac(max)=Maximum output power =1W\n",
      "ii) %eta = (P_ac*100)/(P_DC)=50.00 %\n",
      "P_d(max)=V_cc*I_CQ= 2W\n",
      "The power dissipation rating of the transistor must be higher than 2W\n",
      "Now  R''_L = (V_1m)/(I_1m)=9.95 ohm\n",
      "Now R_L=2 ohm and n =N2/N1=1/5=0.20\n",
      "R''_L =(R_L)/n**2=50.00 ohm\n",
      "As R''_L required matches with the R''_L of the circuit, impedance matching is perfect\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "print \"When no signal is applied, current drawn is\"\n",
    "print \"I_CQ =200mA from V_cc= 10V\"\n",
    "p=10*200*10**-3\n",
    "print \"P_DC(in W)=V_CC*I_CQ:\"\n",
    "print \"For maximum power output,\"\n",
    "print \"V_1m=V_cc=10V and I_1m=I_CQ=200mA\"\n",
    "p=2/2\n",
    "print \"P_ac = (V_1rms*I_1rms)=(V_1m*I_1m)/2=(10*200*10**-3)/2=%0.2f W\"%p\n",
    "print \"i) P_ac(max)=Maximum output power =1W\"\n",
    "n=100/2\n",
    "print \"ii) %%eta = (P_ac*100)/(P_DC)=%0.2f %%\"%n\n",
    "print \"P_d(max)=V_cc*I_CQ= 2W\"\n",
    "print \"The power dissipation rating of the transistor must be higher than 2W\"\n",
    "r=10/(200**10**-3)\n",
    "print \"Now  R''_L = (V_1m)/(I_1m)=%0.2f ohm\"%r\n",
    "n=1/5\n",
    "print \"Now R_L=2 ohm and n =N2/N1=1/5=%0.2f\"%n\n",
    "r=2/(0.2**2)\n",
    "print \"R''_L =(R_L)/n**2=%0.2f ohm\"%r\n",
    "print \"As R''_L required matches with the R''_L of the circuit, impedance matching is perfect\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.33 Page No. 6-86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "B1 = 5*10**-2,  B2 = 10**-4,  B3 = 3*10**-6\n",
      "These are the amplitudes of various frequency components\n",
      "Therefore,  D2 = |B2|/|B1| =0.00\n",
      "Therefore,  D2 = |B3|/|B1| =0.00\n",
      "Therefore,  %D = sqrt(D2**2 + D3**2)*100 =0.02 %\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"B1 = 5*10**-2,  B2 = 10**-4,  B3 = 3*10**-6\"\n",
    "print \"These are the amplitudes of various frequency components\"\n",
    "d2=10**-4/(50*10**-2)\n",
    "d3=(3*10**-6)/(50*10**-2)\n",
    "d=sqrt((2*10**-4)**2+(6*10**-6)**2)*100\n",
    "print \"Therefore,  D2 = |B2|/|B1| =%0.2f\"%d2\n",
    "print \"Therefore,  D2 = |B3|/|B1| =%0.2f\"%d3\n",
    "print \"Therefore,  %%D = sqrt(D2**2 + D3**2)*100 =%0.2f %%\"%d"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.34 Page No. 6-87"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "V_CC = 12 V,  I_PP = 100 mA,  R_L = 5 ohm\n",
      "Therefore,  I_m = I_PP/2 = 50 mA\n",
      "(i)  P_ac = I_m**2*R_L / 2 =0.01 W\n",
      "(ii)  P_ac(max) = 1/2 * V_CC**2/R_L\n",
      "But  P_ac = V_m*I_m/2 and V_m = V_CC for maximum power\n",
      "Therefore,  R''_L = 240.00 ohm\n",
      "But  R''_L = R_L/n**2  i.e. 240 = 5/n**2\n",
      "Therefore,  n**2 = 0.02083  i.e. n = 0.1443 = N2/N1\n",
      "Therefore,  N1/N2 = 6.928 : 1\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "print \"V_CC = 12 V,  I_PP = 100 mA,  R_L = 5 ohm\"\n",
    "print \"Therefore,  I_m = I_PP/2 = 50 mA\"\n",
    "pac=((2500*10**-6)*5)/2\n",
    "print \"(i)  P_ac = I_m**2*R_L / 2 =%0.2f W\"%pac\n",
    "print \"(ii)  P_ac(max) = 1/2 * V_CC**2/R_L\"\n",
    "print \"But  P_ac = V_m*I_m/2 and V_m = V_CC for maximum power\"\n",
    "rl=12**2/0.6\n",
    "print \"Therefore,  R''_L = %0.2f ohm\"%rl\n",
    "print \"But  R''_L = R_L/n**2  i.e. 240 = 5/n**2\"\n",
    "print \"Therefore,  n**2 = 0.02083  i.e. n = 0.1443 = N2/N1\"\n",
    "print \"Therefore,  N1/N2 = 6.928 : 1\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.35 Page No. 6-88"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I_CQ = 250 mA,  V_CEQ = 8 V\n",
      "V_max = 15 V,  V_min = 1 V,  I_max = 450 mA,  I_min = 40 mA\n",
      "Therefore,  I_pp( = I_max - I_min =410.00 mA\n",
      "Therefore,  V_pp = V_max - V_min =14.00 V\n",
      "Therefore,  V_m = V_pp/2 =7.00 V\n",
      "Therefore,  I_m = I_pp/2 =205.00 mA\n",
      "(i)  P_ac = V_m*I_m/2 = 0.72 W               ...output power\n",
      "(ii)  P_DC = I_CQ*V_CEQ = %0.2f W             ...inpu:\n",
      "   %eta = P_ac/P_DC * 100 = 1.28 %          ...efficien Wcy\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "from __future__ import division  \n",
    "print \"I_CQ = 250 mA,  V_CEQ = 8 V\"\n",
    "print \"V_max = 15 V,  V_min = 1 V,  I_max = 450 mA,  I_min = 40 mA\"\n",
    "ipp=450-40\n",
    "print \"Therefore,  I_pp( = I_max - I_min =%0.2f mA\"%ipp\n",
    "vpp=15-1\n",
    "print \"Therefore,  V_pp = V_max - V_min =%0.2f V\"%vpp\n",
    "vm=14/2\n",
    "print \"Therefore,  V_m = V_pp/2 =%0.2f V\"%vm\n",
    "im=410/2\n",
    "print \"Therefore,  I_m = I_pp/2 =%0.2f mA\"%im\n",
    "pac=(7*205*10**-3)/2\n",
    "pdc=250*8*10**-3\n",
    "n=71.75/2\n",
    "pd=2-0.7175\n",
    "print \"(i)  P_ac = V_m*I_m/2 = %0.2f W               ...output power\"%pac\n",
    "print \"(ii)  P_DC = I_CQ*V_CEQ = %0.2f W             ...inpu:\"\n",
    "print \"   %%eta = P_ac/P_DC * 100 = %0.2f %%          ...efficien Wcy\"%pd"
   ]
  }
 ],
 "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
