{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6 : A.C. Bridges"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.1\n",
      " : Page No - 6.4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from cmath import rect\n",
      "#Given data\n",
      "Z1 = 50 # in ohm\n",
      "Z2 = 250 # in ohm\n",
      "Z3 = 200 # in ohm\n",
      "theta1 = 80 # in degree\n",
      "theta2 = 0 # in degree\n",
      "theta3 = 30 # in degree\n",
      "#bridge balance equation, Z1*Z4 = Z2*Z3 \n",
      "Z4 = (Z2*Z3)/Z1 # in ohm\n",
      "#phase angle condition, theta1+theta4 = theta2+theta3 \n",
      "theta4 = theta2+theta3-theta1 # in degree\n",
      "theta4= theta4*pi/180 # in radian\n",
      "Z4= rect(Z4,theta4) \n",
      "print \"The resistance part of Z4 = %0.2f \u03a9\" %Z4.real\n",
      "print \"while it is in series with capacitive reactance of\",abs(round(Z4.imag,1)),\"\u03a9\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance part of Z4 = 642.79 \u03a9\n",
        "while it is in series with capacitive reactance of 766.0 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.2\n",
      " : Page No - 6.4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Z1 = 50 # in ohm\n",
      "Z2 = 100 # in ohm\n",
      "Z3 = 15 # in ohm\n",
      "Z4 = 30 # in ohm\n",
      "theta1 = 40 # in degree\n",
      "theta2 = -90 # in degree\n",
      "theta3 = 45 # in degree\n",
      "theta4 = 30 # in degree\n",
      "if abs(Z1*Z4)== abs(Z3*Z2) :\n",
      "    flag1=1 \n",
      "    print \"The condition of balance for magnitude is satisfied\"\n",
      "else :\n",
      "    flag1=0\n",
      "    print \"The condition of balance for magnitude is not satisfied\"\n",
      "if theta1+theta4 == theta2+theta3 :\n",
      "    flag2=1\n",
      "    print \"The condition of balance for phase is also satisfied\"\n",
      "else :\n",
      "    flag2=0\n",
      "    print \"But the condition of balance for phase is not satisfied\"\n",
      "\n",
      "if flag1==1 :\n",
      "    if flag2==1 :\n",
      "        print \"Hence the bridge is under balanced condition\" \n",
      "    else :\n",
      "        print \"Hence the bridge is not under balanced condition\"\n",
      "else :\n",
      "        print \"Hence the bridge is not under balanced condition\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The condition of balance for magnitude is satisfied\n",
        "But the condition of balance for phase is not satisfied\n",
        "Hence the bridge is not under balanced condition\n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.3\n",
      " : Page No - 6.6"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C3 = 10 # in \u00b5F\n",
      "C3 = C3*10**-6 # in F\n",
      "R1 = 1.2 # in k ohm\n",
      "R1 = R1 * 10**3 # in ohm\n",
      "R2 = 100 # in k ohm\n",
      "R2 = R2 * 10**3 # in ohm\n",
      "R3 = 120 # in k ohm\n",
      "R3 = R3 * 10**3 # in ohm\n",
      "Rx = (R2*R3)/R1 #unknown resistance in ohm\n",
      "Rx = Rx * 10**-6 # in M ohm\n",
      "print \"The value of Rx = %0.f M\u03a9 \" %Rx\n",
      "Cx = (R1*C3)/R2 # in F\n",
      "Cx = Cx * 10**6 #unknown capacitance in \u00b5F\n",
      "print \"The value of Cx = %0.2f \u00b5F \" %Cx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Rx = 10 M\u03a9 \n",
        "The value of Cx = 0.12 \u00b5F \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.4\n",
      " : Page No - 6.8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "L3 = 8 # in mH\n",
      "L3 = L3 * 10**-3 # in H\n",
      "R1 = 1 # in k ohm\n",
      "R1 = R1 * 10**3 # in ohm\n",
      "R2 = 25 # in k ohm\n",
      "R2 = R2 * 10**3 # in ohm\n",
      "R3 = 50 # in  k ohm\n",
      "R3 = R3 * 10**3 # in ohm\n",
      "Rx = (R2*R3)/R1 #unknown resistance in ohm\n",
      "Rx = Rx * 10**-6 # in M ohm\n",
      "print \"The value of Rx = %0.2f M\u03a9 \" %Rx\n",
      "Lx = (R2*L3)/R1 #unknown inductance in H\n",
      "Lx = Lx * 10**3 # in mH\n",
      "print \"The value of Lx = %0.f mH \" %Lx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Rx = 1.25 M\u03a9 \n",
        "The value of Lx = 200 mH \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.5\n",
      " : Page No - 6.13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C1 = 0.5 # in \u00b5F\n",
      "C1 = C1 * 10**-6 # in \u00b5F\n",
      "R1 = 1200 # in ohm\n",
      "R2 = 700 # in ohm\n",
      "R3 = 300 # in ohm\n",
      "# From bridge balance equation\n",
      "Rx = (R2*R3)/R1 # in ohm\n",
      "print \"Component of the brach BC :\"\n",
      "print \"Rx = \",int(Rx),\"\u03a9\"\n",
      "Lx = R2*R3*C1 # in H\n",
      "Lx = Lx * 10**3 # in mH\n",
      "print \"Lx = \",int(Lx),\"mH\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Component of the brach BC :\n",
        "Rx =  175 \u03a9\n",
        "Lx =  105 mH\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.6\n",
      " : Page No - 6.16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R2 = 1000 #resistance in ohm\n",
      "R3 = 500 # resistance in ohm\n",
      "R4 = 1000 # resistance in ohm\n",
      "C = 3 #capacitance in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "r = 100 # in ohm\n",
      "Rx = (R2*R3)/R4 #value of Rx in ohm\n",
      "print \"The value of Rx = %0.f \u03a9 \" %Rx\n",
      "Lx = ((C*R2)/R4)*( (R3*r) + (R4*r) + (R3*R4) ) #value of Lx in H\n",
      "print \"The value of Lx = %0.2f H \" %Lx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Rx = 500 \u03a9 \n",
        "The value of Lx = 1.95 H \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.7\n",
      " : Page No - 6.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 5.1 # in k ohm\n",
      "R1 = R1 * 10**3 # in ohm\n",
      "R2 = 7.9 # in k ohm\n",
      "R2 = R2 * 10**3 # in ohm\n",
      "R3 = 790 # in ohm\n",
      "C1 = 2 # in \u00b5F\n",
      "C1 = C1 * 10**-6 # in F\n",
      "omega = 1000 # in rad/sec\n",
      "Rx = (((omega)**2)*R1*((C1)**2)*R2*R3)/( 1+(((omega)**2) * ((R1)**2)* ((C1)**2)) ) # unknown resistance in ohm\n",
      "Rx = Rx * 10**-3 # in k ohm\n",
      "print \"The value of unknown resistance = %0.3f k\u03a9 \" %Rx\n",
      "Lx = (R2*R3*C1)/( 1+(((omega)**2) * ((R1)**2)* ((C1)**2)) ) # unknown inductance in H\n",
      "Lx = Lx * 10**3 # in mH\n",
      "print \"The value of unknown inductance = %0.2f mH \" %Lx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of unknown resistance = 1.212 k\u03a9 \n",
        "The value of unknown inductance = 118.83 mH \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.8\n",
      " : Page No - 6.24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi\n",
      "#Given data\n",
      "R1 = 1.2 # in k ohm\n",
      "R1 = R1 * 10**3 # in ohm\n",
      "R2 = 4.7 # in k ohm\n",
      "R2 = R2 * 10**3 # in ohm\n",
      "C1 = 1 # in \u00b5F\n",
      "C1 = C1 * 10**-6 # in F\n",
      "C3 = 1 # in \u00b5F\n",
      "C3 = C3 * 10**-6 # in F\n",
      "Rx = (R2*C1)/C3 # unknown resistance in ohm\n",
      "Rx = Rx * 10**-3 # in k ohm\n",
      "Cx = (R1*C3)/R2 # unknown capacitance in F\n",
      "Cx = Cx * 10**6 # in \u00b5F\n",
      "print \"The unknown resistance = %0.1f k\u03a9 is \" %Rx\n",
      "print \"The unknown capacitance = %0.3f \u00b5F \" %Cx\n",
      "f = 0.5 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "# omega = 2*pi*f \n",
      "D = 2*pi*f*Cx*10**-6*Rx*10**3 # dissipation factor \n",
      "print \"The dissipation factor = %0.3f \" %D"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The unknown resistance = 4.7 k\u03a9 is \n",
        "The unknown capacitance = 0.255 \u00b5F \n",
        "The dissipation factor = 3.770 \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.9\n",
      " : Page No - 6.28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1 = 2.7 # in k ohm\n",
      "R1 = R1 * 10**3 # in ohm\n",
      "R2 = 22 # in k ohm\n",
      "R2 = R2 * 10**3 # in ohm\n",
      "R4 = 100 # in k ohm\n",
      "R4 = R4 * 10**3 # in ohm\n",
      "C1 = 5 # in \u00b5F\n",
      "C1 = C1 * 10**-6 # in F\n",
      "f = 2.2 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "#From omega**2 = 1/(R1*C1*R3*C3) \n",
      "# C3 = 1/(R1*C1*R3*(omega**2))            (i)\n",
      "# R2/R4 = R1/R3 + C3/C1                   (ii)\n",
      "# From eq(i) and (ii)\n",
      "R3 = R4*(R1+1/((2*pi*f)**2*R1*C1**2))/R2 # equivalent parallel resistance in ohm\n",
      "R3= R3*10**-3 # in k ohm\n",
      "print \"The equivalent parallel resistance = %0.3f k\u03a9 \" %R3\n",
      "R3= R3*10**3 # in ohm\n",
      "C3 = 1/(R1*C1*R3*((2*pi*f)**2)) # equivalent parallel capacitance in F\n",
      "C3 = C3 * 10**12 # in pF\n",
      "print \"The equivalent parallel capacitance = %0.2f pF \" %C3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equivalent parallel resistance = 12.273 k\u03a9 \n",
        "The equivalent parallel capacitance = 31.59 pF \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.10\n",
      " : Page No - 6.47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#Given data\n",
      "C1 = 550 # in pF\n",
      "C2 = 110 # in pF\n",
      "Cd = (C1-(4*C2))/3 # distributed capacitance in pF\n",
      "print \"The distributed capacitance = %0.2f pF \" %Cd\n",
      "Cd = Cd * 10**-12 # in F\n",
      "C1 = C1 * 10**-12 # in F\n",
      "f1 = 1.5 # in MHz\n",
      "f1 = f1 * 10**6 # in Hz\n",
      "# f1 = 1/(2*pi*(sqrt( L*(C1+Cd)))) \n",
      "L = ((1/(2*pi*f1))**2) * (1/(C1+Cd)) # distributed inductance in H\n",
      "L = L * 10**6 # in \u00b5H\n",
      "print \"The distributed inductance = %0.2f \u00b5H \" %L"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The distributed capacitance = 36.67 pF \n",
        "The distributed inductance = 19.19 \u00b5H \n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.11\n",
      " : Page No - 6.48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1.5 #frequency in MHz\n",
      "f = f * 10**6 # in Hz\n",
      "C = 60 # in pF\n",
      "C = C * 10**-12 # in F\n",
      "R = 8 # in ohm\n",
      "R_SH = 0.02 # in ohm\n",
      "omega = 2*pi*f \n",
      "Qactual = 1/(omega*C*R) # true value of Q\n",
      "Qobserved = 1/(omega*C*(R+R_SH)) # observed value of Q\n",
      "PerError = ((Qactual-Qobserved)/Qactual) * 100 # Percentage error in %\n",
      "print \"The Percentage error = %0.2f %% \" %PerError"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Percentage error = 0.25 % \n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.12\n",
      " : Page No - 6.49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f1 = 2 #frequency in MHz\n",
      "f1 = f1 * 10**6 # in Hz\n",
      "C1 = 500 # in pF\n",
      "C2 = 60 # in pF\n",
      "# f1 = 1/(2*pi*sqrrt(L*(C1+Cd)))  (i)\n",
      "# f2 = 1/(2*pi*sqrrt(L*(C2+Cd)))  (ii)\n",
      "# and f2 = 2.5*f1      (iii)\n",
      "#From eq(i),(ii) and (iii)\n",
      "Cd = (C1 - (6.25*C2))/5.25 # value of self capacitance in pF\n",
      "print \"The value of self capacitance = %0.2f pF \" %Cd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of self capacitance = 23.81 pF \n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.13\n",
      " : Page No - 6.50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1 # in MHz\n",
      "f = f * 10**6 # in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "C = 65 # in pF\n",
      "C = C * 10**-12 # in F\n",
      "R = 10 # in ohm\n",
      "R_SH = 0.02 # in ohm\n",
      "# Q = X_L/R = X_C/R = 1/(omega*C*R) \n",
      "Qactual = 1/(omega*C*R) # True value of Q\n",
      "Qmeasured = 1/(omega*C*(R+R_SH)) # measured value of Q\n",
      "PerError = ((Qactual-Qmeasured)/Qactual)*100 #percentage error in %\n",
      "print  \"The Percentage error = %0.1f %% \" %PerError"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Percentage error = 0.2 % \n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.14\n",
      " : Page No - 6.51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C1 = 450 #capacitance in pF\n",
      "C1 = C1 * 10**-12 # in F\n",
      "C2 = 60 #capacitance in pF\n",
      "C2 = C2 * 10**-12 # in F\n",
      "# f1 = 1/(2*pi*(sqrt(L*(C1+Cd))))     (i)\n",
      "# f2 = 1/(2*pi*(sqrt(L*(C2+Cd))))     (ii)\n",
      "# and f2 = 2.5*f1      (iii)\n",
      "# from eq(i),(ii) and (iii)\n",
      "Cd = (C1 - (6.25*C2))/5.25 # value of self capacitance in F\n",
      "Cd = Cd * 10**12 # in pF\n",
      "print \"The value of self capacitance = %0.2f pF \" %Cd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of self capacitance = 14.29 pF \n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.15\n",
      " : Page No - 6.52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#Given data\n",
      "f1 = 8 #frequency in MHz\n",
      "f1= f1*10**6 # in Hz\n",
      "f2 = 12 #frequency in MHz\n",
      "f2= f2*10**6 # in Hz\n",
      "C1 = 120 #capacitance in pF\n",
      "C1 = C1 * 10**-12 # in F\n",
      "C2 = 40 #capacitance in pF\n",
      "C2 = C2 * 10**-12 # in F\n",
      "# f1 = 1/(2*pi*(sqrt(L*(C1+Cd))))     (i)\n",
      "# f2 = 1/(2*pi*(sqrt(L*(C2+Cd))))     (ii)\n",
      "# From eq(i) and (ii)\n",
      "Cd= (f2**2*C2-f1**2*C1)/(f1**2-f2**2) # in F\n",
      "# From eq(i)\n",
      "C=C1+Cd \n",
      "L=1/((C1+Cd)*(2*pi*f1)**2) # inductance in H\n",
      "L= L*10**6 # in \u00b5H\n",
      "Cd= Cd*10**12 # self capacitance in pF\n",
      "print \"The self capacitance = %0.1f pF \" %Cd\n",
      "print \"The inductance = %0.3f \u00b5H \" %L"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The self capacitance = 24.0 pF \n",
        "The inductance = 2.749 \u00b5H \n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.16\n",
      " : Page No - 6.53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f1 = 1 #frequency in MHz\n",
      "f1= f1*10**6 # in Hz\n",
      "f2 = 2 #frequency in MHz\n",
      "f2= f2*10**6 # in Hz\n",
      "C1 = 500 #capacitance in pF\n",
      "C1 = C1 * 10**-12 # in F\n",
      "C2 = 110 #capacitance in pF\n",
      "C2 = C2 * 10**-12 # in F\n",
      "# f1 = 1/(2*pi*(sqrt(L*(C1+Cd))))     (i)\n",
      "# f2 = 1/(2*pi*(sqrt(L*(C2+Cd))))     (ii)\n",
      "# From eq(i) and (ii)\n",
      "Cd= (f2**2*C2-f1**2*C1)/(f1**2-f2**2) # in F\n",
      "# From eq(i)\n",
      "C=C1+Cd \n",
      "L=1/((C1+Cd)*(2*pi*f1)**2) # in H\n",
      "L= L*10**6 #inductance in \u00b5H\n",
      "Cd= Cd*10**12 # self capacitance in pF\n",
      "print \"The self capacitance = %0.f pF \" %Cd\n",
      "print \"The inductance = %0.2f \u00b5H \" %L"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The self capacitance = 20 pF \n",
        "The inductance = 48.71 \u00b5H \n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.17\n",
      " : Page No - 6.54"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1 #frequency in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "R1 = 400 #resistance in ohm\n",
      "R2 = 150 #resistance in ohm\n",
      "C2 = 0.2 #capacitance in \u00b5F\n",
      "C2 = C2 * 10**-6 # in F\n",
      "XC2= 1/(2*pi*f*C2) \n",
      "R3 = 100 #resistance in ohm\n",
      "L3 = 10 #inductance in mH\n",
      "L3 = L3 * 10**-3 # in H\n",
      "XL3= 2*pi*f*L3 \n",
      "Z1= complex(R1,0) # in \u03a9\n",
      "Z2= R2-1j*XC2 # in \u03a9\n",
      "Z3= R3+1j*XL3 # in \u03a9\n",
      "Z4= Z2*Z3/Z1 # in \u03a9\n",
      "R4= Z4.real#resistance in \u03a9\n",
      "XC4= abs(Z4.imag) # in \u03a9\n",
      "C4= 1/(2*pi*f*XC4) # in F\n",
      "C4= C4*10**6 # in \u00b5F\n",
      "print \"The components of branch CD : \"\n",
      "print \"R4 = \",round(R4,1),\" \u03a9\" \n",
      "print \"C4 = \",round(C4,4),\" \u00b5F\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The components of branch CD : \n",
        "R4 =  162.5  \u03a9\n",
        "C4 =  0.9075  \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 57
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.18\n",
      " : Page No - 6.55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C3 = 10 #capacitance in \u00b5F\n",
      "C3 = C3 * 10**-6 # in F\n",
      "R1 = 1.2 #resistance in  k ohm\n",
      "R1 = R1 * 10**3 # in ohm\n",
      "R2 = 100 #resistance in k ohm\n",
      "R2 = R2 * 10**3 # in ohm\n",
      "R3 = 120 #resistance in k ohm\n",
      "R3 = R3 * 10**3 # in ohm\n",
      "Rx = (R2*R3)/R1 #resistance of unknown impedance  in ohm\n",
      "Rx = Rx * 10**-6 # in M ohm\n",
      "print \"The resistance of unknown impedance = %0.f M\u03a9 \" %Rx\n",
      "Cx = (R1*C3)/R2 #capacitance of unknown impedance  in F\n",
      "Cx = Cx * 10**6 # in \u00b5F\n",
      "print \"The capacitance of unknown impedance = %0.2f \u00b5F \" %Cx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance of unknown impedance = 10 M\u03a9 \n",
        "The capacitance of unknown impedance = 0.12 \u00b5F \n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.19\n",
      " : Page No - 6.56"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1000 #frequency in Hz\n",
      "C1 = 0.2 #capacitance in \u00b5F\n",
      "C1 = C1 * 10**-6 # in F\n",
      "XC1= 1/(2*pi*f*C1) \n",
      "R2= 500 # in \u03a9\n",
      "R3= 300 # in \u03a9\n",
      "C3= 0.1*10**-6 # in F\n",
      "XC3= 1/(2*pi*f*C3) \n",
      "omega = 2*pi*f # in rad/sec\n",
      "Z1= 0-1j*XC1 # in \u03a9\n",
      "Z2= R2 # in \u03a9\n",
      "Y3= 1/R3+1j*1/XC3 # in \u03a9\n",
      "Z3= R3*XC3/(R3+XC3) # in \u03a9\n",
      "Z4= Z2/(Z1*Y3) # in \u03a9\n",
      "R4= Z4.real # in \u03a9\n",
      "XL4= abs(Z4.imag) # in \u03a9\n",
      "L4= XL4/(2*pi*f) # in F\n",
      "L4= L4*10**3 # in mH\n",
      "print \"The components of branch CD : \"\n",
      "print \"Rx = \",round(R4,2),\"\u03a9\"\n",
      "print \"Lx = %0.f mH\" %L4 "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The components of branch CD : \n",
        "Rx =  34.31 \u03a9\n",
        "Lx = 29 mH\n"
       ]
      }
     ],
     "prompt_number": 61
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.20\n",
      " : Page No - 6.57"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 2 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "Z1 = 10 # in k ohm\n",
      "Z2 = 50 # in k ohm\n",
      "R3 = 100 # in k ohm\n",
      "C3 = 100 # in \u00b5F\n",
      "C3 = C3 * 10**-6 # in F\n",
      "XC3= 1/(2*pi*f*C3) \n",
      "Z3= R3-1j*XC3 # in \u03a9\n",
      "# From balance equation, Z1*Z4= Z2*Z3\n",
      "Z4= Z2*Z3/Z1 # in \u03a9\n",
      "R4= Z4.real # in k\u03a9\n",
      "XC4= abs(Z4.imag) # in k\u03a9\n",
      "C4= 1/(2*pi*f*XC4) # in F\n",
      "C4= C4*10**6 # in \u00b5F\n",
      "print \"The components of branch DC : \"\n",
      "print \"Rx= %0.f k\u03a9\" %R4\n",
      "print \"Cx= %0.f \u00b5F\" %C4"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The components of branch DC : \n",
        "Rx= 500 k\u03a9\n",
        "Cx= 20 \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 62
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.21\n",
      " : Page No - 6.59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "Z1 = 200 # in ohm\n",
      "R2 = 200 # in ohm\n",
      "C2 = 5 # in \u00b5F\n",
      "C2 = C2 * 10**-6 # in F\n",
      "XC2= 1/(2*pi*f*C2) \n",
      "Z2= R2-1j*XC2 # in \u03a9\n",
      "R3 = 500 # in ohm\n",
      "C3 = 0.2 # in \u00b5F\n",
      "C3 = C3 * 10**-6 # in F\n",
      "XC3= 1/(2*pi*f*C3) \n",
      "Z3= R3-1j*XC3 # in \u03a9\n",
      "# From balance equation, Z1*Z4= Z2*Z3\n",
      "Z4= Z2*Z3/Z1 # in \u03a9\n",
      "R4= Z4.real# in \u03a9\n",
      "XC4= abs(Z4.imag) # in \u03a9\n",
      "C4= 1/(2*pi*f*XC4) # in F\n",
      "C4= C4*10**9 # in nF\n",
      "print \"The components of Zx : \"\n",
      "print \"Rx = \",round(R4,3),\"\u03a9\" \n",
      "print \"Cx = \",round(C4,3),\"nF\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The components of Zx : \n",
        "Rx =  373.349 \u03a9\n",
        "Cx =  181.818 nF\n"
       ]
      }
     ],
     "prompt_number": 67
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.22\n",
      " : Page No - 6.60"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "Z1 = 1.65 # in k ohm\n",
      "Z2 = 15.3 # in k ohm\n",
      "R3 = 2.5 # in k ohm\n",
      "C3 = 10 # in \u00b5F\n",
      "C3 = C3 * 10**-6 # in F\n",
      "XC3= 1/(2*pi*f*C3) \n",
      "Z3= R3-1j*XC3 # in \u03a9\n",
      "# From balance equation, Z1*Z4= Z2*Z3\n",
      "Z4= Z2*Z3/Z1 # in \u03a9\n",
      "R4= Z4.real # in k\u03a9\n",
      "XC4= abs(Z4.imag) # in k\u03a9\n",
      "C4= 1/(2*pi*f*XC4) # in F\n",
      "C4= C4*10**6 # in \u00b5F\n",
      "print \"The components of branch DC : \"\n",
      "print \"Rx = \",round(R4,3),\" k\u03a9\" \n",
      "print \"Cx = \",round(C4,2),\" \u00b5F\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The components of branch DC : \n",
        "Rx =  23.182  k\u03a9\n",
        "Cx =  1.08  \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 69
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.23\n",
      " : Page No - 6.61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "R1 = 600 # in ohm\n",
      "C1 = 1 # in \u00b5F\n",
      "C1 = C1 * 10**-6 # in F\n",
      "XC1= 1/(2*pi*f*C1) \n",
      "R2 = 100 # in ohm\n",
      "R3 = 1 # in k ohm\n",
      "R3 = R3 * 10**3 # in ohm\n",
      "omega = 2*pi*f # in rad/sec\n",
      "Y1= 1/R1+1j*1/XC1 # in \u03a9\n",
      "Z2=R2 # in \u03a9\n",
      "Z3= R3 # in \u03a9\n",
      "# From balance equation, Z1*Z4= Z2*Z3\n",
      "Z4= Z2*(Z3*Y1) # in \u03a9\n",
      "R4= Z4.real # in \u03a9\n",
      "XL4= abs(Z4.imag) # in \u03a9\n",
      "L4= XL4/(2*pi*f) # in F\n",
      "print \"Rx= \",int(R4),\" \u03a9\" \n",
      "print \"Lx= %0.3f H\" %L4"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rx=  166  \u03a9\n",
        "Lx= 0.100 H\n"
       ]
      }
     ],
     "prompt_number": 76
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.24\n",
      " : Page No - 6.62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R2 = 842 #resistance in ohm\n",
      "C2 = 0.135 #capacitance in \u00b5F\n",
      "C2 = C2 * 10**-6 # in F\n",
      "f=1000 #frequency in Hz\n",
      "XC2= 1/(2*pi*f*C2) \n",
      "R3= 10 #resistance in ohm\n",
      "C4= 1*10**-6 #capacitance in F\n",
      "XC4= 1/(2*pi*f*C4) \n",
      "Z2= R2-1j*XC2 #impedance in ohm\n",
      "Z3= complex(R3,0) #impedance in ohm\n",
      "Z4= -1j*XC4 #impedance in ohm\n",
      "# From balance equation\n",
      "Z1= Z2*Z3/Z4 # in \u03a9\n",
      "R1= Z1.real # in \u03a9\n",
      "XL1= abs(Z1.imag) # in \u03a9\n",
      "L1= XL1/(2*pi*f) # in F\n",
      "L1= L1*10**3 # in mH\n",
      "print \"The value of R1 = %0.3f \u03a9 \" %R1\n",
      "print \"The value of L1 = %0.2f mH \" %L1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 = 74.074 \u03a9 \n",
        "The value of L1 = 8.42 mH \n"
       ]
      }
     ],
     "prompt_number": 81
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.25\n",
      " : Page No - 6.63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "L2 = 47.8 #inductance in mH\n",
      "R2 = 1.36 #resistance in ohm\n",
      "r1 = 32.7 #resistance in ohm\n",
      "R1 = 1.36 #resistance in ohm\n",
      "#At balance, 100*(r1+J*oemga*L1) = 100*((R2+r2)+(J*omega*L2)) \n",
      "L1 = L2 # in mH (equating imaginary terms)\n",
      "print \"The inductance of coil = %0.1f mH \" %L1\n",
      "# R2+r2 = r1 (equating real terms)\n",
      "r2 = r1-R1 #resistance of coil in ohm\n",
      "print \"The resistance of coil = %0.2f ohm \" %r2\n",
      "\n",
      "# Note: In the book the value of L1 is wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The inductance of coil = 47.8 mH \n",
        "The resistance of coil = 31.34 ohm \n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.26\n",
      " : Page No - 6.64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R=1.36 #resistance in ohm\n",
      "r2= 32.7 #resistance in ohm\n",
      "L2= 47.8 #inductance in mH\n",
      "L2= L2*10**-3 # in H\n",
      "f=1000 #frequency in Hz\n",
      "XL2=2*pi*f*L2 # in \u03a9\n",
      "Z3 = 100 # in ohm\n",
      "Z4 = 100 # in ohm\n",
      "Z2= r2+1j*XL2 # in ohm\n",
      "# Under balance condition\n",
      "Z1= Z2*Z3/Z4 # in ohm\n",
      "R1= Z1.real # in ohm \n",
      "r1= R1-R #resistance of the coil in ohm\n",
      "XL1= Z1.imag # in ohm\n",
      "L1= XL1/(2*pi*f) #inductance of the coil in F\n",
      "L1= L1*10**3 # in mH\n",
      "print \"The resistance of the coil = %0.2f \u03a9 \" %r1\n",
      "print \"The inductance of the coil = %0.1f mH \" %L1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance of the coil = 31.34 \u03a9 \n",
        "The inductance of the coil = 47.8 mH \n"
       ]
      }
     ],
     "prompt_number": 82
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.27\n",
      " : Page No - 6.66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Z1 = 400 # in ohm\n",
      "Z2 = 200 # in ohm\n",
      "Z3 = 800 # in ohm\n",
      "Z4 = 400 # in ohm\n",
      "theta1 = 50 # in degree\n",
      "theta2 = 40 # in degree\n",
      "theta3 = -50 # in degree\n",
      "theta4 = 20 # in degree\n",
      "if abs(Z1*Z4) == abs(Z3*Z2) : # Applying the condition of balance for magnitude\n",
      "    flag1=1 \n",
      "    print \"The condition of balance for magnitude is satisfied\" \n",
      "else :\n",
      "    flag1=0\n",
      "    print \"The condition of balance for magnitude is not satisfied\" \n",
      "\n",
      "if theta1+theta4==theta2+theta3 : # Applying the condition of balance for phases\n",
      "    flag2=1\n",
      "    print \"The condition of balance for phase is also satisfied\" \n",
      "else :\n",
      "    flag2=0\n",
      "    print \"But the condition of balance for phase is not satisfied\" \n",
      "\n",
      "if flag1==1 :\n",
      "    if flag2==1 :\n",
      "        print \"Hence the bridge is under balanced condition\" \n",
      "    else :\n",
      "        print \"Hence the bridge is not under balanced condition\" \n",
      "else :\n",
      "        print \"Hence the bridge is not under balanced condition\" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The condition of balance for magnitude is satisfied\n",
        "But the condition of balance for phase is not satisfied\n",
        "Hence the bridge is not under balanced condition\n"
       ]
      }
     ],
     "prompt_number": 85
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.28\n",
      " : Page No - 6.67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Z1 = 200 # in ohm\n",
      "Z2 = 400 # in ohm\n",
      "Z3 = 300 # in ohm\n",
      "Z4 = 600 # in ohm\n",
      "theta1 = 60 # in degree\n",
      "theta2 = -60 # in degree\n",
      "theta3 = 0 # in degree\n",
      "theta4 = 30 # in degree\n",
      "if abs(Z1*Z4)== abs(Z3*Z2) : # Applying the condition of balance for magnitude\n",
      "    flag1=1 \n",
      "    print \"The condition of balance for magnitude is satisfied\" \n",
      "else :\n",
      "    flag1=0\n",
      "    print \"The condition of balance for magnitude is not satisfied\" \n",
      "\n",
      "if theta1+theta4==theta2+theta3 : # Applying the condition of balance for phases\n",
      "    flag2=1\n",
      "    print \"The condition of balance for phase is also satisfied\" \n",
      "else :\n",
      "    flag2=0\n",
      "    print \"But the condition of balance for phase is not satisfied\" \n",
      "\n",
      "if flag1==1 :\n",
      "    if flag2==1 :\n",
      "        print \"Hence the bridge is under balanced condition\" \n",
      "    else :\n",
      "        print \"Hence the bridge is not under balanced condition\" \n",
      "    \n",
      "else :\n",
      "        print \"Hence the bridge is not under balanced condition\" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The condition of balance for magnitude is satisfied\n",
        "But the condition of balance for phase is not satisfied\n",
        "Hence the bridge is not under balanced condition\n"
       ]
      }
     ],
     "prompt_number": 86
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.29\n",
      " : Page No - 6.68"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1 #frequency in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "C1 = 0.2 # in \u00b5F\n",
      "C1 = C1 * 10**-6 # in F\n",
      "XC1= 1/(2*pi*f*C1) # in \u03a9\n",
      "C2 = 0.1 # in \u00b5F\n",
      "C2 = C2 * 10**-6 # in F\n",
      "XC2= 1/(2*pi*f*C2) # in \u03a9\n",
      "R2= 300 # in \u03a9\n",
      "R3= 500 # in \u03a9\n",
      "Z1= 0-1j*XC1 # in \u03a9\n",
      "Z2= R2*-1j*XC2/(R2-1j*XC2) # in \u03a9\n",
      "Z3=R3 # in \u03a9\n",
      "# For balanced condition\n",
      "Z4= Z2*Z3/Z1 # in \u03a9\n",
      "R4= Z4.real # in \u03a9\n",
      "XL4= Z4.imag # in \u03a9\n",
      "L4= XL4/(2*pi*f) # in H\n",
      "L4= L4*10**3 # in mH\n",
      "print \"Components of arm CD : \" \n",
      "print \"L4 =\",round(L4,2),\"mH\" \n",
      "print \"R4 =\",round(R4,4),\"\u03a9\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Components of arm CD : \n",
        "L4 = 28.97 mH\n",
        "R4 = 34.3115 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 91
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.30\n",
      " : Page No - 6.69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R3 = 100 # in ohm\n",
      "R4 = 200 # in ohm\n",
      "R2 = 250 # in ohm\n",
      "C = 1 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "r = 229.7 # in ohm\n",
      "r1 = 43.1 # in ohm\n",
      "# Value of unknown resistance for Anderson's bridge\n",
      "R1 = ((R2*R3)/R4) - r1 #resistance in ohm\n",
      "print \"The resistance = %0.1f ohm \" %R1\n",
      "L1 = ((C*R3)/R4) * ( ((R2+R4)*r) + (R2*R4) ) #inductance in H\n",
      "L1 = L1 * 10**3 # in mH\n",
      "print \"The inductance = %0.4f mH \" %L1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance = 81.9 ohm \n",
        "The inductance = 76.6825 mH \n"
       ]
      }
     ],
     "prompt_number": 51
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.31\n",
      " : Page No - 6.70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 450 #frequency in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "R2 = 4.8 # in ohm\n",
      "R3 = 200 # in ohm\n",
      "R4 = 2850 # in ohm\n",
      "C2 = 0.5 # in \u00b5F\n",
      "C2 = C2*10**-6 # in F\n",
      "XC2= 1/(2*pi*f*C2) # in \u03a9\n",
      "r2 = 0.4 # in ohm\n",
      "Z2= (R2+r2)-1j*XC2 # in \u03a9\n",
      "Z3= R3 # in \u03a9\n",
      "Z4= R4 # in \u03a9\n",
      "# For balanced condition\n",
      "Z1= Z2*Z3/Z4 # in \u03a9\n",
      "r1= Z1.real # in \u03a9\n",
      "XC1= abs(Z1.imag) # in \u03a9\n",
      "C1= 1/(2*pi*f*XC1) # in F\n",
      "Df= 2*pi*f*C1*r1 # dissipating factor\n",
      "C1= C1*10**6 # in \u00b5F\n",
      "print \"The value of r1 = %0.4f \u03a9 \" %r1\n",
      "print \"The value of C1 = %0.3f \u00b5F \" %C1\n",
      "print \"The dissipating factor = %0.6f \" %Df"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of r1 = 0.3649 \u03a9 \n",
        "The value of C1 = 7.125 \u00b5F \n",
        "The dissipating factor = 0.007351 \n"
       ]
      }
     ],
     "prompt_number": 92
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.32\n",
      " : Page No - 6.72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 2 #frequency in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "R2 = 834 #resistance in ohm\n",
      "C2 = 0.124 #capacitance in \u00b5F\n",
      "C2 = C2 * 10**-6 # in F\n",
      "XC2= 1/(2*pi*f*C2) # in \u03a9\n",
      "R3= 100 #resistane in \u03a9\n",
      "C4= 0.1*10**-6 #capacitance in F\n",
      "XC4= 1/(2*pi*f*C4) # in \u03a9\n",
      "Z2= R2-1j*XC2 # in \u03a9\n",
      "Z3=R3 # in \u03a9\n",
      "Z4= 0-1j*XC4 # in \u03a9\n",
      "# For balanced condition, effective impedance   \n",
      "Z1= Z2*Z3/Z4 #in \u03a9\n",
      "print \"The effective impedance = (\",round(Z1.real,4),\"+ j\",round(Z1.imag,4),\")\u03a9\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The effective impedance = ( 80.6452 + j 104.8035 )\u03a9\n"
       ]
      }
     ],
     "prompt_number": 99
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.33\n",
      " : Page No - 6.73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R1= 20*10**3 #resistance in ohm\n",
      "R2= 50*10**3 #resistance in ohm\n",
      "C2= 0.003*10**-6 #capacitance in F\n",
      "R4= 10*10**3 #resistance in ohm\n",
      "C1= 150*10**-12 #capacitance in F\n",
      "omega= 10**6 # in rad/sec\n",
      "Z1= R1/(1+1j*omega*C1*R1) # in ohm\n",
      "Z2= (1+1j*omega*C2*R2)/(1j*omega*C2) # in ohm\n",
      "# At balance condition : Z1*R4 = Z2*(Rx+1j*omega*Lx) or\n",
      "# R4= omega**2*R1*C2*(R1*R4*C1-Lx)      (i)\n",
      "# R4= R1*(Rx*C2-R4*C1)/(R2*C2)             (ii)\n",
      "Rx= R4*(R1*C1+R2*C2)/(R1*C2) # in \u03a9 from eq(ii)\n",
      "Lx= R4*(R2*C1-1/(omega**2*R1*C2)) # in H from eq (i)\n",
      "Rx= Rx*10**-3 # in ohm\n",
      "Lx= Lx*10**3 # in mH\n",
      "print \"The value of Rx = %0.1f \u03a9 \" %Rx\n",
      "print \"The value of Lx = %0.3f mH \" %Lx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Rx = 25.5 \u03a9 \n",
        "The value of Lx = 74.833 mH \n"
       ]
      }
     ],
     "prompt_number": 102
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.34\n",
      " : Page No - 6.75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R2 = 1000 #resistance in \u03a9\n",
      "R3 = 1000 #resistance in \u03a9\n",
      "R4 = 1000 #resistance in \u03a9\n",
      "C4 = 0.5 #capacitance in \u00b5F\n",
      "C4 = C4 * 10**-6 # in F\n",
      "#At balance, (R1+(%i*omega*L1))*(R4/( 1+(%i*omega*C4*R4) )) = R2*R3 \n",
      "# R1*R4 + (%i*omega*L1*R4) = (R2*R3) + (%i*omega*R2*R4*C4) \n",
      "R1 = (R2*R3)/R4 # in \u03a9 (equating real terms)\n",
      "L1 = R2*R3*C4 # in H (equating imaginary terms)\n",
      "print \"The value of R1 = %0.f ohm \" %R1\n",
      "print \"The value of L1 = %0.1f H \" %L1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 = 1000 ohm \n",
        "The value of L1 = 0.5 H \n"
       ]
      }
     ],
     "prompt_number": 55
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.35\n",
      " : Page No - 6.76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R3 = 260 #resistance in ohm\n",
      "C4 = 0.5 # in \u00b5F\n",
      "C4 = C4 * 10**-6 # in F\n",
      "C2 = 106 # in pF\n",
      "C2 = C2 * 10**-12 # in F\n",
      "R4 = 1000/pi #resistance in ohm\n",
      "r1 = (C4/C2)*R3 #resistance in ohm\n",
      "C1 = (R4/R3)*C2 # in F\n",
      "Epsilon_o = 8.854*10**-12 \n",
      "d = 4.5# in mm\n",
      "d = d * 10**-3 # in m\n",
      "D= 0.12 # in m\n",
      "A= pi*D**2/4 # in m**2\n",
      "print \"The resistance = %0.2e \u03a9 \" %r1\n",
      "C1= C1*10**12 # in pF\n",
      "print \"The capacitance = %0.2f pF \" %C1\n",
      "C1= C1*10**-12 # in F\n",
      "f = 50 # in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "Pf= omega*C1*r1 # power factor\n",
      "print \"The power factor = %0.2f \" %Pf\n",
      "# C1 = Epsilon_r*Epsilon_o*(A/d) \n",
      "Epsilon_r = (C1*d)/(Epsilon_o*A) # the relative permittivity \n",
      "print \"The relative permittivity = %0.1f \" %Epsilon_r\n",
      "\n",
      "# Note: The calculation of evaluating the value of C1 is wrong, so the answer of C1 in the book is wrong. \n",
      "#       But they putted the correct value of C1 to find the value of relative permittivity"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance = 1.23e+06 \u03a9 \n",
        "The capacitance = 129.77 pF \n",
        "The power factor = 0.05 \n",
        "The relative permittivity = 5.8 \n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.36\n",
      " : Page No - 6.76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import atan\n",
      "from numpy import pi\n",
      "#Given data\n",
      "C2 = 500 # capacitance in nF\n",
      "C2 = C2 * 10**-9 # in F\n",
      "f = 50 #frequency in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "C4 = 0.148 #capacitance in \u00b5F\n",
      "C4 = C4 * 10**-6 # in F\n",
      "R4 = 72.6 #resistance in ohm\n",
      "R3 = 300 #resistance in ohm\n",
      "C1 = C2*(R4/R3) # capacitance in F\n",
      "C1 = C1 * 10**6 # in \u00b5F\n",
      "print \"The capacitance = %0.3f \u00b5F \" %C1\n",
      "delta = 90-(atan(omega*C4*R4)*180/pi) #dielectric loss angle of capacitance in degree\n",
      "print \"The dielectric loss angle of capacitance = %0.2f degree \" %delta\n",
      "\n",
      "# Note: The calculation in the book is wrong, so the answer in the book is wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The capacitance = 0.121 \u00b5F \n",
        "The dielectric loss angle of capacitance = 89.81 degree \n"
       ]
      }
     ],
     "prompt_number": 76
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.37\n",
      " : Page No - 6.77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f1 = 3 #frequency in MHz\n",
      "f1 = f1 * 10**6 # in Hz\n",
      "C1 = 251 #capacitance in pF\n",
      "C1 = C1  * 10**-12 # in F\n",
      "f2 = 6 #frequency in MHz\n",
      "f2 = f2 * 10**6 # in Hz\n",
      "C2 = 50 #capacitance in pF\n",
      "C2 = C2 * 10**-12 # in F\n",
      "# f1 = 1/(2*pi*(sqrt(L*(C1+Cd))) )    (i)\n",
      "# f2 = 1/(2*pi*(sqrt(L*(C2+Cd))) )    (ii)\n",
      "# From eq(i) and (ii)\n",
      "Cd = (C1 - (4*C2))/3 # self capacitance of the coil in F\n",
      "Cd = Cd * 10**12 # in pF\n",
      "print \"The self capacitance of the coil = %0.f pF \" %Cd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The self capacitance of the coil = 17 pF \n"
       ]
      }
     ],
     "prompt_number": 69
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.38\n",
      " : Page No - 6.78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f=500 #frequency in Hz\n",
      "R2 = 2410 #resistance in ohm\n",
      "R3 = 750 #resistance in ohm\n",
      "R4 = 64.5 #resistance in ohm\n",
      "R_C4 = 0.4 #resistance in ohm\n",
      "C4 = 0.35 #capacitance in \u00b5F\n",
      "C4 = C4 * 10**-6 # in F\n",
      "XC4= 1/(2*pi*f*C4) # in \u03a9\n",
      "Z4= R4+R_C4-1j*XC4 # in \u03a9\n",
      "Z2= R2 # in \u03a9\n",
      "Z3= R3 # in \u03a9\n",
      "Z1= Z2*Z3/Z4 # in \u03a9\n",
      "R1= Z1.real #resistance of choke coil  in \u03a9\n",
      "XL1= Z1.imag # in \u03a9\n",
      "L1= XL1/(2*pi*f) #inductance of choke coil  in H\n",
      "print \"The resistance of choke coil = %0.4f \u03a9 \" %R1\n",
      "print \"The inductance of choke coil = %0.4f H \" %L1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance of choke coil = 141.1084 \u03a9 \n",
        "The inductance of choke coil = 0.6294 H \n"
       ]
      }
     ],
     "prompt_number": 103
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.39\n",
      " : Page No - 6.79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 50 # in Hz\n",
      "omega = 2*pi*f # in rad/sec\n",
      "R1 = 50 # in ohm\n",
      "L1 = 0.1 # in H\n",
      "XL1= 2*pi*f*L1 # in \u03a9\n",
      "R2= 100 # in \u03a9\n",
      "R3= 1000 # in \u03a9\n",
      "Z1= R1+1j*XL1 # in \u03a9\n",
      "Z2= R2 # in \u03a9\n",
      "Z3= R3 # in \u03a9\n",
      "# The bridge balance condition\n",
      "Zx= Z2*Z3/Z1 # in \u03a9\n",
      "# Comparing real part\n",
      "Rx= Zx.real # in \u03a9\n",
      "# Comparing imaginary part\n",
      "XCx= abs(Zx.imag) # in \u03a9\n",
      "Cx= 1/(2*pi*f*XCx) # in F\n",
      "print \"The value of Rx = %0.4f \u03a9 \" %Rx\n",
      "print \"The value of Cx = %0.4f \u00b5F \" %(Cx*10**6)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Rx = 1433.9136 \u03a9 \n",
        "The value of Cx = 3.5330 \u00b5F \n"
       ]
      }
     ],
     "prompt_number": 105
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.40\n",
      " : Page No - 6.80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import atan2\n",
      "from numpy import pi\n",
      "#Given data\n",
      "f = 2 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "R2= 834 # in \u03a9\n",
      "C2= 0.124*10**-6 # in F\n",
      "XC2= 1/(2*pi*f*C2) # in \u03a9\n",
      "R3= 100 # in \u03a9\n",
      "C4 = 0.1 # in \u00b5F\n",
      "C4 = C4*10**-6 # in F\n",
      "XC4= 1/(2*pi*f*C4) # in \u03a9\n",
      "Z2= R2+1j*XC2 # in \u03a9\n",
      "Z3= R3 # in \u03a9\n",
      "Z4= -1j*XC4 # in \u03a9\n",
      "# The bridge balance condition\n",
      "Z1= Z2*Z3/Z4 # in \u03a9\n",
      "mag= abs(Z1) # magnitude of effective impedence in \u03a9\n",
      "theta= atan2(Z1.imag,Z1.real)*180/pi # phase angle of effective impedence in \u00b0\n",
      "print \"The magnitude of effective impedence = %0.2f \u03a9 \" %mag\n",
      "print \"The phase angle of effective impedence = %0.2f \u00b0 \" %theta"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The magnitude of effective impedence = 132.24 \u03a9 \n",
        "The phase angle of effective impedence = 127.58 \u00b0 \n"
       ]
      }
     ],
     "prompt_number": 110
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.41\n",
      " : Page No - 6.81 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "L1 = 52.6 #inductance in mH\n",
      "R2 = 1.68 #resistance in ohm\n",
      "# 80*(r1+(J*omega*L1)) = 80*( (R2+r2) + (J*omega*L2) ) \n",
      "L2 = L1 #inductance of the coil in mH\n",
      "print \"The inductance of the coil = %0.1f mH \" %L2\n",
      "r1 = 28.5 # in ohm\n",
      "r2 = r1-R2 #resistance of the coil in ohm\n",
      "print \"The resistance of the coil = %0.2f ohm \" %r2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The inductance of the coil = 52.6 mH \n",
        "The resistance of the coil = 26.82 ohm \n"
       ]
      }
     ],
     "prompt_number": 73
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example - 6.42\n",
      " : Page No - 6.83 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "Q = 1 # in k ohm\n",
      "Q = Q * 10**3 # in  ohm\n",
      "S = Q # in ohm\n",
      "P = 500 # in ohm\n",
      "r = 100 # in ohm\n",
      "C = 0.5 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "#Using standard condition, Rx = (R2*R3)/R4 \n",
      "Rx = (P*Q)/S # in ohm\n",
      "print \"The value of Rx = %0.f \u03a9 \" %Rx\n",
      "#Lx = ((C*R2)/R4) * ( (R3*r) + (R4*r) + (R3*R4) ) \n",
      "Lx = ((C*P)/S) * ( (Q*r) + (S*r) + (Q*S) ) # in H\n",
      "print \"The value of Lx = %0.1f H \" %Lx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Rx = 500 \u03a9 \n",
        "The value of Lx = 0.3 H \n"
       ]
      }
     ],
     "prompt_number": 74
    }
   ],
   "metadata": {}
  }
 ]
}