{
 "metadata": {
  "name": "",
  "signature": "sha256:cd92732b89aba9dec0c4f42de79fa75bac0a4c551a65b1e08ee3d7196bca88ee"
 },
 "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-pg9"
     ]
    },
    {
     "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-pg10"
     ]
    },
    {
     "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-pg11"
     ]
    },
    {
     "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-pg12"
     ]
    },
    {
     "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": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg12"
     ]
    },
    {
     "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
    }
   ],
   "metadata": {}
  }
 ]
}