{
 "metadata": {
  "name": "",
  "signature": "sha256:a70fbdcc8331977a000d59120f5c4fa11beaa27b252ae9d065173da18ee666e9"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 14: Alternating voltages and currents</h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 1, page no. 195</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "f1  =  50;#  in  Hz\n",
      "f2  =  20000;#  in  Hz\n",
      "\n",
      "#calculation:\n",
      "T1  =  1/f1\n",
      "T2  =  1/f2\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)  Periodic  time  T  =  \",T1,\"  secs\\n\"\n",
      "print  \"\\n  (b)  Periodic  time  T  =  \",(T2/1E-6),\"  usecs\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)  Periodic  time  T  =   0.02   secs\n",
        "\n",
        "\n",
        "  (b)  Periodic  time  T  =   50.0   usecs\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2, page no. 195</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "T1  =  0.004;#  in  secs\n",
      "T2  =  4E-6;#  in  secs\n",
      "\n",
      "#calculation:\n",
      "f1  =  1/T1\n",
      "f2  =  1/T2\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)  Frequency  f  =  \",f1,\"  Hz\\n\"\n",
      "print  \"\\n  (b)  Frequency  f  =  \",(f2/1E6),\"  MHz\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)  Frequency  f  =   250.0   Hz\n",
        "\n",
        "\n",
        "  (b)  Frequency  f  =   0.25   MHz\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3, page no. 195</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "T  =  (8E-3)/5;#  in  secs\n",
      "\n",
      "#calculation:\n",
      "f  =  1/T\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  Frequency  f  =  \",f,\"  Hz\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  Frequency  f  =   625.0   Hz"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 4, page no. 196</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "Ta  =  0.02;#  Time  for  1  complete  cycle  in  secs\n",
      "Vamax  =  200;#  in  volts\n",
      "Va1  =  25;#  in  volts\n",
      "Va2  =  75;#  in  volts\n",
      "Va3  =  125;#  in  volts\n",
      "Va4  =  175;#  in  volts\n",
      "Tb  =  0.016;#  Time  for  1  complete  cycle  in  secs\n",
      "Ibmax  =  10;#  in  Amperes\n",
      "\n",
      "#calculation:\n",
      "#for  Triangular  waveform  (Figure  14.5(a))\n",
      "fa  =  1/Ta\n",
      "Aaw  =  Ta*Vamax/4\n",
      "Vaavg  =  Aaw*2/Ta\n",
      "Varms  =  (((Va1**2)  +  (Va2**2)  +  (Va3**2)  +  (Va4**2))/4)**0.5\n",
      "#Note  that  the  greater  the  number  of  intervals  chosen,  the  greater  the  accuracy  of  the  result\n",
      "Ffa  =  Varms/Vaavg\n",
      "Pfa  =  Vamax/Varms\n",
      "\n",
      "#for  Rectangular  waveform  (Figure  14.5(b))\n",
      "fb  =  1/Tb\n",
      "Abw  =  Tb*Ibmax/2\n",
      "Ibavg  =  Abw*2/Tb\n",
      "Ibrms  =  10\n",
      "Ffb  =  Ibrms/Ibavg\n",
      "Pfb  =  Ibmax/Ibrms\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a1)Frequency  f  =  \",fa,\"  Hz\\n\"\n",
      "print  \"\\n  (a2)average  value  over  half  a  cycle  =  \",Vaavg,\"  V\\n\"\n",
      "print  \"\\n  (a3)rms  value  =  \",round(Varms,2),\"  V\\n\"\n",
      "print  \"\\n  (a4)Form  factor  =  \",round(Ffa,2),\"\\n\"\n",
      "print  \"\\n  (a5)Peak  factor  =  \",round(Pfa,2),\"\\n\"\n",
      "print  \"\\n  (b1)Frequency  f  =  \",fb,\"  Hz\\n\"\n",
      "print  \"\\n  (b2)average  value  over  half  a  cycle  =  \",Ibavg,\"  A\\n\"\n",
      "print  \"\\n  (b3)rms  value  =  \",Ibrms,\"  A\\n\"\n",
      "print  \"\\n  (b4)Form  factor  =  \",Ffb,\"\\n\"\n",
      "print  \"\\n  (b5)Peak  factor  =  \",Pfb,\"\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a1)Frequency  f  =   50.0   Hz\n",
        "\n",
        "\n",
        "  (a2)average  value  over  half  a  cycle  =   100.0   V\n",
        "\n",
        "\n",
        "  (a3)rms  value  =   114.56   V\n",
        "\n",
        "\n",
        "  (a4)Form  factor  =   1.15 \n",
        "\n",
        "\n",
        "  (a5)Peak  factor  =   1.75 \n",
        "\n",
        "\n",
        "  (b1)Frequency  f  =   62.5   Hz\n",
        "\n",
        "\n",
        "  (b2)average  value  over  half  a  cycle  =   10.0   A\n",
        "\n",
        "\n",
        "  (b3)rms  value  =   10   A\n",
        "\n",
        "\n",
        "  (b4)Form  factor  =   1.0 \n",
        "\n",
        "\n",
        "  (b5)Peak  factor  =   1.0 "
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5, page no. 198</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import numpy \n",
      "from numpy import mean, sqrt, arange\n",
      "#initializing  the  variables:\n",
      "Thalf = 5; #in ms\n",
      "Ta  =  0.02;#  Time  for  1  complete  cycle  in  secs\n",
      "\n",
      "#calculation:\n",
      "Tfull = 2*Thalf/1000 # in sec\n",
      "f = 1/Tfull\n",
      "A=[3, 10, 19, 30, 49, 63, 73, 72, 30, 2]\n",
      "Iinst125 = 19\n",
      "Iinst38 = 70\n",
      "sq = 0\n",
      "Ipeak = 76\n",
      "#B=arange(A)\n",
      "Imean = (0.5*1E-3)*numpy.mean(A)*10/(5*1E-3)\n",
      "for h in range(10):\n",
      "    sq = sq + A[h]**2\n",
      "\n",
      "Irms = sqrt(sq/10)\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)Frequency  f  =  \",f,\"  Hz\\n\"\n",
      "print  \"\\n  (b)Instantaneous value of current after 1.25 ms  =\",Iinst125,\"A \"\n",
      "print   \"and Instantaneous value of current after 3.8 ms\", Iinst38,\"A\\n\"\n",
      "print  \"\\n  (c)Peak or maximum value  =  \",Ipeak,\"  A\\n\"\n",
      "print  \"\\n  (d)Mean or average value  =  \",round(Imean,2),\"A\\n\"\n",
      "print  \"\\n  (e)rms value =  \",round(Irms,1),\"A\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)Frequency  f  =   100.0   Hz\n",
        "\n",
        "\n",
        "  (b)Instantaneous value of current after 1.25 ms  = 19 A and Instantaneous value of current after 3.8 ms 70 A\n",
        "\n",
        "\n",
        "  (c)Peak or maximum value  =   76   A\n",
        "\n",
        "\n",
        "  (d)Mean or average value  =   35.1 A\n",
        "\n",
        "\n",
        "  (e)rms value =   43.8 A"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 6, page no. 200</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "Imax  =  20;#  in  Amperes\n",
      "\n",
      "#calculation:\n",
      "#for  a  sine  wave\n",
      "Irms  =  Imax/(2**0.5)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  Rms  value  =  \",round(Irms,2),\"  A\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  Rms  value  =   14.14   A"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 7, page no. 200</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "Vrms  =  240;#  in  Volts\n",
      "\n",
      "#calculation:\n",
      "#for  a  sine  wave\n",
      "Vmax  =  Vrms*(2**0.5)\n",
      "Vmean  =  0.637*Vmax\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  peak  value  =  \",round(Vmax,2),\"  V\\n\"\n",
      "print  \"\\n  mean  value  =  \",round(Vmean,2),\"  V\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  peak  value  =   339.41   V\n",
        "\n",
        "\n",
        "  mean  value  =   216.2   V"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8, page no. 200</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "Vmean  =  150;#  in  Volts\n",
      "\n",
      "#calculation:\n",
      "#for  a  sine  wave\n",
      "Vmax  =  Vmean/0.637\n",
      "Vrms  =  0.707*Vmax\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  peak  value  =  \",round(Vmax,2),\"  V\\n\"\n",
      "print  \"\\n  rms  value  =  \",round(Vrms,2),\"  V\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  peak  value  =   235.48   V\n",
        "\n",
        "\n",
        "  rms  value  =   166.48   V"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 9, page no. 201</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "Vmax  =  282.8;#  in  Volts\n",
      "w  =  314;#  in  rad/sec\n",
      "t  =  0.004;#  in  sec\n",
      "\n",
      "#calculation:\n",
      "#for  a  sine  wave\n",
      "Vrms  =  0.707*Vmax\n",
      "f  =  w/(2*math.pi)\n",
      "v  =  Vmax*math.sin(w*t)\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)rms  value  =  \",round(Vrms,2),\"  V\\n\"\n",
      "print  \"\\n  (b)frequency  f  =  \",round(f,2),\"  Hz\\n\"\n",
      "print  \"\\n  (c)instantaneous  value  of  voltage  at  4  ms  =  \",round(v,2),\"  V\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)rms  value  =   199.94   V\n",
        "\n",
        "\n",
        "  (b)frequency  f  =   49.97   Hz\n",
        "\n",
        "\n",
        "  (c)instantaneous  value  of  voltage  at  4  ms  =   268.9   V"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 10, page no. 202</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "Vmax  =  75;#  in  Volts\n",
      "w  =  200*math.pi;#  in  rad/sec\n",
      "t  =  0.004;#  in  sec\n",
      "phi  =  0.25;#  in  radians\n",
      "\n",
      "#calculation:\n",
      "#for  a  sine  wave\n",
      "Vptp  =  2*Vmax\n",
      "Vrms  =  0.707*Vmax\n",
      "f  =  w/(2*math.pi)\n",
      "T  =  1/f\n",
      "v  =  Vmax*math.sin(w*t)\n",
      "phid  =  phi*180/math.pi\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)  Amplitude,  or  peak  value  =  \",Vmax,\"  V\\n\"\n",
      "print  \"\\n  (b)  Peak-to-peak  value  =  \",Vptp,\"  V\\n\"\n",
      "print  \"\\n  (c)rms  value  =  \",Vrms,\"  V\\n\"\n",
      "print  \"\\n  (d)periodic  time,  T  =  \",T,\"  sec\\n\"\n",
      "print  \"\\n  (e)frequency  f  =  \",f,\"  Hz\\n\"\n",
      "print  \"\\n  (f)phase  angle  =  \",round(phid,2),\"deg lagging\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)  Amplitude,  or  peak  value  =   75   V\n",
        "\n",
        "\n",
        "  (b)  Peak-to-peak  value  =   150   V\n",
        "\n",
        "\n",
        "  (c)rms  value  =   53.025   V\n",
        "\n",
        "\n",
        "  (d)periodic  time,  T  =   0.01   sec\n",
        "\n",
        "\n",
        "  (e)frequency  f  =   100.0   Hz\n",
        "\n",
        "\n",
        "  (f)phase  angle  =   14.32 deg lagging\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 11, page no. 202</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "Vmax  =  40;#  in  Volts\n",
      "T  =  0.01;#  in  sec\n",
      "v  =  -20;#  when  t  =  0sec,  in  volts\n",
      "t  =  0;#  in  secs\n",
      "\n",
      "#calculation:\n",
      "#for  a  sine  wave\n",
      "w  =  2*math.pi/T\n",
      "phir  =  math.asin(v/Vmax)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n    instantaneous  voltage  v  =  \",  Vmax,\"  sin(\",round(w,2),\"t\",round(phir,2),\")  V\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "    instantaneous  voltage  v  =   40   sin( 628.32 t -0.52 )  V"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12, page no. 203</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "Imax  =  120;#  in  Amperes\n",
      "w  =  100*math.pi;#  in  rad/sec\n",
      "phi  =  0.36;#  in  rad\n",
      "t1  =  0;#  in  secs\n",
      "t2  =  0.008;#  in  secs\n",
      "i  =  60;#  in  amperes\n",
      "\n",
      "#calculation:\n",
      "#for  a  sine  wave\n",
      "f  =  w/(2*math.pi)\n",
      "T  =  1/f\n",
      "phid  =  phi*180/math.pi\n",
      "i0  =  Imax*math.sin((w*t1)+phi)\n",
      "i8  =  Imax*math.sin((w*t2)+phi)  \n",
      "ti  =  (math.asin(i/Imax)  -  phi)/w\n",
      "tm1  =  (math.asin(Imax/Imax)  -  phi)/w\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)Peak  value  =  \",  Imax,\"  A,  Periodic  time  T  =  \",  T,\"  sec, \"\n",
      "print   \" Frequency,  f  =  \",  f,\"  Hz  Phase  angle  =  \",round(phid,2),\"deg leading\\n\"\n",
      "print  \"\\n  (b)  When  t  =  0,  i  =  \",round(i0,2),\"  A\\n\"\n",
      "print  \"\\n  (c)When  t  =  8  ms  =  \",  round(i8,2),\"  A\\n\"\n",
      "print  \"\\n  (d)When  i  is  60  A,  then  time  t  =  \",round((ti/1E-3),2),\"  ms\\n\"\n",
      "print  \"\\n  (e)When  the  current  is  a  maximum,  time,  t  =  \",  round((tm1/1E-3),2),\"  ms\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)Peak  value  =   120   A,  Periodic  time  T  =   0.02   sec, \n",
        " Frequency,  f  =   50.0   Hz  Phase  angle  =   20.63 deg leading\n",
        "\n",
        "\n",
        "  (b)  When  t  =  0,  i  =   42.27   A\n",
        "\n",
        "\n",
        "  (c)When  t  =  8  ms  =   31.81   A\n",
        "\n",
        "\n",
        "  (d)When  i  is  60  A,  then  time  t  =   0.52   ms\n",
        "\n",
        "\n",
        "  (e)When  the  current  is  a  maximum,  time,  t  =   3.85   ms\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 13, page no. 204</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "i1max  =  20;#  in  Amperes\n",
      "i2max  =  10;#  in  Amperes\n",
      "phi1  =  0;#  in  rad\n",
      "phi2  =  math.pi/3;#  in  rad\n",
      "\n",
      "#calculation:\n",
      "#Ig = i1 + i2\n",
      "Igmax  = 26.5\n",
      "phiIg = 19*math.pi/180\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  Current  Ig = i1 + i2 =\", Igmax,\"sin(wt + \",round(phiIg,3),\") Amps\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  Current  Ig = i1 + i2 = 26.5 sin(wt +  0.332 ) Amps"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 14, page no. 205</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "V1max  =  50;#  in  volts\n",
      "V2max  =  100;#  in  volts\n",
      "phi2  =  -1*math.pi/6;#  in  rad\n",
      "\n",
      "#calculation:\n",
      "#vR2  =  v1**2  +  v2**2  -  2*v1*v2  cos  150\n",
      "phidiff  =  math.pi  +  phi2\n",
      "Vrmax  =  (V1max**2  +  V2max**2  -  2*V1max*V2max*math.cos(phidiff))**0.5\n",
      "#Using  the  sine  rule\n",
      "phi  =  math.asin(V2max*math.sin(phidiff)/Vrmax)\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  VR  =  \",round(Vrmax,2),\"sin(wt  -  \",round(phi,2),\")  V\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  VR  =   145.47 sin(wt  -   0.35 )  V"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 15, page no. 206</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "I1max  =  20;#  in  volts\n",
      "I2max  =  10;#  in  volts\n",
      "phi2  =  1*math.pi/3;#  in  rad\n",
      "\n",
      "#calculation:\n",
      "#iR2  =  i1**2  +  i2**2  -  2*i1*i2cos150\n",
      "phidiff  =  math.pi  -  phi2\n",
      "Irmax  =  (I1max**2  +  I2max**2  -  2*I1max*I2max*math.cos(phidiff))**0.5\n",
      "#Using  the  sine  rule\n",
      "phi  =  math.asin(I2max*math.sin(phidiff)/Irmax)\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  IR  =  \",  round(Irmax,2),\"sin(wt  +  \",round(phi,2),\")  V\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  IR  =   26.46 sin(wt  +   0.33 )  V"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}