{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 8 Amplifiers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex8_1 PG-8.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Therefore gain in decibel=40 dB \n",
      "\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import log10\n",
    "Av=100##voltage gain\n",
    "G=20*log10(Av)##gain in decibel\n",
    "print \"\\n Therefore gain in decibel=%.0f dB \\n\"%(G)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex8_2 PG-8.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Therefore maximum voltage gain=282.84 \n",
      "\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "Av=200##gain at cut-off frequencies\n",
    "Avm=Av*sqrt(2)##maximum voltage gain\n",
    "print \"\\n Therefore maximum voltage gain=%.2f \\n\"%(Avm)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex8_3 PG-8.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Therefore  the gain of the amplifier at f = 20Hz is 2 \n",
      "\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "Amid=100##mid-band gain\n",
    "f1=1e3##loer cut-off frequency\n",
    "f=20##frquency at which the gain of the amplifier should be found\n",
    "A=Amid/sqrt(1+(f1/f)**2)\n",
    "print \"\\n Therefore  the gain of the amplifier at f = 20Hz is %.0f \\n\"%(A)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex8_4 PG-8.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Therefore  the gain of the amplifier at f=100kHz is 55.47 \n",
      "\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "G=200##3dB gain\n",
    "f2=20e3##higher cut-off frequency\n",
    "Amid=G*sqrt(2)##mid-band gain\n",
    "f=100e3##frquency at which the gain of the amplifier should be found\n",
    "A=Amid/sqrt(1+(f/f2)**2)\n",
    "print \"\\n Therefore  the gain of the amplifier at f=100kHz is %.2f \\n\"%(A)\n",
    "#in the  book the answer for the gain is 115.47 which is wrong \n",
    "#the corect answer is 55.47"
   ]
  }
 ],
 "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
}
