{
 "metadata": {
  "name": "chapter18.ipynb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 18: Impulse and Momentum"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-8, Page No 435"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "W=100 #lb\n",
      "u=0.2 #coefficient of friction\n",
      "t=5 #s\n",
      "v1=5 #ft/s\n",
      "v2=10 #ft/s\n",
      "g=32.2 #ft/s**2\n",
      "ll=0 #lower limit of integration\n",
      "ul=5 #upper limit of integration\n",
      "\n",
      "#Calculations\n",
      "Fr=u*W #lb\n",
      "#Using The impulse momentum theorem\n",
      "#Since the integration is just subtraction of limits we can skip that\n",
      "F=((W/g)*v2-(W/g)*v1+Fr*ul)/ul #lb\n",
      "\n",
      "#Result\n",
      "print'The Force is',round(F,1),\"lb\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Force is 23.1 lb\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-9, Page No 435"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "m=10 #kg\n",
      "#theta=30,thus\n",
      "cos30=sqrt(3)*2**-1\n",
      "sin30=2**-1\n",
      "u=0.3 #coefficient of kinetic friction\n",
      "t=5 #s\n",
      "g=9.8 #m/s**2\n",
      "\n",
      "#Calculations\n",
      "#Asthere is no motion in the vertical direction \n",
      "#Summing forces along vertical direction\n",
      "Na=m*g*cos30 #N\n",
      "#Using impulse momentum theorem\n",
      "vx=(m*g*sin30-u*Na)*(t*m**-1) #m/s\n",
      "\n",
      "#Result\n",
      "print'The speed after 5s is',round(vx,1),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed after 5s is 11.8 m/s\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-10, Page No 436"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "from scipy.integrate import quad\n",
      "def integrand(t, a, b):\n",
      "    return 20*t-16\n",
      "a=1\n",
      "b=1\n",
      "F=quad(integrand, 1, 5, args=(a,b))\n",
      "g=32.2 # ft/s**2\n",
      "v=(F[0]*32.2)/80\n",
      "\n",
      "# Results\n",
      "print'The speed of the block is',round(v,1),\"ft/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed of the block is 70.8 ft/s\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-12, Page No 436"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "m1=40 #kg\n",
      "m2=10 #kg\n",
      "m3=15 #kg\n",
      "v0=2.5 #m/s\n",
      "vf=5 #m/s\n",
      "t=12 #s\n",
      "u=0.1 #coefficient of friction\n",
      "g=9.8 #m/s**2\n",
      "#theta=45 degrees,thus\n",
      "sin45=(sqrt(2))**-1\n",
      "cos45=(sqrt(2))**-1\n",
      "\n",
      "#Calculations\n",
      "#Applying Impulse-Momentum Theoroem\n",
      "P=(((m1+m2+m3)*(vf-v0))+(t*(-m2*g*sin45+u*g*m2*cos45+u*g*m3+g*m1)))*t**-1 #N\n",
      "\n",
      "#Result\n",
      "print'The value of P is',round(P),\"N\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of P is 358.0 N\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-13, Page Noo 437"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "W1=4 #lb\n",
      "W2=2 #lb\n",
      "t2=0.04 #s\n",
      "W3=-2 #lb\n",
      "t3=0.02 #s\n",
      "t=3 #s\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "#Algebraic sum of two areas\n",
      "A=t2*W2+t3*W3 #lb-s\n",
      "#Using Impulse Momentum Theorem\n",
      "v=(A*g)/W1 #ft/s\n",
      "\n",
      "#Result\n",
      "print'The spped after 3s is',round(v,3),\"ft/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The spped after 3s is 0.322 ft/s\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-14, Page No 437"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "f_r=1 #in/s rate of fall of mercury\n",
      "ll=18 #in length of left column\n",
      "lr=22 #in length of right column\n",
      "rho=850 #lb/ft**3\n",
      "d=4**-1 #in\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "#Applying Impulse momentum theorem\n",
      "M=((d*pi*d**2*4)/12**3)*(rho/g)*(12**-1) #lb-s\n",
      "\n",
      "#Result\n",
      "print'The upward momentum of mercury is +',round(M,5),\"lb-s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The upward momentum of mercury is + 0.00025 lb-s\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-15, Page No 437"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "m=2000 #kg\n",
      "k=1.200 #m\n",
      "w=120 #rpm\n",
      "t=200 #s\n",
      "\n",
      "#Calculations\n",
      "#Applying Angular Momentum theorem\n",
      "M=((m*k**2*(w*2*pi))/60)/t #N.m\n",
      "\n",
      "#Result\n",
      "print'The Momentum necessary is',round(M),\"N.m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Momentum necessary is 181.0 N.m\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-17, Page No 438"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "m1=5 #kg\n",
      "m2=7 #kg\n",
      "mp=5 #kg\n",
      "r=0.6 #m\n",
      "k=0.45 #m\n",
      "vi=3 #m/s\n",
      "vf=6 #m/s\n",
      "g=9.8 #m/s**2\n",
      "\n",
      "#Calculations\n",
      "I=m1*k**2 #kg.m**2\n",
      "wnet=(vf/r)-(vi/r) #rad/s\n",
      "#Solving the system of linear equations\n",
      "#Simplfying the equation we get\n",
      "t=((I*wnet)+m1*(vf-vi)+m2*(vf-vi))*r/(r*(m2-m1)*g) #s\n",
      "\n",
      "#Result\n",
      "print'The time required is',round(t,2),\"s\"\n",
      "# The ans in the textbook is incorrect.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The time required is 2.1 s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-18, Page No 438"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "m=50 #kg\n",
      "vo=4 #m/s\n",
      "vf=8 #m/s\n",
      "t=6 #s\n",
      "g=9.8 #m/s**2\n",
      "r=0.8 #m\n",
      "u=0.25 #coefficient of friction\n",
      "I=30 #kg-m**2\n",
      "\n",
      "#Calculations\n",
      "Na=m*g #N\n",
      "F=u*Na #N\n",
      "#Angular Speeds\n",
      "wo=vo/r #rad/s\n",
      "wf=vf/r #rad/s\n",
      "#Applying impulse momentum theorem\n",
      "mb=(I*wo+m*vo*r-F*r*t-I*wf-m*vf*r)/(vf*r-vo*r-g*r*t) #kg\n",
      "\n",
      "#Result\n",
      "print'The mass of block B is',round(mb,1),\"kg\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass of block B is 20.5 kg\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-19, Page No 439"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "Ws=250 #lb\n",
      "Wl=500 #lb\n",
      "W3=161 #lb\n",
      "W4=64.4 #lb\n",
      "wo=100 #rpm\n",
      "wf=300 #rpm\n",
      "rl=3 #ft\n",
      "rs=2 #ft\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "#Moment Of Inertia\n",
      "I=(0.5*(Wl/g)*rl**2+0.5*(Ws/g)*rs**2) #slug-ft**2\n",
      "#Change in angular Momentum\n",
      "change1=I*((wf-wo)*2*(pi/60)) #lb-s-ft\n",
      "#Change in angular momentum about G for 161lb\n",
      "change2=2*((W3*g**-1)*(wf-wo)*(4*60**-1)*pi) #lb-s-ft\n",
      "#Similarly change in 64lb is\n",
      "change3=3*((W4*g**-1)*(wf-wo)*(6*60**-1)*pi) #lb-s-ft\n",
      "#Change in linear impulse\n",
      "#Without t term in it\n",
      "m1=2*W3\n",
      "m2=-3*W4\n",
      "#Total angular impulse\n",
      "t=(change1+change2+change3)/(m1+m2) #s\n",
      "\n",
      "#Result\n",
      "print'The time required is',round(t),\"s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The time required is 20.0 s\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-21, Page No 440"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "\n",
      "#Initilization of variables\n",
      "d=3 #ft\n",
      "W=300 #lb\n",
      "# as theta=20 degrees\n",
      "sintheta=0.342\n",
      "F=250 #lb\n",
      "t=6 #s\n",
      "vo=0 #ft/s\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "#Applying linear impulse momentum theorem\n",
      "#Solving by matrix method\n",
      "A=np.array([[-W*g**-1,1*t],[-((0.5)*(W*g**-1)*(d*2**-1)**2*(d*2**-1)**-1),(-t)*d*2**-1]])\n",
      "B=np.array([[-F*t+W*sintheta*t],[-F*(d*2**-1)*6]]) \n",
      "C=np.linalg.solve(A,B)\n",
      "\n",
      "#Result\n",
      "print'The speed after 6s is',round(C[0]),\"ft/s,parallel to the plane\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed after 6s is 171.0 ft/s,parallel to the plane\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-22, Page No 440"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Initilization of variables\n",
      "#theta=30 degrees\n",
      "sin30=2**-1\n",
      "vo=20 #ft/s\n",
      "r=4 #ft\n",
      "vf=0 #ft/s\n",
      "W=300 #lb\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "wo=vo*r**-1 #rad/s\n",
      "wf=vf*r**-1 #rad/s\n",
      "#Applying impulse momentum theorem\n",
      "#Solving simultaneous equations\n",
      "t=-((W*g**-1)*(vf-vo)+((0.5*(W*g**-1)*r**2*(wf-wo))*r**-1))/(W*sin30) #s\n",
      "\n",
      "#Result\n",
      "print'The time t is',round(t,2),\"s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The time t is 1.86 s\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-23, Page No 441"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "\n",
      "#Initilization of variables\n",
      "mw=75 #kg\n",
      "k=0.9 #m\n",
      "wi=10 #rad/s\n",
      "wf=6 #rad/s\n",
      "r=1.2 #m\n",
      "m=30 #kg\n",
      "g=9.8 #m/s**2\n",
      "\n",
      "#Calculations\n",
      "#Initial speed\n",
      "vi=-r*wi #m/s\n",
      "vf=r*wf #m/s\n",
      "#Initial speed of B is\n",
      "vib=-0.8*wi+vi #m/s\n",
      "#Similarly\n",
      "vfb=12 #m/s\n",
      "#Applying impulse momentum theorem\n",
      "#Solving by matrix method\n",
      "A=np.array([[1,-1,-(mw*(vf-vi))],[0.8,1.2,-(mw*(k**2)*(wf+wi))],[-1,0,-(m*(vfb-vi))]])\n",
      "B=np.array([[0],[0],[-g*m]])\n",
      "C=np.linalg.solve(A,B)\n",
      "#Here t is calculated as 1/t for simplicity\n",
      "\n",
      "#Result\n",
      "print'The time required is',round(C[2]**-1,2),\"s\" \n",
      "#Decimal accuracy causes discrepancy in answers\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The time required is 7.04 s\n"
       ]
      }
     ],
     "prompt_number": 59
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-24, Page No 441"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "d=8 #in\n",
      "W=96.6 #lb\n",
      "w=36 #rad/s\n",
      "u=0.15 #coefficient of friction\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "r=(d/2)*12**-1 #m\n",
      "N=W #lb\n",
      "F=u*N #lb\n",
      "m=W/g #slugs\n",
      "I=0.5*m*(r**2) #slug-ft**2\n",
      "#Applying the impulse momentum theorem\n",
      "#Solving the two equations simultaneously\n",
      "A=np.array([[F,-m],[F*r,I*(1*r**-1)]])\n",
      "B=np.array([[0],[w*I]])\n",
      "C=np.linalg.solve(A,B)\n",
      "#Distance travelled\n",
      "s=0.5*C[1]*C[0] #ft\n",
      "t=C[0] #s\n",
      "\n",
      "#Result\n",
      "print'The time required is',round(t,2),\"s\",'and it travels',round(s,2),\"ft\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The time required is 0.83 s and it travels 1.66 ft\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-25, Page No 442"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilisation of variables\n",
      "d=2*12**-1 #ft\n",
      "v=80 #ft/s\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "#Mass flow reate without time\n",
      "m=(1*4**-1)*pi*d**2*v*(62.4/g) \n",
      "#Let P=force of plate on mass m of water\n",
      "P=m*(0-v) #lb\n",
      "\n",
      "#Result\n",
      "print'The force water exerts on the plate is +',round(-P),\"lb,that is,to the right\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The force water exerts on the plate is + 271.0 lb,that is,to the right\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-26, Page No 442"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "v1=20 #ft/s\n",
      "vw=80 #ft/s\n",
      "d=2*12**-1 #ft\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "v=vw-v1 #ft/s\n",
      "#mass flow rate without t\n",
      "m=(4**-1)*(pi*d**2)*(62.4/g)*v\n",
      "#Applying impulse momentum theorem\n",
      "P=m*v #lb\n",
      "\n",
      "#Result\n",
      "print'The force exerted by water on the plate is +',round(P),\"lb,that is,to the right\"\n",
      "\n",
      "# Decimal poinat accuracy causes a small discrepancy in the answer"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The force exerted by water on the plate is + 152.0 lb,that is,to the right\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-27, Page No 443"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "A=2000*10**-6 #m**2\n",
      "v=10 #m/s\n",
      "rho=1000 #kg/m**3\n",
      "#theta=45 degrees,thus\n",
      "cos45=(2**0.5)**-1\n",
      "sin45=(2**0.5)**-1\n",
      "\n",
      "#Calculations\n",
      "#Mass flow \n",
      "m=A*v*rho\n",
      "#Applying impulse momentum theorem\n",
      "Px=m*(-v*cos45-v) #N\n",
      "Py=m*(v*sin45-0) #N\n",
      "\n",
      "#Result\n",
      "print'The x component of force is',round(Px),\"N (to left on water)\",'and y component is +',round(Py),\"N (up on the water)\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The x component of force is -341.0 N (to left on water) and y component is + 141.0 N (up on the water)\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-28, Page No 443"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilisation of variables\n",
      "W=150 #lb\n",
      "v=20 #ft/s\n",
      "A=0.2 #in**2\n",
      "t=60 #s\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "#Mass flow\n",
      "m=(A/12**2)*v*(62.4/g)\n",
      "#Force\n",
      "F=m*(0-v) #lb\n",
      "#At t=60s the tank holds\n",
      "Ww=(A/12**2)*v*t*62.4 #lb\n",
      "#Total reading on scale\n",
      "S=-F+W+Ww #lb\n",
      "\n",
      "#Result\n",
      "print'The scale reading is',round(S),\"lb\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The scale reading is 255.0 lb\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-29, Page No 444"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "Wp=130 #lb\n",
      "Wb=150 #lb\n",
      "Wbullet=2*16**-1 #lb\n",
      "g=32.2 #ft/s**2\n",
      "vbullet=1200 #ft/s\n",
      "\n",
      "#Calculations\n",
      "v=((-Wbullet*g**-1)*vbullet)/((Wb+Wp)/g) #ft/s\n",
      "\n",
      "#Result\n",
      "print'The speed of the boat is',round(v,2),\"ft/s\"\n",
      "#Negative sign indicates direction opposite to that of bullet\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed of the boat is -0.54 ft/s\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-30, Page No 444"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "mb=0.06 #kg\n",
      "ms=50 #kg\n",
      "h=0.03 #m\n",
      "g=9.8 #m/s**2\n",
      "\n",
      "#Calculations\n",
      "#Speed of bag+bullet\n",
      "v2=sqrt(2*g*h) #m/s\n",
      "#Applying conservation of momentum \n",
      "v1=((mb+ms)*v2)/mb #m/s\n",
      "\n",
      "#Result\n",
      "print'The speed of bullet as it entered the bag was',round(v1),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed of bullet as it entered the bag was 640.0 m/s\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-32, Page No 445"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "mb=0.06 #kg\n",
      "vb=500 #m/s\n",
      "mblock=5 #kg\n",
      "vblock=30 #m/s\n",
      "\n",
      "#Calculations\n",
      "#Applying conservation of momentum\n",
      "v=(mb*vb+mblock*vblock)/(mb+mblock) #m/s\n",
      "\n",
      "#Result\n",
      "print'The speed of the system is',round(v,1),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed of the system is 35.6 m/s\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-33, Page No 445"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Initilization of variables\n",
      "W1=2 #lb\n",
      "W2=3 #lb\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "import math\n",
      "from scipy.integrate import quad\n",
      "def integrand(x, a, b):\n",
      "    return 12*(2-x)\n",
      "a=1\n",
      "b=1\n",
      "W=quad(integrand, 0, 2, args=(a,b))\n",
      "Work=W[0]/12 # ft-lb\n",
      "\n",
      "# Solving the simultaneousequations\n",
      "v3=(Work*(0.5*(W2*g**-1)+0.5*(W1*g**-1)*(-W2*W1**-1)**2)**-1)**0.5 #ft/s\n",
      "v2=-(W2*W1**-1)*v3 #ft/s\n",
      "\n",
      "# Results\n",
      "print'The speed of 2lb block is',round(v2,2),\"ft/s (to the left)\",'and that of 3lb block is',round(v3,2),\"ft/s (to the right) respectively.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed of 2lb block is -6.22 ft/s (to the left) and that of 3lb block is 4.14 ft/s (to the right) respectively.\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-34, Page No 445"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "#Here the integration is indefinite hence it will be computed manually and entered\n",
      "W=10 #lb\n",
      "l=4 #ft\n",
      "w=2 #rad/s\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "#Part (a)\n",
      "wf=1.5 #rad/s\n",
      "t=(((W/g)*(l*w*l))-((W/g)*(l*wf*l)))**0.5 #s\n",
      "#Part (b)\n",
      "#Applying conservation of angular momentum\n",
      "r=(l*wf*l)*(l*w)**-1 #ft\n",
      "\n",
      "#Result\n",
      "print'The answer for part (a) is',round(t,2),\"s\",'and the answer for part (b) is',round(r,2),\"ft\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The answer for part (a) is 1.58 s and the answer for part (b) is 3.0 ft\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-35, Page No 446"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "W=2.5 #lb\n",
      "w=36 #rad/s\n",
      "Idisk=0.4 #slug-ft**2\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "Ii=Idisk+(2*(W*g**-1)*(3*12**-1)**2) #slug-ft**2\n",
      "If=Idisk+(2*(W*g**-1)*(11*12**-1)**2) #slug-ft**2\n",
      "#Since no external moments act\n",
      "#Applying conservation of momentum\n",
      "wf=(Ii*w)*If**-1 #rad/s\n",
      "\n",
      "#Result\n",
      "print'The final angular speed is',round(wf,1),\"rad/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The final angular speed is 27.8 rad/s\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-39, Page No 448"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "u1=6 #ft/s\n",
      "u2=-8 #ft/s\n",
      "e=0.8 #coefficient of restitution\n",
      "\n",
      "#Calculations\n",
      "#Solving both simultaneous equations\n",
      "A=np.array([[1,-1],[1,1]])\n",
      "B=np.array([[11.2],[-2]])\n",
      "C=np.linalg.solve(A,B) #ft/s\n",
      "\n",
      "#Result\n",
      "print'The velocities are v1=',round(C[1],1),\"ft/s\",'and v2=',round(C[0],1),\"ft/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocities are v1= -6.6 ft/s and v2= 4.6 ft/s\n"
       ]
      }
     ],
     "prompt_number": 52
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-40, Page No 448"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "h1=20 #m\n",
      "h2=14 #m\n",
      "g=9.8 #m/s**2\n",
      "\n",
      "#Calculations\n",
      "u1=sqrt(2*g*h1) #m/s\n",
      "u2=0 #m/s\n",
      "v1=-sqrt(2*g*h2) #m/s\n",
      "v2=0 #m/s\n",
      "e=(v2-v1)/(u1-u2) #coefficient of restitution\n",
      "\n",
      "#Result\n",
      "print'The value of coefficient of restitution is',round(e,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of coefficient of restitution is 0.84\n"
       ]
      }
     ],
     "prompt_number": 53
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-41, Page No 448"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "u=6.55 #ft/s\n",
      "g=32.2 #ft/s**2\n",
      "L=6 #ft\n",
      "W=5 #lb\n",
      "c=0.7 #fraction of impulse acting in second phase\n",
      "\n",
      "#Calculations\n",
      "#Impulse\n",
      "I=(W*g**-1)*(u*3**-1) #N.s\n",
      "#Second Phase\n",
      "v=((-c*10.9)/2)+u #ft/s\n",
      "wprime=(1.09*60+c*(W*u*(3**-1)*6))/60 #rad/s\n",
      "\n",
      "#Result\n",
      "print'The value is v=',round(v,2),\"ft/s to the right\",' and that of w is',round(wprime,2),\"rad/s counterclockwise.\"\n",
      "\n",
      "#The value of w is incorrect in the textbook\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value is v= 2.73 ft/s to the right  and that of w is 1.85 rad/s counterclockwise.\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-42, Page No 449"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "m1=9 #kg\n",
      "m2=5.5 #kg\n",
      "u1=-3 #m/s\n",
      "u2=1.77 #m/s\n",
      "e=0.8 #coefficient of restitution\n",
      "\n",
      "#Calculations\n",
      "#Solving by matrix method after we get the two equations\n",
      "A=np.array([[-1,1],[m1,m2]])\n",
      "B=np.array([[(e*u1-e*u2)],[m1*u1+m2*u2]])\n",
      "C=np.linalg.solve(A,B) #m/s\n",
      "\n",
      "#Result\n",
      "print'The 9kg ball will rebound up the speed of',round(C[0],2),\"m/s\",'and the 5.5 kg ball will move to the right and down with components of',round(u2,2),\"m/s\",'and',round(-C[1],2),\"m/s respectively.\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The 9kg ball will rebound up the speed of 0.26 m/s and the 5.5 kg ball will move to the right and down with components of 1.77 m/s and 3.56 m/s respectively.\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-46, Page No 451"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "v=4 #m/s\n",
      "m=9 #kg\n",
      "s=1.5 #m\n",
      "\n",
      "#Calculations\n",
      "Io=(2*3**-1)*(m*s**2) #kg.m\n",
      "w=(m*v*s*0.5)/Io #rad/s\n",
      "\n",
      "#Result\n",
      "print'The angular velocity of the box is',round(w),\"rad/s clockwise.\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The angular velocity of the box is 2.0 rad/s clockwise.\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-48, Page No 452"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "m=2000 #kg\n",
      "mf=8500 #kg\n",
      "vr=2000 #m/s\n",
      "a=9.8 #m/s**2\n",
      "\n",
      "#Calculations\n",
      "#Applying Newtons Second Law\n",
      "dm_dt=-(-((m+mf)*a)-(m+mf)*a)/(-vr) #kg/s\n",
      "\n",
      "#Result\n",
      "print'dm/dt=',round(dm_dt),\"kg/s\"\n",
      "#The negative sign indicates the loss in the mass of the system\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "dm/dt= -103.0 kg/s\n"
       ]
      }
     ],
     "prompt_number": 72
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-50, Page No 453"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "W=4000 #lb\n",
      "k=3 #ft\n",
      "wp=(60**-1)*2*pi #rad/s\n",
      "ws=(300/60)*2*pi #rad/s\n",
      "d=3.5 #ft\n",
      "g=32.2 #ft/s**2\n",
      "\n",
      "#Calculations\n",
      "I=(W/g)*k**2 #slug-ft**2\n",
      "M=I*ws*wp #lb-ft\n",
      "#Now equating M to Rf-Rr gives one equations and vertical sum yields other\n",
      "#solving them by matrix method\n",
      "A=np.array([[1,-1],[1,1]])\n",
      "B=np.array([[M*(2/d)],[W]])\n",
      "C=np.linalg.solve(A,B) #lb\n",
      "\n",
      "#Result\n",
      "print'The weight of Rf and Rr are',round(C[0]),\"lb\",'and',round(C[1]),\"lb respectively.\"\n",
      "\n",
      "# The answers in the textbook are incorrect"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The weight of Rf and Rr are 3051.0 lb and 949.0 lb respectively.\n"
       ]
      }
     ],
     "prompt_number": 74
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-51, Page No 454"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#As the integration is indefinite we will directly consider the equation with R\n",
      "#Initillization of variables\n",
      "GM=1.41*10**16 #ft**3/s**2\n",
      "r=2640000 #ft\n",
      "theta=60 #degrees\n",
      "R=21120000 #ft\n",
      "\n",
      "#Calculations\n",
      "v1=sqrt((GM*((R**-1)-((R+r)**-1)))/2.031) #ft/s\n",
      "\n",
      "#Result\n",
      "print'The speed required will be',round(v1),\"ft/s\"\n",
      "\n",
      "# Answer may wary due to decimal point discrepancy."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed required will be 6043.0 ft/s\n"
       ]
      }
     ],
     "prompt_number": 78
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18.18-52, Page No 454"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "k=4 #lb/ft\n",
      "so=1 #ft\n",
      "W=2**-1 #lb\n",
      "g=32.2 #ft/s**2\n",
      "vo=5 #ft/s\n",
      "\n",
      "#Calculations\n",
      "m=W/g #kg\n",
      "#Angular momentum is conserved\n",
      "v=sqrt((0.5*k*so**2*2*2*g)+vo**2) #ft/s\n",
      "#Using vd=15\n",
      "d=15/v #ft\n",
      "\n",
      "#Result\n",
      "print'The ball passes',round(d,2),\"ft close to the fixed pin\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The ball passes 0.89 ft close to the fixed pin\n"
       ]
      }
     ],
     "prompt_number": 26
    }
   ],
   "metadata": {}
  }
 ]
}