{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 10: Chain Rule" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.1, Page number 10.2" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of days is 80.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=120; #number of men\n", "N2=150; #number of men\n", "D1=100; #number of days\n", "\n", "#Calculation\n", "D2=N1*D1/N2; #number of days\n", "\n", "#Result\n", "print \"number of days is\",D2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.2, Page number 10.2" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of men is 15.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=18; #number of men\n", "D1=8; #number of days\n", "D2=6; #number of days\n", "R1=5; #number of hours\n", "R2=8; #number of hours\n", "\n", "#Calculation\n", "N2=N1*D1*R1/(D2*R2); #number of men\n", "\n", "#Result\n", "print \"number of men is\",N2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.3, Page number 10.2" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of days is 10.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=1000; #number of men\n", "D1=12; #number of days\n", "N2=200; #number of men joined\n", "\n", "#Calculation\n", "D2=N1*D1/(N1+N2); #number of days\n", "\n", "#Result\n", "print \"number of days is\",D2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.4, Page number 10.3" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of acres is 72.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=4; #number of men\n", "D1=30; #number of days\n", "D2=12; #number of days\n", "W1=40; #number of acres\n", "N2=18; #number of men\n", "\n", "#Calculation\n", "W2=N2*D2*W1/(D1*N1); #number of acres\n", "\n", "#Result\n", "print \"number of acres is\",W2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.5, Page number 10.3" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of days is 6.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=12; #number of men\n", "D1=25; #number of days\n", "N2=20; #number of men\n", "W1=100*3*0.5; #volume of wall\n", "W2=60*4*0.25; #volume of wall\n", "\n", "#Calculation\n", "D2=N1*D1*W2/(W1*N2); #number of days\n", "\n", "#Result\n", "print \"number of days is\",D2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.6, Page number 10.3" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of days is 30.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=15; #number of men\n", "D1=21; #number of days\n", "N2=14; #number of men\n", "R1=8; #number of hours\n", "R2=6; #number of hours\n", "\n", "#Calculation\n", "D2=N1*D1*R1/(N2*R2); #number of days\n", "\n", "#Result\n", "print \"number of days is\",D2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.7, Page number 10.3" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of days is 5.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=100; #number of men\n", "D2=40-35; #number of days\n", "N2=100; #number of men joined\n", "\n", "#Calculation\n", "D=(N1+N2)*D2/N1;\n", "D1=D-D2; #number of days\n", "\n", "#Result\n", "print \"number of days is\",D1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.8, Page number 10.4" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of additional men is 56.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=104; #number of men\n", "D1=30; #number of days\n", "D=56; #number of days\n", "R1=8; #number of hours\n", "R2=9; #number of hours\n", "W1=2/5; #fraction of work\n", "\n", "#Calculation\n", "D2=D-D1; #number of days\n", "W2=1-W1; #rest of the work\n", "N=N1*D1*R1*W2/(D2*R2*W1);\n", "N2=N-N1; #number of additional men\n", "\n", "#Result\n", "print \"number of additional men is\",N2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.9, Page number 10.4" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of days is 25.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "M1=10; #number of men\n", "D1=40; #number of days\n", "M2=4; #number of men\n", "M3=6; #number of men\n", "D3=50; #number of days\n", "\n", "#Calculation\n", "D2=((M1*D1)-(M3*D3))/M2; #number of days\n", "\n", "#Result\n", "print \"number of days is\",D2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.10, Page number 10.4" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of days is 30.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=4; #number of lorries\n", "D1=8; #number of days\n", "R1=4; #number of tons\n", "R2=3; #number of tons\n", "W1=128; #number of tons\n", "N2=6; #number of lorries\n", "W2=540; #number of tons\n", "\n", "#Calculation\n", "D2=N1*D1*R1*W2/(N2*R2*W1);\n", "N2=N-N1; #number of days\n", "\n", "#Result\n", "print \"number of days is\",D2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.11, Page number 10.4" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of days is 19.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N=250; #number of students\n", "D=30; #number of days \n", "N_1=25; #number of students added\n", "D1=10; #number of days\n", "\n", "#Calculation\n", "N1=N+N_1; #number of students\n", "N2=N; #number of students\n", "D2=((N*D)-(N1*D1))/N2; #number of days\n", "\n", "#Result\n", "print \"number of days is\",D2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.12, Page number 10.5" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of men is 1500.0\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=3000; #number of men\n", "D1=25-11; #number of days\n", "R1=900; #rate per head\n", "D2=10; #number of days\n", "R2=840; #rate per head\n", "\n", "#Calculation\n", "N=N1*D1*R1/(D2*R2); \n", "N2=N-N1; #number of men\n", "\n", "#Result\n", "print \"number of men is\",N2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.13, Page number 10.5" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "required diesel is 1350.0 litres\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=6; #number of diesel engines\n", "D1=5; #number of hours\n", "R1=1/5; \n", "R2=1/8; \n", "W1=900; #number of litres\n", "N2=9; #number of diesel engines\n", "D2=8; #number of hours\n", "\n", "#Calculation\n", "W2=N2*D2*R2*W1/(N1*R1*D1); #required diesel(litres)\n", "\n", "#Result\n", "print \"required diesel is\",W2,\"litres\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.14, Page number 10.5" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "each machine should work 16.0 h/day\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=2; #number of machines\n", "D1=8; #number of days\n", "R1=12; #number of hours/day\n", "E2=80/100; #efficiency \n", "E1=90/100; #efficiency\n", "W1=9000; #tonnes of coal\n", "N2=3; #number of machines\n", "D2=6; #number of days\n", "W2=12000; #tonnes of coal\n", "\n", "#Calculation\n", "R2=N1*D1*R1*E1*W2/(N2*D2*E2*W1); #number of hours/day\n", "\n", "#Result\n", "print \"each machine should work\",R2,\"h/day\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example number 10.15, Page number 10.5" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "amount charged is 300.0 Rs\n" ] } ], "source": [ "#importing modules\n", "import math\n", "from __future__ import division\n", "\n", "#Variable declaration\n", "N1=1; #number of persons\n", "D1=5/2; #number of days\n", "R1=50; #amount(Rs) \n", "R2=42.50; #amount(Rs) \n", "W2=340; #amount(Rs)\n", "N2=1; #number of persons\n", "D2=10/3; #number of days\n", "\n", "#Calculation\n", "W1=N1*D1*R1*W2/(N2*R2*D2); #amount charged(Rs)\n", "\n", "#Result\n", "print \"amount charged is\",W1,\"Rs\"" ] } ], "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.9" } }, "nbformat": 4, "nbformat_minor": 0 }