diff options
-rw-r--r-- | sample_notebooks/Haseen/Chapter3.ipynb | 285 | ||||
-rw-r--r-- | sample_notebooks/MohdRizwan/Chapter2.ipynb | 364 |
2 files changed, 649 insertions, 0 deletions
diff --git a/sample_notebooks/Haseen/Chapter3.ipynb b/sample_notebooks/Haseen/Chapter3.ipynb new file mode 100644 index 00000000..c683fff5 --- /dev/null +++ b/sample_notebooks/Haseen/Chapter3.ipynb @@ -0,0 +1,285 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3 Elementry Operations in Algebra" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_5 pgno:33" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3x**4/6x**6\n" + ] + } + ], + "source": [ + "#3x**4/6x**6\n", + "\n", + "x=('x')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convince poly(0,'a');poly(0,'x');\n", + "p1='3*x**4';\n", + "p2='6*x**6';\n", + "#p=p1/p2\n", + "print '3x**4/6x**6'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_6 pgno:34" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "val=8*x/15\n" + ] + } + ], + "source": [ + "#x/3 + x/5\n", + "\n", + "x=('x')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convince poly(0,'a');poly(0,'x');poly(0,'x');\n", + "p1='x/3';\n", + "p2='x/5';\n", + "p=p1+p2;\n", + "q='8*x/15';\n", + "if(p==q):\n", + " print\"val=8*x/15 \\n\"\n", + "print\"val=8*x/15\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_9 pgno:35" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ans=\n", + "(a+b)/k 8 25 60\n" + ] + } + ], + "source": [ + "#2a/15 + 5b/12\n", + "\n", + "\n", + "d=60#\"L.C.M of denominators\"\n", + "k=d;\n", + "a_coeff=60/15*2;\n", + "b_coeff=60/12*5;\n", + "print'ans='\n", + "print\"(a+b)/k\",a_coeff,b_coeff,k" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_10 pgno:35" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ans=\n", + "(bx-ay)/a**2b**2 3 2 36\n" + ] + } + ], + "source": [ + "#x/12a**2b - y/18ab**2\n", + "\n", + "k=36#lcm(d);#L.C.M of denominators\n", + "\n", + "#\"L.C.M of a**2*b and a*b**2 is a**2*b**2\"\n", + "x_coeff=36/12;\n", + "y_coeff=36/18;\n", + "print'ans='\n", + "print\"(bx-ay)/a**2b**2\",x_coeff,y_coeff,k" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_11 pgno:36" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "val=\n", + "/*x**2/y**2 2 3\n" + ] + } + ], + "source": [ + "#4*x**3*y/(6*x*y**3)\n", + "\n", + "gcd_d=1#GCD of 4 and 6 is 2\n", + "m=4/gcd_d\n", + "n=6/gcd_d\n", + "x=1#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');\n", + "y=1#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'y');\n", + "p1=x**3;p2=x;p=p1/p2;\n", + "q1=y;q2=y**3;q=q1/q2;\n", + "#val=m/n*p*q \n", + "print'val='\n", + "print\"/*x**2/y**2\",m/2,n/2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_12 pgno:36" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "val=\n", + "*x**2*y/a**3 0.285714285714\n" + ] + } + ], + "source": [ + "#6*a*x**4*2*y**3/(14*x**2*y**2*3*a**4)\n", + "\n", + "\n", + "x=('x')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'x');\n", + "y=('y')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'y');\n", + "a=('a')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'a');\n", + "num=6.*2./(14.*3.);\n", + "p1='x**4';p2='x**2';p='p1/p2';\n", + "q1='y**3';q2='y**2';q='q1/q2';\n", + "r1='a';r2='a**4';r='r1/r2';\n", + "#val=num*p*q*r\n", + "print'val='\n", + "print\"*x**2*y/a**3\",num" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_13 pgno:36" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "val=\n", + "*x/(a*y) 1.2\n" + ] + } + ], + "source": [ + "#(8x**3)/(5a**2y) *(3a)/(4x**2)\n", + "\n", + "\n", + "x=('x')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'x');\n", + "y=('y')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'y');\n", + "a=('a')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'a');\n", + "p1='x**3';p2='x**2';p='p1/p2';\n", + "q='1/y';\n", + "r1='a';r2='a**2';r='r1/r2';\n", + "num=8.*3./(5.*4.);\n", + "#val=num*p*q*r\n", + "print('val=')\n", + "print\"*x/(a*y)\",num" + ] + } + ], + "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 +} diff --git a/sample_notebooks/MohdRizwan/Chapter2.ipynb b/sample_notebooks/MohdRizwan/Chapter2.ipynb new file mode 100644 index 00000000..39ad283e --- /dev/null +++ b/sample_notebooks/MohdRizwan/Chapter2.ipynb @@ -0,0 +1,364 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapater 2 - Ohm's Law " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3,Page number: 19" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The voltage across resistor 1 is: 12 V.\n", + "The voltage across resistor 2 is: 12 V.\n", + "The voltage across resistor 3 is: 16 V.\n", + "The voltage across resistor 4 is: 8 V.\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "#Variable Declaration:\n", + "Req=(8.0*12)/(8+12) #Equivalent Resistance of the circuit(in Ohms)\n", + "I=5 #Current in the circuit(in Amperes) \n", + "\n", + "\n", + "#Calculations:\n", + "V=I*Req\n", + "V1=(4.0*V)/(4+4)\n", + "V2=(4.0*V)/(4+4)\n", + "V3=(8.0*V)/(8+4)\n", + "V4=(4.0*V)/(8+4)\n", + "\n", + "\n", + "#Result:\n", + "print \"The voltage across resistor 1 is: %d V.\" % (V1)\n", + "print \"The voltage across resistor 2 is: %d V.\" % (V2)\n", + "print \"The voltage across resistor 3 is: %d V.\" % (V3)\n", + "print \"The voltage across resistor 4 is: %d V.\" % (V4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.4,Page number:20" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The current i1= 2.00 A.\n", + "The current i2= 1.20 A.\n", + "The current i3= 0.80 A.\n", + "The voltage v1= 4.00 V.\n", + "The voltage v2= 4.80 V.\n", + "The voltage v3= 4.80 V.\n", + "\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "#Variable Declaration:\n", + "I=2.0 #Current in Circuit(in Amperes)\n", + "R1=2.0 #Resistance of resistor 1(in Ohms) \n", + "R2=4.0 #Resistance of resistor 2(in Ohms)\n", + "R3=6.0 #Resistance of resistor 3(in Ohms)\n", + "\n", + "\n", + "#Calculations:\n", + "Rp=1/((1/R2)+(1/R3))\n", + "Req=R1+Rp\n", + "Vs=I*Req\n", + "v1=Vs*(R1/(R1+Rp))\n", + "v2=Vs*(Rp/(R1+Rp))\n", + "v3=v2\n", + "i1=I\n", + "i2=v2/R2\n", + "i3=v3/R3\n", + "\n", + "\n", + "#Result:\n", + "print \"The current i1= %.2f A.\\nThe current i2= %.2f A.\\nThe current i3= %.2f A.\" %(i1,i2,i3)\n", + "print \"The voltage v1= %.2f V.\\nThe voltage v2= %.2f V.\\nThe voltage v3= %.2f V.\\n\" %(v1,v2,v3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5,Page number: 23" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)The effective resistance between points A and B for the combination of resistances is R_AB = 20.00 Ohms.\n", + "(b)The effective resistance between points A and B for the combination of resistances is R_AB = 0.4545*R Ohms.\n", + "(c)The effective resistance between points A and B for the combination of resistances is R_AB = 15.00 Ohms.\n" + ] + } + ], + "source": [ + "from sympy import symbols\n", + "from __future__ import division\n", + "#Calculations:\n", + "Rp=1.0/((1.0/20)+(1.0/10)+(1.0/20))\n", + "R_AB_1=15+Rp\n", + "R = symbols('R')\n", + "R1=1.0/((1.0/2.0)+1.0)+ 1.0\n", + "R2=R1\n", + "R_AB_2= 1.0/((1/R1)+(1/R2)+(1))\n", + "R_AB_b=round(R_AB_2,4)*R\n", + "R3=1.0/((1.0/3)+(1.0/6)) + 18\n", + "R_AB_3= 1.0/((1.0/20)+(1/R3)) + 5\n", + "\n", + "\n", + "#Result:\n", + "print \"(a)The effective resistance between points A and B for the combination of resistances is R_AB = %.2f Ohms.\" %(R_AB_1)\n", + "print \"(b)The effective resistance between points A and B for the combination of resistances is R_AB = %s Ohms.\" %(R_AB_b)\n", + "print \"(c)The effective resistance between points A and B for the combination of resistances is R_AB = %.2f Ohms.\" %(R_AB_3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.6,Page number: 24" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The current I1= 5.00 A.\n", + "The current I2= 3.00 A.\n", + "The current I3= 2.00 A.\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "#Variable Declaration:\n", + "V=100 #Voltage of the DC source(in Volts) \n", + "\n", + "\n", + "#Calculations:\n", + "Reff= 2+ (1.0/((1.0/12)+(1.0/20)+(1.0/30)))+2\n", + "I=V/Reff\n", + "\n", + "#Applying Ohm's Law, we have 12*I1=20*I2=30*I3;\n", + " \n", + "#I2=0.6*I1; I3=0.4*I1 \"\"\"\n", + "\n", + "I1=I/(0.6+0.4+1)\n", + "I2=0.6*I1\n", + "I3=0.4*I1\n", + "\n", + "\n", + "#Result:\n", + "\n", + "print \"The current I1= %.2f A.\\nThe current I2= %.2f A.\\nThe current I3= %.2f A.\" %(I1,I2,I3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.7,Page number: 25" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The supply current( I ) is 3 A.\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "from __future__ import division\n", + "#Variable Declaration:\n", + "P=20.0 #Power dissipated by resistor(in Watts)\n", + "RL=5.0 #Resistance of the load resistor(in Ohms)\n", + "R=10.0 #Resistance of resistor(in Ohms)\n", + "\n", + "\n", + "#Calculations:\n", + "I1=sqrt(P/RL)\n", + "I=(I1*(R+RL))/R\n", + "\n", + "\n", + "#Result:\n", + "\n", + "print \"The supply current( I ) is %d A.\"%(I)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.8,Page number:25" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The voltage across bulb A is 80.00 V. \n", + "The voltage across bulb B is 40.00 V. \n", + "The voltage across bulb C is 40.00 V.\n", + "The total power dissipated in the three bulbs is 40.00 W.\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "#Variable Declaration:\n", + "V=120.0 #Voltage of the power line(in Volts)\n", + "P_bulb=60.0 #Power rating of the bulb(in Watts)\n", + "V_bulb=120.0 #Voltage rating of the bulb(in Volts)\n", + "\n", + "\n", + "#Calculations:\n", + "R=(V_bulb*V_bulb)/P_bulb\n", + "R_A=R\n", + "R_B=R\n", + "R_C=R\n", + "R_BC=1.0/((1.0/R)+(1.0/R))\n", + "V_B=V*(R_BC/(R_BC+R_A)) \n", + "V_C=V*(R_BC/(R_BC+R_A))\n", + "V_A=V-V_B\n", + "P_A=(V_A*V_A)/R_A \n", + "P_B=(V_B*V_B)/R_B\n", + "P_C=(V_C*V_C)/R_C\n", + "P=P_A+P_B+P_C\n", + "\n", + "\n", + "#Result:\n", + "print \"The voltage across bulb A is %.2f V. \\nThe voltage across bulb B is %.2f V. \\nThe voltage across bulb C is %.2f V.\" %(V_A,V_B,V_C)\n", + "print \"The total power dissipated in the three bulbs is %.2f W.\" %(P)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.9,Page number: 26" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)Minimum value of Req is obtained when R=0(i.e.,a short circuit,because the parallel combination of R2 and R is reduced to 0).\n", + " Maximum value of Req is obtained when R is an open ciruit.\n", + " Hence, R1 = 30.00 Ohms and R2 = 45.00 Ohms. \n", + " \n", + "(b)The resistance R to give Req=(30+75)/2 ohm is R = 45.00 Ohms.\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "#Variable Declaration:\n", + "R1=30.0 #Resistance of the resistor(in Ohms)\n", + "\n", + "\n", + "#Calculations:\n", + "R2=75-R1\n", + "Req=(30+75)/2.0\n", + "Rp=Req-R1\n", + "R=1/((1/Rp)-(1/R2))\n", + "\n", + "#Result:\n", + "print \"(a)Minimum value of Req is obtained when R=0(i.e.,a short circuit,because the parallel combination of R2 and R is reduced to 0).\" \n", + "print \" Maximum value of Req is obtained when R is an open ciruit.\\n Hence, R1 = %.2f Ohms and R2 = %.2f Ohms. \\n \" %(R1,R2)\n", + "print \"(b)The resistance R to give Req=(30+75)/2 ohm is R = %.2f Ohms.\" %(R)" + ] + } + ], + "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 +} |