{
 "metadata": {
  "name": "",
  "signature": "sha256:d23c488e06827cad82da0b4ae722d620d666ee7bafdcca01ad1272abc13ad886"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter1-Basic Circuit Concepts"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg1.9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##page no-1.9\n",
      "##example1.1\n",
      "print(\"Current through 15Ohm resistor is given by:\");\n",
      "print(\"I1=30/15\");\n",
      "I1=30/15\n",
      "print\"%s %.2f %s \"%(\"current through 15Ohm resistor = \",I1,\" Ampere\")\n",
      "print(\"Current through 5Ohm resistor is given by:\")\n",
      "print(\"I2=5+2\");\n",
      "I2=5+2\n",
      "print\"%s %.2f %s \"%(\"current through 5ohm resistor = \",I2,\" Ampere\")\n",
      "print(\"R=100-30-5*I2/I1\");\n",
      "R=(100-30-5*I2)/I1\n",
      "print\"%s %.2f %s \"%(\"R = \",R,\" Ohm\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current through 15Ohm resistor is given by:\n",
        "I1=30/15\n",
        "current through 15Ohm resistor =  2.00  Ampere \n",
        "Current through 5Ohm resistor is given by:\n",
        "I2=5+2\n",
        "current through 5ohm resistor =  7.00  Ampere \n",
        "R=100-30-5*I2/I1\n",
        "R =  17.00  Ohm \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg1.10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##page no-1.10\n",
      "##example1.2\n",
      "import math\n",
      "import numpy\n",
      "print(\"from the given fig:\")\n",
      "print(\"I2-I3=13\");\n",
      "print(\"-20*I1+8*I2=0\");\n",
      "print(\"-12*I1-16*I3=0\");\n",
      "##solving these equations in the matrix form\n",
      "A=numpy.matrix([[0, 1 ,-1],[-20, 8, 0],[-12 ,0 ,-16]])\n",
      "B=numpy.matrix([[13], [0] ,[0]])\n",
      "print(\"A=\")\n",
      "print[A]\n",
      "print(\"B=\")\n",
      "print[B]\n",
      "X=numpy.dot(numpy.linalg.inv(A),B)\n",
      "print(\"X=\")\n",
      "print[X]\n",
      "print(\"I1 = 4Ampere\")\n",
      "print(\"I2 = 10Ampere\")\n",
      "print(\"I3 = -3Ampere\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "from the given fig:\n",
        "I2-I3=13\n",
        "-20*I1+8*I2=0\n",
        "-12*I1-16*I3=0\n",
        "A=\n",
        "[matrix([[  0,   1,  -1],\n",
        "        [-20,   8,   0],\n",
        "        [-12,   0, -16]])]\n",
        "B=\n",
        "[matrix([[13],\n",
        "        [ 0],\n",
        "        [ 0]])]\n",
        "X=\n",
        "[matrix([[  4.],\n",
        "        [ 10.],\n",
        "        [ -3.]])]\n",
        "I1 = 4Ampere\n",
        "I2 = 10Ampere\n",
        "I3 = -3Ampere\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg1.11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##pg no-1.11\n",
      "##example 1.3\n",
      "print(\"Iaf=x\")\n",
      "print(\"Ife=x-30\")\n",
      "print(\"Ied=x+40\")\n",
      "print(\"Idc=x-80\")\n",
      "print(\"Icb=x-20\")\n",
      "print(\"Iba=x-80\")\n",
      "print(\"Applying KVL to the closed path AFEDCBA:\")##Applying KVL to the path AFEDCBA\n",
      "print(\"x=4.1/0.1\")\n",
      "x=4.1/0.1;\n",
      "Iaf=x;\n",
      "print\"%s %.2f %s \"%(\"\\nIaf = \",Iaf,\" Ampere\");\n",
      "Ife=x-30.\n",
      "print\"%s %.2f %s \"%(\"\\nIfe = \",Ife,\" Ampere\");\n",
      "Ied=x+40.;\n",
      "print\"%s %.2f %s \"%(\"\\nIed = \",Ied,\" Ampere\");\n",
      "Idc=x-80;\n",
      "print\"%s %.2f %s \"%(\"\\nIdc = \",Idc,\" Ampere\");\n",
      "Icb=x-20.;\n",
      "print\"%s %.2f %s \"%(\"\\nIcb = \",Icb,\" Ampere\");\n",
      "Iba=x-80.;\n",
      "print\"%s %.2f %s \"%(\"\\nIba = \",Iba,\" Ampere\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Iaf=x\n",
        "Ife=x-30\n",
        "Ied=x+40\n",
        "Idc=x-80\n",
        "Icb=x-20\n",
        "Iba=x-80\n",
        "Applying KVL to the closed path AFEDCBA:\n",
        "x=4.1/0.1\n",
        "\n",
        "Iaf =  41.00  Ampere \n",
        "\n",
        "Ife =  11.00  Ampere \n",
        "\n",
        "Ied =  81.00  Ampere \n",
        "\n",
        "Idc =  -39.00  Ampere \n",
        "\n",
        "Icb =  21.00  Ampere \n",
        "\n",
        "Iba =  -39.00  Ampere \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg1.12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##pg no- 1.12\n",
      "##example 1.4\n",
      "import math\n",
      "import numpy\n",
      "print(\"Applying KVL to the closed path OBAO\");##Applying KVL to the closed path OBAO\n",
      "print(\"3*x-3*y=2\");\n",
      "print(\"Applying KVL to the closed path ABCA\");##Applying KVL to the closed path ABCA\n",
      "print(\"9*x+12*y=4\");\n",
      "a=numpy.matrix([[3, -3],[9, 12]]);\n",
      "b=([[2] ,[4]])\n",
      "print(\"a=\")\n",
      "print[a]\n",
      "print(\"b=\")\n",
      "print[b]\n",
      "X=numpy.dot(numpy.linalg.inv(a),b)\n",
      "\n",
      "print(X)\n",
      "print(\"x=0.5714286 Ampere\");\n",
      "print(\"y=-0.095238 Ampere\");\n",
      "print(\"Ioa=0.57A\")\n",
      "print(\"Iob=1-0.57\")\n",
      "Iob=1-0.57;\n",
      "print\"%s %.2f %s \"%(\"\\nIob = \",Iob,\" A\");\n",
      "print(\"Iab = 0.095\");\n",
      "Iac=0.57-0.095;\n",
      "print\"%s %.2f %s \"%(\"\\nIac =\",Iac,\" A\");\n",
      "print(\"Iab=1-0.57 + 0.095\")\n",
      "Iab=1-0.57 + 0.095;\n",
      "print\"%s %.2f %s \"%(\"\\nIob = \",Iab,\" A\") "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Applying KVL to the closed path OBAO\n",
        "3*x-3*y=2\n",
        "Applying KVL to the closed path ABCA\n",
        "9*x+12*y=4\n",
        "a=\n",
        "[matrix([[ 3, -3],\n",
        "        [ 9, 12]])]\n",
        "b=\n",
        "[[[2], [4]]]\n",
        "[[ 0.57142857]\n",
        " [-0.0952381 ]]\n",
        "x=0.5714286 Ampere\n",
        "y=-0.095238 Ampere\n",
        "Ioa=0.57A\n",
        "Iob=1-0.57\n",
        "\n",
        "Iob =  0.43  A \n",
        "Iab = 0.095\n",
        "\n",
        "Iac = 0.47  A \n",
        "Iab=1-0.57 + 0.095\n",
        "\n",
        "Iob =  0.53  A \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg1.12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##pg no-1.12\n",
      "##example 1.5\n",
      "I1=2./5.;\n",
      "print\"%s %.2f %s \"%(\"I1=2/5= \",I1,\" Ampere\")\n",
      "I2=4./8.;\n",
      "print\"%s %.2f %s \"%(\"\\nI2=4/8= \",I2,\" Ampere\")\n",
      "print(\"\\nPotential difference between points x and y = Vxy = Vx-Vy\")\n",
      "print(\"\\nWriting KVL equations for the path x to y\")##Writing KVL equation from x to y\n",
      "print(\"\\nVs+3*I1+4-3*I2-Vy=0\")\n",
      "print(\"\\nVs+3*(0.4) + 4- 3*(0.5) -Vy = 0\")\n",
      "print(\"\\nVs+3*I1+4-3*I2-Vy = 0\")\n",
      "print(\"\\nVx-Vy = -3.7\")\n",
      "print(\"\\nVxy = -3.7V\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I1=2/5=  0.40  Ampere \n",
        "\n",
        "I2=4/8=  0.50  Ampere \n",
        "\n",
        "Potential difference between points x and y = Vxy = Vx-Vy\n",
        "\n",
        "Writing KVL equations for the path x to y\n",
        "\n",
        "Vs+3*I1+4-3*I2-Vy=0\n",
        "\n",
        "Vs+3*(0.4) + 4- 3*(0.5) -Vy = 0\n",
        "\n",
        "Vs+3*I1+4-3*I2-Vy = 0\n",
        "\n",
        "Vx-Vy = -3.7\n",
        "\n",
        "Vxy = -3.7V\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg1.13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##pg no-1.13\n",
      "##example 1.6\n",
      "import math\n",
      "#calculate the \n",
      "I1=20/15.;\n",
      "print'%s %.2f %s'%(\"I1=2/5= \",I1,\" Ampere\")\n",
      "I2=15./10.;\n",
      "print'%s %.2f %s'%(\"\\nI2=4/8= \",I2,\" Ampere\")\n",
      "print(\"Voltage between points A and B = VAB = VA-VB\");\n",
      "print(\"Writing KVL equations for the path A to B:\");##Writing KVL equations for the path A to B\n",
      "print(\"VA - 5*I1 - 5 - 15 + 6*I2 - VB = 0\");\n",
      "print(\"VA - VB = 5*1.33 + 5 + 15 + 6*1.5\");\n",
      "VAB=(5*1.33)+5.+15.-(6*1.5);\n",
      "print'%s %.2f %s'%(\"VAB = \",VAB,\" Volt\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I1=2/5=  1.33  Ampere\n",
        "\n",
        "I2=4/8=  1.50  Ampere\n",
        "Voltage between points A and B = VAB = VA-VB\n",
        "Writing KVL equations for the path A to B:\n",
        "VA - 5*I1 - 5 - 15 + 6*I2 - VB = 0\n",
        "VA - VB = 5*1.33 + 5 + 15 + 6*1.5\n",
        "VAB =  17.65  Volt\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg1.13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##page no-1.13\n",
      "##example1.7\n",
      "import math\n",
      "#calculate the \n",
      "I1=5./2.;\n",
      "print'%s %.2f %s'%(\"I1=2/5= \",I1,\" Ampere\")\n",
      "I2=2.;\n",
      "print'%s %.2f %s'%(\"\\nI2=4/8= \",I2,\" Ampere\")\n",
      "print(\"Potential difference VAB = VA - VB\");\n",
      "print(\"Writing KVL equations for path A to B\")  ##Writing KVL equations for path A to B\n",
      "print(\"VA - 2*I1 + 8 - 5*I2 - VB = 0\");\n",
      "print(\"VA - VB = (2*2.5) - 8 5 + (5*2)\");\n",
      "VAB=(2.*2.5)-8.+(5.*2.)\n",
      "print'%s %.2f %s'%(\"VAB = \",VAB,\" Volt\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I1=2/5=  2.50  Ampere\n",
        "\n",
        "I2=4/8=  2.00  Ampere\n",
        "Potential difference VAB = VA - VB\n",
        "Writing KVL equations for path A to B\n",
        "VA - 2*I1 + 8 - 5*I2 - VB = 0\n",
        "VA - VB = (2*2.5) - 8 5 + (5*2)\n",
        "VAB =  7.00  Volt\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex8-pg1.14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##page no-1.14\n",
      "##example1.8\n",
      "import math\n",
      "#calculate the \n",
      "I1=10./8.;\n",
      "print'%s %.2f %s'%(\"I1=2/5= \",I1,\" Ampere\")\n",
      "I2=5.;\n",
      "print'%s %.2f %s'%(\"\\nI2=4/8= \",I2,\" Ampere\")\n",
      "print(\"Applying KVL to the path from A to B\")  ##Applying KVL to the path from A to B\n",
      "print(\"VA - 3*I1 - 8 + 3*I2 - VB = 0\");\n",
      "print(\"VA - VB = 3*1.25 + 8 - 3*5\")\n",
      "VAB= (3*1.25)+8.-(3.*5.);\n",
      "print'%s %.2f %s'%(\"VAB = \",VAB,\" Volt\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I1=2/5=  1.25  Ampere\n",
        "\n",
        "I2=4/8=  5.00  Ampere\n",
        "Applying KVL to the path from A to B\n",
        "VA - 3*I1 - 8 + 3*I2 - VB = 0\n",
        "VA - VB = 3*1.25 + 8 - 3*5\n",
        "VAB =  -3.25  Volt\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.12-pg1.17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##page no-1.17\n",
      "##example1.12\n",
      "print(\"Applying KVL to the circuit :\");\n",
      "print(\"50 - 5*I - 1.2*I - 16 = 0\")\n",
      "I=(50.-16.)/6.2;\n",
      "print'%s %.2f %s'%(\"I= \",I,\" Amp\");\n",
      "P=50.*I;\n",
      "print'%s %.2f %s'%(\"\\nPower delivered 50 V source = 50 * 5.48= \",P,\" W\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Applying KVL to the circuit :\n",
        "50 - 5*I - 1.2*I - 16 = 0\n",
        "I=  5.48  Amp\n",
        "\n",
        "Power delivered 50 V source = 50 * 5.48=  274.19  W\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.13-pg1.18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##page no-1.18\n",
      "##example1.13\n",
      "print(\"By Current Division formula ;\");\n",
      "I4=4.*(2./(2.+4.));\n",
      "print'%s %.2f %s'%(\"I4 = 4 * (2/(2+4)) = \",I4,\" Amp\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "By Current Division formula ;\n",
        "I4 = 4 * (2/(2+4)) =  1.33  Amp\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.14-pg1.19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##page no-1.19\n",
      "##example1.14\n",
      "print(\"Applying KVL to the mesh\");\n",
      "print(\"15 - 50*I - 50*I - 5*I\");\n",
      "I=15./105.;\n",
      "print'%s %.2f %s'%(\"I=15/105 = \",I,\" Amp\");\n",
      "V=15-(50*0.143);\n",
      "print'%s %.2f %s'%(\"\\nVoltage at node 2 = 15 - 50*I = \",V,\" Volt\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Applying KVL to the mesh\n",
        "15 - 50*I - 50*I - 5*I\n",
        "I=15/105 =  0.14  Amp\n",
        "\n",
        "Voltage at node 2 = 15 - 50*I =  7.85  Volt\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1.15-pg1.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Basic Circuit Concepts\n",
      "##pg no.-1.20\n",
      "##example 1.15\n",
      "r1=3.;\n",
      "r2=2.33;\n",
      "r3=6.;\n",
      "v1=18.;\n",
      "v2=5.985;\n",
      "print(\"\\nApplying KCL at the node, \\n(Va-18)/3+(Va-5.985)/2.33+Va/6 = 0\");\n",
      "Va=((v1*r2*r3)+(v2*r1*r3))/((r2*r3)+(r1*r3)+(r1*r2));\n",
      "print'%s %.2f %s'%(\"\\nSolving the equation,we get, \\nVa = \",Va,\" V\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Applying KCL at the node, \n",
        "(Va-18)/3+(Va-5.985)/2.33+Va/6 = 0\n",
        "\n",
        "Solving the equation,we get, \n",
        "Va =  9.22  V\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}