{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 15:Electric Forces and Fields"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex15.1:pg-719"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of q is= 3.61e-06  C\n",
      "\n",
      "Number of electrons to be removed is=\n",
      "2.25625e+13\n",
      "Fraction of atoms lost is=\n",
      "7.52083333333e-10\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example15_1\n",
    " \n",
    "  #To find the value of q and how many electrons must be removed and fraction of atoms lost\n",
    "dist=2       #Units in meters\n",
    "f=0.0294     #Units in N\n",
    "s=9*10**9   #Units in N meter**2/C**2\n",
    "q=math.sqrt((dist**2*f)/s)    #Units in C\n",
    "print \"The value of q is=\",round(q,8),\" C\\n\"\n",
    "charge=3.61*10**-6   #Units in C\n",
    "c_elec=1.6*10**-19       #Units in C\n",
    "n=charge/c_elec     #Units in number\n",
    "print \"Number of electrons to be removed is=\"\n",
    "print n\n",
    "f1=3*10.0**22     #Units in number\n",
    "fraction=n/f1     #Units of number\n",
    "print \"Fraction of atoms lost is=\"\n",
    "print fraction\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex15.2:pg-721"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The force on the center charge is= 0.02813  N\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example15_2\n",
    " \n",
    "  \n",
    "  #To find the force on the center charge\n",
    "k=9*10**9      #Units in N meter**2/C**2\n",
    "q1=4*10.0**-6      #Units in C\n",
    "q2=5*10.0**-6     #Units in C\n",
    "r1=2           #Units in meters\n",
    "r2=4       #Units in meters\n",
    "q3=6*10.0**-6       #Units in C\n",
    "f1=(k*q1*q2)/r1**2         #Units in N\n",
    "f2=(k*q2*q3)/r2**2         #Units in N\n",
    "f=f1-f2         #Units in C\n",
    "print \"The force on the center charge is=\",round(f,5),\" N\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex15.3:pg-722"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resultant force is f= 19.0  N \n",
      "The resultant angle is theta= 71.6  degrees\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example15_3\n",
    " \n",
    "  \n",
    "  #To find the resultant force\n",
    "f1=6   #Units in N\n",
    "f2=18       #Units in N\n",
    "f=math.sqrt(f1**2+f2**2)   #Units in N\n",
    "theta=math.atan(f2/f1)*180/math.pi    #Units in degrees\n",
    "print \"The resultant force is f=\",round(f),\" N \\nThe resultant angle is theta=\",round(theta,1),\" degrees\"\n",
    "  #In text book answer printed wrong as f=19 N correct answer is f=18N \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex15.4:pg-724"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resultant force is f= 3.4  N \n",
      " The resultant angle is theta= 65.0  degrees\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example15_4\n",
    " \n",
    "\n",
    "  #To find the resultant force on 20 micro C\n",
    "f1=2   #Units in N\n",
    "f2=1.8       #Units in N\n",
    "theta=37.0         #Units in degrees\n",
    "f2x=f2*math.cos(theta*math.pi/180)        #Units in N\n",
    "f2y=f2*math.sin(theta*math.pi/180)        #Units in N\n",
    "fy=f1+f2y       #Units in N\n",
    "f=math.sqrt(fy**2+f2x**2)   #Units in N\n",
    "theta=math.atan(fy/f2x)*180/math.pi    #Units in degrees\n",
    "print \"The resultant force is f=\",round(f,1),\" N \\n The resultant angle is theta=\",round(theta,1),\" degrees\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex15.6:pg-726 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The magnitude of E is=\n",
      "7198876.9\n",
      "N/C\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example15_6\n",
    " \n",
    "  \n",
    "  #To find the magnitude of E\n",
    "k=9*10**9      #Units in N meter**2/C**2\n",
    "q=3.6*10**-6        #Units in C\n",
    "theta=37            #Units in degrees\n",
    "r=10*math.sin(theta*math.pi/180)*10**-2      #Units in meters  \n",
    "e1=(k*q)/r**2       #Units in N/C\n",
    "q2=5*10**-6        #Units in C\n",
    "theta=37            #Units in degrees\n",
    "r1=10*10**-2   #Units in meters  \n",
    "e2=(k*q2)/r1**2       #Units in N/C\n",
    "e1y=e1           #Units in N/C\n",
    "e2x=e2*math.cos(theta*math.pi/180)      #Units in N/C\n",
    "e2y=-e2*math.sin(theta*math.pi/180)   #Units in N/C\n",
    "ex=e2x         #Units in N/C\n",
    "ey=e1y+e2y          #Units in N/C\n",
    "e=math.sqrt(ex**2+ey**2)           #Units in N/C\n",
    "print \"The magnitude of E is=\"\n",
    "print round(e,2)\n",
    "print \"N/C\"\n",
    "  #In text book the answer isprinted wrong as E=7.26*10**6 N/C but the correct answer is E=7198876.9 N/C\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex15.7:pg-726"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The charge occured is q= 8.33e-07  C\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example15_7\n",
    " \n",
    "  \n",
    "  #To find out how much charge occurs\n",
    "e=3*10.0**6      #Units in N/C\n",
    "r=0.050      #Units in meters\n",
    "k=9*10.0**9   #Units in N meter**2/C**2\n",
    "q=(e*r**2)/k       #Units in C\n",
    "print \"The charge occured is q=\",round(q,9),\" C\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex15.8:pg-727"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lines of force come out of positive charge q suspended in cavity.\n",
      "Cavity \n",
      "surface must possess a negative charge since lines of force go and terminate on q.\n",
      "Therefore a charge +q must exist on outer portions.\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example15_8\n",
    " \n",
    "  \n",
    "  #To show using lines of force that a charge suspended with in cavity induces an equal and opposite charge on surface\n",
    "print \"Lines of force come out of positive charge q suspended in cavity.\\nCavity \\nsurface must possess a negative charge since lines of force go and terminate on q.\\nTherefore a charge +q must exist on outer portions.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex15.9:pg-728"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The field goes by a speed of  47952.0  meters/sec\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example15_9\n",
    "  \n",
    "  #To find the speed just before the field strikes\n",
    "e=6000     #Units in N/C\n",
    "q=1.6*10**-19    #Units in C\n",
    "f=e*q           #Units in N\n",
    "m=1.67*10**-27          #Units in Kg\n",
    "a=f/m        #Units in meters/sec**2\n",
    "vo=0       #Units in meters/sec\n",
    "x=2*10**-3        #Units in meters\n",
    "v=math.sqrt(vo**2+(2*a*x))          #Units in meters/sec\n",
    "print \"The field goes by a speed of \",round(v),\" meters/sec\"\n",
    "  #In text book answer printed wrong as v=48000 meters/sec the correct answer is v=47952 meters/sec \n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}