{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1: Vector Analysis"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 13, Page number 25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "divergence of force vector is 3\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "from scipy.integrate import tplquad\n",
    "\n",
    "#Calculation\n",
    "func = lambda x,y,z: 2*(x+y+z)\n",
    "x1,x2 = 0,1\n",
    "y1,y2 = lambda x: 0, lambda x: 1\n",
    "z1,z2 = lambda x,y: 0, lambda x,y: 1\n",
    "r1,r2=tplquad(func,x1,x2,y1,y2,z1,z2)      \n",
    "r=r1-r2;          #divergence of force vector\n",
    "\n",
    "#Result\n",
    "print \"divergence of force vector is\",int(round(r))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16, Page number 28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the result is 59 /60\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "from scipy.integrate import quad\n",
    "\n",
    "#Calculation\n",
    "def zintg(x):\n",
    "    return x**3\n",
    "r1=quad(zintg,0,1)[0]\n",
    "def zintg(x):\n",
    "    return 2*x**4\n",
    "r2=quad(zintg,0,1)[0]\n",
    "def zintg(x):\n",
    "    return 3*x**8\n",
    "r3=quad(zintg,0,1)[0]\n",
    "r=r1+r2+r3;             #result\n",
    "\n",
    "#Result\n",
    "print \"the result is\",int(r*60),\"/60\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 17, Page number 29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the result is 2 /3\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "from scipy.integrate import quad\n",
    "from fractions import Fraction\n",
    "\n",
    "#Calculation\n",
    "def zintg(x):\n",
    "    return (x-(x**2))\n",
    "r1=quad(zintg,0,1)[0]\n",
    "def zintg(x):\n",
    "    return 2*((x**2)+(x**3))\n",
    "r2=quad(zintg,0,1)[0]\n",
    "def zintg(y):\n",
    "    return 2*((y**3)-(y**2))\n",
    "r3=quad(zintg,1,0)[0]\n",
    "def zintg(y):\n",
    "    return (y**2)+y\n",
    "r4=quad(zintg,1,0)[0]\n",
    "r=r1+r2+r3+r4;             #result\n",
    "\n",
    "#Result\n",
    "print \"the result is\",int(r*3),\"/3\""
   ]
  }
 ],
 "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
}
