{
 "metadata": {
  "name": "",
  "signature": "sha256:ba3f78351f4be2023ce816790e91ae988fafb883f552e13733bb7da3271b13e0"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "1: Electrostatics-Basic concepts"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.1, Page number 12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "r=0.053*10**-9;      #distance(m)\n",
      "q1=1.6*10**-19;     #charge on electron(C)\n",
      "q2=1.6*10**-19;     #charge on proton(C)\n",
      "#let x=1/(4*math.pi*epsilon0)\n",
      "x=9*10**9;\n",
      "\n",
      "#Calculation\n",
      "F=x*q1*q2/(r**2);    #force of attraction(N)\n",
      "\n",
      "#Result\n",
      "print \"force of attraction is\",round(F*10**8,1),\"*10**-8 N\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "force of attraction is 8.2 *10**-8 N\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.2, Page number 13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "r=2;      #distance(m)\n",
      "q1plusq2=5*10**-4;     #positive charge(C)\n",
      "#let x=1/(4*math.pi*epsilon0)\n",
      "x=9*10**9;\n",
      "F=1;    #force(N)\n",
      "\n",
      "#Calculation\n",
      "q1q2=F*(r**2)/x;     #product of charges(C**2)\n",
      "q1minusq2=math.sqrt((q1plusq2**2)-(4*q1q2));     ##difference of charges(C)\n",
      "twoq1=q1plusq2+q1minusq2;\n",
      "q1=twoq1/2;      #charge on individual sphere(C)\n",
      "twoq2=q1plusq2-q1minusq2;\n",
      "q2=twoq2/2;      #charge on individual sphere(C)\n",
      "\n",
      "#Result\n",
      "print \"the charges on individual spheres are\",round(q1*10**4,3),\"*10**-4 and\",round(q2*10**4,3),\"*10**-4\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the charges on individual spheres are 4.991 *10**-4 and 0.009 *10**-4\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.3, Page number 13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "m=9.1*10**-31;    #mass of electron(kg)\n",
      "g=9.8;    #acceleration due to gravity(m/sec**2)\n",
      "q=1.6*10**-19;    #charge on electron(C)\n",
      "\n",
      "#Calculation\n",
      "F1=m*g;    #force by electron(N)\n",
      "E=F1/(2*q);    #intensity of electric field(N/C)\n",
      "\n",
      "#Result\n",
      "print \"intensity of electric field is\",round(E*10**11,3),\"*10**-11 N/C\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "intensity of electric field is 2.787 *10**-11 N/C\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.4, Page number 14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "r=12*10**-2;      #distance(m)\n",
      "q1=2*10**-7;     #charge(C)\n",
      "q2=8.5*10**-8;     #charge(C)\n",
      "#let x=1/(4*math.pi*epsilon0)\n",
      "x=9*10**9;\n",
      "\n",
      "#Calculation\n",
      "E1=x*q2/(r**2);    #intensity at electric field at q1 due to q2(N/C)\n",
      "E2=x*q1/(r**2);    #intensity at electric field at q2 due to q1(N/C)\n",
      "F=x*q1*q2/(r**2);    #force of attraction(N)\n",
      "\n",
      "#Result\n",
      "print \"intensity at electric field at q1 due to q2 is\",round(E1*10**-5,2),\"*10**5 N/C\"\n",
      "print \"intensity at electric field at q1 due to q2 is\",round(E2*10**-5,2),\"*10**5 N/C\"\n",
      "print \"force of attraction is\",round(F,4),\"N\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "intensity at electric field at q1 due to q2 is 0.53 *10**5 N/C\n",
        "intensity at electric field at q1 due to q2 is 1.25 *10**5 N/C\n",
        "force of attraction is 0.0106 N\n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}