{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 4:Alternating quantities"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.1:Page number-193"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "e(t)=0 V\n",
      "e(t)= 362.58 V\n",
      "e(t)= 418.67 V\n"
     ]
    }
   ],
   "source": [
    "import math \n",
    "\n",
    "#given\n",
    "\n",
    "b=0.2\n",
    "a=0.04\n",
    "n=1000/float(60) #rev/sec\n",
    "t=500\n",
    "\n",
    "#case a\n",
    "\n",
    "#since coil is at right angles ang=0\n",
    "\n",
    "print \"e(t)=0 V\"\n",
    "\n",
    "#case b\n",
    "\n",
    "#when coil is 30deg to the field ang=60\n",
    "\n",
    "#p=math.sin(60) \n",
    "\n",
    "p=0.8660254\n",
    "\n",
    "e=2*3.14*a*n*b*t*p\n",
    "\n",
    "\n",
    "print \"e(t)=\",format(e,'.2f'),\"V\"\n",
    "\n",
    "#case c\n",
    "\n",
    "#when ang=90 that is coil is in the plane of the field\n",
    "\n",
    "#p=math.sin(90)\n",
    "\n",
    "p=1\n",
    "e=2*3.14*b*a*n*p*t\n",
    "\n",
    "print \"e(t)=\",format(e,'.2f'),\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 4.2:Page number-202"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "t= 0.0167 sec\n",
      "f= 60.0 Hz\n",
      "t= -0.0014 sec\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#given\n",
    "\n",
    "vm=155\n",
    "omega=377\n",
    "\n",
    "#case a\n",
    "\n",
    "t=(2*3.14)/float(omega)\n",
    "\n",
    "print \"t=\",format(t,'.4f'),\"sec\"\n",
    "\n",
    "#case b\n",
    "\n",
    "f=1/float(t)\n",
    "\n",
    "print \"f=\",format(f,'.1f'),\"Hz\"\n",
    "\n",
    "#case c\n",
    "\n",
    "v=109.60 #rms value\n",
    "\n",
    "#at t=0 -77.5=155*sin(ang)\n",
    "\n",
    "#therefore, ang=-0.5236 rad\n",
    "\n",
    "ang=-0.5236\n",
    "\n",
    "t=ang/omega\n",
    "\n",
    "print \"t=\",format(t,'.4f'),\"sec\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i= 10.0 A\n",
      "f= 50.0 A\n",
      "i= 0.15 A\n",
      "NOTE:Answer calculated wrongly in textbook for i obtained here\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#given\n",
    "\n",
    "#i=14.14*sin(314t)-->i=im*sin(omega*t)\n",
    "\n",
    "#case a\n",
    "\n",
    "im=14.14\n",
    "i=14.14/1.414 #1.414 is  the value of root 2\n",
    "\n",
    "print \"i=\",format(i,'.1f'),\"A\"\n",
    "\n",
    "#case b\n",
    "\n",
    "#omega=314=2*3.14*f\n",
    "\n",
    "f=314/float(2*3.14)\n",
    "\n",
    "print \"f=\",format(f,'.1f'),\"A\"\n",
    "\n",
    "#case c\n",
    "\n",
    "t=0.002\n",
    "\n",
    "#i=im*sin(omega*t)\n",
    "\n",
    "p=0.01096 #value of sin(omega*t)\n",
    "i=im*p\n",
    "\n",
    "print \"i=\",format(i,'.2f'),\"A\" \n",
    "\n",
    "print \"NOTE:Answer calculated wrongly in textbook for i obtained here\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.4:Page number-203"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I= 24.496 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "i=20\n",
    "im=i/float(1.414) #that is i*root 2\n",
    "\n",
    "#the heat produced by i is the sum of heat produced by dc and ac current\n",
    "p=i**2\n",
    "q=im**2\n",
    "r=p+q\n",
    "I=(r**0.5)\n",
    "\n",
    "print \"I=\",format(I,'.3f'),\"A\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i= 0.2 A\n",
      "i= 1.4 A\n",
      "NOTE:The answer given in text is printed wrongly\n",
      "t= 0.00333 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "f=50\n",
    "irms=10\n",
    "\n",
    "im=irms/float(0.707)\n",
    "\n",
    "#omega*t=2*3.14*f*t here the value for t can be substituted and value for i can be found from i=im*sin(omega*t)\n",
    "\n",
    "t=0.0025\n",
    "p=0.0137 #value of sin(314*0.0025)\n",
    "i=(10*p)/float(0.707)\n",
    "\n",
    "print \"i=\",format(i,'.1f'),\"A\"\n",
    "\n",
    "#maximum value is when 314*t=pi/2 (in radians)-->t=0.005\n",
    "\n",
    "#hence at t=0.005+0.0125=0.0175 the value of i nedds to be found\n",
    "p=0.0957\n",
    "i=(10*p)/float(0.707)\n",
    "\n",
    "print \"i=\",format(i,'.1f'),\"A\"\n",
    "print \"NOTE:The answer given in text is printed wrongly\"\n",
    "\n",
    "i=7.07\n",
    "\n",
    "#7.07=(10*sin314t)/0.707-->t=0.00833 sec\n",
    "\n",
    "t=0.00833-0.005 #the time at which the instaneous value is 7.07A after positive maximum value is at this time\n",
    "\n",
    "print \"t=\",format(t,'.5f'),\"A\"\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.6:Page number-204"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "v= 25.79 V\n",
      "vavg= 20.0 v\n",
      "1.28937969582\n",
      "1.93891683582\n",
      "rms value for a sin wave with the same peak value is= 35.35 V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#from graph \n",
    "a=0\n",
    "b=5**2\n",
    "c=10**2\n",
    "c=20**2\n",
    "d=40**2\n",
    "e=50**2\n",
    "f=40**2\n",
    "g=20**2\n",
    "h=10**2\n",
    "i=5**2\n",
    "v=(0.1*(a+b+c+d+e+f+g+h+i))**0.5 #pi and omega values get cancelled\n",
    "\n",
    "print \"v=\",format(v,'.2f'),\"V\"\n",
    "vavg=0.1*(0+5+10+20+40+50+40+20+10+5)\n",
    "print \"vavg=\",format(vavg,'.1f'),\"v\"\n",
    "ff=v/float(vavg)\n",
    "print ff\n",
    "\n",
    "pf=50/float(v) #50 is the maximum value\n",
    "print pf\n",
    "\n",
    "v=0.707*50 \n",
    "\n",
    "print \"rms value for a sin wave with the same peak value is=\",format(v,'.2f'),\"V\"\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.8:Page number-210"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "vac= 130.77 v\n",
      "phase position with respect to vbc=60-36.59=23.41\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#from phasor diagram vac=vab+vbc\n",
    "\n",
    "hcab=60\n",
    "vcab=60\n",
    "hcbc=45\n",
    "vcbc=77.94 #vbc=60*sin(60)\n",
    "\n",
    "p=(vcab+hcbc)**2\n",
    "q=vcbc**2\n",
    "vac=((p+q)**0.5)\n",
    "\n",
    "print \"vac=\",format(vac,'.2f'),\"v\"\n",
    "\n",
    "#the angle is given by ang=taninverse(vcbc/(vcab+hcbc))=36.59\n",
    "\n",
    "print \"phase position with respect to vbc=60-36.59=23.41\"\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.9:Page number-210"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "E1**2+2*E1*E2*cos(alpha)+E2**2=5836.96\n",
      "E1**2+2*E1*E2*cos(alpha)+E2**2=712.89\n",
      "E1=46.12V,E2=33.88V\n",
      "alpha=34.93\n"
     ]
    }
   ],
   "source": [
    "Example 4.9:Page number-210"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10:Page number-215"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a+b=22.72+j2.12\n",
      "a/b=-0.13+j0.74\n",
      "Thus (a+b)/(a-b) gives -0.24-j0.81\n",
      "(a+b*b/(a-b)*a)=-1.01+j0.5\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#a=6.34+j*13.59\n",
    "#b=20angle(35)\n",
    "\n",
    "#case a-->(a+b)\n",
    "\n",
    "#in polar form a=15 at angle 65\n",
    "#in rectangular form b=16.38-j*11.47\n",
    "\n",
    "#a+b=6.34+j13.59+16.38-j11.47=22.72+j2.12\n",
    "\n",
    "print \"a+b=22.72+j2.12\"\n",
    "\n",
    "#a/b=15angle(65)/20angle(-35)=0.75angle(100)=-0.13+j0.74\n",
    "\n",
    "print \"a/b=-0.13+j0.74\"\n",
    "\n",
    "#a-b=-10.04+j25.06\n",
    "\n",
    "print \"Thus (a+b)/(a-b) gives -0.24-j0.81\"\n",
    "\n",
    "#(a+b)*b/(a-b)*a\n",
    "\n",
    "print \"(a+b*b/(a-b)*a)=-1.01+j0.5\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I=7.5+j4.75. Its value in polar form is obtained as 8.8776 at angle 32.34\n",
      "instantaneous value of resultant i is 12.5548*sin(314t+32.34)\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#i1=20*sin(314t+60),i2=-10*sin(314t),i3=15*sin(314t-45)-->angles are in degrees\n",
    "\n",
    "#I1=(7.7072+j12.25),I2=(-7.072),I3=7.5-j7.5\n",
    "\n",
    "#adding phasor currents I1,I2 and I3\n",
    "\n",
    "#I=7.702+j12.25-7.702+7.5-j7.5=7.5+j4.75\n",
    "\n",
    "print \"I=7.5+j4.75. Its value in polar form is obtained as 8.8776 at angle 32.34\"\n",
    "\n",
    "#i=2**0.5*8.8776*sin(314t+32.34)-->instantaneous value of resultant i\n",
    "\n",
    "print \"instantaneous value of resultant i is 12.5548*sin(314t+32.34)\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 4.12:Page number-226"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i= 12.35 A\n",
      "phase angle of current=57.52 lag\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "v=230\n",
    "f=50\n",
    "L=50*10**-3\n",
    "r=10\n",
    "\n",
    "#case a\n",
    "xl=2*3.14*f*L\n",
    "\n",
    "z=complex(r,xl)\n",
    "\n",
    "#the value of z in polar form is 18.62 ohm\n",
    "\n",
    "z=18.62\n",
    "\n",
    "i=v/float(z)\n",
    "\n",
    "print \"i=\",format(i,'.2f'),\"A\"\n",
    "\n",
    "#case b\n",
    "\n",
    "#phy=taninverse(xl/r)=57.52 lag\n",
    "\n",
    "print \"phase angle of current=57.52 lag\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "v= 279.21 V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "vr=150\n",
    "r=50\n",
    "l=250*10**-3\n",
    "f=50\n",
    "\n",
    "i=vr/r\n",
    "\n",
    "xl=2*3.14*f*l\n",
    "\n",
    "vl=i*xl\n",
    "\n",
    "v=(((vr**2)+(vl**2))**0.5)\n",
    "\n",
    "print \"v=\",format(v,'.2f'),\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.14"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6875\n",
      "power consumed= 500.0 w\n",
      "power consumed in choke oil= 187.5 W\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "v=200\n",
    "f=50\n",
    "r=20\n",
    "vr=100\n",
    "vc=144\n",
    "vl=150\n",
    "\n",
    "#case a\n",
    "\n",
    "#from eqn ((vr**2+vl*cos(angle))**2)+((vl*sin(angle))**2)=v**2\n",
    "\n",
    "#on substituting values in the above eqn the value of angle can be found by isolating cos\n",
    "\n",
    "#angle=75.52\n",
    "\n",
    "cos=0.25\n",
    "\n",
    "pf=(vr+vl*cos)/float(v)\n",
    "\n",
    "print pf\n",
    "\n",
    "#case b\n",
    "\n",
    "i=vr/r\n",
    "power=i**2*r\n",
    "\n",
    "print \"power consumed=\",format(power,'.1f'),\"w\"\n",
    "\n",
    "#case c\n",
    "\n",
    "power=vl*i*cos\n",
    "\n",
    "print \"power consumed in choke oil=\",format(power,'.1f'),\"W\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.15:Page number-230"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " xc= 31.85 ohm\n",
      "i= 6.89 A\n",
      "0.299580587178\n",
      "phase angle=72.6\n",
      "v= 68.9 v\n",
      "v= 219.4 v\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r=10\n",
    "c=10**-4\n",
    "v=230\n",
    "f=50\n",
    "omega=314\n",
    "\n",
    "#case a\n",
    "xc=1/float(omega*c)\n",
    "\n",
    "print \"xc=\",format(xc,'.2f'),\"ohm\"\n",
    "\n",
    "#case b\n",
    "\n",
    "zc=33.38 #zc=10-j31.85 into polar form is 33.38\n",
    "\n",
    "i=v/zc\n",
    "\n",
    "print \"i=\",format(i,'.2f'),\"A\"\n",
    "\n",
    "#case c\n",
    "\n",
    "pf=r/zc\n",
    "\n",
    "print pf\n",
    "\n",
    "#case d\n",
    "\n",
    "#phase angle=cosinverse(0.3)=72.6\n",
    "\n",
    "print \"phase angle=72.6\"\n",
    "\n",
    "#case e\n",
    "\n",
    "v=r*i\n",
    "\n",
    "print \"v=\",format(v,'.1f'),\"v\"\n",
    "\n",
    "v=xc*i\n",
    "\n",
    "print \"v=\",format(v,'.1f'),\"v\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.16:Page number-230"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "vc= 207.12 v\n",
      "c= 0.00007688 F\n",
      "maximum voltage across c= 292.92 V\n",
      "phase angle=64.2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "v=230\n",
    "f=50\n",
    "\n",
    "#voltage vr across r is in phase with the current i while voltage vc across c lage i by 90\n",
    "\n",
    "#from phasor diagram v**2=vr**2+vc**2\n",
    "\n",
    "vr=100\n",
    "\n",
    "vc=((v**2)-(vr**2))**0.5\n",
    "\n",
    "print \"vc=\",format(vc,'.2f'),\"v\"\n",
    "p=500 #power\n",
    "\n",
    "i=p/vr\n",
    "\n",
    "c=i/float(2*3.14*f*vc)\n",
    "\n",
    "print \"c=\",format(c,'.8f'),\"F\"\n",
    "\n",
    "#case b\n",
    "\n",
    "v=(2**0.5)*vc\n",
    "\n",
    "print \"maximum voltage across c=\",format(v,'.2f'),\"V\"\n",
    "\n",
    "#case c\n",
    "\n",
    "#phase angle=cosinverse(vr/v)=cosinverse(0.4348)=64.2\n",
    "\n",
    "print \"phase angle=64.2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.17:Page number-234"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "xl= 47.1 ohm\n",
      "xc= 25.48 ohm\n",
      "complex impedance=8+j21.62 at an impedance angle of 69.7\n",
      "current= 9.98 A\n",
      "voltage across coil=446.8 at 10.66 degrees\n",
      "voltage across capacitor=-254.29 at -159.7 degrees\n",
      "phase difference between supply and current i is 69.7 lag\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r=8\n",
    "l=0.15\n",
    "f=50\n",
    "v=230\n",
    "c=125*10**-6\n",
    "\n",
    "#case a inductive reactance\n",
    "\n",
    "xl=2*3.14*f*l\n",
    "\n",
    "print \"xl=\",format(xl,'.1f'),\"ohm\"\n",
    "\n",
    "#case b capacitance reactance\n",
    "\n",
    "xc=1/float(2*3.14*f*c)\n",
    "\n",
    "print 'xc=',format(xc,'.2f'),\"ohm\"\n",
    "\n",
    "#case c complex impedance\n",
    "\n",
    "#z=r+j(xl-xc)-->on substituting valuees we get z=8+j21.62\n",
    "\n",
    "#z=((8**2)+(21.62**2))**0.5\n",
    "\n",
    "print \"complex impedance=8+j21.62 at an impedance angle of 69.7\"\n",
    "\n",
    "#impedance angle=taninverse(xl-xr)/r\n",
    "\n",
    "#case d\n",
    "\n",
    "v=230\n",
    "z=23.05\n",
    "i=v/z\n",
    "\n",
    "print \"current=\",format(i,'.2f'),\"A\"\n",
    "\n",
    "#case e\n",
    "\n",
    "#(r+jxl)*i=446.8 at 10.66 degrees\n",
    "\n",
    "print \"voltage across coil=446.8 at 10.66 degrees\"\n",
    "\n",
    "#-j*xc*i=25.48*9.98\n",
    "print \"voltage across capacitor=-254.29 at -159.7 degrees\"\n",
    "\n",
    "#case e\n",
    "\n",
    "print 'phase difference between supply and current i is 69.7 lag'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.18:Page number-235 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "capacitive reactance= 63.7 ohm\n",
      "f= 50.0 cycles/sec\n",
      "power loss in iron cored choke is= 53.69 w\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "c=50*10**-6\n",
    "i=2.355\n",
    "\n",
    "#case a\n",
    "\n",
    "vl=120\n",
    "vr=70\n",
    "vac=150\n",
    "\n",
    "#the phasor sum of vr and vl is OC;the applied voltage v is the phasor sum of vc and OC and is represented by OV\n",
    "\n",
    "#the theta be the impedance angle of RL combination\n",
    "\n",
    "#from right angled triangle OCD,theta can be determined as follows:\n",
    "#(vr+vl*costheta)**2+(vl*costheta)**2=vac**2\n",
    "#substitute the values then value of costheta can be found\n",
    "\n",
    "zl=vl/i #impedance of the coil\n",
    "\n",
    "p=0.981 #value of sin(79)\n",
    "xl=zl*p\n",
    "\n",
    "q=0.19 #value of cos(79)\n",
    "r=zl*q\n",
    "\n",
    "dc=i*xl\n",
    "bd=i*r\n",
    "#from right angled triangle ODB in fig.\n",
    "\n",
    "v=98.3\n",
    "\n",
    "xc=vac/i\n",
    "\n",
    "print \"capacitive reactance=\",format(xc,'.1f'),\"ohm\"\n",
    "\n",
    "f=1/float(xc*2*3.14*c)\n",
    "\n",
    "print \"f=\",format(f,'.1f'),\"cycles/sec\"\n",
    "\n",
    "ploss=i**2*r\n",
    "\n",
    "\n",
    "print \"power loss in iron cored choke is=\",format(ploss,'.2f'),\"w\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.19:Page number-238"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i= 12.07 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r=20\n",
    "l=200*10**-3\n",
    "v=230\n",
    "f=50\n",
    "\n",
    "xl=314*l #314 is omega\n",
    "\n",
    "ir=v/float(r)\n",
    "\n",
    "il=v/float(xl)\n",
    "\n",
    "i=((ir**2)+(il**2))**0.5\n",
    "\n",
    "print \"i=\",format(i,'.2f'),\"A\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.20:Page number-240 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "current with a lead of 57.5 is obtained as= 4.13 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r=100\n",
    "c=50*10**-6\n",
    "f=50\n",
    "v=230\n",
    "\n",
    "#case a\n",
    "\n",
    "xc=-1/float(314*c) #314 is omega\n",
    "\n",
    "ir=v/r #with angle 0\n",
    "\n",
    "ic=230/float(xc) #with angle of 90 deg\n",
    "\n",
    "i=((ir**2)+(ic**2))**0.5\n",
    "\n",
    "print \"current with a lead of 57.5 is obtained as=\",format(i,'.2f'),\"A\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.21:Page number-242"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "current at 56.76 lead= 4.196 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r=100\n",
    "l=0.1\n",
    "c=150*10**-6\n",
    "v=230\n",
    "f=50\n",
    "\n",
    "#case a\n",
    "\n",
    "xl=314*l #at 90 deg\n",
    "\n",
    "xc=1/float(314*c) #at lag -90 deg\n",
    "\n",
    "ir=v/r #at 0 deg\n",
    "il=v/xl\n",
    "ic=v/xc\n",
    "\n",
    "#i=ir+ic+il-->2.3+j3.51\n",
    "\n",
    "i=((2.3**2)+(3.51**2))**0.5\n",
    "\n",
    "print \"current at 56.76 lead=\",format(i,'.3f'),\"A\"\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 4.22:Page number-244"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of zbc is 8.159-j9.553\n",
      "zac=18.159+j5.447(in rectangular form)\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "z1=18.03 #z1=10+j15 converted to polar form also it is at angle 56.31\n",
    "z2=32.02\n",
    "z3=10.77\n",
    "\n",
    "#ybc=1/zbc=(1/z2+1/z3)=1/32.02+1/10.77\n",
    "\n",
    "#on performing the add operation we get the value of zbc as 8.159-j9.553 that is in rectangular form\n",
    "\n",
    "print \"The value of zbc is 8.159-j9.553\"\n",
    "\n",
    "#thus total impedance between terminals A and C is given by zac=z1+zbc\n",
    "\n",
    "print \"zac=18.159+j5.447(in rectangular form)\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.23:Page number-246"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I= 5.76 A\n",
      "z= 39.91 ohm\n",
      "R= 36.97 ohm\n",
      "x= -15.03 ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r1=25\n",
    "l1=0.159\n",
    "r2=60\n",
    "c=125*10**-6\n",
    "v=230\n",
    "f=50\n",
    "\n",
    "#case a\n",
    "\n",
    "xl=2*3.14*f*l1\n",
    "\n",
    "z1=((r1**2)+(xl**2))**0.5\n",
    "\n",
    "i1=v/z1\n",
    "\n",
    "#phy1=cosinverse(r1/z1)=63.43 lag\n",
    "\n",
    "xc=1/float(2*3.14**c)\n",
    "\n",
    "z2=((r2**2)+(xc**2))**0.5\n",
    "\n",
    "i2=v/z2\n",
    "\n",
    "#i2 has 23 deg lead calculated similar to i1\n",
    "#p=cosphy1\n",
    "#q=cosphy2\n",
    "\n",
    "p=0.44\n",
    "q=0.92\n",
    "I1=i1*p+i2*q\n",
    "a=-0.89\n",
    "b=0.39\n",
    "I2=i1*a+i2*b\n",
    "\n",
    "I=((I1**2)+(I2**2))**0.5\n",
    "\n",
    "print \"I=\",format(I,'.2f'),\"A\"\n",
    "\n",
    "#case b\n",
    "\n",
    "z=v/I\n",
    "\n",
    "print \"z=\",format(z,'.2f'),\"ohm\"\n",
    "\n",
    "R=(z*I1)/I #note the value of I in text is printed wrongly so the result may vary\n",
    "\n",
    "print \"R=\",format(R,'.2f'),\"ohm\"\n",
    "\n",
    "x=(z*I2)/I #same note applicable here as well\n",
    "\n",
    "print \"x=\",format(x,'.2f'),\"ohm\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.24:Page number-247"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I1=6.78A\n",
      "I2=13.22A\n",
      "power loss in z1= 689.53 W\n",
      "power loss in z2= 1398.15 W\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#given\n",
    "#z1=15+j20\n",
    "#z2=8-j10\n",
    "I=20\n",
    "z1=25 #in polar form at angle 53.13\n",
    "z2=12.81 #at angle -51.34\n",
    "\n",
    "#v=I1z1=I2z2\n",
    "#I2=1.95I1\n",
    "\n",
    "#from diagram I**2=(I1cosang1+I2cosang2)**2+(I2sinang2-I1sinang1)**2\n",
    "#on substituting values in the above eqn and simplifying\n",
    "I1=6.78\n",
    "print \"I1=6.78A\"\n",
    "I2=13.22\n",
    "#substitute this in I2=1.95I1\n",
    "\n",
    "print \"I2=13.22A\"\n",
    "\n",
    "pow1=I1**2*15\n",
    "pow2=I2**2*8\n",
    "\n",
    "print \"power loss in z1=\",format(pow1,'.2f'),\"W\"\n",
    "print \"power loss in z2=\",format(pow2,'.2f'),\"W\"\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.25:Page number-248"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i1= 7.19 A\n",
      "current lags by voltage 38.66\n",
      "c= 0.00006218 F\n",
      "ir= 5.606 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r=25\n",
    "f=50\n",
    "xl=20\n",
    "v=230\n",
    "\n",
    "#case a\n",
    "\n",
    "#z1=r+jxl\n",
    "\n",
    "z1=32 #in polar form\n",
    "i1=v/float(z1)\n",
    "\n",
    "print \"i1=\",format(i1,'.2f'),'A'\n",
    "\n",
    "#case b\n",
    "\n",
    "print \"current lags by voltage 38.66\"\n",
    "\n",
    "#case c\n",
    "\n",
    "p=0.78 #cos value\n",
    "q=-0.62 #sin value\n",
    "\n",
    "ir=i1*p\n",
    "il=i1*q\n",
    "\n",
    "#from phasor diagram current c is equal to il\n",
    "\n",
    "ic=il=4.491\n",
    "\n",
    "c=ic/float(v*2*3.14*50)\n",
    "\n",
    "print \"c=\",format(c,'.8f'),\"F\"\n",
    "\n",
    "#case d\n",
    "\n",
    "print \"ir=\",format(ir,'.3f'),\"A\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.26:Page number-249"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(12.9596827495-2.78255122274j)\n",
      "the phase angle is -12.11\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "z1=complex(6,-10)\n",
    "z2=complex(10,15)\n",
    "z3=complex(18,12)\n",
    "\n",
    "#z1+z2 is parallel to z3\n",
    "\n",
    "zab=z1+(z2*z3)/(z2+z3)\n",
    "\n",
    "print zab\n",
    "\n",
    "print \"the phase angle is -12.11\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.27:Page number-258"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "current at -63 lag is= 13.05 A\n",
      "phase angle between supply voltage and current is -63\n",
      "power= 3002.3 VA\n",
      "active power= 1351.0 W\n",
      "reactive power= 2672.0 VAR\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r=8\n",
    "l=0.05\n",
    "v=230\n",
    "f=50\n",
    "\n",
    "#case a\n",
    "\n",
    "xl=2*3.14*f*l\n",
    "\n",
    "zl=complex(r,xl)\n",
    "\n",
    "zl=17.62\n",
    "\n",
    "i=v/zl #since v=230 at angle 0 and zl in polar form has 63 deg i has a lag of 63\n",
    "\n",
    "print \"current at -63 lag is=\",format(i,'.2f'),'A'\n",
    "\n",
    "#case b\n",
    "\n",
    "print \"phase angle between supply voltage and current is -63\"\n",
    "\n",
    "#case c\n",
    "\n",
    "power=v*i\n",
    "\n",
    "print \"power=\",format(power,'.1f'),\"VA\"\n",
    "\n",
    "#case d\n",
    "p=0.45 #cos63\n",
    "actpow=v*i*p\n",
    "print \"active power=\",format(actpow,'.1f'),\"W\"\n",
    "\n",
    "#case e\n",
    "\n",
    "q=0.89 #sin63\n",
    "\n",
    "reapow=v*i*q\n",
    "\n",
    "print 'reactive power=',format(reapow,'.1f'),\"VAR\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.28:Page number-259"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "input= 13392.86 VA\n",
      "active component= 40.76 A\n",
      "reactive component= 41.34 A\n",
      "reactive power= 9508.9 VAR\n",
      "c= 0.00006218 F\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "v=230\n",
    "f=50\n",
    "pf=0.7\n",
    "n=0.8\n",
    "op=7500\n",
    "\n",
    "#case a\n",
    "\n",
    "ip=op/float(0.7*0.8)\n",
    "\n",
    "print \"input=\",format(ip,'.2f'),\"VA\"\n",
    "\n",
    "#case b\n",
    "\n",
    "im=ip/v\n",
    "\n",
    "p=0.71 #sin\n",
    "\n",
    "activecompo=im*pf\n",
    "\n",
    "print \"active component=\",format(activecompo,'.2f'),\"A\"\n",
    "\n",
    "reacompo=p*im\n",
    "\n",
    "print \"reactive component=\",format(reacompo,'.2f'),\"A\"\n",
    "\n",
    "#case c\n",
    "\n",
    "reacpow=p*ip\n",
    "\n",
    "print \"reactive power=\",format(reacpow,'.1f'),\"VAR\"\n",
    "\n",
    "#case d\n",
    "\n",
    "cos=0.95\n",
    "\n",
    "i=activecompo/cos\n",
    "\n",
    "isin=13.40 #i*sinang=i*(1-cos**2)**0.5ic=28.18 #since i=ic+im\n",
    "\n",
    "c=ic/float(2*3.14*f*v)\n",
    "\n",
    "print \"c=\",format(c,'.8f'),\"F\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.29:Page number-266"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "c= 0.00004057\n",
      "i= 115.0 A\n",
      "39.25\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#case a\n",
    "\n",
    "l=0.25\n",
    "f=50\n",
    "v=230\n",
    "r=2\n",
    "\n",
    "c=1/float(((2*3.14*f)**2)*l)\n",
    "\n",
    "print \"c=\",format(c,'.8f')\n",
    "\n",
    "#case b\n",
    "\n",
    "i=v/r\n",
    "\n",
    "print \"i=\",format(i,'.1f'),\"A\"\n",
    "\n",
    "#case c\n",
    "\n",
    "vl=2*3.14*f*l*i\n",
    "vc=i/float(c*2*3.14*f)\n",
    "\n",
    "q=(2*3.14*f*l)/float(r)\n",
    "\n",
    "print q"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.30:Page number-266"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "f0= 102.0860 Hz\n",
      "f1= 101.2898 Hz\n",
      "f2= 102.8822 Hz\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "l=10\n",
    "r=100\n",
    "i=1\n",
    "f=100\n",
    "i1=0.5\n",
    "\n",
    "c=1/float(4*(3.14**2)*(r**2)*l)\n",
    "\n",
    "v=i*r\n",
    "z=v/i1\n",
    "\n",
    "#z=100+jX\n",
    "\n",
    "x=((200**2)-(100**2))**0.5\n",
    "\n",
    "omega=641.1 #angular frequency in rad/sec\n",
    "\n",
    "f0=omega/float(2*3.14)\n",
    "\n",
    "f1=f0-(r/float(4*3.14*l))\n",
    "\n",
    "f2=f0+(r/float(4*3.14*l))\n",
    "\n",
    "print \"f0=\",format(f0,'.4f'),\"Hz\"\n",
    "\n",
    "print \"f1=\",format(f1,'.4f'),\"Hz\"\n",
    "\n",
    "print \"f2=\",format(f2,'.4f'),\"Hz\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.31:Page number-271 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "l= 0.00507 H\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "v=3*10**8\n",
    "lamb=3000\n",
    "c=0.0005*10**-6\n",
    "f=v/lamb\n",
    "\n",
    "l=1/float(4*3.14*3.14*f**2*c)\n",
    "\n",
    "print \"l=\",format(l,'.5f'),\"H\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.32:Page number-272"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "c= 0.0000000005599 F\n",
      "z= 238130.4 ohm\n",
      "i= 0.0000063 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "r=1500\n",
    "l=0.2\n",
    "v=1.5\n",
    "f=15000\n",
    "\n",
    "#case a\n",
    "\n",
    "#p=1/0.2c\n",
    "\n",
    "p=(4*3.14*3.14*f**2)+(r**2)/float(l**2)\n",
    "\n",
    "c=1/float(0.2*p)\n",
    "\n",
    "print \"c=\",format(c,'.13f'),\"F\"\n",
    "\n",
    "#case b\n",
    "\n",
    "z=l/float(c*r)\n",
    "\n",
    "print \"z=\",format(z,'.1f'),\"ohm\"\n",
    "\n",
    "#case c\n",
    "\n",
    "i=v/float(z)\n",
    "\n",
    "print \"i=\",format(i,'.7f'),\"A\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.33:Page number-274"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "v1 at -47.63 is= 18.80 V\n",
      "v2 at -42.30 is= 21.55 V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#the eqns are formed using the given diagram\n",
    "#the derivations from the eqns are obtained as below using matrices for their construction\n",
    "#the below eqns are in polar form\n",
    "delta=0.3165\n",
    "delta1=5.95\n",
    "delta2=6.82\n",
    "\n",
    "v1=delta1/delta\n",
    "\n",
    "print \"v1 at -47.63 is=\",format(v1,'.2f'),\"V\"\n",
    "\n",
    "v2=delta2/delta\n",
    "\n",
    "print \"v2 at -42.30 is=\",format(v2,'.2f'),\"V\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.34:Page number-275 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i at -84.21 is= -1.32 V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#in polar form\n",
    "\n",
    "z1=10\n",
    "z2=12.806\n",
    "z3=13.416\n",
    "\n",
    "#the mesh currents are written in matrix form\n",
    "\n",
    "delta=329.31 #in polar form\n",
    "\n",
    "delta1=360\n",
    "delta2=793.22\n",
    "\n",
    "i1=delta1/delta\n",
    "i2=delta2/delta\n",
    "\n",
    "i=i1-i2 #answer obtained in text is wrongly printed\n",
    "\n",
    "print \"i at -84.21 is=\",format(i,'.2f'),\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.35:Page number-276 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1.638+4.839j)\n",
      "(0.732-5.144j)\n",
      "(2.37-0.305j)\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#superposition theorem\n",
    "\n",
    "r=4\n",
    "\n",
    "#z=4+(8+6j)*(0-j10)/8+j6+0-j10\n",
    "\n",
    "#z=14-j5\n",
    "\n",
    "z=14.87\n",
    "l=40\n",
    "#I1a=z/l=2.69 in polar form\n",
    "I1a=complex(2.533,0.904)\n",
    "\n",
    "I2a=complex(-0.324,-2.67)\n",
    "\n",
    "\n",
    "#from fig c\n",
    "\n",
    "z=complex(2.93,-9.47)\n",
    "\n",
    "I1b=complex(-0.895,3.935)\n",
    "\n",
    "I2b=complex(1.056,-2.474)\n",
    "\n",
    "I1=I1a+I1b\n",
    "\n",
    "print I1\n",
    "\n",
    "I2=I2a+I2b\n",
    "\n",
    "print I2\n",
    "\n",
    "I=I1+I2\n",
    "\n",
    "print I"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.36:Page number-278"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(3.07692307692+5.38461538462j)\n",
      "(8.81695846645+9.55403833866j)\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#thevenin's theorem\n",
    "#all the values are derived from the figures\n",
    "z1=complex(8,-6)\n",
    "z2=complex(0,5)\n",
    "\n",
    "zth=(z1*z2)/(z1+z2)\n",
    "\n",
    "print zth\n",
    "\n",
    "vth=complex(-17.71,141.54)\n",
    "\n",
    "zload=complex(4,3)\n",
    "\n",
    "I=vth/(zth+zload)\n",
    "\n",
    "print I"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.37:Page number-279"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(8.8178913738+9.55271565495j)\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#norton's theorem\n",
    "\n",
    "#values derived and calculated from figure\n",
    "\n",
    "v=complex(230,0)\n",
    "xl=complex(8,-6)\n",
    "\n",
    "isc=v/xl\n",
    "\n",
    "IN=isc\n",
    "\n",
    "rl=complex(0,5)\n",
    "zn=(rl*xl)/(rl+xl)\n",
    "zload=complex(4,3)\n",
    "\n",
    "I=(IN*zn)/(zn+zload)\n",
    "\n",
    "print I"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.38:Page number-281"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I= 4.51 A\n",
      "pl= 18.75 w\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#all values derived from figure\n",
    "\n",
    "\n",
    "#zth=complex(0.923,2.615)\n",
    "\n",
    "#vth=complex(-4.615,-6.923) #derived using formula\n",
    "\n",
    "#zl=complex(0.923,-2.615)\n",
    "\n",
    "#z=zl+zth\n",
    "vth=8.32 #polar form\n",
    "z=1.846\n",
    "I=vth/z\n",
    "\n",
    "print \"I=\",format(I,'.2f'),\"A\"\n",
    "\n",
    "rl=0.923\n",
    "pl=(I**2)*rl\n",
    "\n",
    "print \"pl=\",format(pl,'.2f'),\"w\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "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
}