{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5 Characteristic of Operational Amplifier"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.1 Pg 110"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is = 404.00  mV \n",
      " the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = 75.00  mV \n",
      " the total offset voltage (Vo) of an op-amp circuit is = 479.00  mV \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "# find the total offset voltage of feedback op-amp\n",
    "\n",
    "Vos = 4 # #mV  # input offset volt\n",
    "Ios = 150*10**-3 # # input offset current\n",
    "R1 = 5 # #kilo ohm  # input resistance\n",
    "R2 = 500 # #kilo ohm  # feedback resistance\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is\n",
    "Vo1 = ((R1+R2)/(R1)*Vos) #\n",
    "print ' the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is = %0.2f'%Vo1,' mV '#\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is\n",
    "Vo2 = R2*Ios #\n",
    "print ' the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = %0.2f'%Vo2,' mV '#\n",
    "\n",
    "# the total offset voltage is\n",
    "Vo = Vo1+Vo2 #\n",
    "print ' the total offset voltage (Vo) of an op-amp circuit is = %0.2f'%Vo,' mV '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.2 Pg 111"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is = 52.00  mV \n",
      " the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = 5.00  mV \n",
      " the total offset voltage (Vo) of an op-amp circuit is = 57.00  mV \n"
     ]
    }
   ],
   "source": [
    "# find the total offset voltage of feedback op-amp\n",
    "\n",
    "Vos = 2 # #mV  # input offset volt\n",
    "Ios = 20*10**-3 # # input offset current\n",
    "R1 = 10 # #kilo ohm  # input resistance\n",
    "R2 = 250 # #kilo ohm  # feedback resistance\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is\n",
    "Vo1 = ((R1+R2)/(R1)*Vos) #\n",
    "print ' the output voltage (Vo) of an op-amp circuit due to input offset voltage (Vos) is = %0.2f'%Vo1,' mV '#\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is\n",
    "Vo2 = R2*Ios #\n",
    "print ' the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = %0.2f'%Vo2,' mV '#\n",
    "\n",
    "# the total offset voltage is\n",
    "Vo = Vo1+Vo2 #\n",
    "print ' the total offset voltage (Vo) of an op-amp circuit is = %0.2f'%Vo,' mV '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.3 Pg 111"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the input offset voltage (Vos) of an op-amp circuit is = 1.187  mV \n"
     ]
    }
   ],
   "source": [
    "# find the input offset voltage of an op-amp circuit\n",
    "\n",
    "Vo = 90.2 # #mV  # output voltage\n",
    "R1 = 2 # #kilo ohm  # input resistence\n",
    "R2 = 150 # #kilo ohm  # feedback resistence\n",
    "\n",
    "# the input offset voltage (Vos) of an op-amp circuit is defined as\n",
    "Vos = ((R1)/(R1+R2)*Vo) #\n",
    "print 'the input offset voltage (Vos) of an op-amp circuit is = %0.3f'%Vos,' mV '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.4 Pg 112"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the output voltage due to the input offset voltage  is = 36.00  mV \n"
     ]
    }
   ],
   "source": [
    "# find the output voltage of an op-amp circuit\n",
    "\n",
    "Vos = 1 # #mV  # input offset volt\n",
    "R1 = 10 # #kilo ohm  # input resistance\n",
    "R2 = 350 # #kilo ohm  # feedback resistance\n",
    "\n",
    "# the output voltage due to the input offset voltage of the op-amp circuit is defined by\n",
    "Vo1 = ((R1+R2)/(R1)*Vos) #\n",
    "print 'the output voltage due to the input offset voltage  is = %0.2f'%Vo1,' mV '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.5 Pg 113"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the output voltage of the circuit due to bias current is = 0.11  V \n",
      "Bias compensated resistor is = 9.09  kilo ohm \n",
      "Bias compensated output voltage is = 0.01  V \n"
     ]
    }
   ],
   "source": [
    "# Determine the bias current effect with and without current compensation method\n",
    "\n",
    "R1 = 10 # #kilo ohm\n",
    "R2 = 100 # #kilo ohm\n",
    "Ib1 = 1.1*10**-3 #\n",
    "Ib2 = 1*10**-3 # \n",
    "# the output voltage of the circuit due to bias current is\n",
    "Vo = Ib1*R2 #\n",
    "print 'the output voltage of the circuit due to bias current is = %0.2f'%Vo,' V '#\n",
    "\n",
    "#Bias compensated resistor is given by\n",
    "R3 = (R1*R2)/(R1+R2) #\n",
    "print 'Bias compensated resistor is = %0.2f'%R3,' kilo ohm '#\n",
    "\n",
    "#Bias compensated output voltage is given by\n",
    "Vo = R2*(Ib1-Ib2)#\n",
    "print 'Bias compensated output voltage is = %0.2f'%Vo,' V '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.6 Pg 113"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = 80 nA \n"
     ]
    }
   ],
   "source": [
    "# find the input offset current of an op-amp circuit\n",
    "\n",
    "Vo = 12*10**-3# # V  # output voltage\n",
    "R1 = 2*10**3 # # ohm  # input resistence\n",
    "R2 = 150*10**3# # ohm  # feedback resistence\n",
    "\n",
    "# the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is\n",
    "# Vo = R2*Ios #\n",
    "Ios = Vo/R2 *1e9 # nA\n",
    "print 'the output voltage (Vo) of an op-amp circuit due to input offset current (Ios) is = %0.f'%Ios,'nA '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.7 Pg 114"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current in the inverting input terminal is = 27.50  nA \n",
      "The current in the non-inverting input terminal is= 32.50  nA \n"
     ]
    }
   ],
   "source": [
    "# Determine the bias current of inverting and non-inverting\n",
    "Ios = 5 # #nA # input offset current\n",
    "Ib = 30 # #nA # input bias current\n",
    "\n",
    "# the input bias current of an op-amp is \n",
    "\n",
    "#Ib =(Ib1+Ib2)/(2)#\n",
    "\n",
    "# the offset current Ios is define as\n",
    "\n",
    "#Ios = abs(Ib1-Ib2) #\n",
    "\n",
    "Ib1=Ib-(Ios/2)#\n",
    "print 'The current in the inverting input terminal is = %0.2f'%Ib1,' nA '#\n",
    "\n",
    "Ib2 =Ib+(Ios/2)#\n",
    "print 'The current in the non-inverting input terminal is= %0.2f'%Ib2,' nA '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.8 Pg 115"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Feedback transfer function is = 0.01 \n",
      "OR 1/Beta  is = 100.10 \n",
      "Feedback transfer function is = -0.01 \n",
      "OR 1/Beta  is = -100.10 \n"
     ]
    }
   ],
   "source": [
    "#determine the feedback transfer function of an op-amp for the following condition\n",
    "# a) When open loop gain of 10**5 and the closed loop gain of 100\n",
    "A = 10**5 # # open loop gain\n",
    "Af = 100 # #closed loop gain\n",
    "# Feedback transfer function is\n",
    "beta =(1/Af)-(1/A)#\n",
    "print 'Feedback transfer function is = %0.2f'%beta,''#\n",
    "beta = 1/beta #\n",
    "print 'OR 1/Beta  is = %0.2f'%beta,''#\n",
    "\n",
    "# For an open loop gain of -10**5 and closed loop gain of -100\n",
    "A = -10**5 # # open loop gain\n",
    "Af = -100 # #closed loop gain\n",
    "# Feedback transfer function is\n",
    "beta =(1/Af)-(1/A)#\n",
    "print 'Feedback transfer function is = %0.2f'%beta,''#\n",
    "beta = 1/beta #\n",
    "print 'OR 1/Beta  is = %0.2f'%beta,''#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.9 Pg 115"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "open loop gain is = 2000.00\n"
     ]
    }
   ],
   "source": [
    "#to determine open loop gain\n",
    "beta = 0.0120 # # Feedback transfer function\n",
    "Af = 80 # #closed loop gain\n",
    "A = (Af)/(1-beta*Af) #\n",
    "print 'open loop gain is = %0.2f'%A"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.10 Pg 116"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "close loop gain dAf is = 49.78\n",
      "the percent change of closed loop gain dAf is = 0.45 %\n"
     ]
    }
   ],
   "source": [
    " # To Determine the percent of change in the closed loop gain Af of feedback op-amp circuit\n",
    "A = 10**5 #  # open loop gain\n",
    "Af = 50 #  # close loop gain\n",
    "beta = 0.01999 #  # feedback transfer function\n",
    "dA = 10**4 #  # the change in the open llop gain \n",
    "\n",
    "# close loop gain\n",
    "dAf = ((dA)/(1+dA*beta))#\n",
    "print 'close loop gain dAf is = %0.2f'%dAf\n",
    "\n",
    "# the percent change of closed loop gain \n",
    "dAf = (((Af-dAf)/(Af))*100)#\n",
    "print 'the percent change of closed loop gain dAf is = %0.2f'%dAf,'%'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.11 Pg 116"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the feedback transfer function beta is = 0.0199\n",
      "the closed loop bandwidth wfH is = 125600\n"
     ]
    }
   ],
   "source": [
    "# To Determine the bandwidth of feedback amplifier\n",
    "A = 10**4 #  # open loop gain\n",
    "Af = 50 #  # close loop gain\n",
    "wH = 628 # #(2*pi*100)  # rad/sec # open loop bandwidth\n",
    "\n",
    "# close loop gain of an op-amp is defined as\n",
    "# Af = ((A)/(1+A*beta))# \n",
    "\n",
    "# the feedback transfer function is given as\n",
    "beta = (1/Af)-(1/A) #\n",
    "print 'the feedback transfer function beta is = %0.4f'%beta\n",
    "\n",
    "# closed loop bandwidth\n",
    "wfH = wH*(1+beta*A)#\n",
    "print 'the closed loop bandwidth wfH is = %0.f'%wfH"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.12 Pg 117"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the unity gain bandwidth is = 1e+06 Hz\n",
      "the maximum close loop gain ACL is = 50.00 \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "# To calculate unity gain bandwidth and maximum close loop gain\n",
    "A = 10**5 #  # open loop gain\n",
    "fo = 10 # # Hz  # dominant pole frequency\n",
    "fdb = 20*10**3 # #Hz  # 3-db frequency\n",
    "\n",
    "# the unity gain bandwidth\n",
    "f1 = fo*A #\n",
    "print 'the unity gain bandwidth is = %0.e'%f1,'Hz'#\n",
    "\n",
    "# the maximum close loop gain\n",
    "ACL = (f1/fdb) #\n",
    "print 'the maximum close loop gain ACL is = %0.2f'%ACL,''#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.13 Pg 117"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the unity gain bandwidth is = 60 kHz\n",
      "the maximum close loop gain ACL is = 5.00 \n"
     ]
    }
   ],
   "source": [
    "# To calculate unity gain bandwidth and maximum close loop gain\n",
    "A = 10**3 #  # open loop gain\n",
    "fo = 60 # # Hz  # dominant pole frequency\n",
    "fdb = 12*10**3 # #Hz  # 3-db frequency\n",
    "\n",
    "# the unity gain bandwidth\n",
    "f1 = fo*A #\n",
    "print 'the unity gain bandwidth is = %0.f'%(f1/1e3),'kHz'#\n",
    "\n",
    "# the maximum close loop gain\n",
    "ACL = (f1/fdb) #\n",
    "print 'the maximum close loop gain ACL is = %0.2f'%ACL,''#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.14 Pg 118"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the dominant pole frequency (fPD) of an op-amp is = 2.5 kHz\n"
     ]
    }
   ],
   "source": [
    "# To determine the dominant pole frequency of an op-amp\n",
    "Ao = 2*10**5 #  # low frequency open loop gain\n",
    "f = 5*10**6 # # Hz  # pole frequency\n",
    "ACL = 100 #  # low frequency closed lkoop gain\n",
    "p_margin = 80 # \n",
    "\n",
    "# the dominant pole frequency of an op-amp\n",
    "fPD = (ACL)*(f/Ao)/1e3\n",
    "print 'the dominant pole frequency (fPD) of an op-amp is = %0.1f'%fPD,'kHz'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.15 Pg 118"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FL = 6.37  KHz \n",
      "Acom =  [ magnitude = 6.3*10**-3   angle = -89.6 degree ]\n",
      "Ac =  [ magnitude = 0.68   angle = 0.4 degree ]\n"
     ]
    }
   ],
   "source": [
    " # Determine the loop gain of compensated network\n",
    "C = 0.0025*10**-6 # # farad\n",
    "R = 10*10**3 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "Ac1 = 100 #  \n",
    "angle1 = 90 #\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "# Ac = Acl*Acom #\n",
    "\n",
    "#Acom = 1/(1+%(F/FL))#\n",
    "\n",
    "FL = 1/(2*3.14*R*C)#\n",
    "print 'FL = %0.2f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "#  Acom = 1/(1+%j(F/FL))#\n",
    "# After putting value of F ,FL we get\n",
    "\n",
    "#  Acom = 1/(1+%j(158.7))#  #  1+%j(158.7)  Rectangular Form   where real part is 1 and imaginary part is 158.7\n",
    "\n",
    "# After converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom =  [ magnitude = 6.3*10**-3   angle = -89.6 degree ]'#\n",
    "\n",
    "#   Ac = Ac1*Acom #         equation 1\n",
    "\n",
    "# after putting Ac1 and Acom value in equation 1  we get   Ac1 = 100 angle 90  and Acom = 6.3*10**-3  angle = -89.6    \n",
    "\n",
    "print 'Ac =  [ magnitude = 0.68   angle = 0.4 degree ]'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.16 Pg 119"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FL = 1.1  KHz \n",
      "Acom =  [ magnitude = 0.68   angle = -47.7 degree ]\n"
     ]
    }
   ],
   "source": [
    "# Determine the loop gain of compensated network\n",
    "\n",
    "C = 0.01*10**-6 # # farad\n",
    "R = 15*10**3 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "# Ac = Acl*Acom #\n",
    "\n",
    "#Acom = 1/(1+%(F/FL))#\n",
    "\n",
    "FL = 1/(2*3.14*R*C)#\n",
    "print 'FL = %0.1f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "#  Acom = 1/(1+%j(F/FL))#\n",
    "# After putting value of F ,FL we get\n",
    "\n",
    "#  Acom = 1/(1+%j(0.9))#  #  1+%j(0.9)  Rectangular Form   where real part is 1 and imaginary part is 0.9\n",
    "\n",
    "# After converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom =  [ magnitude = 0.68   angle = -47.7 degree ]'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.17 Pg 120"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FL = 4.25  KHz \n",
      "Acom for F = 0 KHz =   [ magnitude = 150   angle = 85 degree ]\n",
      "Acom for F = 2 KHz=  [  magnitude = 136.4   angle = 64.5 degree ]\n",
      "Acom for F = 4 KHz = [ magnitude = 107.14   angle = 41.7 degree ]\n",
      "Acom for F = 6 KHz =  [ magnitude = 88.24   angle = 30.25 degree ]\n",
      "Acom for F = 8 KHz  =  [ magnitude = 71.4   angle = 23 degree ]\n",
      "Acom  for F = 10 KHz =   [ magnitude = 58.59  angle = 18 degree ]\n",
      "Acom for F = 20 KHz =  [ magnitude = 31.12   angle = 7 degree ]\n",
      "Acom  for F = 40 KHz =  [ magnitude = 15.9   angle = 1.1 degree ]\n",
      "Acom for F = 80 KHz =  [ magnitude = 7.9  angle = -2 degree ]\n",
      "Acom for F = 100 KHz =  [ magnitude = 6.4   angle = -2.6 degree ]\n",
      "Acom for F = 200 KHz =  [ magnitude = 3.18  angle = -3.8 degree ]\n",
      "Acom for F = 400 KHz =  [ magnitude = 1.59   angle = -4.4 degree ]\n",
      "Acom for F = 800 KHz =  [ magnitude = 0.79   angle = -4.7 degree ]\n",
      "Acom for F = 1 MHz =  [ magnitude = 0.64   angle = -4.7 degree ]\n",
      "Acom for F = 1.2 MHz =  [ magnitude = 0.52   angle = -4.7 degree ]\n",
      "Acom for F = 1.4 MHz =  [ magnitude = 0.45   angle = -4.7 degree ]\n",
      "Acom for F = 1.6 MHz =  [ magnitude = 0.4   angle = -4.7 degree ]\n"
     ]
    }
   ],
   "source": [
    "# Determine the loop gain of compensated network\n",
    "\n",
    "C = 0.5*10**-6 # # farad\n",
    "R = 75 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "Ac1 = 150 #  \n",
    "angle1 = 85 #\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "# Ac = Acl*Acom #\n",
    "\n",
    "#Acom = 1/(1+%(F/FL))#\n",
    "\n",
    "FL = 1/(2*3.14*R*C)#\n",
    "print 'FL = %0.2f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "#  Acom = 1/(1+%j(F/FL))#\n",
    "\n",
    "# After putting value of  FL we get\n",
    "\n",
    "#  Acom = 1/(1+%j(F/4.24*10**3))#       equation 1\n",
    "\n",
    "# As F is unknown in above equation 1 \n",
    "#  by putting different value of F we get Acom for different frequency\n",
    "\n",
    "\n",
    "# If F = 0 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(0/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 0 KHz =   [ magnitude = 150   angle = 85 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 2 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(2*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 2 KHz=  [  magnitude = 136.4   angle = 64.5 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 4 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(4*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 4 KHz = [ magnitude = 107.14   angle = 41.7 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 6 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(6*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 6 KHz =  [ magnitude = 88.24   angle = 30.25 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 8 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(8*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 8 KHz  =  [ magnitude = 71.4   angle = 23 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 10 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(10*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom  for F = 10 KHz =   [ magnitude = 58.59  angle = 18 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 20 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(20*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 20 KHz =  [ magnitude = 31.12   angle = 7 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 40 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(40*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom  for F = 40 KHz =  [ magnitude = 15.9   angle = 1.1 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# If F = 80 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(80*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 80 KHz =  [ magnitude = 7.9  angle = -2 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# If F = 100 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(100*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 100 KHz =  [ magnitude = 6.4   angle = -2.6 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# If F = 200 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(200*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 200 KHz =  [ magnitude = 3.18  angle = -3.8 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 400 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(400*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 400 KHz =  [ magnitude = 1.59   angle = -4.4 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 800 KHz\n",
    "\n",
    "# Acom = 1/(1+%j(800*10**3/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 800 KHz =  [ magnitude = 0.79   angle = -4.7 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 1 MHz\n",
    "\n",
    "# Acom = 1/(1+%j(1*10**6/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 1 MHz =  [ magnitude = 0.64   angle = -4.7 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 1.2 MHz\n",
    "\n",
    "# Acom = 1/(1+%j(1.2*10**6/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 1.2 MHz =  [ magnitude = 0.52   angle = -4.7 degree ]'#\n",
    "\n",
    "\n",
    "\n",
    "# If F = 1.4 MHz\n",
    "\n",
    "# Acom = 1/(1+%j(1.4*10**6/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 1.4 MHz =  [ magnitude = 0.45   angle = -4.7 degree ]'#\n",
    "\n",
    "\n",
    "# If F = 1.6 MHz\n",
    "\n",
    "# Acom = 1/(1+%j(1.6*10**6/4.24*10**3))#  \n",
    "\n",
    "# After solving and converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom for F = 1.6 MHz =  [ magnitude = 0.4   angle = -4.7 degree ]'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.18 Pg 123"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The compensating resistor value is = 15.92  ohm \n"
     ]
    }
   ],
   "source": [
    "# to design compensating network\n",
    "fp = 500*10**3 #  # pole frequency\n",
    "C = 0.02*10**-6 # # F  # we choose\n",
    "# loop gain of compensated network\n",
    "\n",
    "# ACom =(1)/(1+j(f/fp))\n",
    "# fp = (1/2*pie*R*C)\n",
    "R = (1/(2*3.14*C*fp))#\n",
    "print 'The compensating resistor value is = %0.2f'%R,' ohm '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.19 Pg 123"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FH = 6.37  KHz \n",
      "FL = 2.12  KHz \n",
      "Acom =  [ magnitude = 0.34   angle = -0.24 degree ]\n",
      "Ac = [ magnitude = 34   angle = 89.76 degree ]\n"
     ]
    }
   ],
   "source": [
    " # Determine the loop gain of compensated network\n",
    "\n",
    "C = 0.0025*10**-6 # # farad\n",
    "R1 = 10*10**3 # #  ohm\n",
    "R2 = 20*10**3 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "Ac1 = 100 #  \n",
    "angle1 = 90 #\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "\n",
    "# Ac = Acl*Acom #\n",
    "\n",
    "#Acom = (1+%(F/FH))/(1+%(F/FL))#\n",
    "\n",
    "FH = 1/(2*3.14*R1*C)#\n",
    "print 'FH = %0.2f'%(FH/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "\n",
    "FL = 1/(2*3.14*(R1+R2)*C)#\n",
    "print 'FL = %0.2f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "\n",
    "#Acom = (1+%(F/FH))/(1+%(F/FL))#\n",
    "\n",
    "# After putting value of FH ,FL we get\n",
    "\n",
    "#  Acom = (1+%j(158.7))/(1+%j(471.7) \n",
    "\n",
    "# After converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom =  [ magnitude = 0.34   angle = -0.24 degree ]'#\n",
    "\n",
    "#   Ac = Ac1*Acom #         equation 1\n",
    "\n",
    "# after putting Ac1 and Acom value in equation 1  we get   Ac1 = 100 angle 90  and Acom = 0.34  angle = -0.24    \n",
    "\n",
    "print 'Ac = [ magnitude = 34   angle = 89.76 degree ]'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.20 Pg 124"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FH = 1.59  KHz \n",
      "FL = 0.64  KHz \n",
      "Acom =   [magnitude = 0.4]  \n"
     ]
    }
   ],
   "source": [
    " # Determine the loop gain of compensated network\n",
    "C = 0.01*10**-6 # # farad\n",
    "R1 = 10*10**3 # #  ohm\n",
    "R2 = 15*10**3 # #  ohm\n",
    "F = 1*10**6 # # Hz\n",
    "\n",
    "\n",
    "# the close loop gain of a compensated network is defined as\n",
    "\n",
    "#Acom = (1+%(F/FH))/(1+%(F/FL))#\n",
    "\n",
    "FH = 1/(2*3.14*R1*C)#\n",
    "print 'FH = %0.2f'%(FH/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "\n",
    "FL = 1/(2*3.14*(R1+R2)*C)#\n",
    "print 'FL = %0.2f'%(FL/1000),' KHz '#   # Round Off Error\n",
    "\n",
    "\n",
    "#Acom = (1+%(F/FH))/(1+%(F/FL))#\n",
    "\n",
    "# After putting value of FH ,FL we get\n",
    "\n",
    "#  Acom = (1+%j(658.9))/(1+%j(1.56*10**3) \n",
    "\n",
    "# After converting  rectangular from into polar from we get\n",
    " \n",
    "print 'Acom =   [magnitude = 0.4]  '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.21 Pg 125"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The compensating first resistor R1 value is = 0.80  K ohm \n",
      "The compensating second resistor R2 value is = 7.17  K ohm \n"
     ]
    }
   ],
   "source": [
    "# to design compensating network\n",
    "fH = 10 # #k ohm # break frequency initiated by a zero\n",
    "fL = 1 #  #k ohm # break frequency initiated by a pole\n",
    "C = 0.02# # uF  # we choose\n",
    "# loop gain of compensated network\n",
    "\n",
    "# ACom =(1+j(f/fH))/(1+j(f/fL))\n",
    "# fH = (1/2*pie*R1*C)\n",
    "# fL = (1/2*pie*(R1+R2)*C)\n",
    "R1 = (1/(2*3.14*C*fH))#\n",
    "print 'The compensating first resistor R1 value is = %0.2f'%R1,' K ohm '#\n",
    "R2 = ((1)/(2*3.14*C*fL))-(R1)#\n",
    "print 'The compensating second resistor R2 value is = %0.2f'%R2,' K ohm '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.22 Pg 126"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The input miller capacitance Cin value is = 10.10 uF \n",
      "The output miller capacitance Cout value is = 0.10 uF \n"
     ]
    }
   ],
   "source": [
    "# To determine input output miller capacitances\n",
    "A = 100 # #gain\n",
    "Cm = 0.1 #  # uF # compensated capacitor\n",
    "\n",
    "# the input output miller capacitance are defined as\n",
    "Cin = Cm*(A+1)#\n",
    "print 'The input miller capacitance Cin value is = %0.2f'%Cin,'uF '#\n",
    "Cout = (Cm*((A+1)/A))# \n",
    "print 'The output miller capacitance Cout value is = %0.2f'%Cout,'uF '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.23 Pg 127"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The input miller capacitance Cin value is = 3.02 uF \n",
      "The output miller capacitance Cout value is = 0.02 uF \n",
      "The initiated frequency of miller compensating network by pole is = 7.96  KHz \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "# To determine input output miller capacitances\n",
    "A = 150 # #gain\n",
    "Cm = 0.02 #  # uF # compensated capacitor\n",
    "\n",
    "# the input output miller capacitance are defined as\n",
    "Cin = Cm*(A+1)#\n",
    "print 'The input miller capacitance Cin value is = %0.2f'%Cin,'uF '#\n",
    "Cout = (Cm*((A+1)/A))# \n",
    "print 'The output miller capacitance Cout value is = %0.2f'%Cout,'uF '#\n",
    "\n",
    "# In the miller compensating network input capacitance introduce a pole . The initiated frequency of miller compensating network by pole is define as\n",
    "\n",
    "# fp = 1/(2*pi*R*Cin)#\n",
    "R = 1 # # K ohm\n",
    "fp = 1/(2*pi*R*Cout)#\n",
    "print 'The initiated frequency of miller compensating network by pole is = %0.2f'%fp,' KHz '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.24 Pg 128"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the slew rate of an op-amp is = 17.58  V/u sec \n",
      "The compansated capacitance value is = 1.12 pF \n"
     ]
    }
   ],
   "source": [
    "# To determine the slew rate of an op-amp\n",
    "f = 1 # # MHz # unity frequency\n",
    "Ic = 1*10**-6 #  # uA # capacitor current\n",
    "Vt = 0.7 # # V  # threshold voltage\n",
    "\n",
    "# the slew rate of an op-amp is defined as\n",
    "# Slew rate = (dVo/dt)\n",
    "Slewrate = 8*3.14*Vt*f #\n",
    "print 'the slew rate of an op-amp is = %0.2f'%Slewrate,' V/u sec '#\n",
    "\n",
    "# The compansated capacitance Cm is\n",
    "gm = (Ic/Vt)#\n",
    "Cm = (gm/4*3.14*f)*1e6 # pF\n",
    "print 'The compansated capacitance value is = %0.2f'%Cm,'pF '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.25 Pg 129"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cut -off frequency of an op-amp is = 5.00  Hz \n"
     ]
    }
   ],
   "source": [
    " # To determine the cut off frequency of an op-amp\n",
    "f = 1*10**3 # # Hz # unity frequency\n",
    "Av = 200 # # V/mV  # dc gain\n",
    "\n",
    "# the unity gain frequency of an op-amp is defined as\n",
    "# f = Av*fc #\n",
    "\n",
    "# cut off frequency\n",
    "fc = (f/Av)#\n",
    "print 'Cut -off frequency of an op-amp is = %0.2f'%fc,' Hz '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.26 Pg 129"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the closed loop gain ACL is = 35.00  \n",
      "The output gain factor K is = 0.88  V\n",
      "The maximum frequency of an op-amp fmax = 145.59  KHz\n"
     ]
    }
   ],
   "source": [
    "# To find the maximum frequency of input signal in op-amp circuit\n",
    "Vin = 25*10**-3 # # V  # input voltage\n",
    "Slewrate = 0.8/10**-6 #  # V/uV   # Slew rate of an op-amp\n",
    "R2 = 350*10**3 #  #  ohm  # feedback resistance\n",
    "R1 = 10*10**3 #  # ohm  # input resistance\n",
    "\n",
    "# the closed loop gain\n",
    "# ACL = (mod (Vo/Vin)) = (mod(R2/R1))#\n",
    "ACL = abs(R2/R1)#\n",
    "print 'the closed loop gain ACL is = %0.2f'%ACL,' '#\n",
    "\n",
    "# the output gain factor K is given as\n",
    "K = ACL*Vin #\n",
    "print 'The output gain factor K is = %0.2f'%K,' V'#\n",
    "\n",
    "# the maximum frequency of an op-amp is\n",
    "wmax = (Slewrate/K)#\n",
    "fmax = wmax/(2*3.14)#\n",
    "print 'The maximum frequency of an op-amp fmax = %0.2f'%(fmax/1000),' KHz'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.27 Pg 129"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the closed loop gain ACL is = 24.00  \n",
      "The output gain factor K is = 0.36  V\n",
      "The wmax is = 2.22 *10**6 rad/sec\n"
     ]
    }
   ],
   "source": [
    "# To find the maximum frequency of op-amp circuit\n",
    "Vin = 0.015 # # V  # input voltage\n",
    "Slewrate = 0.8 #  # V/uV   # Slew rate of an op-amp\n",
    "R2 = 120*10**3 #  #  ohm  # feedback resistance\n",
    "R1 = 5*10**3 #  # ohm  # input resistance\n",
    "\n",
    "# the closed loop gain\n",
    "# ACL = (mod (Vo/Vin)) = (mod(R2/R1))#\n",
    "ACL = abs(R2/R1)#\n",
    "print 'the closed loop gain ACL is = %0.2f'%ACL,' '#\n",
    "\n",
    "# the output gain factor K is given as\n",
    "K = ACL*Vin #\n",
    "print 'The output gain factor K is = %0.2f'%K,' V'#\n",
    "\n",
    "# the maximum frequency of an op-amp is\n",
    "wmax = (Slewrate/K)#\n",
    "print 'The wmax is = %0.2f'%wmax,'*10**6 rad/sec'# # *10**6 because Slewrate is V/uV \n",
    "\n",
    "# the signal frequency may be w = 500*10**3 rad/sec  that is less than the maximum frequency value"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.28 Pg 130"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the unity frequency f is = 568.70 kHz \n",
      "The compansated capacitance Cm value is = 0.2 nF \n"
     ]
    }
   ],
   "source": [
    " # To determine the compensated capacitance of an op-amp\n",
    "Slewrate = 10 # # V/u sec\n",
    "Ic = 1*10**-3 #  # mA # capacitor current\n",
    "Vt = 0.7 # # V  # threshold voltage\n",
    "\n",
    "# the slew rate of an op-amp is defined as\n",
    "# Slew rate = (dVo/dt)\n",
    "# the unity frequency f is\n",
    "f =(Slewrate/(8*3.14*Vt))#\n",
    "f = f*10**6#  # *10**6 because Slew rate is V/uV \n",
    "print 'the unity frequency f is = %0.2f'%(f/1e3),'kHz '#\n",
    "\n",
    "# The compansated capacitance Cm is\n",
    "gm = (Ic/Vt)#\n",
    "Cm = (gm)/(4*3.14*f)*1e9 #\n",
    "print 'The compansated capacitance Cm value is = %0.1f'%Cm,'nF '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.29 Pg 131"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the Slew rate of an op-amp is = 0.50  V/u sec\n"
     ]
    }
   ],
   "source": [
    " # To find Slew rate of an op-amp\n",
    "Iq = 15 # # uA  # bias current\n",
    "Cm = 30  # # pF  # internal frequency compensated capacitor\n",
    "Slewrate = (Iq/Cm)\n",
    "print 'the Slew rate of an op-amp is = %0.2f'%Slewrate,' V/u sec'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.30 Pg 131"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the Slew rate of an op-amp is = 0.68  V/u sec\n"
     ]
    }
   ],
   "source": [
    "# To find Slew rate of an op-amp\n",
    "Iq = 21 # # uA  # bias current\n",
    "Cm = 31  # # pF  # internal frequency compensated capacitor\n",
    "Slewrate = (Iq/Cm)#\n",
    "print 'the Slew rate of an op-amp is = %0.2f'%Slewrate,' V/u sec'#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.31 Pg 131"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The full power bandwidth FPBW is = 8.12 kHz \n",
      "The 3-db frequency or small signal band width f3db is = 10 kHz \n"
     ]
    }
   ],
   "source": [
    " # To determine full power and small signal bandwidth of an op-amp with unity gain\n",
    "f = 100*10**6 # # Hz  unity gain bandwidth\n",
    "ACL = 10**4 # # maximum closed loop gain\n",
    "Slewrate = 0.51 # # V/u sec\n",
    "Vp = 10 # # V peak volt\n",
    "\n",
    "# The full power bandwidth\n",
    "FPBW = (Slewrate/(2*3.14*Vp))#\n",
    "FPBW = FPBW*10**6 #  # *10**6 because Slew rate is V/uV \n",
    "print 'The full power bandwidth FPBW is = %0.2f'%(FPBW/1e3),'kHz '#\n",
    "\n",
    "# the 3-db frequency or small signal band width \n",
    "f3db = (f/ACL)#\n",
    "print 'The 3-db frequency or small signal band width f3db is = %0.f'%(f3db/1e3),'kHz '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.32 Pg 132"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The full power bandwidth FPBW is = 8.12 kHz \n",
      "The 3-db frequency or small signal band width f3db is = 10 kHz \n"
     ]
    }
   ],
   "source": [
    "# To determine full power and small signal bandwidth of an op-amp with unity gain\n",
    "f = 100*10**6 # # Hz  unity gain bandwidth\n",
    "ACL = 10**4 # # maximum closed loop gain\n",
    "Slewrate = 0.51 # # V/u sec\n",
    "Vp = 10 # # V peak volt\n",
    "\n",
    "# The full power bandwidth\n",
    "FPBW = (Slewrate/(2*3.14*Vp))#\n",
    "FPBW = FPBW*10**6 #  # *10**6 because Slew rate is V/uV \n",
    "print 'The full power bandwidth FPBW is = %0.2f'%(FPBW/1e3),'kHz '#\n",
    "\n",
    "# the 3-db frequency or small signal band width \n",
    "f3db = (f/ACL)#\n",
    "print 'The 3-db frequency or small signal band width f3db is = %0.f'%(f3db/1e3),'kHz '#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.33 Pg 132"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the Slew rate of an op-amp is = 0.31  V/u sec \n",
      "The closed loop gain ACL is = 83.33  \n"
     ]
    }
   ],
   "source": [
    "# To find Slew rate and closed loop gain of an op-amp\n",
    "fu = 1*10**6 # # Hz  # unity gain bandwidth\n",
    "fmax = 5*10**3 # # KHz  # full power bandwidth\n",
    "F3db = 12*10**3 # # Hz  # small signal bandwidth\n",
    "Vp = 10 # # V  # peak volt\n",
    "\n",
    "# the full power bandwidth of an op-amp\n",
    "# fmax=FPBW = (Slew rate/2*3.14*Vp)#\n",
    "Slewrate = 2*3.14*Vp*fmax#\n",
    "Slewrate = Slewrate*(10**-6)#  # *10**-6 because Slewrate is V/u \n",
    "print 'the Slew rate of an op-amp is = %0.2f'%Slewrate,' V/u sec '#\n",
    "\n",
    "# # the 3-db frequency or small signal band width \n",
    "#f3db = (f/ACL)#\n",
    "#the closed loop gain ACL\n",
    "ACL = fu/F3db #\n",
    "print 'The closed loop gain ACL is = %0.2f'%ACL,' '#"
   ]
  }
 ],
 "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
}