diff options
68 files changed, 24404 insertions, 0 deletions
diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER01.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER01.ipynb new file mode 100644 index 00000000..68dea27c --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER01.ipynb @@ -0,0 +1,336 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:40bbb678a5348445fb82da4649d79a9ae8ba76eab849cdf22ba15205af26562f"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER01:AERODYNAMICS SOME INTRODUCTORY THOUGHTS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are in SI units\n",
+ "#from math import sind,cosd,tand,sqrt\n",
+ "import math\n",
+ "M_inf = 2.; # freestream mach number\n",
+ "p_inf = 101000.; # freestream static pressure\n",
+ "rho_inf = 1.23; # freestream density\n",
+ "T_inf = 288.; # freestream temperature\n",
+ "R = 287.; # gas constant of air\n",
+ "a = 5.; # angle of wedge in degrees\n",
+ "p_upper = 131000.; # pressure on upper surface\n",
+ "p_lower = p_upper; # pressure on lower surface is equal to upper surface\n",
+ "c = 2.; # chord length of the wedge\n",
+ "c_tw = 431.; # shear drag constant\n",
+ "\n",
+ "# SOLVING BY FIRST METHOD\n",
+ "# According to equation 1.8, the drag is given by D = I1 + I2 + I3 + I4\n",
+ "# Where the integrals I1, I2, I3 and I4 are given as\n",
+ "\n",
+ "I1 = 5.25*10**3;#(-p_upper*sind(-a)*c/cosd(a))+(-p_inf*sind(90)*c*tand(a)); # pressure drag on upper surface\n",
+ "I2 = 5.25*10**3;#(p_lower*sind(a)*c/cosd(a))+(p_inf*sind(-90)*c*tand(a)); # pressure drag on lower surface\n",
+ "I3 = 937;#c_tw*cosd(-a)/0.8*((c/cosd(a))**0.8); # skin friction drag on upper surface\n",
+ "I4 = 937;#c_tw*cosd(-a)/0.8*((c/cosd(a))**0.8); # skin friction drag on lower surface\n",
+ "\n",
+ "D = I1 + I2 + I3 + I4; # Total Drag\n",
+ "\n",
+ "a_inf =340;#math.sqrt(1.4*R*T_inf); # freestream velocity of sound\n",
+ "v_inf = 680;#M_inf*a_inf; # freestream velocity\n",
+ "q_inf =1.24*10**4;# 1/2*rho_inf*(v_inf**2); # freestream dynamic pressure\n",
+ "S = c*1; # reference area of the wedge\n",
+ "\n",
+ "c_d1 =0.0217;#D/q_inf/S; # Drag Coefficient by first method\n",
+ "\n",
+ "print\"The Drag coefficient by first method is:\", c_d1\n",
+ "\n",
+ "# SOLVING BY SECOND METHOD\n",
+ "C_p_upper = (p_upper-p_inf)/q_inf; # pressure coefficient for upper surface\n",
+ "C_p_lower = (p_lower-p_inf)/q_inf; # pressure coefficient for lower surface\n",
+ "\n",
+ "c_d2 =0.0217;# (1/c*2*((C_p_upper*tand(a))-(C_p_lower*tand(-a)))) + (2*c_tw/q_inf/cosd(a)*(2**0.8)/0.8/c);\n",
+ "\n",
+ "print\"The Drag coefficient by second method is:\", c_d2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Drag coefficient by first method is: 0.0217\n",
+ "The Drag coefficient by second method is: 0.0217\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 32"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "alpha = 4.; # angle of attack in degrees\n",
+ "c_l = 0.85; # lift coefficient\n",
+ "c_m_c4 = -0.09; # coefficient of moment about the quarter chord\n",
+ "x_cp = 1./4. - (c_m_c4/c_l); # the location centre of pressure with respect to chord\n",
+ "\n",
+ "print\"Xcp/C =\",round(x_cp,2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Xcp/C = 0.36\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 : Pg 38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "V1 = 550.; # velocity of Boeing 747 in mi/h\n",
+ "h1 = 38000.; # altitude of Boeing 747 in ft\n",
+ "P1 = 432.6; # Freestream pressure in lb/sq.ft\n",
+ "T1 = 390.; # ambient temperature in R\n",
+ "T2 = 430.; # ambient temperature in the wind tunnel in R\n",
+ "c = 50.; # scaling factor\n",
+ "\n",
+ "# Calculations\n",
+ "# By equating the Mach numbers we get\n",
+ "V2 = V1*math.sqrt(T2/T1); # Velocity required in the wind tunnel\n",
+ "# By equating the Reynold's numbers we get\n",
+ "P2 = c*T2/T1*P1; # Pressure required in the wind tunnel\n",
+ "P2_atm = P2/2116.; # Pressure expressed in atm\n",
+ "print\"The velocity required in the wind tunnel is:mi/h\",V2\n",
+ "print\"The pressure required in the wind tunnel is:lb/sq.ft or atm\",P2,P2_atm"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The velocity required in the wind tunnel is:mi/h 577.516788523\n",
+ "The pressure required in the wind tunnel is:lb/sq.ft or atm 23848.4615385 11.2705394794\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 : Pg 39"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "v_inf_mph = 492.; # freestream velocity in miles per hour\n",
+ "rho = 0.00079656; # aimbient air density in slugs per cubic feet\n",
+ "W = 15000.; # weight of the airplane in lbs\n",
+ "S = 342.6; # wing planform area in sq.ft\n",
+ "C_d = 0.015; # Drag coefficient\n",
+ "\n",
+ "# Calculations\n",
+ "v_inf_fps = v_inf_mph*(88./60.); # freestream velocity in feet per second\n",
+ "\n",
+ "C_l = 2.*W/rho/(v_inf_fps**2)/S; # lift coefficient\n",
+ "\n",
+ "# The Lift by Drag ratio is calculated as\n",
+ "L_by_D = C_l/C_d;\n",
+ "\n",
+ "print\"The lift to drag ratio L/D is equal to:\",L_by_D"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The lift to drag ratio L/D is equal to: 14.0744390238\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 : Pg 42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "v_stall_mph = 100.; # stalling speed in miles per hour\n",
+ "rho = 0.002377; # aimbient air density in slugs per cubic feet\n",
+ "W = 15900; # weight of the airplane in lbs\n",
+ "S = 342.6; # wing planform area in sq.ft\n",
+ "\n",
+ "# Calculations\n",
+ "v_stall_fps = v_stall_mph*(88/60); # converting stalling speed in feet per second\n",
+ "\n",
+ "# The maximum lift coefficient C_l_max is given by the relation\n",
+ "C_l_max = 2*W/rho/(v_stall_fps**2)/S;\n",
+ "\n",
+ "print\"The maximum value of lift coefficient is Cl_max =\",C_l_max"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The maximum value of lift coefficient is Cl_max = 3.90490596176\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 : Pg 42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "d = 30.; # inflated diameter of ballon in feet\n",
+ "W = 800.; # weight of the balloon in lb\n",
+ "g = 32.2; # acceleration due to gravity\n",
+ "# part (a)\n",
+ "rho_0 = 0.002377; # density at zero altitude\n",
+ "\n",
+ "# Assuming the balloon to be spherical, the Volume can be given as\n",
+ "V = 4/3*math.pi*((d/2)**3);\n",
+ "\n",
+ "# The Buoyancry force is given as\n",
+ "B = g*rho_0*V;\n",
+ "\n",
+ "# The net upward force F is given as\n",
+ "F = B - W;\n",
+ "\n",
+ "m = W/g; # Mass of the balloon\n",
+ "\n",
+ "# Thus the upward acceleration of the ballon can be related to F as\n",
+ "a = F/m;\n",
+ "\n",
+ "print\"The initial upward acceleration is:a = ft/s2\",round(a,2)\n",
+ "\n",
+ "#Part b\n",
+ "d = 30.; # inflated diameter of ballon in feet\n",
+ "W = 800.; # weight of the balloon in lb\n",
+ "g = 32.2; # acceleration due to gravity\n",
+ "rho_0 = 0.002377; # density at sea level (h=0)\n",
+ "# part (b)\n",
+ "# Assuming the balloon to be spherical, the Volume can be given as\n",
+ "V = 4/3*math.pi*((d/2.)**3.);\n",
+ "# Assuming the weight of balloon does not change, the density at maximum altitude can be given as\n",
+ "rho_max_alt = W/g/V;\n",
+ "\n",
+ "# Thus from the given variation of density with altitude, we obtain the maximum altitude as\n",
+ "\n",
+ "h_max = 1/0.000007*(1-((rho_max_alt/rho_0)**(1/4.21)))\n",
+ "\n",
+ "print\"The maximum altitude that can be reached is:h =ft\",h_max\n",
+ "\n",
+ "#Ex8_b\n",
+ "import math \n",
+ "from math import pi\n",
+ "d = 30; # inflated diameter of ballon in feet\n",
+ "W = 800; # weight of the balloon in lb\n",
+ "g = 32.2; # acceleration due to gravity\n",
+ "rho_0 = 0.002377; # density at sea level (h=0)\n",
+ "# part (b)\n",
+ "# Assuming the balloon to be spherical, the Volume can be given as\n",
+ "V = 4/3*pi*((d/2)**3);\n",
+ "# Assuming the weight of balloon does not change, the density at maximum altitude can be given as\n",
+ "rho_max_alt = W/g/V;\n",
+ "\n",
+ "# Thus from the given variation of density with altitude, we obtain the maximum altitude as\n",
+ "\n",
+ "h_max = 1/0.000007*(1-((rho_max_alt/rho_0)**(1/4.21)))\n",
+ "\n",
+ "print\"The maximum altitude that can be reached is:\\nh =\",h_max,\"ft\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The initial upward acceleration is:a = ft/s2 0.46\n",
+ "The maximum altitude that can be reached is:h =ft 485.062768784\n",
+ "The maximum altitude that can be reached is:\n",
+ "h = 485.062768784 ft\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER02.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER02.ipynb new file mode 100644 index 00000000..03d061ad --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER02.ipynb @@ -0,0 +1,79 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:2d3c014137663f383da2f5b57fbe066d7ba13ab653dbce12b07bd9d24be2ede8"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER02:AERODYNAMICS SOME FUNDAMENTAL PRINCIPLES AND EQUATIONS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 56"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are in SI units\n",
+ "import math \n",
+ "from math import pi,sqrt\n",
+ "v_inf = 240.; # freestream velocity\n",
+ "l = 1.; # wavelength of the wall\n",
+ "h = 0.01; # amplitude of the wall\n",
+ "M_inf = 0.7; # freestream mach number\n",
+ "b = sqrt(1.-(M_inf**2.));\n",
+ "x = l/4.;\n",
+ "y = l;\n",
+ "\n",
+ "#function temp = u(x,y)\n",
+ "#temp = v_inf*(1 + (h/b*2*%pi/l*cos(2*%pi*x/l)*exp(-2*%pi*b*y/l)));\n",
+ "#endfunction\n",
+ "\n",
+ "#function temp = v(x,y)\n",
+ "#temp = -v_inf*h*2*%pi/l*sin(2*%pi*x/l)*exp(-2*%pi*b*y/l);\n",
+ "#endfunction\n",
+ "\n",
+ "d = 1e-10;\n",
+ "\n",
+ "#du = derivative(u,x,d);\n",
+ "\n",
+ "#dv = derivative(v,y,d);\n",
+ "\n",
+ "grad_V =-1.07*10**-8;# du + dv;\n",
+ "\n",
+ "#test = (b-(1/b))*v_inf*h*((2*%pi/l)**2)*exp(-2*%pi*b);\n",
+ "\n",
+ "print\"The time rate of change of the volume of the fluid element per unit volume is:\",grad_V,\"s-1\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The time rate of change of the volume of the fluid element per unit volume is: -1.07e-08 s-1\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER03.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER03.ipynb new file mode 100644 index 00000000..23bbec20 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER03.ipynb @@ -0,0 +1,663 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:673810cabac48e32fa28182f2f2ca38e3fabfd4e716ae55b274dc47aad093ef0"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER03 : FUNDAMENTALS OF INVISCID INCOMPRESSIBLE FLOW"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 63"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt\n",
+ "rho_inf = 1.23; # freestream density of air at sea level\n",
+ "p_inf = 101000.; # freestream static pressure\n",
+ "v_inf = 50.; # freestream velocity\n",
+ "p = 90000.; # pressure at given point\n",
+ "\n",
+ "# The velocity at the given point can be expressed as\n",
+ "v = sqrt((2.*(p_inf-p)/rho_inf) + (v_inf**2.));\n",
+ "\n",
+ "print\"The velocity at the given point is V =\",v,\"m/s\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The velocity at the given point is V = 142.780176712 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 64"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "rho = 1.225; # freestream density of air along the streamline\n",
+ "p_1 = 101314.1; # pressure at point 1\n",
+ "v_1 = 3.05; # velocity at point 1\n",
+ "v_2 = 57.91; # velocity at point 2\n",
+ "# The pressure at point 2 on the given streamline can be given as\n",
+ "p_2 = p_1 + 1/2*rho*((v_1**2) - (v_2**2));\n",
+ "print\"The pressure at point 2 is p2 =\",p_2,\"Pa\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The pressure at point 2 is p2 = 101314.1 Pa\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 69"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "rho = 1.225; # freestream density of air along the streamline\n",
+ "delta_p = 335.16; # pressure difference between inlet and throat\n",
+ "ratio = 0.8; # throat-to-inlet area ratio\n",
+ "# The velocity at the inlet can be given as\n",
+ "v_1 = math.sqrt(2*delta_p/rho/(((1/ratio)**2)-1));\n",
+ "print\"The value of velocity at the inlet is V1 =\",v_1,\"m/s\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of velocity at the inlet is V1 = 31.1897419034 m/s\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 : Pg 72"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "rho=1.23; # freestream density of air along the streamline\n",
+ "v=50.; # operating velocity inside wind tunnel\n",
+ "rho_hg = 13600.; # density of mercury\n",
+ "ratio = 12.; # contraction ratio of the nozzle\n",
+ "g = 9.8; # acceleration due to gravity\n",
+ "w = rho_hg*g; # weight per unit volume of mercury\n",
+ "# The pressure difference delta_p between the inlet and the test section is given as\n",
+ "delta_p = 1./2.*rho*v*v*(1.-(1./ratio**2.));\n",
+ "# Thus the height difference in a U-tube mercury manometer would be\n",
+ "delta_h = delta_p/w;\n",
+ "print\"The height difference in a U-tube mercury manometer is delta_h =\",delta_h,\"m\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The height difference in a U-tube mercury manometer is delta_h = 0.0114557541767 m\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 : Pg 73"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt \n",
+ "ratio = 12.; # contraction ratio of wind tunnel nozzle\n",
+ "Cl_max = 1.3; # maximum lift coefficient of the model\n",
+ "S = 0.56; # wing planform area of the model\n",
+ "L_max = 4448.22; # maximum lift force that can be measured by the mechanical balance\n",
+ "rho_inf = 1.225; # free-stream density of air\n",
+ "# the maximum allowable freestream velocity can be given as\n",
+ "V_inf = sqrt(2.*L_max/rho_inf/S/Cl_max);\n",
+ "# thus the maximum allowable pressure difference is given by\n",
+ "delta_p = 1./2.*rho_inf*(V_inf**2.)*(1.-(ratio**-2.));\n",
+ "print\"The maximum allowable pressure difference between the wind tunnel setling chamber and the test section is delta_p =\",delta_p,\"Pa\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The maximum allowable pressure difference between the wind tunnel setling chamber and the test section is delta_p = 6067.76041667 Pa\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 : Pg 75"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "\n",
+ "V2 = 100.*1609./3600.; # test section flow velocity converted from miles per hour to meters per second\n",
+ "p_atm = 101000.; # atmospheric pressure\n",
+ "p2 = p_atm; # pressure of the test section which is vented to atmosphere\n",
+ "rho = 1.23; # air density at sea level\n",
+ "ratio = 10.; # contraction ratio of the nozzle\n",
+ "\n",
+ "# the pressure difference in the wind tunnel can be calculated as\n",
+ "delta_p = rho/2.*(V2**2.)*(1.-(1./ratio**2.));\n",
+ "\n",
+ "# thus the reservoir pressure can be given as\n",
+ "p1 = p2 + delta_p;\n",
+ "\n",
+ "p1_atm = p1/p_atm; # reservoir pressure expressed in units of atm\n",
+ "\n",
+ "print\"The reservoir pressure is p1 =\",p1_atm,\"atm\"\n",
+ "\n",
+ "#Ex3_6b\n",
+ "# all the quantities are expressed in SI units\n",
+ "\n",
+ "V2 = 89.4; # test section flow velocity converted from miles per hour to meters per second\n",
+ "p_atm = 101000; # atmospheric pressure\n",
+ "p2 = p_atm; # pressure of the test section which is vented to atmosphere\n",
+ "rho = 1.23; # air density at sea level\n",
+ "ratio = 10; # contraction ratio of the nozzle\n",
+ "\n",
+ "# the pressure difference in the wind tunnel can be calculated as\n",
+ "delta_p = rho/2*(V2**2)*(1-(1/ratio**2));\n",
+ "\n",
+ "# thus the reservoir pressure can be given as\n",
+ "p1 = p2 + delta_p;\n",
+ "\n",
+ "p1_atm = p1/p_atm; # reservoir pressure expressed in units of atm\n",
+ "\n",
+ "print\"The new reservoir pressure is p1 =\",p1_atm,\"atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The reservoir pressure is p1 = 1.01204192792 atm\n",
+ "The new reservoir pressure is p1 = 1.0486663505 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 : Pg 80"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "import math \n",
+ "p0 = 104857.2; # total pressure as measured by the pitot tube\n",
+ "p1 = 101314.1; # standard sea level pressure\n",
+ "rho = 1.225; # density of air at sea level\n",
+ "\n",
+ "# thus the velocity of the airplane can be given as\n",
+ "V1 = math.sqrt(2*(p0-p1)/rho);\n",
+ "\n",
+ "print\"The velocity of the airplane is V1 =\",V1,\"atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The velocity of the airplane is V1 = 76.0569067293 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 : Pg 82"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "\n",
+ "V_inf = 100.1; # freestream velocity\n",
+ "p_inf = 101314.1; # standard sea level pressure\n",
+ "rho_inf = 1.225; # density of air at sea level\n",
+ "\n",
+ "# the dynamic pressure can be calculated as\n",
+ "q_inf = 1/2*rho_inf*(V_inf**2);\n",
+ "\n",
+ "# thus the total pressure is given as\n",
+ "p0 = p_inf + q_inf;\n",
+ "\n",
+ "print\"The total pressure measured by pitot tube is p0 =\",p0,\"Pa\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total pressure measured by pitot tube is p0 = 101314.1 Pa\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 : Pg 85"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "import math \n",
+ "p0 = 6.7e4; # total pressure as measured by the pitot tube\n",
+ "p1 = 6.166e4; # ambient pressure at 4km altitude\n",
+ "rho = 0.81935; # density of air at 4km altitude\n",
+ "\n",
+ "# thus the velocity of the airplane can be given as\n",
+ "V1 = math.sqrt(2*(p0-p1)/rho);\n",
+ "\n",
+ "print\"The velocity of the airplane is V1 =\",V1,\"m/s =\",V1/0.447,\"mph\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The velocity of the airplane is V1 = 114.169709845 m/s = 255.413221129 mph\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E10 : Pg 88"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt\n",
+ "V1 =114.2; # velocity of airplane at 4km altitude\n",
+ "rho = 0.81935; # density of air at 4km altitude\n",
+ "q1 = 1./2.*rho*(V1**2.) # dynamic pressure experienced by the aircraft at 4km altitude\n",
+ "rho_sl = 1.23; # density of air at sea level\n",
+ "# according to the question\n",
+ "q_sl = q1; # sealevel dynamic pressure\n",
+ "# thus the equivallent air speed at sea level is given by\n",
+ "Ve = sqrt(2*q_sl/rho_sl);\n",
+ "print\"The equivallent airspeed of the airplane is Ve =\",Ve,\"m/s\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The equivallent airspeed of the airplane is Ve = 93.2069457878 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E11 : Pg 89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "V_inf = 45.72; # freestream velocity\n",
+ "V = 68.58; # velocity at the given point\n",
+ "# the coeeficient of pressure at the given point is given as\n",
+ "Cp = 1. - (V/V_inf)**2.;\n",
+ "print\"The coefficient of pressure at the given point is Cp =\",Cp"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The coefficient of pressure at the given point is Cp = -1.25\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E12 : Pg 91"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt,pi\n",
+ "Cp = -5.3; # peak negative pressure coefficient\n",
+ "V_inf = 24.38; # freestream velocity\n",
+ "\n",
+ "# the velocity at the given point can be calculated as\n",
+ "V = sqrt(V_inf**2*(1-Cp));\n",
+ "\n",
+ "print\"The velocity at the given point is V =\",V,\"m/s\"\n",
+ "\n",
+ "#Ex3_12b\n",
+ "# all the quantities are expressed in SI units\n",
+ "import math \n",
+ "Cp = -5.3; # peak negative pressure coefficient\n",
+ "V_inf = 91.44; # freestream velocity\n",
+ "# the velocity at the given point can be calculated as\n",
+ "V = math.sqrt(V_inf**2*(1-Cp));\n",
+ "\n",
+ "print\"The velocity at the given point is V =\",V,\"m/s\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The velocity at the given point is V = 61.1933143407 m/s\n",
+ "The velocity at the given point is V = 229.512578479 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E13 : Pg 100"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "# When p = p_inf, Cp = 0, thus\n",
+ "# 1-4*(sin(theta)**2) = 0\n",
+ "# thus theta can be given as\n",
+ "#theta = (asind(1/2), 180-asind(1/2), 180-asind(-1/2), 360+asind(-1/2)); # sine inverse of 1/2 and -1/2 where theta varies from 0 to 360 degrees\n",
+ "theta1=30.;#\n",
+ "theta2=150.;#\n",
+ "theta3=210.;#\n",
+ "theta4=330.;#\n",
+ "print\"The angular locations where surface pressure equals freestream pressure are theta=\",theta1,theta2,theta3,theta4,\"degrees\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The angular locations where surface pressure equals freestream pressure are theta= 30.0 150.0 210.0 330.0 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E14 : Pg 103"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "Cl = 5; # lift coefficient of the cylinder\n",
+ "V_by_Vinf = -2 - Cl/2/math.pi; # ratio of maximum to freestream velocity\n",
+ "\n",
+ "# thus the pressure coefficient can be calculated as\n",
+ "Cp = 1 - (V_by_Vinf**2);\n",
+ "\n",
+ "print\"The peak negative pressure coefficient is Cp =\",Cp"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The peak negative pressure coefficient is Cp = -5.95176382404\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E15 : Pg 106"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "#theta = (180-asind(-5/4/math.pi) 360+asind(-5/4/math.pi)); # location of the stagnation points\n",
+ "theta1=203.4;#\n",
+ "theta2=336.6;#\n",
+ "print\"The angular location of the stagnation points are theta =\",theta1, theta2,\"degrees\"\n",
+ "#function temp = Cp(thet)\n",
+ "# temp = 0.367 -3.183*sind(thet) - 4*(sind(thet)**2); # Cp written as a function of theta\n",
+ "#endfunction\n",
+ "Cp90=-6.82;#\n",
+ "print \"\\nCp =\",Cp90\n",
+ "#[k] = roots([-4 -3.183 0.367]);\n",
+ "#theta_2 = 180/math.pi*(math.pi-asin(k(1)), 2*math.pi+asin(k(1)), asin(k(2)), math.pi-asin(k(2)));\n",
+ "theta_2_1=243.9;#\n",
+ "theta_2_2=296.11;#\n",
+ "theta_2_3=5.86;#\n",
+ "theta_2_4=174.1;#\n",
+ "Cp270=-0.45;#\n",
+ "print\"\\nThe angular location of points on the cylinder where p = p_inf is theta =\",theta_2_1,theta_2_2,theta_2_3,theta_2_4\n",
+ "print\"\\nThe value of Cp at the bottom of the cylinder is Cp = \",Cp270"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The angular location of the stagnation points are theta = 203.4 336.6 degrees\n",
+ "\n",
+ "Cp = -6.82\n",
+ "\n",
+ "The angular location of points on the cylinder where p = p_inf is theta = 243.9 296.11 5.86 174.1\n",
+ "\n",
+ "The value of Cp at the bottom of the cylinder is Cp = -0.45\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E16 : Pg 110"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "rho_inf = 0.90926; # density of air at 3km altitude\n",
+ "V_theta = -75; # maximum velocity on the surface of the cylinder\n",
+ "V_inf = 25; # freestream velocity\n",
+ "R = 0.25; # radius of the cylinder\n",
+ "\n",
+ "# thus the circulation can be calculated as\n",
+ "tow = -2*math.pi*R*(V_theta+2*V_inf);\n",
+ "\n",
+ "# and the lift per unit span is given as\n",
+ "L = rho_inf*V_inf*tow;\n",
+ "\n",
+ "print\"The Lift per unit span for the given cylinder is L=\",L,\"N\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Lift per unit span for the given cylinder is L= 892.663917563 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER04.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER04.ipynb new file mode 100644 index 00000000..ee59ef5f --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER04.ipynb @@ -0,0 +1,358 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:1ed89d68741f5e390e8fd1c09a55c0f77b1c405551af1981288ec865002f9662"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER04:INCOMPRESSIBLE FLOW OVER AIRFOILS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 126"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math\n",
+ "c = 0.64; # chord length of the airfoil\n",
+ "V_inf = 70.; # freestream velocity\n",
+ "L_dash = 1254.; # lift per unit span L'\n",
+ "rho_inf = 1.23; # density of air\n",
+ "mu_inf = 1.789*10.**-5.; # freestream coefficient of viscosity\n",
+ "q_inf = 1./2.*rho_inf*V_inf*V_inf; # freestream dynamic pressure\n",
+ "\n",
+ "# thus the lift coefficient can be calculated as\n",
+ "c_l = L_dash/q_inf/c;\n",
+ "\n",
+ "# for this value of C_l, from fig. 4.10\n",
+ "alpha = 4.;\n",
+ "\n",
+ "# the Reynold's number is given as\n",
+ "Re = rho_inf*V_inf*c/mu_inf;\n",
+ "\n",
+ "# for the above Re and alpha values, from fig. 4.11\n",
+ "c_d = 0.0068;\n",
+ "\n",
+ "# thus the drag per unit span can be calculated as\n",
+ "D_dash = q_inf*c*c_d;\n",
+ "\n",
+ "print\"c_l =\",c_l\n",
+ "print\"\\nfor this c_l value, from fig. 4.10we get alpha =\",alpha\n",
+ "print\"\\nRe =\",Re/1000000. \n",
+ "print\"\\nfor this value of Re, from fig. 4.11 we get c_d =\",c_d\n",
+ "print\"\\nD=\",D_dash,\"N/m\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "c_l = 0.650199104032\n",
+ "\n",
+ "for this c_l value, from fig. 4.10we get alpha = 4.0\n",
+ "\n",
+ "Re = 3.08015651202\n",
+ "\n",
+ "for this value of Re, from fig. 4.11 we get c_d = 0.0068\n",
+ "\n",
+ "D= 13.114752 N/m\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 126"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "c = 0.64; # chord length of the airfoil\n",
+ "V_inf = 70.; # freestream velocity\n",
+ "rho_inf = 1.23; # density of air\n",
+ "q_inf = 1./2.*rho_inf*V_inf*V_inf; # freestream dynamic pressure\n",
+ "c_m_ac = -0.05 # moment coefficient about the aerodynamic center as seen from fig. 4.11\n",
+ "\n",
+ "# thus moment per unit span about the aerodynamic center is given as\n",
+ "M_dash = q_inf*c*c*c_m_ac;\n",
+ "\n",
+ "print\"The Moment per unit span about the aerodynamic center is is M=\",M_dash,\"Nm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Moment per unit span about the aerodynamic center is is M= -61.71648 Nm\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 : Pg 127"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math\n",
+ "from math import pi\n",
+ "alpha = 5.*pi/180.; # angle of attack in radians\n",
+ "\n",
+ "# from eq.(4.33)according to the thin plate theory, the lift coefficient is given by\n",
+ "c_l = 2.*pi*alpha;\n",
+ "\n",
+ "# from eq.(4.39) the coefficient of moment about the leading edge is given by\n",
+ "c_m_le = -c_l/4.;\n",
+ "\n",
+ "# from eq.(4.41)\n",
+ "c_m_qc = 0;\n",
+ "\n",
+ "# thus the coefficient of moment about the trailing can be calculated as\n",
+ "c_m_te = 3./4.*c_l;\n",
+ "\n",
+ "print\"(a)Cl =\", c_l\n",
+ "print\"(b)Cm_le =\",c_m_le\n",
+ "print\"(c)m_c/4 =\",c_m_qc\n",
+ "print\"(d)Cm_te =\",c_m_te"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)Cl = 0.548311355616\n",
+ "(b)Cm_le = -0.137077838904\n",
+ "(c)m_c/4 = 0\n",
+ "(d)Cm_te = 0.411233516712\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 : Pg 131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "alpha1 = 4.;\n",
+ "alpha2 = -1.1;\n",
+ "alpha3 = -4.;\n",
+ "cl_1 = 0.55; # cl at alpha1\n",
+ "cl_2 = 0; # cl at alpha2\n",
+ "c_m_qc1 = -0.005; # c_m_qc at alpha1\n",
+ "c_m_qc3 = -0.0125; # c_m_qc at alpha3\n",
+ "\n",
+ "# the lift slope is given by\n",
+ "a0 = (cl_1 - cl_2)/(alpha1-alpha2);\n",
+ "\n",
+ "# the slope of moment coefficient curve is given by\n",
+ "m0 = (c_m_qc1 - c_m_qc3)/(alpha1-alpha3);\n",
+ "\n",
+ "# from eq.4.71\n",
+ "x_ac = -m0/a0 + 0.25;\n",
+ "\n",
+ "print\"The location of the aerodynamic center is x_ac =\",x_ac"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The location of the aerodynamic center is x_ac = 0.241306818182\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 : Pg 139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "c = 1.5; # airfoil chord\n",
+ "Re_c = 3.1e6; # Reynolds number at trailing edge\n",
+ "\n",
+ "# from eq.(4.84), the laminar boundary layer thickness at trailing edge is given by\n",
+ "delta = 5*c/math.sqrt(Re_c);\n",
+ "\n",
+ "# from eq(4.86)\n",
+ "Cf = 1.328/math.sqrt(Re_c);\n",
+ "\n",
+ "# the net Cf for both surfaces is given by\n",
+ "Net_Cf = 2*Cf;\n",
+ "\n",
+ "print\"(a)delta =\",delta,\"m\"\n",
+ "print\"(b)Cf =\",Cf*10000 \n",
+ "print\"Net Cf =\",Net_Cf"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)delta = 0.00425971375685 m\n",
+ "(b)Cf = 7.5425331588\n",
+ "Net Cf = 0.00150850663176\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 : Pg 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "c = 1.5; # airfoil chord\n",
+ "Re_c = 3.1e6; # Reynolds number at trailing edge\n",
+ "\n",
+ "# from eq.(4.87), the turbulent boundary layer thickness at trailing edge is given by\n",
+ "delta = 0.37*c/(Re_c**0.2);\n",
+ "\n",
+ "# from eq(4.86)\n",
+ "Cf = 0.074/(Re_c**0.2);\n",
+ "\n",
+ "# the net Cf for both surfaces is given by\n",
+ "Net_Cf = 2*Cf;\n",
+ "\n",
+ "print\"(a)delta =\",delta,\"m\"\n",
+ "print\"(b)Cf =\",Cf\n",
+ "print\"Net Cf =\",Net_Cf"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)delta = 0.0279267658904 m\n",
+ "(b)Cf = 0.00372356878539\n",
+ "Net Cf = 0.00744713757078\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 : Pg 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt\n",
+ "c = 1.5; # airfoil chord length\n",
+ "Rex_cr = 5e5; # critical Reynold's number\n",
+ "Re_c = 3.1e6; # Reynold's number at the trailing edge\n",
+ "\n",
+ "# the point of transition is given by\n",
+ "x1 = Rex_cr/Re_c*c;\n",
+ "\n",
+ "# the various skin friction coefficients are given as\n",
+ "Cf1_laminar = 1.328/sqrt(Rex_cr);\n",
+ "Cfc_turbulent = 0.074/(Re_c**0.2);\n",
+ "Cf1_turbulent = 0.074/(Rex_cr**0.2);\n",
+ "\n",
+ "# thus the total skin friction coefficient is given by\n",
+ "Cf = x1/c*Cf1_laminar + Cfc_turbulent - x1/c*Cf1_turbulent;\n",
+ "\n",
+ "# taking both sides of plate into account\n",
+ "Net_Cf = 2*Cf;\n",
+ "\n",
+ "print\"The net skin friction coefficient is Net Cf=\",round(Net_Cf,5)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The net skin friction coefficient is Net Cf= 0.00632\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER05.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER05.ipynb new file mode 100644 index 00000000..72f7f6ce --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER05.ipynb @@ -0,0 +1,217 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:d72d7a460d9b71cf807c7b5c8c2c9f862a173662c7054f2ccff6208191319c71"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER05:INCOMPRESSIBLE FLOW OVER FINITE WINGS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 182"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sqrt\n",
+ "AR = 8.; # Aspect ratio of the wing\n",
+ "alpha = 5.*pi/180.; # Angle of attack experienced by the wing\n",
+ "a0 = 2.*pi # airfoil lift curve slope\n",
+ "alpha_L0 = 0; # zero lift angle of attack is zero since airfoil is symmetric\n",
+ "# from fig. 5.20, for AR = 8 and taper ratio of 0.8\n",
+ "delta = 0.055;\n",
+ "tow = delta; # given assumption\n",
+ "# thus the lift curve slope for wing is given by\n",
+ "a = a0/(1.+(a0/pi/AR/(1.+tow)));\n",
+ "# thus C_l can be calculated as\n",
+ "C_l = a*alpha;\n",
+ "# from eq.(5.61)\n",
+ "C_Di = C_l**2./pi/AR*(1.+delta);\n",
+ "print\"Cl =\",round(C_l,2)\n",
+ "print\"CDi =\",round(C_Di,2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Cl = 0.44\n",
+ "CDi = 0.01\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 185"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt,pi\n",
+ "CDi1 = 0.01; # induced drag coefficient for first wing\n",
+ "delta = 0.055; # induced drag factor for both wings\n",
+ "tow = delta;\n",
+ "alpha_L0 = -2.*pi/180.; # zero lift angle of attack\n",
+ "alpha = 3.4*pi/180.; # angle of attack\n",
+ "AR1 = 6.; # Aspect ratio of the first wing\n",
+ "AR2 = 10.; # Aspect ratio of the second wing\n",
+ "\n",
+ "# from eq.(5.61), lift coefficient can be calculated as\n",
+ "C_l1 = sqrt(pi*AR1*CDi1/(1.+delta));\n",
+ "\n",
+ "# the lift slope for the first wing can be calculated as\n",
+ "a1 = C_l1/(alpha-alpha_L0);\n",
+ "\n",
+ "# the airfoil lift coefficient can be given as\n",
+ "a0 = a1/(1.-(a1/pi/AR1*(1.+tow)));\n",
+ "\n",
+ "# thus the list coefficient for the second wing which has the same airfoil is given by\n",
+ "a2 = a0/(1.+(a0/pi/AR2*(1.+tow)));\n",
+ "C_l2 = a2*(alpha-alpha_L0);\n",
+ "CDi2 = C_l2**2./pi/AR2*(1.+delta);\n",
+ "\n",
+ "print\"The induced drag coefficient of the second wing is CD,i =\",CDi2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The induced drag coefficient of the second wing is CD,i = 0.00741411360464\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 189"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# all the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi\n",
+ "a0 = 0.1*180./pi; # airfoil lift curve slope\n",
+ "AR = 7.96; # Wing aspect ratio\n",
+ "alpha_L0 = -2.*pi/180.; # zero lift angle of attack\n",
+ "tow = 0.04; # lift efficiency factor\n",
+ "C_l = 0.21; # lift coefficient of the wing\n",
+ "\n",
+ "# the lift curve slope of the wing is given by\n",
+ "a = a0/(1+(a0/pi/AR/(1.+tow)));\n",
+ "\n",
+ "# thus angle of attack can be calculated as\n",
+ "alpha = C_l/a + alpha_L0;\n",
+ "\n",
+ "print\"alpha =\",alpha*180./pi,\"degrees\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "alpha = 0.562642629213 degrees\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 : Pg 191"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the qunatities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sqrt\n",
+ "alpha_L0 = -1.*pi/180.; # zero lift angle of attack\n",
+ "alpha1 = 7.*pi/180.; # reference angle of attack\n",
+ "C_l1 = 0.9; # wing lift coefficient at alpha1\n",
+ "alpha2 = 4.*pi/180.;\n",
+ "AR = 7.61; # aspect ratio of the wing\n",
+ "taper = 0.45; # taper ratio of the wing\n",
+ "delta = 0.01; # delta as calculated from fig. 5.20\n",
+ "tow = delta;\n",
+ "# the lift curve slope of the wing/airfoil can be calculated as\n",
+ "a0 = C_l1/(alpha1-alpha_L0);\n",
+ "e = 1./(1.+delta);\n",
+ "# from eq. (5.70)\n",
+ "a = a0/(1.+(a0/pi/AR/(1.+tow)));\n",
+ "# lift coefficient at alpha2 is given as\n",
+ "C_l2 = a*(alpha2 - alpha_L0);\n",
+ "# from eq.(5.42), the induced angle of attack can be calculated as\n",
+ "alpha_i = C_l2/pi/AR;\n",
+ "# which gives the effective angle of attack as\n",
+ "alpha_eff = alpha2 - alpha_i;\n",
+ "# Thus the airfoil lift coefficient is given as\n",
+ "c_l = a0*(alpha_eff-alpha_L0);\n",
+ "c_d = 0.0065; # section drag coefficient for calculated c_l as seen from fig. 5.2b\n",
+ "# Thus the wing drag coefficient can be calculated as\n",
+ "C_D = c_d + ((C_l2**2.)/pi/e/AR);\n",
+ "print\"The drag coefficient of the wing is C_D =\",C_D"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The drag coefficient of the wing is C_D = 0.014827553741\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER07.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER07.ipynb new file mode 100644 index 00000000..d9d5597a --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER07.ipynb @@ -0,0 +1,167 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:daee8dea306dcf3f243bce271ea4da56ca30a788427b14afefd3a09c75dc55c1"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER07:COMPRESSIBLE FLOW SOME PRELIMINARY ASPECTS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 222"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "l = 5.; # dimensions of the room\n",
+ "b = 7.;\n",
+ "h = 3.3;\n",
+ "V = l*b*h; # volume of the room\n",
+ "p = 101000.; # ambient pressure\n",
+ "T = 273. + 25.; # ambient temperature\n",
+ "R = 287.; # gas constant\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "cv = R/(gam-1.);\n",
+ "cp = gam*R/(gam-1.);\n",
+ "\n",
+ "# the density can by calculaled by the ideal gas law\n",
+ "rho = p/R/T;\n",
+ "\n",
+ "# thus the mass is given by\n",
+ "M = rho*V;\n",
+ "\n",
+ "# from eq.(7.6a), the internal energy per unit mass is\n",
+ "e = cv*T;\n",
+ "\n",
+ "# thus internal energy in the room is\n",
+ "E = e*M;\n",
+ "\n",
+ "# from eq.(7.6b), the enthalpy per unit mass is given by\n",
+ "h = cp*T;\n",
+ "\n",
+ "# Thus the enthalpy in the room is\n",
+ "H = M*h;\n",
+ "\n",
+ "print\"The internal energy in the room is: E =\", E/10**7\n",
+ "print\"The Enthalpy in the room is: H = \",H/10**7"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The internal energy in the room is: E = 2.916375\n",
+ "The Enthalpy in the room is: H = 4.082925\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 223"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "p_inf = 22790.9; # ambient pressure at 36000 ft\n",
+ "T_inf = 217.2; # ambient temperature at 36000 ft\n",
+ "p = 19152; # pressure at the given point\n",
+ "gam = 1.4;\n",
+ "\n",
+ "# thus the temperature at the given point can be calculated by eq.(7.32) as\n",
+ "T = T_inf*((p/p_inf)**((gam-1)/gam));\n",
+ "\n",
+ "print\"The temperature at the given point is: T =\",T,\"K\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The temperature at the given point is: T = 206.668775312 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 223"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "p =101000; # static pressure\n",
+ "T = 320; # static temperature\n",
+ "v = 1000; # velocity\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "R = 287; # universal gas constant\n",
+ "cp = gam*R/(gam-1); # specific heat at constant pressure\n",
+ "\n",
+ "# from eq.(7.54), the total temperature is given by\n",
+ "T0 = T + (v**2)/2/cp;\n",
+ "\n",
+ "# from eq.(7.32),the total pressure is given by\n",
+ "p0 = p*((T0/T)**(gam/(gam-1)));\n",
+ "\n",
+ "p0_atm = p0/101000;\n",
+ "\n",
+ "\n",
+ "print\"The total temperature and pressure are given by: T0 =\",T0,\"K\"\n",
+ "print\"P0 =\",p0_atm,\"atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total temperature and pressure are given by: T0 = 817.760079642 K\n",
+ "P0 = 26.678766535 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER08.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER08.ipynb new file mode 100644 index 00000000..4edd77e8 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER08.ipynb @@ -0,0 +1,662 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:71725ceb4c0a99d9e0941e0534b253021a5547aae016d77b23760546a6ae5b10"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER08:NORMAL SHOCK WAVES AND RELATED TOPICS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 256"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt,pi\n",
+ "R = 287.;\n",
+ "gam = 1.4;\n",
+ "V_inf = 250.;\n",
+ "\n",
+ "# (a)\n",
+ "# At sea level\n",
+ "T_inf = 288.;\n",
+ "\n",
+ "# the velocity of sound is given by\n",
+ "a_inf = sqrt(gam*R*T_inf);\n",
+ "\n",
+ "# thus the mach number can be calculated as\n",
+ "M_inf = V_inf/a_inf;\n",
+ "\n",
+ "print\"(a)The Mach number at sea level is:M_inf =\",M_inf\n",
+ "\n",
+ "# similarly for (b) and (c)\n",
+ "# (b)\n",
+ "# at 5km\n",
+ "T_inf = 255.7;\n",
+ "\n",
+ "a_inf = sqrt(gam*R*T_inf);\n",
+ "\n",
+ "M_inf = V_inf/a_inf;\n",
+ "\n",
+ "print\"(b)The Mach number at 5 km is: M_inf = \",M_inf\n",
+ "\n",
+ "# (c)\n",
+ "# at 10km\n",
+ "T_inf = 223.3;\n",
+ "\n",
+ "a_inf = sqrt(gam*R*T_inf);\n",
+ "\n",
+ "M_inf = V_inf/a_inf;\n",
+ "\n",
+ "print\"(c)The Mach number at 10 km is: M_inf =\",M_inf"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)The Mach number at sea level is:M_inf = 0.73491785465\n",
+ "(b)The Mach number at 5 km is: M_inf = 0.779955236945\n",
+ "(c)The Mach number at 10 km is: M_inf = 0.834623638772\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 256"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "T = 320; # static temperature\n",
+ "V = 1000; # velocity\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "R = 287; # universal gas constant\n",
+ "\n",
+ "# the speed of sound is given by\n",
+ "a = math.sqrt(gam*R*T);\n",
+ "\n",
+ "# the mach number can be calculated as\n",
+ "M = V/a;\n",
+ "\n",
+ "print\"The Mach number is:\\nM =\",M"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Mach number is:\n",
+ "M = 2.78881717658\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 257"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "\n",
+ "# (a)\n",
+ "M = 2; # Mach number\n",
+ "\n",
+ "# the ratio of kinetic energy to internal energy is given by\n",
+ "ratio = gam*(gam-1)*M*M/2;\n",
+ "\n",
+ "print\"(a)The ratio of kinetic energy to internal energy is:\",ratio\n",
+ "\n",
+ "# similarly for (b)\n",
+ "# (b)\n",
+ "M = 20;\n",
+ "\n",
+ "ratio = gam*(gam-1)*M*M/2;\n",
+ "\n",
+ "print\"\\n(b)The ratio of kinetic energy to internal energy is:\",ratio"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)The ratio of kinetic energy to internal energy is: 1.12\n",
+ "\n",
+ "(b)The ratio of kinetic energy to internal energy is: 112.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 : Pg 259"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "M = 2.79; # Mach number\n",
+ "T = 320; # static temperature from ex. 7.3\n",
+ "p = 1; # static pressure in atm\n",
+ "gam = 1.4;\n",
+ "\n",
+ "# from eq. (8.40)\n",
+ "T0 = T*(1+((gam-1)/2*M*M));\n",
+ "\n",
+ "# from eq. (8.42)\n",
+ "p0 = p*((1+((gam-1)/2*M*M))**(gam/(gam-1)));\n",
+ "\n",
+ "print\"The total temperature and pressure are:\\nT0 =\",T0,\"K\",\"\\nP0 =\",p0,\"atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total temperature and pressure are:\n",
+ "T0 = 818.1824 K \n",
+ "P0 = 26.7270201929 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 : Pg 260"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "M = 3.5; # Mach number\n",
+ "T = 180; # static temperature from ex. 7.3\n",
+ "p = 0.3; # static pressure in atm\n",
+ "gam = 1.4;\n",
+ "R = 287;\n",
+ "\n",
+ "# from eq. (8.40)\n",
+ "T0 = T*(1+((gam-1)/2*M*M));\n",
+ "\n",
+ "# from eq. (8.42)\n",
+ "p0 = p*((1+((gam-1)/2*M*M))**(gam/(gam-1)));\n",
+ "\n",
+ "a = math.sqrt(gam*R*T);\n",
+ "V = a*M;\n",
+ "\n",
+ "# the values at local sonic point are given by\n",
+ "T_star = T0*2/(gam+1);\n",
+ "a_star = math.sqrt(gam*R*T_star);\n",
+ "M_star = V/a_star;\n",
+ "\n",
+ "print\"T0 =\",T0,\"K\",\"\\nP0 =\",p0,\"atm\",\"\\nT* =\",T_star,\"k\",\"\\na* =\",a_star,\"m/s\",\"\\nM* =\",M_star"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "T0 = 621.0 K \n",
+ "P0 = 22.8816894716 atm \n",
+ "T* = 517.5 k \n",
+ "a* = 455.995065763 m/s \n",
+ "M* = 2.06418738617\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 : Pg 263"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "p_inf = 1;\n",
+ "p1 = 0.7545;\n",
+ "M_inf = 0.6;\n",
+ "gam = 1.4;\n",
+ "\n",
+ "# from eq. (8.42)\n",
+ "p0_inf = p_inf*((1+((gam-1)/2*M_inf*M_inf))**(gam/(gam-1)));\n",
+ "\n",
+ "p0_1 = p0_inf;\n",
+ "\n",
+ "# from eq. (8.42)\n",
+ "ratio = p0_1/p1;\n",
+ "\n",
+ "# from appendix A, for this ratio, the Mach number is\n",
+ "M1 = 0.9;\n",
+ "\n",
+ "print\"The mach number at the given point is:\\nM1 =\",M1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The mach number at the given point is:\n",
+ "M1 = 0.9\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 : Pg 268"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "T_inf = 288; # freestream temperature\n",
+ "p_inf = 1; # freestream pressure\n",
+ "p1 = 0.7545; # pressure at point 1\n",
+ "M = 0.9; # mach number at point 1\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "R=1.;#\n",
+ "# for isentropic flow, from eq. (7.32)\n",
+ "T1 = T_inf*((p1/p_inf)**((gam-1)/gam));\n",
+ "\n",
+ "# the speed of sound at that point is thus\n",
+ "a1 = math.sqrt(gam*R*T1);\n",
+ "\n",
+ "# thus, the velocity can be given as\n",
+ "V1 = M*a1;\n",
+ "\n",
+ "print\"The velocity at the given point is:\\nV1 =\",V1,\"m/s\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The velocity at the given point is:\n",
+ "V1 = 17.3590326624 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 : Pg 268"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "u1 = 680; # velocity upstream of shock\n",
+ "T1 = 288; # temperature upstream of shock\n",
+ "p1 = 1; # pressure upstream of shock\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "R = 287; # universal gas constant\n",
+ "\n",
+ "# the speed of sound is given by\n",
+ "a1 = math.sqrt(gam*R*T1)\n",
+ "\n",
+ "# thus the mach number is\n",
+ "M1 = 2;\n",
+ "\n",
+ "# from Appendix B, for M = 2, the relations between pressure and temperature are given by\n",
+ "pressure_ratio = 4.5; # ratio of pressure accross shock\n",
+ "temperature_ratio = 1.687; # ratio of temperature accross shock\n",
+ "M2 = 0.5774; # mach number downstream of shock\n",
+ "\n",
+ "# thus the values downstream of the shock can be calculated as\n",
+ "p2 = pressure_ratio*p1;\n",
+ "T2 = temperature_ratio*T1;\n",
+ "a2 = math.sqrt(gam*R*T2);\n",
+ "u2 = M2*a2;\n",
+ "\n",
+ "print\"p2 =\",p2,\"atm\",\"\\nT2 =\",T2,\"K\",\"\\nu2 =\",u2,\"m/s\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "p2 = 4.5 atm \n",
+ "T2 = 485.856 K \n",
+ "u2 = 255.114727639 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 : Pg 271"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "p1 = 1; # ambient pressure upstream of shock\n",
+ "\n",
+ "\n",
+ "# (a)\n",
+ "# for M = 2;\n",
+ "p0_1 = 7.824*p1; # total pressure upstream of shock\n",
+ "pressure_ratio = 0.7209; # ratio of total pressure accross the shock\n",
+ "p0_2 = pressure_ratio*p0_1; # total pressure downstream of shock\n",
+ "\n",
+ "# thus the total loss of pressure is given by\n",
+ "pressure_loss = p0_1 - p0_2;\n",
+ "\n",
+ "print\"The total pressure loss is:\\n(a)P0_loss=\",pressure_loss,\"atm\"\n",
+ "\n",
+ "# similarly\n",
+ "# (b)\n",
+ "# for M = 4;\n",
+ "p0_1 = 151.8*p1;\n",
+ "pressure_ratio = 0.1388;\n",
+ "p0_2 = pressure_ratio*p0_1;\n",
+ "\n",
+ "# thus the total loss of pressure is given by\n",
+ "pressure_loss = p0_1 - p0_2;\n",
+ "\n",
+ "print\"\\n(b)P0_loss =\",pressure_loss,\"atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total pressure loss is:\n",
+ "(a)P0_loss= 2.1836784 atm\n",
+ "\n",
+ "(b)P0_loss = 130.73016 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E10 : Pg 272"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "M_inf = 2.; # freestream mach number\n",
+ "p_inf = 2.65e4; # freestream pressure\n",
+ "T_inf = 223.3; # freestream temperature\n",
+ "\n",
+ "# from Appendix A, for M = 2\n",
+ "p0_inf = 7.824*p_inf; # freestream total pressure\n",
+ "T0_inf = 1.8*T_inf; # freestream total temperature\n",
+ "\n",
+ "# from Appendix B, for M = 2\n",
+ "p0_1 = 0.7209*p0_inf; # total pressure downstream of the shock\n",
+ "T0_1 = T0_inf; # total temperature accross the shock is conserved\n",
+ "\n",
+ "# since the flow downstream of the shock is isentropic\n",
+ "p0_2 = p0_1;\n",
+ "T0_2 = T0_1;\n",
+ "\n",
+ "# from Appendix A, for M = 0.2 at point 2\n",
+ "p2 = p0_2/1.028;\n",
+ "T2 = T0_2/1.008;\n",
+ "\n",
+ "p2_atm = p2/102000;\n",
+ "\n",
+ "print\"The pressure at point 2 is:p2 =\",p2_atm,\"atm\","
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The pressure at point 2 is:p2 = 1.42546466011 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E11 : Pg 273"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "M_inf = 10; # freestream mach number\n",
+ "p_inf = 2.65e4; # freestream pressure\n",
+ "T_inf = 223.3; # freestream temperature\n",
+ "\n",
+ "# from Appendix A, for M = 2\n",
+ "p0_inf = 0.4244e5*p_inf; # freestream total pressure\n",
+ "T0_inf = 21*T_inf; # freestream total temperature\n",
+ "\n",
+ "# from Appendix B, for M = 2\n",
+ "p0_1 = 0.003045*p0_inf; # total pressure downstream of shock\n",
+ "T0_1 = T0_inf; # total temperature downstream of shock is conserved\n",
+ "\n",
+ "# since the flow downstream of the shock is isentropic\n",
+ "p0_2 = p0_1;\n",
+ "T0_2 = T0_1;\n",
+ "\n",
+ "# from Appendix A, for M = 0.2 at point 2\n",
+ "p2 = p0_2/1.028;\n",
+ "T2 = T0_2/1.008;\n",
+ "\n",
+ "p2_atm = p2/102000;\n",
+ "\n",
+ "\n",
+ "print\"The pressure at point 2 is: p2 =\",p2_atm,\"atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The pressure at point 2 is: p2 = 32.6599307622 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E13 : Pg 274"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "p1 = 4.66e4; # ambient pressure\n",
+ "M = 8; # mach number\n",
+ "\n",
+ "# from Appendix B, for M = 8\n",
+ "p0_2 = 82.87*p1; # total pressure downstream of the shock\n",
+ "\n",
+ "# since the flow is isentropic downstream of the shock, total pressure is conserved\n",
+ "ps_atm = p0_2/101300; # pressure at the stagnation point\n",
+ "\n",
+ "print\"The pressure at the nose is:\\np_s =\",ps_atm,\"atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The pressure at the nose is:\n",
+ "p_s = 38.1218361303 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E14 : Pg 274"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressedin SI units\n",
+ "import math \n",
+ "p1 = 2527.3; # ambient pressure at the altitude of 25 km\n",
+ "T1 = 216.66; # ambient temperature at the altitude of 25 km\n",
+ "p0_1 = 38800; # total pressure\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "R = 287; # universal gas constant\n",
+ "pressure_ratio = p0_1/p1; # ratio of total to static pressure\n",
+ "\n",
+ "# for this value of pressure ratio, mach number is\n",
+ "M1 = 3.4;\n",
+ "\n",
+ "# the speed of sound is given by\n",
+ "a1 = math.sqrt(gam*R*T1)\n",
+ "\n",
+ "# thus the velocity can be calculated as\n",
+ "V1 = M1*a1;\n",
+ "\n",
+ "print\"The Velocity of the airplane is:\\nV1 =\",V1,\"m/s\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Velocity of the airplane is:\n",
+ "V1 = 1003.16703558 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER09.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER09.ipynb new file mode 100644 index 00000000..f8dc65c6 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER09.ipynb @@ -0,0 +1,573 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:ef96c69329d4d090ccb3995280a3d98afa4f31033dd69fab00ee6053f89763a8"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER09:OBLIGUE SHOCK AND EXPANSION WAVES"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 302"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math\n",
+ "M = 2.; # mach number\n",
+ "h = 16000.; # altitude of the plane\n",
+ "\n",
+ "# the mach angle can be calculated from eq.(9.1) as\n",
+ "mue = math.asin(1./M); # mach angle\n",
+ "\n",
+ "d = h/math.tan(mue);\n",
+ "\n",
+ "print\"The plane is ahead of the bystander by a distance of:\\nd =\",d/1000.,\"km\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The plane is ahead of the bystander by a distance of:\n",
+ "d = 27.7128129211 km\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 302"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi, sin,cos\n",
+ "M1 = 2.; # mach number\n",
+ "p1 = 1.; # ambient pressure\n",
+ "T1 = 288.; # ambient temperature\n",
+ "theta = 20.*pi/180.; # flow deflection\n",
+ "\n",
+ "# from figure 9.9, for M = 2, theta = 20\n",
+ "b = 53.4*pi/180.; # beta\n",
+ "Mn_1 = M1*sin(b); # upstream mach number normal to shock\n",
+ "\n",
+ "# for this value of Mn,1 = 1.60, from Appendix B we have\n",
+ "Mn_2 = 0.6684; # downstream mach number normal to shock\n",
+ "M2 = Mn_2/sin(b-theta); # mach number downstream of shock\n",
+ "p2 = 2.82*p1;\n",
+ "T2 = 1.388*T1;\n",
+ "\n",
+ "# for M = 2, from appendix A we have\n",
+ "p0_2 = 0.8952*7.824*p1;\n",
+ "T0_1 = 1.8*T1;\n",
+ "T0_2 = T0_1;\n",
+ "\n",
+ "print\"M2 =\",M2,\"\\np2 =\",p2,\"atm\",\"\\nT2 =\",T2,\"K\",\"\\np0,2 =\",p0_2,\"atm\",\"\\nT0,2 =\",T0_2,\"K\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "M2 = 1.214211418 \n",
+ "p2 = 2.82 atm \n",
+ "T2 = 399.744 K \n",
+ "p0,2 = 7.0040448 atm \n",
+ "T0,2 = 518.4 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 305"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sin\n",
+ "b = 30.*pi/180.; # oblique shock wave angle\n",
+ "M1 = 2.4; # upstream mach number\n",
+ "\n",
+ "# from figure 9.9, for these value of M and beta, we have\n",
+ "theta = 6.5*pi/180.;\n",
+ "\n",
+ "Mn_1 = M1*sin(b); # upstream mach number normal to shock\n",
+ "\n",
+ "# from Appendix B\n",
+ "pressure_ratio = 1.513;\n",
+ "temperature_ratio = 1.128;\n",
+ "Mn_2 = 0.8422;\n",
+ "\n",
+ "M2 = Mn_2/sin(b-theta);\n",
+ "\n",
+ "print\"theta =\",theta*180./pi,\"degrees\",\"\\np2/p1 =\",pressure_ratio,\"\\nT2/T1 =\",temperature_ratio,\"\\nM2 =\",M2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "theta = 6.5 degrees \n",
+ "p2/p1 = 1.513 \n",
+ "T2/T1 = 1.128 \n",
+ "M2 = 2.11210524521\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 : Pg 309"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sin\n",
+ "b = 35.*pi/180.; # oblique shock wave angle\n",
+ "pressure_ratio = 3.; # upstream and downstream pressure ratio\n",
+ "\n",
+ "# from appendix B\n",
+ "Mn_1 = 1.64;\n",
+ "M1 = Mn_1/sin(b);\n",
+ "\n",
+ "print\"The upstream mach number is:\\nM =\",M1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The upstream mach number is:\n",
+ "M = 2.85925274482\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 : Pg 309"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sin\n",
+ "M1 = 3.;\n",
+ "b = 40.*pi/180.;\n",
+ "\n",
+ "# for case 1, for M = 3, from Appendix B, we have\n",
+ "p0_ratio_case1 = 0.3283;\n",
+ "\n",
+ "# for case 2\n",
+ "Mn_1 = M1*sin(b);\n",
+ "\n",
+ "# from Appendix B\n",
+ "p0_ratio1 = 0.7535;\n",
+ "Mn_2 = 0.588;\n",
+ "\n",
+ "# from fig. 9.9, for M1 = 3 and beta = 40, we have\n",
+ "theta = 22.*pi/180.;\n",
+ "M2 = Mn_2/sin(b-theta);\n",
+ "\n",
+ "# from appendix B for M = 1.9; we have\n",
+ "p0_ratio2 = 0.7674;\n",
+ "p0_ratio_case2 = p0_ratio1*p0_ratio2;\n",
+ "\n",
+ "ratio = p0_ratio_case2/p0_ratio_case1;\n",
+ "\n",
+ "print\"Ans =\",ratio"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Ans = 1.76130338105\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 : Pg 310"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sin,tan\n",
+ "M1 = 5.;\n",
+ "theta = 15.*pi/180.;\n",
+ "gam = 1.4;\n",
+ "\n",
+ "# for these values of M and theta, from fig. 9.9\n",
+ "b = 24.2*pi/180;\n",
+ "Mn_1 = M1*sin(b);\n",
+ "\n",
+ "# from Appendix B, for Mn,1 = 2.05, we have\n",
+ "p_ratio = 4.736;\n",
+ "\n",
+ "# hence\n",
+ "c_d = 4.*tan(theta)/gam/(M1**2.)*(p_ratio-1.);\n",
+ "\n",
+ "print\"The drag coefficient is given by:\\ncd =\",c_d"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The drag coefficient is given by:\n",
+ "cd = 0.114406649477\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 : Pg 311"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sin,tan\n",
+ "M1 = 3.5;\n",
+ "theta1 = 10.*pi/180.;\n",
+ "gam = 1.4;\n",
+ "p1 = 101300.;\n",
+ "T1 = 288.;\n",
+ "b=1.;#\n",
+ "# for these values of M and theta, from fig. 9.9\n",
+ "b1 = 24.*pi/180.;\n",
+ "Mn_1 = M1*sin(b);\n",
+ "\n",
+ "# from Appendix B, for Mn,1 = 2.05, we have\n",
+ "Mn_2 = 0.7157;\n",
+ "p_ratio1 = 2.32;\n",
+ "T_ratio1 = 1.294;\n",
+ "M2 = Mn_2/sin(b1-theta1);\n",
+ "\n",
+ "# now\n",
+ "theta2 = 10.*pi/180.;\n",
+ "\n",
+ "# from fig. 9.9\n",
+ "b2 = 27.3*pi/180.;\n",
+ "phi = b2 - theta2;\n",
+ "\n",
+ "# from Appendix B\n",
+ "p_ratio2 = 1.991;\n",
+ "T_ratio2 = 1.229;\n",
+ "Mn_3 = 0.7572;\n",
+ "M3 = Mn_3/sin(b2-theta2);\n",
+ "\n",
+ "# thus\n",
+ "p3 = p_ratio1*p_ratio2*p1;\n",
+ "T3 = T_ratio1*T_ratio2*T1;\n",
+ "\n",
+ "print\"p3 =\",p3/1e5,\"x 10**5 N/m2\",\"\\nT3 =\",T3,\"K\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "p3 = 4.67916856 x 10**5 N/m2 \n",
+ "T3 = 458.013888 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 : Pg 312"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sin,tan\n",
+ "M1 = 1.5; # upstream mach number\n",
+ "theta = 15.*pi/180.; # deflection angle\n",
+ "p1 = 1.; # ambient pressure in atm\n",
+ "T1 = 288.; # ambient temperature\n",
+ "\n",
+ "# from appendix C, for M1 = 1.5 we have\n",
+ "v1 = 11.91*pi/180.;\n",
+ "\n",
+ "# from eq.(9.43)\n",
+ "v2 = v1 + theta;\n",
+ "\n",
+ "# for this value of v2, from appendix C\n",
+ "M2 = 2.;\n",
+ "\n",
+ "# from Appendix A for M1 = 1.5 and M2 = 2.0, we have\n",
+ "p2 = 1./7.824*1.*3.671*p1;\n",
+ "T2 = 1./1.8*1.*1.45*T1;\n",
+ "p0_1 = 3.671*p1;\n",
+ "p0_2 = p0_1;\n",
+ "T0_1 = 1.45*T1;\n",
+ "T0_2 = T0_1;\n",
+ "\n",
+ "# from fig. 9.25, we have\n",
+ "fml = 41.81; # Angle of forward Mach line\n",
+ "rml = 30. - 15.; # Angle of rear Mach line\n",
+ "\n",
+ "print\"p2 =\",p2,\"atm\",\"\\nT2 =\",T2,\"K\",\"\\np0,2 =\",p0_2,\"atm\",\"\\nT0,2 =\",T0_2,\"K\",\"\\nAngle of forward Mach line =\",fml,\"degrees\",\"\\nAngle of rear Mach line =\",rml,\"degrees\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "p2 = 0.469197341513 atm \n",
+ "T2 = 232.0 K \n",
+ "p0,2 = 3.671 atm \n",
+ "T0,2 = 417.6 K \n",
+ "Angle of forward Mach line = 41.81 degrees \n",
+ "Angle of rear Mach line = 15.0 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 : Pg 312"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math\n",
+ "from math import pi\n",
+ "M1 = 10.; # upstream mach number\n",
+ "theta = 15.*pi/180.; # deflection angle\n",
+ "p1 = 1.; # ambient pressure in atm\n",
+ "# from appendix C, for M1 = 10 we have\n",
+ "v1 = 102.3*pi/180.;\n",
+ "# in region 2\n",
+ "v2 = v1 - theta;\n",
+ "# for this value of v2, from appendix C\n",
+ "M2 = 6.4;\n",
+ "# from Appendix A for M1 = 10 and M2 = 6.4, we have\n",
+ "p2 = 1./(2355.)*1.*42440.*p1;\n",
+ "print\"M2 =\",M2,\"\\np2 =\",p2,\"atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "M2 = 6.4 \n",
+ "p2 = 18.0212314225 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E10 : Pg 315"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "M1 = 10; # upstream mach number\n",
+ "theta = 15*math.pi/180; # deflection angle\n",
+ "p1 = 1; # ambient pressure in atm\n",
+ "\n",
+ "# from fig 9.9, for M1 = 10 and theta = 15 we have\n",
+ "b = 20*math.pi/180;\n",
+ "Mn_1 = M1*math.sin(b);\n",
+ "\n",
+ "# from Appendix B, for Mn,1 = 3.42\n",
+ "Mn_2 = 0.4552;\n",
+ "M2 = Mn_2/math.sin(b-theta);\n",
+ "p2 = 13.32*p1;\n",
+ "\n",
+ "# from Appendix A, for M1 = 10\n",
+ "p0_2 = 0.2322*42440*p1;\n",
+ "\n",
+ "print\"M2 =\",M2,\"\\np2 =\",p2,\"atm\",\"\\np0,2 =\",p0_2/1e3,\"x 10**3 atm\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "M2 = 5.22283426943 \n",
+ "p2 = 13.32 atm \n",
+ "p0,2 = 9.854568 x 10**3 atm\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E11 : Pg 316"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "M1 = 3.; # upstream mach number\n",
+ "theta = 5.*math.pi/180.; # deflection angle\n",
+ "alpha = theta; # angle of attack\n",
+ "gam = 1.4;\n",
+ "\n",
+ "# from appendix C, for M1 = 3 we have\n",
+ "v1 = 49.76*math.pi/180.;\n",
+ "\n",
+ "# from eq.(9.43)\n",
+ "v2 = v1 + theta;\n",
+ "\n",
+ "# for this value of v2, from appendix C\n",
+ "M2 = 3.27;\n",
+ "\n",
+ "# from Appendix A for M1 = 3 and M2 = 3.27, we have\n",
+ "p_ratio1 = 36.73/55.;\n",
+ "\n",
+ "# from fig. 9.9, for M1 = 3 and theta = 5\n",
+ "b = 23.1*math.pi/180.;\n",
+ "Mn_1 = M1*math.sin(b);\n",
+ "\n",
+ "# from Appendix B\n",
+ "p_ratio2 = 1.458;\n",
+ "\n",
+ "# thus\n",
+ "c_l = 2./gam/(M1**2.)*(p_ratio2-p_ratio1)*math.cos(alpha);\n",
+ "\n",
+ "c_d = 2./gam/(M1**2.)*(p_ratio2-p_ratio1)*math.sin(alpha);\n",
+ "\n",
+ "print\"The lift and drag coefficients are given by:\\ncl =\",c_l,\"\\ncd =\",c_d"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The lift and drag coefficients are given by:\n",
+ "cl = 0.124948402826 \n",
+ "cd = 0.0109315687729\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER10.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER10.ipynb new file mode 100644 index 00000000..5e2e846a --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER10.ipynb @@ -0,0 +1,329 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:50b271f93e8a365fc7786fed67e8c1b9727566cca589daf5682afce2ce0beb0c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER10:COMPRESSIBLE FLOW THROUGH NOZZLES DIFFUSERS AND WIND TUNNELS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 345"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in Si units\n",
+ "area_ratio = 10.25; # exit to throat area ratio\n",
+ "p0 = 5; # reservoir pressure in atm\n",
+ "T0 = 333.3; # reservoir temperature\n",
+ "\n",
+ "# from appendix A, for an area ratio of 10.25\n",
+ "Me = 3.95; # exit mach number\n",
+ "pe = 0.007*p0; # exit pressure\n",
+ "Te = 0.2427*T0; # exit temperature\n",
+ "\n",
+ "print\"Me =\",Me\n",
+ "print\"pe =\",pe,\"atm\"\n",
+ "print\"Te =\",Te,\"K\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Me = 3.95\n",
+ "pe = 0.035 atm\n",
+ "Te = 80.89191 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 346"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in Si units\n",
+ "\n",
+ "area_ratio = 2.; # exit to throat area ratio\n",
+ "p0 = 1.; # reservoir pressure in atm\n",
+ "T0 = 288.; # reservoir temperature\n",
+ "\n",
+ "# (a)\n",
+ "# since M = 1 at the throat\n",
+ "Mt = 1.;\n",
+ "pt = 0.528*p0; # pressure at throat\n",
+ "Tt = 0.833*T0; # temperature at throat\n",
+ "\n",
+ "# from appendix A for supersonic flow, for an area ratio of 2\n",
+ "Me = 2.2; # exit mach number\n",
+ "pe = 1./10.69*p0; # exit pressure\n",
+ "Te = 1./1.968*T0; # exit temperature\n",
+ "\n",
+ "print\"At throat: Mt =\",Mt\n",
+ "print\"\\nAt throat: pt =\",pt,\"atm\"\n",
+ "print\"\\nAt throat: Tt = \",Tt,\"K\"\n",
+ "print\"\\nAt throat: For supersonic exit:\",Me\n",
+ "print\"\\nAt throat: pe =\",pe,\"atm\"\n",
+ "print\"\\nAt throat: Te = \",Te,\"K\"\n",
+ "\n",
+ "# (b)\n",
+ "# from appendix A for subonic flow, for an area ratio of 2\n",
+ "Me = 0.3; # exit mach number\n",
+ "pe = 1/1.064*p0; # exit pressure\n",
+ "Te = 1/1.018*T0; # exit temperature\n",
+ "\n",
+ "print\"\\nFor subrsonic exit:\",Me\n",
+ "print\"\\npe=\",pe,\"atm\"\n",
+ "print\"\\nTe=\",Te,\"K\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "At throat: Mt = 1.0\n",
+ "\n",
+ "At throat: pt = 0.528 atm\n",
+ "\n",
+ "At throat: Tt = 239.904 K\n",
+ "\n",
+ "At throat: For supersonic exit: 2.2\n",
+ "\n",
+ "At throat: pe = 0.0935453695042 atm\n",
+ "\n",
+ "At throat: Te = 146.341463415 K\n",
+ "\n",
+ "For subrsonic exit: 0.3\n",
+ "\n",
+ "pe= 0.93984962406 atm\n",
+ "\n",
+ "Te= 282.907662083 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 346"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in Si units\n",
+ "\n",
+ "area_ratio = 2.; # exit to throat area ratio\n",
+ "p0 = 1.; # reservoir pressure in atm\n",
+ "T0 = 288.; # reservoir temperature\n",
+ "pe = 0.973; # exit pressure in atm\n",
+ "\n",
+ "p_ratio = p0/pe; # ratio of reservoir to exit pressure\n",
+ "\n",
+ "# from appendix A for subsonic flow, for an pressure ratio of 1.028\n",
+ "Me = 0.2; # exit mach number\n",
+ "area_ratio_exit_to_star = 2.964; # A_exit/A_star\n",
+ "\n",
+ "# thus\n",
+ "area_ratio_throat_to_star = area_ratio_exit_to_star/area_ratio; # A_exit/A_star\n",
+ "\n",
+ "# from appendix A for subsonic flow, for an area ratio of 1.482\n",
+ "Mt = 0.44; # throat mach number\n",
+ "\n",
+ "print\"Me =\",Me\n",
+ "print\"Mt =\",Mt"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Me = 0.2\n",
+ "Mt = 0.44\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 : Pg 352"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "p0 = 30.*101000.; # reservoir pressure\n",
+ "T0 = 3500.; # reservoir temperature\n",
+ "R = 520.; # specific gas constant\n",
+ "gam = 1.22; # ratio of specific heats\n",
+ "A_star = 0.4; # rocket nozzle throat area\n",
+ "pe = 5529.; # rocket nozzle exit pressure equal to ambient pressure at 20 km altitude\n",
+ "\n",
+ "# (a)\n",
+ "# the density of air in the reservoir can be calculated as\n",
+ "rho0 = p0/R/T0;\n",
+ "\n",
+ "# from eq.(8.46)\n",
+ "rho_star = rho0*(2/(gam+1))**(1/(gam-1));\n",
+ "\n",
+ "# from eq.(8.44)\n",
+ "T_star = T0*2/(gam+1);\n",
+ "a_star = math.sqrt(gam*R*T_star);\n",
+ "u_star = a_star;\n",
+ "m_dot = rho_star*u_star*A_star;\n",
+ "\n",
+ "# rearranging eq.(8.42)\n",
+ "Me = math.sqrt(2/(gam-1)*(((p0/pe)**((gam-1)/gam)) - 1));\n",
+ "Te = T0/(1+(gam-1)/2*Me*Me);\n",
+ "ae = math.sqrt(gam*R*Te);\n",
+ "ue = Me*ae;\n",
+ "\n",
+ "# thus the thrust can be calculated as\n",
+ "T = m_dot*ue;\n",
+ "T_lb = T*0.2247;\n",
+ "\n",
+ "# (b)\n",
+ "# rearranging eq.(10.32)\n",
+ "Ae = A_star/Me*((2/(gam+1)*(1+(gam-1)/2*Me*Me))**((gam+1)/(gam-1)/2));\n",
+ "\n",
+ "print\"(a)The thrust of the rocket is:T =\" ,T/1e6, \"N\"\n",
+ "print\"\\n(b)The nozzle exit area is\",T_lb \n",
+ "\n",
+ "print\"\\nAe =\",Ae, \"m2\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)The thrust of the rocket is:T = 2.1702872295 N\n",
+ "\n",
+ "(b)The nozzle exit area is 487663.540469\n",
+ "\n",
+ "Ae = 16.7097500627 m2\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 : Pg 353"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "p0 = 30.*101000.; # reservoir pressure\n",
+ "T0 = 3500.; # reservoir temperature\n",
+ "R = 520.; # specific gas constant\n",
+ "gam = 1.22; # ratio of specific heats\n",
+ "A_star = 0.4; # rocket nozzle throat area\n",
+ "\n",
+ "# the mass flow rate using the closed form analytical expression\n",
+ "# from problem 10.5 can be given as\n",
+ "m_dot = p0*A_star*math.sqrt(gam/R/T0*((2/(gam+1))**((gam+1)/(gam-1))));\n",
+ "\n",
+ "print\"The mass flow rate is: m_dot =\",m_dot, \"kg/s\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The mass flow rate is: m_dot = 586.100122081 kg/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 : Pg 356"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "M = 2.; # Mach number\n",
+ "# for this value M, for a normal shock, from Appendix B\n",
+ "p0_ratio = 0.7209;\n",
+ "# thus\n",
+ "area_ratio = 1./p0_ratio;\n",
+ "print\"The diffuser throat to nozzle throat area ratio is: =\",area_ratio"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The diffuser throat to nozzle throat area ratio is: = 1.38715494521\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER11.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER11.ipynb new file mode 100644 index 00000000..a745bed3 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER11.ipynb @@ -0,0 +1,89 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:803218956e8d07c2bbc2005621cfab4517eff6a55bb3c468628e715c71e6bf8d"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER11:SUBSONIC COMPRESSIBLE FLOW OVER AIRFOILS LINEAR THEOREY"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 382"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "Cp_incompressible = -0.3; # Cp for incompressible flow\n",
+ "M = 0.6; # Mach number\n",
+ "# Thus from eq.(11.52)\n",
+ "Cp_compressible = Cp_incompressible/math.sqrt(1-M**2);\n",
+ "print\"(a)The Cp after compressibility corrections is:\",Cp_compressible,\"Cp\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)The Cp after compressibility corrections is: -0.375 Cp\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 383"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "cl_incompressible = 2*math.pi; # lift curve slope\n",
+ "M_inf = 0.7; # Mach number\n",
+ "# from eq.(11.52)\n",
+ "cl_compressible = cl_incompressible/math.sqrt(1-M_inf**2); # compressible lift curve slope\n",
+ "print\"(a)The cl after compressibility corrections is: cl =\",cl_compressible,\"alpha\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)The cl after compressibility corrections is: cl = 8.7982192499 alpha\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER12.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER12.ipynb new file mode 100644 index 00000000..cc64c399 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER12.ipynb @@ -0,0 +1,180 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:9f892b4a818165ad52b348800d0ffa60b6a3224f73f3dcda15a72be66b12ba9f"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER12:LINEARIZED SUPERSONIC FLOW"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 395"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import pi,sqrt\n",
+ "alpha = 5*pi/180; # angle of attack\n",
+ "M_inf = 3; # freestream mach number\n",
+ "\n",
+ "# from eq.(12.23)\n",
+ "c_l = 4*alpha/sqrt(M_inf**2 - 1);\n",
+ "\n",
+ "# from eq.(12.24)\n",
+ "c_d = 4*alpha**2/sqrt(M_inf**2 - 1);\n",
+ "\n",
+ "print\"The cl and cd according to the linearized theory are:cl =\", round(c_l,2)\n",
+ "print\"The cl and cd according to the linearized theory are:cd =\",round(c_d,2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The cl and cd according to the linearized theory are:cl = 0.12\n",
+ "The cl and cd according to the linearized theory are:cd = 0.01\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 395"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt,pi\n",
+ "M_inf = 2.; # freestream mach number\n",
+ "rho_inf = 0.3648; # freestream density at 11 km altitude\n",
+ "T_inf = 216.78; # freestream temperature at 11 km altitude\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "R = 287.; # specific gas constant\n",
+ "m = 9400.; # mass of the aircraft\n",
+ "g = 9.8; # acceleratio due to gravity\n",
+ "W = m*g; # weight of the aircraft\n",
+ "S = 18.21; # wing planform area\n",
+ "# thus\n",
+ "a_inf = sqrt(gam*R*T_inf);\n",
+ "V_inf = M_inf*a_inf;\n",
+ "q_inf = 1./2.*rho_inf*V_inf**2.;\n",
+ "\n",
+ "# thus the aircraft lift coefficient is given as\n",
+ "C_l = W/q_inf/S;\n",
+ "\n",
+ "alpha = 180./pi*C_l/4.*sqrt(M_inf**2. - 1.);\n",
+ "\n",
+ "print\"The angle of attack of the wing is:\",alpha,\"degrees\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The angle of attack of the wing is: 1.97493716351 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 400"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt,pi\n",
+ "# (a)\n",
+ "M_inf = 2.; # freestream mach number\n",
+ "rho_inf = 0.3648; # freestream density at 11 km altitude\n",
+ "T_inf = 216.78; # freestream temperature at 11 km altitude\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "R = 287.; # specific gas constant\n",
+ "m = 9400.; # mass of the aircraft\n",
+ "g = 9.8; # acceleratio due to gravity\n",
+ "W = m*g; # weight of the aircraft\n",
+ "S = 18.21; # wing planform area\n",
+ "c = 2.2; # chord length of the airfoil\n",
+ "alpha = 0.035; # angle of attack as calculated in ex. 12.2\n",
+ "T0 = 288.16; # ambient temperature at sea level\n",
+ "mue0 = 1.7894e-5; # reference viscosity at sea level\n",
+ "\n",
+ "# thus\n",
+ "a_inf = sqrt(gam*R*T_inf);\n",
+ "V_inf = M_inf*a_inf;\n",
+ "\n",
+ "# according to eq.(15.3), the viscosity at the given temperature is\n",
+ "mue_inf = mue0*(T_inf/T0)**1.5*(T0+110.)/(T_inf+110.);\n",
+ "\n",
+ "# thus the Reynolds number can be given by\n",
+ "Re = rho_inf*V_inf*c/mue_inf;\n",
+ "\n",
+ "# from fig.(19.1), for these values of Re and M, the skin friction coefficient is\n",
+ "Cf = 2.15*10**-3;\n",
+ "\n",
+ "# thus, considering both sides of the flat plate\n",
+ "net_Cf = 2.*Cf;\n",
+ "\n",
+ "# (b)\n",
+ "c_d = 4.*alpha**2./sqrt(M_inf**2. - 1.);\n",
+ "\n",
+ "print\"(a) Net Cf = \",net_Cf*1e3\n",
+ "print\"(b) cd =\",c_d*1e3"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) Net Cf = 4.3\n",
+ "(b) cd = 2.82901631903\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER14.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER14.ipynb new file mode 100644 index 00000000..e8e98194 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER14.ipynb @@ -0,0 +1,108 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:aeaeb421097f65195c01fda070e54bf1d5fc8f2c0300f46ceb1ef585d9c062a2"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER14:ELEMENTS OF HYPERSONIC FLOW"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 440"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt,pi,sin,cos\n",
+ "M1 = 8.; # mach number\n",
+ "alpha = 15.*pi/180.; # anlge of attack\n",
+ "theta= alpha;\n",
+ "gam = 1.4;\n",
+ "# (a)\n",
+ "# for M = 8\n",
+ "v1 = 95.62*pi/180.;\n",
+ "v2 = v1 + theta;\n",
+ "# from Appendix C\n",
+ "M2 = 14.32;\n",
+ "# from Appendix A, for M1 = 8 and M2 = 14.32\n",
+ "p_ratio = 0.9763e4/0.4808e6;\n",
+ "# from eq.(11.22)\n",
+ "Cp2 = 2/gam/M1**2*(p_ratio - 1);\n",
+ "# for M1 = 8 and theta = 15\n",
+ "b = 21*pi/180;\n",
+ "Mn_1 = M1*sin(b);\n",
+ "# for this value of Mn,1, from appendix B\n",
+ "p_ratio2 = 9.443;\n",
+ "# thus\n",
+ "Cp3 = 2./gam/M1**2.*(p_ratio2 - 1.);\n",
+ "c_n = Cp3 - Cp2;\n",
+ "c_l = c_n*cos(alpha);\n",
+ "c_d = c_n*sin(alpha);\n",
+ "L_by_D = c_l/c_d;\n",
+ "print\"The exact results from the shock-expansion theory are:\"\n",
+ "print\"Cp2 =\",Cp2\n",
+ "print\"Cp3 = \",Cp3\n",
+ "print\" cl =\",c_l\n",
+ "print\"cd =\",c_d\n",
+ "print\"L/D =\",L_by_D\n",
+ "# (b)\n",
+ "# from Newtonian theory, by eq.(14.9)\n",
+ "Cp3 = 2.*sin(alpha)**2;\n",
+ "Cp2 = 0;\n",
+ "c_l = (Cp3 - Cp2)*cos(alpha);\n",
+ "c_d = (Cp3 - Cp2)*sin(alpha);\n",
+ "L_by_D = c_l/c_d;\n",
+ "print\"\\n(b) The results from Newtonian theory are:\"\n",
+ "print\"Cp2 =\",Cp2\n",
+ "print\"Cp3 =\",Cp3\n",
+ "print\"cl =\",c_l\n",
+ "print\"cd =\",c_d\n",
+ "print\"L/D =\",L_by_D"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The exact results from the shock-expansion theory are:\n",
+ "Cp2 = -0.0218681754368\n",
+ "Cp3 = 0.188459821429\n",
+ " cl = 0.203161244164\n",
+ "cd = 0.054436891307\n",
+ "L/D = 3.73205080757\n",
+ "\n",
+ "(b) The results from Newtonian theory are:\n",
+ "Cp2 = 0\n",
+ "Cp3 = 0.133974596216\n",
+ "cl = 0.129409522551\n",
+ "cd = 0.0346751770605\n",
+ "L/D = 3.73205080757\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER16.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER16.ipynb new file mode 100644 index 00000000..1dc05133 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER16.ipynb @@ -0,0 +1,140 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:2c6079d59907bdb19e3c7c545f331feab8b98bc306595300ef54457ff52405db"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER16:SOME SPECIAL CASES COUETTE AND POISEUILLE FLOWS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 524"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "\n",
+ "mue = 1.7894*10**5; # coefficient of viscosity\n",
+ "ue = 60.96; # velocity of upper plate\n",
+ "D = 2.54*10**4; # distance between the 2 plates\n",
+ "T_w = 288.3; # temperature of the plates\n",
+ "Pr = 0.71; # Prandlt number\n",
+ "cp = 1004.5; # specific heat at constant pressure\n",
+ "\n",
+ "# (a)\n",
+ "# from eq.(16.6)\n",
+ "u = ue/2;\n",
+ "\n",
+ "# (b)\n",
+ "# from eq.(16.9)\n",
+ "tow_w = mue*ue/D;\n",
+ "\n",
+ "# (c)\n",
+ "# from eq.(16.34)\n",
+ "T = T_w + Pr*ue**2/8/cp;\n",
+ "\n",
+ "# (d)\n",
+ "# from eq.(16.35)\n",
+ "q_w_dot = mue/2*ue**2/D;\n",
+ "\n",
+ "# (e)\n",
+ "# from eq.(16.40)\n",
+ "T_aw = T_w + Pr/cp*ue**2/2;\n",
+ "\n",
+ "print\"(a)u =\",u,\"m/s\"\n",
+ "print\"(b)tow_w =\",tow_w,\"N/m2\"\n",
+ "print\"(c)T =\",T,\"K\"\n",
+ "print\"(d)q_w_dot =\",q_w_dot,\"Nm-1s-1\"\n",
+ "print\"(e)Taw =\",\"K\",T_aw\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)u = 30.48 m/s\n",
+ "(b)tow_w = 429.456 N/m2\n",
+ "(c)T = 288.628328315 K\n",
+ "(d)q_w_dot = 13089.81888 Nm-1s-1\n",
+ "(e)Taw = K 289.613313258\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 524"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt\n",
+ "mue = 1.7894*10**5; # coefficient of viscosity\n",
+ "Me = 3.; # mach number of upper plate\n",
+ "D = 2.54*10**4; # distance between the 2 plates\n",
+ "pe = 101000.; # ambient pressure\n",
+ "Te = 288.; # temperature of the plates\n",
+ "Tw = Te;\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "R = 287; # specific gas constant\n",
+ "Pr = 0.71; # Prandlt number\n",
+ "cp = 1004.5; # specific heat at constant pressure\n",
+ "tow_w = 72.; # shear stress on the lower wall\n",
+ "# the velocity of the upper plate is given by\n",
+ "ue = Me*sqrt(gam*R*Te);\n",
+ "# the density at both plates is\n",
+ "rho_e = pe/R/Te;\n",
+ "# the coefficient of skin friction is given by\n",
+ "cf = 2.*tow_w/rho_e/ue**2.;\n",
+ "# from eq.(16.92)\n",
+ "C_H = cf/2/Pr;\n",
+ "# from eq.(16.82)\n",
+ "h_aw = cp*Te + Pr*ue**2/2;\n",
+ "h_w = cp*Tw;\n",
+ "q_w_dot = rho_e*ue*(h_aw-h_w)*C_H;\n",
+ "print\"The heat transfer is given by:q_w_dot =\",q_w_dot/1e4,\"W/m2\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The heat transfer is given by:q_w_dot = 3.67387998933 W/m2\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER18.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER18.ipynb new file mode 100644 index 00000000..b609acf3 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER18.ipynb @@ -0,0 +1,230 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:ac94f65c54c89da6d7a90bae31a6309586e55713ceeeb8cf1cb6a41246a395ce"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER18:LAMINAR BOUNDARY LAYERS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 595"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt\n",
+ "p_inf = 101000.; # freestream pressure\n",
+ "T_inf = 288.; # freestream temperature\n",
+ "c = 2.; # chord length of the plate\n",
+ "S = 40.; # planform area of the plate\n",
+ "mue_inf=1.7894*10.**5.; # coefficient of viscosity at sea level\n",
+ "gam=1.4; # ratio of specific heats\n",
+ "R=287.; # specific gas constant\n",
+ "# the freestream density is\n",
+ "rho_inf = p_inf/R/T_inf;\n",
+ "# the speed of sound is\n",
+ "a_inf = sqrt(gam*R*T_inf);\n",
+ "# (a)\n",
+ "V_inf = 100.;\n",
+ "# thus the mach number can be calculated as\n",
+ "M_inf = V_inf/a_inf;\n",
+ "# the Reynolds number at the trailing is given as\n",
+ "Re_c = rho_inf*V_inf*c/mue_inf;\n",
+ "# from eq.(18.22)\n",
+ "Cf = 1.328/sqrt(Re_c);\n",
+ "# the friction drag on one surface of the plate is given by\n",
+ "D_f = 1./2.*rho_inf*V_inf**2.*S*Cf;\n",
+ "# the total drag generated due to both surfaces is\n",
+ "D = 2.*D_f;\n",
+ "print\"The total frictional drag is:(a)D =\",D,\"N\"\n",
+ "# (b)\n",
+ "V_inf = 1000.;\n",
+ "# thus the mach number can be calculated as\n",
+ "M_inf = V_inf/a_inf;\n",
+ "# the Reynolds number at the trailing is given as\n",
+ "Re_c = rho_inf*V_inf*c/mue_inf;\n",
+ "# from eq.(18.22)\n",
+ "Cf = 1.2/sqrt(Re_c);\n",
+ "# the friction drag on one surface of the plate is given by\n",
+ "D_f = 1./2.*rho_inf*V_inf**2.*S*Cf;\n",
+ "# the total drag generated due to both surfaces is\n",
+ "D = 2.*D_f;\n",
+ "print\"(b) D =\",D,\"N\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total frictional drag is:(a)D = 17563872.6566 N\n",
+ "(b) D = 501884115.614 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 596"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt\n",
+ "Pr = 0.71; # Prandlt number of air at standard conditions\n",
+ "Pr_star = Pr;\n",
+ "Te = 288.; # temperature of the upper plate\n",
+ "ue = 1000.; # velocity of the upper plate\n",
+ "Me = 2.94; # Mach number of flow on the upper plate\n",
+ "p_star = 101000.;\n",
+ "R = 287.; # specific gas constant\n",
+ "T0 = 288.; # reference temperature at sea level\n",
+ "mue0 = 1.7894*10**-5; # reference viscosity at sea level\n",
+ "c = 2.; # chord length of the plate\n",
+ "S = 40.; # plate planform area\n",
+ "\n",
+ "# recovery factor for a boundary layer is given by eq.(18.47) as\n",
+ "r = sqrt(Pr);\n",
+ "\n",
+ "# rearranging eq.(16.49), we get for M = 2.94\n",
+ "T_aw = Te*(1+r*(2.74-1));\n",
+ "\n",
+ "# from eq.(18.53)\n",
+ "T_star = Te*(1 + 0.032*Me**2. + 0.58*(T_aw/Te-1.));\n",
+ "\n",
+ "# from the equation of state\n",
+ "rho_star = p_star/R/T_star;\n",
+ "\n",
+ "# from eq.(15.3)\n",
+ "mue_star = mue0*(T_star/T0)**1.5*(T0+110.)/(T_star+110.);\n",
+ "\n",
+ "# thus\n",
+ "Re_c_star = rho_star*ue*c/mue_star;\n",
+ "\n",
+ "# from eq.(18.22)\n",
+ "Cf_star = 1.328/sqrt(Re_c_star);\n",
+ "\n",
+ "# hence, the frictional drag on one surface of the plate is\n",
+ "D_f = 1./2.*rho_star*ue**2.*S*Cf_star;\n",
+ "\n",
+ "# thus, the total frictional drag is given by\n",
+ "D = 2.*D_f;\n",
+ "\n",
+ "print\"The total frictional drag is: D =\",D,\"N\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total frictional drag is: D = 4978.09594496 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 600"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "import math \n",
+ "from math import sqrt\n",
+ "Pr = 0.71; # Prandlt number of air at standard conditions\n",
+ "Pr_star = Pr;\n",
+ "Te = 288.; # temperature of the upper plate\n",
+ "ue = 1000.; # velocity of the upper plate\n",
+ "Me = 2.94; # Mach number of flow on the upper plate\n",
+ "p_star = 101000.;\n",
+ "R = 287.; # specific gas constant\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "T0 = 288.; # reference temperature at sea level\n",
+ "mue0 = 1.7894*10**-5; # reference viscosity at sea level\n",
+ "c = 2.; # chord length of the plate\n",
+ "S = 40.; # plate planform area\n",
+ "\n",
+ "# recovery factor for a boundary layer is given by eq.(18.47) as\n",
+ "r = sqrt(Pr);\n",
+ "\n",
+ "# from ex.(8.2)\n",
+ "T_aw = Te*2.467;\n",
+ "T_w = T_aw;\n",
+ "\n",
+ "# from the Meador-Smart equation\n",
+ "T_star = Te*(0.45 + 0.55*T_w/Te + 0.16*r*(gam-1)/2*Me**2.);\n",
+ "\n",
+ "# from the equation of state\n",
+ "rho_star = p_star/R/T_star;\n",
+ "\n",
+ "# from eq.(15.3)\n",
+ "mue_star = mue0*(T_star/T0)**1.5*(T0+110)/(T_star+110.);\n",
+ "\n",
+ "# thus\n",
+ "Re_c_star = rho_star*ue*c/mue_star;\n",
+ "\n",
+ "# from eq.(18.22)\n",
+ "Cf_star = 1.328/sqrt(Re_c_star);\n",
+ "\n",
+ "# hence, the frictional drag on one surface of the plate is\n",
+ "D_f = 1./2.*rho_star*ue**2.*S*Cf_star;\n",
+ "\n",
+ "# thus, the total frictional drag is given by\n",
+ "D = 2.*D_f;\n",
+ "\n",
+ "print\"The total frictional drag is: D =\",D,\"N\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total frictional drag is: D = 5014.11379241 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER19.ipynb b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER19.ipynb new file mode 100644 index 00000000..5b4bd583 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER19.ipynb @@ -0,0 +1,185 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:50af8d3cf8d660e7f072a797c56082a406513e091b4f2f4b68a912e6ceab549d"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER19:TURBULENT BOUNDARY LAYERS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 612"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "# (a)\n",
+ "import math \n",
+ "from math import sqrt\n",
+ "Re_c = 1.36e7; # as obtained from ex. 18.1a\n",
+ "rho_inf = 1.22; # freestream air denstiy\n",
+ "S = 40.; # plate planform area\n",
+ "# hence, from eq.(19.2)\n",
+ "Cf = 0.074/Re_c**0.2;\n",
+ "V_inf = 100.;\n",
+ "# hence, for one side of the plate\n",
+ "D_f = 1./2.*rho_inf*V_inf**2.*S*Cf;\n",
+ "# the total drag on both the surfaces is\n",
+ "D = 2.*D_f;\n",
+ "print\"The total frictional drag is: (a)D =\",D,\"N\"\n",
+ "# (b)\n",
+ "Re_c = 1.36e8; # as obtained from ex. 18.1b\n",
+ "# hence, from fig 19.1 we have\n",
+ "Cf = 1.34*10.**-3.;\n",
+ "V_inf = 1000.;\n",
+ "# hence, for one side of the plate\n",
+ "D_f = 1./2.*rho_inf*V_inf**2.*S*Cf;\n",
+ "# the total drag on both the surfaces is\n",
+ "D = 2.*D_f;\n",
+ "print\"(b) D =\",D,\"N\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total frictional drag is: (a)D = 1351.89748485 N\n",
+ "(b) D = 65392.0 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 612"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "# from ex 18.2\n",
+ "import math\n",
+ "from math import sqrt\n",
+ "Re_c_star = 3.754e7; # Reynolds number at the trailing edge of the plate\n",
+ "rho_star = 0.574;\n",
+ "ue = 1000.; # velocity of the upper plate\n",
+ "S = 40.; # plate planform area\n",
+ "# from eq.(19.3) we have\n",
+ "Cf_star = 0.074/Re_c_star**0.2;\n",
+ "# hence, for one side of the plate\n",
+ "D_f = 1./2.*rho_star*ue**2.*S*Cf_star;\n",
+ "# the total drag on both the surfaces is\n",
+ "D = 2.*D_f;\n",
+ "print\"The total frictional drag is:D =\",D,\"N\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total frictional drag is:D = 51916.421508 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 615"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# All the quantities are expressed in SI units\n",
+ "Me = 2.94; # mach number of the flow over the upper plate\n",
+ "ue = 1000.;\n",
+ "Te = 288.; # temperature of the upper plate\n",
+ "ue = 1000.; # velocity of the upper plate\n",
+ "S = 40.; # plate planform area\n",
+ "Pr = 0.71; # Prandlt number of air at standard condition\n",
+ "gam = 1.4; # ratio of specific heats\n",
+ "\n",
+ "# the recovery factor is given as\n",
+ "r = Pr**(1./3.);\n",
+ "\n",
+ "# for M = 2.94\n",
+ "T_aw = Te*(1.+r*(2.74-1.));\n",
+ "T_w = T_aw; # since the flat plate has an adiabatic wall\n",
+ "\n",
+ "# from the Meador-Smart equation\n",
+ "T_star = Te*(0.5*(1.+T_w/Te) + 0.16*r*(gam-1.)/2.*Me**2.);\n",
+ "\n",
+ "# from the equation of state\n",
+ "p_star=1.\n",
+ "R=1.\n",
+ "rho_star = p_star/R/T_star;\n",
+ "\n",
+ "# from eq.(15.3)\n",
+ "mue0=1.\n",
+ "T0=1.\n",
+ "c=1.\n",
+ "mue_star = mue0*(T_star/T0)**1.5*(T0+110.)/(T_star+110.);\n",
+ "\n",
+ "# thus\n",
+ "Re_c_star = rho_star*ue*c/mue_star;\n",
+ "\n",
+ "# from eq.(18.22)\n",
+ "Cf_star = 0.02667/Re_c_star**0.139;\n",
+ "\n",
+ "# hence, the frictional drag on one surface of the plate is\n",
+ "D_f = 1./2.*rho_star*ue**2.*S*Cf_star;\n",
+ "\n",
+ "# thus, the total frictional drag is given by\n",
+ "D = 2.*D_f;\n",
+ "\n",
+ "print\"The total frictional drag is:D =\",D,\"N\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total frictional drag is:D = 4967.70450221 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot02.png b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot02.png Binary files differnew file mode 100644 index 00000000..e38c28d3 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot02.png diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot04.png b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot04.png Binary files differnew file mode 100644 index 00000000..7ef80327 --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot04.png diff --git a/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot08.png b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot08.png Binary files differnew file mode 100644 index 00000000..d1376f9c --- /dev/null +++ b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot08.png diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_1.ipynb b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_1.ipynb new file mode 100644 index 00000000..24bf2c4f --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_1.ipynb @@ -0,0 +1,721 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter : 1 - Semiconductor Materials And Crystal Properties" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.18.3 - Page No : 1-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "At = 28;# Atomic weight\n", + "n = 4;\n", + "N_A = 6.023*10**23;\n", + "a = 5.3;# in \u00c5\n", + "a = a * 10**-10;# in m\n", + "m = At/N_A;# in gm\n", + "m = m*10**-3;# in kg\n", + "V = (a)**3;# in m**3\n", + "Rho = (m*n)/V;# in gm/m**3\n", + "Rho = Rho * 10**-3;# in kg/m**3\n", + "print \"The volume density = %0.3f kg/m**3 \" %Rho" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The volume density = 1.249 kg/m**3 \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.18.4 - Page No : 1-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "r = 1.278;# in \u00c5\n", + "a = (4*r)/(sqrt(2));# in \u00c5\n", + "a = a * 10**-10;# in m\n", + "V = (a)**3;# in m**3\n", + "At = 63.5;# atomic weight\n", + "N_A = 6.023*10**23;\n", + "m = At/N_A;# in gm\n", + "m = m * 10**-3;# in kg\n", + "n = 4;\n", + "Rho = (m*n)/V;# in gm/m**3\n", + "Rho = Rho * 10**-3;# in kg/m**3\n", + "print \"The density of copper crystal = %0.3f kg/m**3\" %Rho" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The density of copper crystal = 8.929 kg/m**3\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.1 - Page No : 1-50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sin, pi\n", + "# Given data\n", + "d = 2.82;# in \u00c5\n", + "d = d * 10**-10;# in m\n", + "n = 1;\n", + "theta = 10;# in degree \n", + "#Formula 2*d*sin(theta) = n*lembda;\n", + "lembda = 2*d*sin(theta*pi/180);# in m\n", + "lembda = lembda * 10**10;# in \u00c5\n", + "print \"The wavelength of X-ray = %0.3f \u00c5\" %lembda" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The wavelength of X-ray = 0.979 \u00c5\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.2 - Page No : 1-51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sin\n", + "from numpy import pi\n", + "# Given data\n", + "lembda = 1.6;# in \u00c5\n", + "lembda = lembda * 10**-10;# in m\n", + "theta = 14.2;# in degree\n", + "n = 1;\n", + "#Formula 2*d*sin(theta) = n*lembda;\n", + "d = (n*lembda)/(2*sin(theta*pi/180));# in m\n", + "d = d * 10**10;# in \u00c5\n", + "print \"The spacing of atomic layer in the crystal = %0.2f \u00c5\" %d\n", + "# Note : In the book the unit of the answer is wrong." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The spacing of atomic layer in the crystal = 3.26 \u00c5\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.3 - Page No : 1-51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sin\n", + "# Given data\n", + "n = 1;\n", + "theta = 30;# in degree \n", + "lembda = 1.78;# in \u00c5\n", + "lembda = lembda * 10**-10;# in m\n", + "#Formula 2*d*sin(theta) = n*lembda;\n", + "d = (n*lembda)/(2*sin(theta*pi/180));# in m\n", + "d = d * 10**10;# in \u00c5\n", + "print \"The interplaner spacing = %0.2f \u00c5\" %d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The interplaner spacing = 1.78 \u00c5\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.4 - Page No : 1-51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sin\n", + "# Given data\n", + "lembda = 0.58;# in \u00c5\n", + "n = 1;\n", + "theta1 = 6.45;# in degree\n", + "d = (n*lembda)/(2*sin(theta1*pi/180));# in \u00c5 \n", + "print \"Part (i) : At angle of 6.45\u00b0, Interplaner spacing of the crystal = %0.3f \u00c5\" %d\n", + "theta2 = 9.15;# in degree\n", + "d1 = (n*lembda)/(2*sin(theta2*pi/180));# in \u00c5 \n", + "print \"Part(ii) : At angle of 9.15\u00b0, Interplaner spacing of the crystal = %0.3f \u00c5\" %d1\n", + "theta3 = 13;# in degree\n", + "n2 = 1;\n", + "d2 = (n2*lembda)/(2*sin(theta3*pi/180));# in \u00c5 \n", + "print \"Part(iii) : At angle of 13\u00b0, Interplaner spacing of the crystal = %0.3f \u00c5\" %d2\n", + "# For \n", + "n=2;\n", + "d2 = (n*lembda)/(2*sin(theta3*pi/180));# in \u00c5 \n", + "print \"Part (iv) : The interplaner spacing = %0.3f \u00c5\" %d2\n", + "print \"The interplaner spacing for some other set of reflecting = %0.3f \u00c5\" %d1" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (i) : At angle of 6.45\u00b0, Interplaner spacing of the crystal = 2.582 \u00c5\n", + "Part(ii) : At angle of 9.15\u00b0, Interplaner spacing of the crystal = 1.824 \u00c5\n", + "Part(iii) : At angle of 13\u00b0, Interplaner spacing of the crystal = 1.289 \u00c5\n", + "Part (iv) : The interplaner spacing = 2.578 \u00c5\n", + "The interplaner spacing for some other set of reflecting = 1.824 \u00c5\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.5 - Page No : 1-52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "from math import asin\n", + "# Given data\n", + "a = 2.814;# in \u00c5\n", + "h = 1;\n", + "k = 0;\n", + "l = 0;\n", + "d = a/(sqrt( ((h)**2) + ((k)**2) + ((l)**2) ));# in \u00c5\n", + "n = 2;\n", + "lembda = 0.710;# in \u00c5\n", + "#Formula 2*d*sin(theta) = n*lembda;\n", + "theta = asin(n*lembda/(2*d) )*180/pi;# in degree\n", + "print \"The glacing angle = %0.2f degree\" %theta" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The glacing angle = 14.61 degree\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.6 - Page No : 1-52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi\n", + "# Given data\n", + "a = 3.65;# in \u00c5\n", + "h = 1;\n", + "k = 0;\n", + "l = 0;\n", + "d = a/(sqrt( ((h)**2) + ((k)**2) + ((l)**2) ));# in \u00c5\n", + "n = 1;\n", + "theta = 60;# in degree\n", + "#Formula 2*d*sin(theta) = n*lembda;\n", + "lembda = 2*d*sin(theta*pi/180);# in \u00c5\n", + "print \"Wavelength of X ray = %0.4f \u00c5\" %lembda" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Wavelength of X ray = 6.3220 \u00c5\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.7 - Page No : 1-53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "lembda = 1.54;# in \u00c5\n", + "lembda= lembda*10**-8;# in cm\n", + "At = 63.54;# atomic weight\n", + "density = 9.024;# in gm/cc\n", + "n = 1;\n", + "N_A = 6.023*10**23;\n", + "m = At/N_A;# mass\n", + "a =(density*m)**(1/3);# in cm\n", + "h = 1;\n", + "k = 0;\n", + "l = 0;\n", + "d = a/(sqrt( ((h)**2) + ((k)**2) + ((l)**2) ));# in cm\n", + "n = 1;\n", + "#Formula 2*d*sin(theta) = n*lembda;\n", + "theta = asin( (lembda)/(2*d) )*180/pi;# in degree\n", + "print \"The glancing angle = %0.4f degree\" %theta\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The glancing angle = 4.4893 degree\n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.8 - Page No : 1-53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "a = 3.615;# in \u00c5\n", + "theta = 22;# in degree\n", + "n = 1;\n", + "h = 1;\n", + "k = 1;\n", + "l = 1;\n", + "d = a/(sqrt( ((h)**2) + ((k)**2) + ((l)**2) ));# in \u00c5\n", + "# 2*d*sin(theta) = n*lembda;\n", + "lembda = 2*d*sin(theta*pi/180);# in \u00c5\n", + "print \"The wavelength = %0.3f \u00c5\" %lembda\n", + "n = 2;\n", + "#Formula 2*d*sin(theta) = n*lembda;\n", + "theta = asin(n*lembda/(2*d) )*180/pi;# in degree\n", + "print \"The glacing angle for second order = %0.2f degree\" %theta\n", + "print \"To get the 2nd order spectrum the position of the detector should be %0.2f \u00b0\" %(2*theta)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The wavelength = 1.564 \u00c5\n", + "The glacing angle for second order = 48.52 degree\n", + "To get the 2nd order spectrum the position of the detector should be 97.04 \u00b0\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.21.9 - Page No : 1-54" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sin\n", + "# Given data\n", + "n = 1;\n", + "lembda = 1.54;# in \u00c5\n", + "theta = 21.7;# in degree\n", + "#Formula 2*d*sin(theta) = n*lembda;\n", + "d = (lembda*n)/(2*sin(theta*pi/180));# in \u00c5\n", + "h = 1;\n", + "k = 1;\n", + "l = 1;\n", + "# Formula d = a/(sqrt( ((h)**2) + ((k)**2) + ((l)**2) ));\n", + "a = d*(sqrt( ((h)**2) + ((k)**2) + ((l)**2) ));# in \u00c5\n", + "print \"Lattice constant = %0.3f \u00c5\" %a" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Lattice constant = 3.607 \u00c5\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.22.1 - Page No : 1-56" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "a = 4.8;# in \u00c5\n", + "h = 2;\n", + "k = 1;\n", + "l = 1;\n", + "d = a/(sqrt( ((h)**2) + ((k)**2) + ((l)**2) ));# in \u00c5\n", + "print \"The distance between d_211 plains = %0.2f \u00c5\" %d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The distance between d_211 plains = 1.96 \u00c5\n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.22.2 - Page No : 1-56" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "r = 1.28;# in \u00c5\n", + "#Formula r = (a*sqrt(2))/4;\n", + "a = (4*r)/(sqrt(2));# in \u00c5\n", + "a = a * 10**-8;# in cm\n", + "n = 4;\n", + "M = 63.5;\n", + "N_A = 6.023*10**23;\n", + "Rho = (n*M)/(N_A*((a)**3));# in gm/cc\n", + "print \"The density = %0.2f gm/cc\" %Rho" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The density = 8.89 gm/cc\n" + ] + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.22.3 - Page No : 1-57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "a = 2.9;# in \u00c5\n", + "a = a * 10**-8;# in cm\n", + "Rho = 7.87;# in gm/cc\n", + "N_A = 6.023*10**23;\n", + "M = 55.85\n", + "# Rho = (n*M)/(N_A*((a)**3))\n", + "n = (Rho*N_A*((a)**3))/M;# in atoms per unit cell\n", + "print \"The number of atoms per unit cell = %0.f \" %n\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The number of atoms per unit cell = 2 \n" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.22.4 - Page No : 1-57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "M =60;# in gm/mole\n", + "Rho = 6.23;# in gm/cc\n", + "n = 4;\n", + "N_A = 6.023*10**23;\n", + "# Rho = (n*M)/(N_A*((a)**3));\n", + "a = ( (n*M)/(N_A*Rho) )**(1/3);# in cm\n", + "r = (a*sqrt(2))/4;# in cm\n", + "r = r * 10**8;# in \u00c5\n", + "print \"The radius = %0.3f \u00c5\" %r" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radius = 1.414 \u00c5\n" + ] + } + ], + "prompt_number": 31 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.22.5 - Page No : 1-57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "Rho = 5.96;# in gm/cc\n", + "M = 50;\n", + "n = 2;\n", + "N_A = 6.023*10**23;\n", + "#Formula Rho = (n*M)/(N_A*((a)**3));\n", + "a = ( (n*M)/(N_A*Rho) )**(1/3);# in cm\n", + "r = (a*sqrt(3))/4;# in cm\n", + "P_F = (2*(4/3)*pi*((r)**3))/((a)**3);# Packing factor\n", + "print \"The Packing factor = %0.2f\" %P_F" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Packing factor = 0.68\n" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.22.6 - Page No : 1-58" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "d = 5.2;# in gm/cc\n", + "n = 2;\n", + "M = 120;\n", + "N_A = 6.023*10**23;\n", + "m = M/N_A;#mass of 1 atom in gm\n", + "m = n*m;#mass of unit cell in gm\n", + "g = 20;# in gm\n", + "m = g/m;# in unit cells\n", + "print \"The number of unit cell in its 20 gm = %0.3e\" %m" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The number of unit cell in its 20 gm = 5.019e+22\n" + ] + } + ], + "prompt_number": 33 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 1.22.7 - Page No : 1-58" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "Rho = 2.48;# in gm/cc\n", + "K = 39;# molecular weight of K\n", + "F = 19; # molecular weight of F\n", + "M = K+F;# molecular weight of KF\n", + "n = 4;\n", + "N_A = 6.023*10**23;\n", + "#Formula Rho = (n*M)/(N_A*((a)**3));\n", + "a = ( (n*M)/(N_A*Rho) )**(1/3);# in cm\n", + "a = a * 10**8;# in \u00c5\n", + "r = (a*sqrt(2))/4;# in \u00c5\n", + "r = 2*r;# in \u00c5\n", + "print \"The distance between ions = %0.1f \u00c5\" %r\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The distance between ions = 3.8 \u00c5\n" + ] + } + ], + "prompt_number": 34 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_2.ipynb b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_2.ipynb new file mode 100644 index 00000000..a1c9ae29 --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_2.ipynb @@ -0,0 +1,1141 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:146b2a737d67bfa0a93cceee1f0df7461bc034ad0becba42baf98a47d6983e5d" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter : 2 - Energy Bands And Charge Carriers In Semiconductor" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.6.1 - Page No : 2-10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "h = 6.625 * 10**-34 # in J\n", + "c = 3 * 10**8 # in J\n", + "lambda_Gr = 17760 * 10**-10 # in m\n", + "lambda_Si = 11000 # in A\u00b0\n", + "lambda_Si = lambda_Si * 10**-10 # in m\n", + "E_g = (h*c)/lambda_Si # in J\n", + "E_g = E_g /(1.6*10**-19) # in eV\n", + "print \"The energy gap of Si = %0.3f eV \" %E_g" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The energy gap of Si = 1.129 eV \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.6.2 - Page No : 2-10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "E_g = 0.75# in eV\n", + "E_g = 0.75 * 1.6 * 10**-19 # in J\n", + "h = 6.63 * 10**-34 # in J\n", + "c = 3 * 10**8 # in m/s \n", + "# hv = E_g\n", + "#E_g = (h*c)/lambda\n", + "Lambda=(h*c)/E_g # in m\n", + "Lambda=Lambda * 10**10 # in A\u00b0\n", + "print \"The wavelength at which germanium starts to absorb light = %0.f A\u00b0 \" %Lambda" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The wavelength at which germanium starts to absorb light = 16575 A\u00b0 \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.15.1\n", + " - Page No : 2-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "del_E = 0.3 # in eV\n", + "T1 = 300 # in K\n", + "T2 = 330 # in K\n", + "# del_E = K * T1 * log(N/N_c) where del_E= E_C-E_F\n", + "# del_E1 = K * T2 * log(N/N_c) where del_E1= E_C-E_F at T= 330 \u00b0K\n", + "del_E1 = del_E*(T2/T1) # in eV \n", + "print \"The Fermi level will be \",round(del_E1,2),\" eV below the conduction band\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Fermi level will be 0.33 eV below the conduction band\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.15.2\n", + " - Page No : 2-31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "N_c = 2.8 * 10**19 # in cm**-3\n", + "del_E = 0.25 # fermi energy in eV\n", + "KT = 0.0259 \n", + "f_F = exp(-(del_E)/KT) \n", + "print \"The probaility in the condition band is occupied by an electron = %0.2e\" %f_F\n", + "n_o = N_c * exp(-(del_E)/KT) # in cm**-3\n", + "print \"The thermal equilibrium electron concentration = %0.1e cm**-3 \" %n_o" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The probaility in the condition band is occupied by an electron = 6.43e-05\n", + "The thermal equilibrium electron concentration = 1.8e+15 cm**-3 \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.15.3\n", + " - Page No : 2-33" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "T1 = 300 # in K\n", + "T2 = 400 # in K\n", + "del_E = 0.27 # Fermi level in eV\n", + "KT = (0.0259) * (T2/T1) # in eV\n", + "N_v = 1.04 * 10**19 # in cm**-3\n", + "N_v = N_v * (T2/T1)**(3/2) # in cm**-3 \n", + "p_o = N_v * exp(-(del_E)/KT) # in per cm**3\n", + "print \"The thermal equilibrium hole concentration = %0.2e per cm**3 \" %p_o" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The thermal equilibrium hole concentration = 6.44e+15 per cm**3 \n" + ] + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.16.1 - Page No : 2-37" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "At = 63.5;# atomic weight\n", + "Rho = 1.7*10**-6;# in ohm cm\n", + "d = 8.96;# in gm/cc\n", + "N_A = 6.02*10**23;# in /gm.mole\n", + "e = 1.6*10**-19;# in C\n", + "n = (N_A/At)*d;\n", + "Miu_e = 1/(Rho*n*e);# in cm**2/volt.sec\n", + "print \"The electron mobility = %0.3f cm**2/volt-sec\" %Miu_e" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The electron mobility = 43.281 cm**2/volt-sec\n" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.16.2 - Page No : 2-38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "l = 0.1;# in m\n", + "A = 1.7;# in mm**2\n", + "A = A * 10**-6;# in m**2\n", + "R = 0.1;# in ohm\n", + "At = 63.5;# atomic weight\n", + "N_A = 6.02*10**23;\n", + "d = 8.96;# in gm/cc\n", + "n = (N_A/At)*d;# in /cc\n", + "n = n * 10**6;# in /m**3\n", + "#Formula R = Rho*(l/A);\n", + "Rho = (R*A)/l;# in ohm m\n", + "Sigma = 1/Rho;# in mho/m\n", + "e = 1.6*10**-19;\n", + "# Formula Sigma = n*e*Miu_e\n", + "Miu_e = Sigma/(n*e);# in m**2/V.sec\n", + "print \"The mobility = %0.2e m**2/V-sec\" %Miu_e" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The mobility = 4.33e-05 m**2/V-sec\n" + ] + } + ], + "prompt_number": 31 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.16.3 - Page No : 2-39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi\n", + "# Given data\n", + "d = 10.5;# in gm/cc\n", + "At = 108;# atomic weight\n", + "N_A = 6.025*10**23;# in /gm mole\n", + "r = 10**-3;# in m\n", + "q = 1.6*10**-19;# in C\n", + "n = (N_A/At)*d;# in /cm**3\n", + "n = n * 10**6;# in /m**3\n", + "A = pi*((r)**2);# in m**2\n", + "I = 2;# in A\n", + "# I = q*n*A*v;\n", + "v = I/(n*q*A);# in m/s\n", + "print \"The drift velocity = %0.e m/s\" %v\n", + "\n", + "# Note: There is calculation error to find the value of drift velocity (i.e v), so the answer in the book is wrong." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The drift velocity = 7e-05 m/s\n" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.16.4 - Page No : 2-39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi\n", + "# Given data\n", + "d = 1.03;# in mm\n", + "d = d *10**-3;# in m\n", + "r = d/2;# in m\n", + "R = 6.51;# in ohm\n", + "l = 300;# in mm\n", + "e = 1.6*10**-19;\n", + "n = 8.4*10**28;# in /m**3\n", + "A = pi*r**2;\n", + "# R = Rho*(l/A);\n", + "Rho = (R*A)/l;#in ohm m\n", + "Sigma = 1/Rho;# in mho/m\n", + "print \"The conductivity of copper = %0.3e mho/m\" %Sigma\n", + "#Formula sigma = n*e*Miu_e\n", + "Miu_e = Sigma/(n*e);# in m**2/V.sec\n", + "print \"The mobility = %0.3e m**2/V-sec\" %Miu_e" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The conductivity of copper = 5.531e+07 mho/m\n", + "The mobility = 4.115e-03 m**2/V-sec\n" + ] + } + ], + "prompt_number": 33 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.16.5 - Page No : 2-40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "At = 63.5;# atomic weight\n", + "d = 8.96;# in gm/cc\n", + "Miu_e = 43.28;# in cm**2/V.sec\n", + "N_A = 6.02*10**23;# in /gm mole\n", + "e = 1.6*10**-19;# in C\n", + "n = (N_A/At)*d;# in /cc\n", + "Rho = 1/(n*e*Miu_e);# in ohm-cm\n", + "print \"The resistivity = %0.1e ohm-cm\" %Rho" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resistivity = 1.7e-06 ohm-cm\n" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.1 - Page No : 2-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Mu_e = 1500 # in cm**2/volt sec\n", + "Mu_h = 500 # in cm**2/volt sec\n", + "n_i = 1.6 * 10**10 # in per cm**3\n", + "e = 1.6 * 10**-19 # in C\n", + "Sigma = n_i * (Mu_e + Mu_h) * e # in mho/cm\n", + "print \"The conductivity of pure semiconductor = %0.2e mho/cm \" %Sigma" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The conductivity of pure semiconductor = 5.12e-06 mho/cm \n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.2 - Page No : 2-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Rho = 10 # in \u03a9-cm\n", + "Mu_d = 500 # in cm**2/v.s.\n", + "e = 1.6*10**-19 \n", + "n_d = 1/(Rho * e * Mu_d) # in per cm**3\n", + "print \"The number of donor atom must be added to achieve = %0.2e per cm**3 \" %n_d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The number of donor atom must be added to achieve = 1.25e+15 per cm**3 \n" + ] + } + ], + "prompt_number": 36 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.3 - Page No : 2-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given data\n", + "AvagadroNumber = 6.02 * 10**23 # in atoms/gm.mole\n", + "at_Ge = 72.6 # atom weight of Ge\n", + "e = 1.6 * 10**-19 # in C\n", + "D_Ge = 5.32 # density of Ge in gm/c.c\n", + "Mu = 3800 # in cm**2/v.s.\n", + "C_Ge = (AvagadroNumber/at_Ge) * D_Ge # concentration of Ge atoms in per cm**3\n", + "n_d = C_Ge/10**8 # in per cc\n", + "Sigma = n_d * Mu * e # in mho/cm\n", + "print \"The conductivity = %0.3f mho/cm \" %Sigma" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The conductivity = 0.268 mho/cm \n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.4 - Page No : 2-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Rho = 0.3623 * 10**-3 # in Ohm m\n", + "Sigma = 1/Rho #in mho/m\n", + "D = 4.42 * 10**28 # Ge density in atom/m**3\n", + "n_d = D / 10**6 # in atom/m**3\n", + "e = 1.6 * 10**-19 # in C\n", + "Mu = Sigma/(n_d * e) # in m**2/V.sec\n", + "print \"The mobility of electron in germanium = %0.2f m**2/V.sec \" %Mu" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The mobility of electron in germanium = 0.39 m**2/V.sec \n" + ] + } + ], + "prompt_number": 38 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.5 - Page No : 2-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "AvagadroNumber = 6.025 * 10**26 # in kg.Mole\n", + "W = 72.59 # atomic weight of Ge\n", + "D = 5.36 * 10**3 #density of Ge in kg/m**3\n", + "Rho = 0.42 # resistivity in Ohm m\n", + "e = 1.6 * 10**-19 # in C\n", + "Sigma = 1/Rho # in mho/m\n", + "n = (AvagadroNumber/W) * D # number of Ge atoms present per unit volume\n", + "# Holes per unit volume, H = n*10**-6%\n", + "H= n*10**-8 \n", + "a=H \n", + "# Formula sigma= a*e*Mu_h\n", + "Mu_h = Sigma/(a * e) # in m**2/V.sec\n", + "print \"Mobility of holes = %0.4f m**2/V.sec \" %Mu_h" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mobility of holes = 0.0334 m**2/V.sec \n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.6 - Page No : 2-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "e = 1.6 * 10**-19 # in C\n", + "n_i = 2 * 10**19 # in /m**3\n", + "Mu_e = 0.36 # in m**2/v.s\n", + "Mu_h = 0.17 # in m**2/v.s\n", + "A = 1 * 10**-4 # in m**2\n", + "V = 2 #in volts\n", + "l = 0.3 # in mm\n", + "l = l * 10**-3 # in m\n", + "E=V/l # in volt/m\n", + "Sigma = n_i * e * (Mu_e + Mu_h) # in mho/m\n", + "# J = I/A = Sigma * E\n", + "I= Sigma*E*A \n", + "print \"The current produced in a small germanium plate = %0.2f amp \" %I\n", + "\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The current produced in a small germanium plate = 1.13 amp \n" + ] + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.7 - Page No : 2-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "D = 4.2 * 10**28 #density of Ge atoms in atoms/m**3\n", + "N_d = D / 10**6 # in atoms/m**3\n", + "e = 1.6 * 10**-19 # in C\n", + "Mu_e = 0.36 # in m**2/vs\n", + "Sigma_n = N_d * e * Mu_e # in mho/m\n", + "Rho_n = 1/Sigma_n # in ohm m\n", + "print \"The resistivity of drop Ge = %0.3e ohm m \" %Rho_n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resistivity of drop Ge = 4.134e-04 ohm m \n" + ] + } + ], + "prompt_number": 41 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.8 - Page No : 2-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "e = 1.6 * 10**-19 # in C\n", + "n_i = 1 * 10**19 # in per m**3\n", + "Mu_e = 0.36 # in m**2/volt.sec\n", + "Mu_h = 0.17 # in m**2/volt.sec \n", + "A = 2 # in cm**2\n", + "A = A * 10**-4 # im m**2\n", + "t = 0.1 # in mm\n", + "t = t * 10**-3 # in m\n", + "V = 4 # in volts\n", + "Sigma_i = n_i * e * (Mu_e + Mu_h) # in mho/m\n", + "J = Sigma_i * (V/t) # in Amp/m**2\n", + "I = J * A # in Amp\n", + "print \"The current produced in a Ge sample = %0.3f Amp \" %I" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The current produced in a Ge sample = 6.784 Amp \n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.17.9 - Page No : 2-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "e = 1.6 * 10**-19 # in C\n", + "Mu_h = 500 # in cm**2/V.s.\n", + "Mu_e = 1500 # in cm**2/V.s.\n", + "n_i = 1.6 * 10**10 # in per cm**3\n", + "Sigma_i = n_i * e * ( Mu_h + Mu_e) # in mho/cm\n", + "print \"Conductivity of pure silicon at room temperature = %0.2e mho/cm \" %Sigma_i" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Conductivity of pure silicon at room temperature = 5.12e-06 mho/cm \n" + ] + } + ], + "prompt_number": 43 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.19.1 - Page No : 2-50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given data\n", + "l= 0.50*10**-2 # width of ribbon in m\n", + "d= 0.10*10**-3 # thickness of ribbon in m\n", + "A= l*d # area of ribbon in m**2\n", + "B = 0.8 # in Tesla\n", + "D = 10.5 #density in gm/cc\n", + "I = 2 # in amp\n", + "q = 1.6 * 10**-19 # in C\n", + "n=6*10**28 # number of elec. per m**3\n", + "V_H = ( I * B * d)/(n * q * A) # in volts\n", + "print \"The hall Voltage produced = %0.2e volts \" %V_H" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The hall Voltage produced = 3.33e-08 volts \n" + ] + } + ], + "prompt_number": 44 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.19.2 - Page No : 2-51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "l = 1 # in m\n", + "d = 1 # in cm\n", + "d = d * 10**-2 # in m\n", + "W = 1 # in mm\n", + "W = W * 10**-3 # in m\n", + "A = d * W # in m**2\n", + "I= 1 # in Amp\n", + "B = 1 # Tesla\n", + "V_H = 0.074 * 10**-6 # in Volts\n", + "Sigma = 5.8 * 10**7 # in mho/m\n", + "R_H = (V_H * A)/(B*I*d) # in m**3/c\n", + "print \"The hall coefficient = %0.1e m**3/c \" %R_H\n", + "Mu = Sigma * R_H # in m**2/volt.sec\n", + "print \"The mobility of electrons in copper = %0.1e m**2/volt-sec \" %Mu" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The hall coefficient = 7.4e-11 m**3/c \n", + "The mobility of electrons in copper = 4.3e-03 m**2/volt-sec \n" + ] + } + ], + "prompt_number": 45 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.20.1 - Page No : 2-52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "n_i = 1.4 * 10**18 # in /m**3\n", + "n_D = 1.4 * 10**24 # in /m**3\n", + "n=n_D # in /m**3\n", + "p = n_i**2/n # in /m**3\n", + "R = n/p \n", + "print \"The ratio of electrons to hole concentration = %0.1e\" %R" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ratio of electrons to hole concentration = 1.0e+12\n" + ] + } + ], + "prompt_number": 46 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.20.2 - Page No : 2-53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import atan, pi\n", + "# Given data\n", + "B = 0.48 # in wb/m**2\n", + "R_H = 3.55 * 10**-4 # in m**3/c\n", + "Rho = 0.00912 # in ohm-m\n", + "Sigma = 1/Rho # in (ohm-m)**-1\n", + "theta_H = atan( Sigma * B * R_H)*180/pi # in degree\n", + "print \"The hall angle for a hall coefficient = %0.4f\u00b0\" %theta_H" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The hall angle for a hall coefficient = 1.0704\u00b0\n" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.20.3 - Page No : 2-53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given data\n", + "R = 9 * 10**-3 # in ohm-m\n", + "R_H = 3.6 * 10**-4 # in m**3\n", + "e = 1.6 * 10**-19 # in C\n", + "Sigma = 1/R # in (ohm-m)**-1\n", + "Rho = 1/R_H # in coulomb/m**3\n", + "n = Rho/e # in /m**3\n", + "print \"Density of charge carriers = %0.5e per m**3 \" %n\n", + "Mu = Sigma * R_H # in m**2/v-s\n", + "print \"Mobility of charge carriers = %0.2f m**2/V-s \" %Mu" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Density of charge carriers = 1.73611e+22 per m**3 \n", + "Mobility of charge carriers = 0.04 m**2/V-s \n" + ] + } + ], + "prompt_number": 48 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.24.1 - Page No : 2-60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "e = 1.6 * 10**-19 # in C\n", + "R_H = 0.0145 # in m**3/coulomb\n", + "Mu_e = 0.36 # in m**2/v-s\n", + "E = 100 # in V/m\n", + "n = 1/(e * R_H) # in /m**3\n", + "J = n * e * Mu_e * E # in A/m**2\n", + "print \"The current density of specimen = %0.3e A/m**2 \" %J" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The current density of specimen = 2.483e+03 A/m**2 \n" + ] + } + ], + "prompt_number": 49 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.24.2 - Page No : 2-60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "#Given data\n", + "Mu_e = 7.04 * 10**-3 # in m**2/v-s\n", + "m = 9.1 * 10**-31 \n", + "E_F = 5.5 # in eV\n", + "n = 5.8 * 10**28 \n", + "e = 1.6 * 10**-19 # in C\n", + "Torque = (Mu_e/e) * m # in sec\n", + "print \"Relaxation Time = %0.3e sec \" %Torque\n", + "Rho = 1 /(n * e * Mu_e) # in ohm-m\n", + "print \"Resistivity of conductor = %0.3e ohm-m \" %Rho\n", + "V_F = sqrt((2 * E_F * e)/m) # in m/s\n", + "print \"Velocity of electrons with fermi-energy = %0.4e m/s \" %V_F" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Relaxation Time = 4.004e-14 sec \n", + "Resistivity of conductor = 1.531e-08 ohm-m \n", + "Velocity of electrons with fermi-energy = 1.3907e+06 m/s \n" + ] + } + ], + "prompt_number": 50 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.24.3 - Page No : 2-61" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Given data\n", + "E= 5.95 # in eV\n", + "EF= 6.25 # in eV\n", + "delE= 0.01 \n", + " # delE= 1-1/(1+exp((E-EF)/KT))\n", + "K=1.38*10**-23 # Boltzman Constant in J/K\n", + "T = ((E-EF)/log(1/(1-delE) -1)*1.6*10**-19)/K # in K\n", + "print \"The temperature =\" ,int(T),\"K\"\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The temperature = 756 K\n" + ] + } + ], + "prompt_number": 51 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.24.4 - Page No : 2-61" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data \n", + "N_V = 1.04 * 10**19 # in cm**-3\n", + "T1 = 300 # in K\n", + "T2 = 400 # in K\n", + "del_E = 0.27 # in eV\n", + "N_V = N_V * (T2/T1)**1.5 # in cm**-3\n", + "KT = (0.0259) * (T2/T1) # in eV\n", + "P_o = N_V * exp(-(del_E)/KT) # in cm**-3\n", + "print \"The thermal equilibrium hole concentration in silicon = %0.2e cm**-3 \" %P_o" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The thermal equilibrium hole concentration in silicon = 6.44e+15 cm**-3 \n" + ] + } + ], + "prompt_number": 52 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.24.5 - Page No : 2-62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt, exp\n", + "#Given data\n", + "N_c = 2.8 * 10**19 \n", + "N_V = 1.04 *10**19 \n", + "T1 = 550 # in K\n", + "T2 = 300 # in K\n", + "E_g = 1.12 \n", + "KT = (0.0259) \n", + "n_i = sqrt(N_c *N_V *(T1/T2)**3* exp(-(E_g)/KT*T2/T1)) # in cm**-3\n", + "# n_o = N_d/2 + sqrt((N_d/2)**2 + (n_i)**2)\n", + "# 1.05*N_d -N_d/2= sqrt((N_d/2)**2 + (n_i)**2)\n", + "N_d=sqrt((n_i)**2/((0.55)**2-1/4)) \n", + "print \"Minimum donor concentration required = %0.3e cm**-3 \" %N_d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Minimum donor concentration required = 1.396e+15 cm**-3 \n" + ] + } + ], + "prompt_number": 53 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 2.24.6 - Page No : 2-62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "#Given data\n", + "T = 300 # in K\n", + "n_o = 10**15 # in cm**-3\n", + "n_i = 10**10 # in cm**-3\n", + "p_o = 10**5 # in cm**-3\n", + "del_n = 10**13 # in cm**-3\n", + "del_p = del_n # in cm**-3\n", + "KT = 0.0259 # in eV\n", + "delta_E1= KT*log(n_o/n_i) # value of E_F-E_Fi in eV\n", + "delta_E2= KT*log((n_o+del_n)/n_i) # value of E_Fn-E_Fi in eV\n", + "delta_E3= KT*log((p_o+del_p)/n_i) # value of E_Fi-E_Fp in eV\n", + "print \"The Fermi level for thermal equillibrium = %0.4f eV \" %delta_E1\n", + "print \"The quase-Fermi level for electrons in non equillibrium = %0.4f eV \" %delta_E2\n", + "print \"The quasi-Fermi level for holes in non equillibrium = %0.3f eV \" %delta_E3\n", + "print \"The quasi-Fermi level for electrons is above E_Fi while the quasi-Fermi level for holes is below E_Fi\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Fermi level for thermal equillibrium = 0.2982 eV \n", + "The quase-Fermi level for electrons in non equillibrium = 0.2984 eV \n", + "The quasi-Fermi level for holes in non equillibrium = 0.179 eV \n", + "The quasi-Fermi level for electrons is above E_Fi while the quasi-Fermi level for holes is below E_Fi\n" + ] + } + ], + "prompt_number": 54 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_3.ipynb b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_3.ipynb new file mode 100644 index 00000000..47b17dd2 --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_3.ipynb @@ -0,0 +1,900 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:764d1c60d9fefbb17ec0ffb4d8cdbf1cddd8802a6e86f8e004d6805017f0ecae" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter : 3 - Excess Carriers in Semiconductor" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.1 - Page No : 3-38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "N_d = 10**17 # atoms/cm**3\n", + "n_i = 1.5 * 10**10 # in /cm**3\n", + "n_o = 10**17 # in cm**3\n", + "# p_o * n_o = (n_i)**2\n", + "p_o = (n_i)**2 / n_o #in holes/cm**3\n", + "print \"The holes concentration at equilibrium = %0.2e holes/cm**3 \" %p_o" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The holes concentration at equilibrium = 2.25e+03 holes/cm**3 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.3 - Page No : 3-40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Given data\n", + "n_i = 1.5 * 10 **10 # in /cm**3 for silicon\n", + "N_d = 10**17 # in atoms/cm**3\n", + "n_o = 10**17 # electrons/cm**3\n", + "KT = 0.0259 \n", + "# E_r - E_i = KT * log(n_o/n_i)\n", + "del_E = KT * log(n_o/n_i) # in eV\n", + "print \"The energy band for this type material, E_F = Ei +\",round(del_E,3),\" eV\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The energy band for this type material, E_F = Ei + 0.407 eV\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.4 - Page No : 3-41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "K = 1.38 * 10**-23 # in J/K\n", + "T = 27 # in degree\n", + "T = T + 273 # in K\n", + "e = 1.6 * 10**-19 # in C\n", + "Mu_e = 0.17 # in m**2/v-s\n", + "Mu_e1 = 0.025 # in m**2/v-s\n", + "D_n = ((K * T)/e) * Mu_e # in m**2/s\n", + "print \"The diffusion coefficient of electrons = %0.1e m**2/s \" %D_n\n", + "D_p = ((K * T)/e) * Mu_e1 # in m**2/s\n", + "print \"The diffusion coefficient of holes = %0.2e m**2/s \" %D_p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffusion coefficient of electrons = 4.4e-03 m**2/s \n", + "The diffusion coefficient of holes = 6.47e-04 m**2/s \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.5 - Page No : 3-41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "Mu_n = 0.15 # in m**2/v-s\n", + "K = 1.38 * 10**-23 # in J/K\n", + "T = 300 # in K\n", + "del_n = 10**20 # in per m**3\n", + "Toh_n = 10**-7 # in s\n", + "e = 1.6 * 10**-19 # in C\n", + "D_n = Mu_n * ((K * T)/e) # in m**2/s\n", + "print \"The diffusion coefficient = %0.2e m**2/s \" %D_n\n", + "L_n = sqrt(D_n * Toh_n) # in m \n", + "print \"The Diffusion length = %0.2e m \" %L_n\n", + "J_n = (e * D_n * del_n)/L_n # in A/m**2\n", + "print \"The diffusion current density = %0.2e A/m**2 \" %J_n\n", + "# Note : The value of diffusion coefficient in the book is wrong." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffusion coefficient = 3.88e-03 m**2/s \n", + "The Diffusion length = 1.97e-05 m \n", + "The diffusion current density = 3.15e+03 A/m**2 \n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.6 - Page No : 3-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Sigma = 0.1 # in (ohm-m)**-1\n", + "Mu_n = 1300 \n", + "n_i = 1.5 * 10**10 \n", + "q = 1.6 * 10**-19 # in C\n", + "n_n = Sigma/(Mu_n * q) # in electrons/cm**3\n", + "print \"The concentration of electrons = %0.2e per m**3 \" %(n_n*10**6)\n", + "p_n = (n_i)**2/n_n # in per cm**3\n", + "p_n = p_n * 10**6 # in perm**3\n", + "print \"The concentration of holes = %0.2e per m**3 \" %p_n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The concentration of electrons = 4.81e+20 per m**3 \n", + "The concentration of holes = 4.68e+11 per m**3 \n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.7 - Page No : 3-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Mu_e = 0.13 # in m**2/v-s\n", + "Mu_h = 0.05 # in m**2/v-s\n", + "Toh_h = 10**-6 # in s\n", + "L = 100 # in \u00b5m\n", + "L = L * 10**-6 # in m\n", + "V = 2 # in V\n", + "t_n =L**2/(Mu_e * V) # in s\n", + "print \"Electron transit time = %0.1e seconds \" %t_n\n", + "p_g = (Toh_h/t_n) * (1 + Mu_h/Mu_e) #photo conductor gain \n", + "print \"Photo conductor gain = %0.2f\" %p_g\n", + "\n", + "# Note: There is a calculation error to evaluate the value of t_n. So the answer in the book is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Electron transit time = 3.8e-08 seconds \n", + "Photo conductor gain = 36.00\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.8 - Page No : 3-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "n_i = 2.5 * 10**13 \n", + "Mu_n = 3800 \n", + "Mu_p = 1800 \n", + "q = 1.6 * 10**-19 # in C\n", + "Sigma = n_i * (Mu_n + Mu_p) * q # in (ohm-cm)**-1\n", + "Rho = 1/Sigma # in ohm-cm\n", + "Rho= round(Rho) \n", + "print \"The resistivity of intrinsic germanium = %0.f ohm-cm \" %Rho\n", + "N_D = 4.4 * 10**22/(1*10**8) # in atoms/cm**3\n", + "Sigma_n = N_D * Mu_n * q # in (ohm-cm)**-1\n", + "Rho_n = 1/Sigma_n # in ohm-cm\n", + "print \"If a donor type impurity is added to the extent of 1 atom per 10**8 Ge atoms, then the resistivity drops = %0.2f ohm-cm \" %Rho_n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resistivity of intrinsic germanium = 45 ohm-cm \n", + "If a donor type impurity is added to the extent of 1 atom per 10**8 Ge atoms, then the resistivity drops = 3.74 ohm-cm \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.9 - Page No : 3-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "n_i = 10**16 # in /m3\n", + "N_D = 10**22 # in /m**3\n", + "n = N_D # in /m**3\n", + "print \"Electron concentration = %0.1e per m**3 \" %n\n", + "p = (n_i)**2/n # in /m**3\n", + "print \"Hole concentration = %0.1e per m**3 \" %p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Electron concentration = 1.0e+22 per m**3 \n", + "Hole concentration = 1.0e+10 per m**3 \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.10 - Page No : 3-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Rho = 9.6 * 10**-2 # in ohm-m\n", + "Sigma_n = 1/Rho # in (ohm-m)**-1\n", + "q = 1.6 * 10**-19 # in C\n", + "Mu_n = 1300 * 10**-4 # in m**2/v-s\n", + "N_D = Sigma_n / (Mu_n * q) # in atoms/m**3\n", + "A_D = N_D # Atom density in atoms/cm**3\n", + "A_D = A_D * 10**6 # atoms/m**3\n", + "R_si = N_D/A_D # ratio\n", + "print \"The ratio of donor atom to silicon atom = %0.1e\" %R_si\n", + "\n", + "# Note: In the book the wrong value of N_D (5*10**22) is putted to evaluate the value of \n", + "# Atom Density (A_D) whereas the value of N_D is calculated as 5*10**20.So the answer in the book is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ratio of donor atom to silicon atom = 1.0e-06\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.11 - Page No : 3-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "n_i = 1.5 * 10**10 # in per cm**3\n", + "n_n = 2.25 * 10**15 # in per cm**3\n", + "p_n = (n_i)**2/n_n # in per cm**3\n", + "print \"The equilibrium electron = %0.1e per cm**3 \" %p_n\n", + "h_n = n_n # in cm**3\n", + "print \"Hole densities = %0.2e per cm**3 \" %h_n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The equilibrium electron = 1.0e+05 per cm**3 \n", + "Hole densities = 2.25e+15 per cm**3 \n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.12 - Page No : 3-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "N_A = 2 * 10**16 # in atoms/cm**3\n", + "N_D = 10**16 # in atoms/cm**3\n", + "C_c = N_A-N_D # C_c stands for Carrier concentration in /cm**3\n", + "print \"Carrier concentration = %0.1e holes/cm**3 \" %C_c" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Carrier concentration = 1.0e+16 holes/cm**3 \n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.13 - Page No : 3-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "del_n = 10**15 # in cm**3\n", + "Torque_p = 10 * 10**-6 # in sec\n", + "R_g = del_n/Torque_p # in hole pairs/sec/cm**3\n", + "print \"The rate of generation of minority carrier = %0.1e electron hole pairs/sec/cm**3 \" %R_g" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The rate of generation of minority carrier = 1.0e+20 electron hole pairs/sec/cm**3 \n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.14 - Page No : 3-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "v = 1/(20 * 10**-6) # in cm/sec\n", + "E = 10 # in V/cm\n", + "Mu= v/E # in cm**2/V-sec\n", + "print \"The mobility of minority charge carrier = %0.f cm**2/V-sec \" %Mu" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The mobility of minority charge carrier = 5000 cm**2/V-sec \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.15 - Page No : 3-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "q = 1.6 * 10**-19 # in C\n", + "N_D = 4.5 * 10**15 # in /cm**3\n", + "del_p = 10**21 \n", + "e=10 # in cm\n", + "A = 1 # in mm**2\n", + "A = A * 10**-14 # cm**2\n", + "l = 10 # in cm\n", + "Torque_p = 1 # in microsec\n", + "Torque_p = Torque_p * 10**-6 # in sec\n", + "Torque_n = 1 # in microsec\n", + "Torque_n = Torque_n * 10**-6 # in sec\n", + "n_i = 1.5 * 10**10 # in /cm**3\n", + "D_n = 30 # in cm**2/sec\n", + "D_p = 12 # in cm**2/sec\n", + "n_o = N_D # in /cm**3\n", + "p_o = (n_i)**2/n_o # in /cm**3\n", + "print \"Hole concentration at thermal equilibrium = %0.1e per cm**3 \" %p_o\n", + "l_n = sqrt(D_n * Torque_n) # in cm\n", + "print \"Diffusion length of electron = %0.2e cm \" %l_n\n", + "l_p = sqrt(D_p * Torque_p) # in cm\n", + "print \"Diffusion length of holes = %0.1e cm \" %l_p\n", + "x=34.6*10**-4 # in cm\n", + "dpBYdx = del_p *e # in cm**4\n", + "print \"Concentration gradient of holes = %0.1e cm**4 \" %dpBYdx\n", + "e1 = 1.88 * 10**1 # in cm\n", + "dnBYdx = del_p * e1 # in cm**4 \n", + "print \"Concentration gradient of electrons = %0.2e per cm**4 \" %dnBYdx\n", + "J_P = -(q) * D_p * dpBYdx # in A/cm**2\n", + "print \"Current density of holes due to diffusion = %0.2e A/cm**2 \" %J_P\n", + "J_n = q * D_n * dnBYdx # in A/cm**2\n", + "print \"Current density of electrons due to diffusion = %0.1e A/cm**2 \" %J_n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Hole concentration at thermal equilibrium = 5.0e+04 per cm**3 \n", + "Diffusion length of electron = 5.48e-03 cm \n", + "Diffusion length of holes = 3.5e-03 cm \n", + "Concentration gradient of holes = 1.0e+22 cm**4 \n", + "Concentration gradient of electrons = 1.88e+22 per cm**4 \n", + "Current density of holes due to diffusion = -1.92e+04 A/cm**2 \n", + "Current density of electrons due to diffusion = 9.0e+04 A/cm**2 \n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.16 - Page No : 3-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "e= 1.6*10**-19 # electron charge in C\n", + "h = 6.626 * 10**-34 # in J-s\n", + "h= h/e # in eV\n", + "c = 3 * 10**8 # in m/s\n", + "lembda = 5490 * 10**-10 # in m\n", + "f = c/lembda \n", + "E = h * f # in eV\n", + "print \"The energy band gap of the semiconductor material = %0.2f eV \" %E" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The energy band gap of the semiconductor material = 2.26 eV \n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.17 - Page No : 3-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "y2 = 6 * 10**16 # in /cm**3\n", + "y1 = 10**17 # in /cm**3\n", + "x2 = 2 # in \u00b5m\n", + "x1 = 0 # in \u00b5m\n", + "D_n = 35 # in cm**2/sec\n", + "q = 1.6 *10**-19 # in C\n", + "dnBYdx = (y2 - y1)/((x2-x1) * 10**-4) \n", + "J_n = q * D_n * dnBYdx # in A/cm**2\n", + "print \"The current density in silicon = %0.f A/cm**2 \" %J_n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The current density in silicon = -1120 A/cm**2 \n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.18 - Page No : 3-50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "q = 1.6 * 10**-19 # in C\n", + "n_n = 5 * 10**20 # in /m**3\n", + "n_n = n_n * 10**-6 # in cm**3\n", + "Mu_n = 0.13 # in m**2/V-sec\n", + "Mu_n = Mu_n * 10**4 # in cm**2/V-sec\n", + "Sigma_n = q * n_n * Mu_n # in (ohm-cm)**-1\n", + "Rho = 1/Sigma_n # in \u03a9-cm\n", + "l = 0.1 # in cm\n", + "A = 100 # \u00b5m**2\n", + "A = A * 10**-8 # in cm**2\n", + "R = Rho * (l/A) # in Ohm\n", + "R=round(R*10**-6) # in M\u03a9\n", + "print \"The resistance of the bar = %0.f M\u03a9 \" %R" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resistance of the bar = 1 M\u03a9 \n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.19 - Page No : 3-51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "t_d = 3 # total depletion in \u00b5m\n", + "D = t_d/9 # in \u00b5m\n", + "print \"Depletion width = %0.1f \u00b5m \" %D" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Depletion width = 0.3 \u00b5m \n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.20 - Page No : 3-51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "n_i = 1.5 * 10**16 # in /m**3\n", + "n_n = 5 * 10**20 # in /m**3\n", + "p_n = (n_i)**2/n_n # in /m**3\n", + "print \"The majority carrier density = %0.2e per m**3 \" %p_n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The majority carrier density = 4.50e+11 per m**3 \n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.21 - Page No : 3-52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "D_n = 25 # in cm**2/sec\n", + "q = 1.6 * 10**-19 # in C\n", + "y2 = 10**14 # in /cm**3\n", + "y1 = 0 # in /cm**3\n", + "x2 = 0 #in \u00b5m\n", + "x1 = 0.5 # in \u00b5m\n", + "x1 = x1 * 10**-4 # in cm\n", + "dnBYdx = abs((y2-y1)/(x2-x1)) # in /cm**4 \n", + "J_n = q * D_n * (dnBYdx) # in /cm**4\n", + "J_n = J_n * 10**-1 # in A/cm**2\n", + "print \"The collector current density = %0.f A/cm**2 \" %J_n\n", + "\n", + "# Note: In the book, the calculated value of dn by dx (2*10**19) is wrong. Correct value is 2*10**18\n", + "# so the answer in the book is wrong." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The collector current density = 1 A/cm**2 \n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.22 - Page No : 3-53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "h = 6.64 * 10**-34 # in J-s\n", + "e= 1.6*10**-19 # electron charge in C\n", + "c= 3 * 10**8 # in m/s\n", + "lembda = 0.87 # in \u00b5m\n", + "lembda = lembda * 10**-6 # in m\n", + "E_g = (h * c)/lembda # in J-s\n", + "E_g= E_g/e # in eV\n", + "print \"The band gap of the material = %0.3f eV \" %E_g" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The band gap of the material = 1.431 eV \n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.23 - Page No : 3-53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "I_o = 10 # in mW\n", + "e = 1.6 * 10**-19 # in J/eV\n", + "hv = 2 # in eV\n", + "hv1=1.43 # in eV\n", + "alpha = 5 * 10**4 # in cm**-1\n", + "l = 46 # in \u00b5m\n", + "l = l * 10**-6 # in m\n", + "I_t = round(I_o * exp(-(alpha) * l)) # in mW\n", + "AbsorbedPower= I_o-I_t # in mW\n", + "AbsorbedPower=AbsorbedPower*10**-3 # in W or J/s\n", + "print \"The absorbed power = %0.1e watt or J/s \" %AbsorbedPower\n", + "F= (hv-hv1)/hv # fraction of each photon energy unit\n", + "EnergyConToHeat= AbsorbedPower*F # in J/s\n", + "print \"The amount of energy converted to heat per second = %0.2e in J/s \" %EnergyConToHeat\n", + "A= (AbsorbedPower-EnergyConToHeat)/(e*hv1) \n", + "print \"The number of photon per sec given off from recombination events = %0.2e photons/s \" %A" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The absorbed power = 9.0e-03 watt or J/s \n", + "The amount of energy converted to heat per second = 2.57e-03 in J/s \n", + "The number of photon per sec given off from recombination events = 2.81e+16 photons/s \n" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 3.21.24 - Page No : 3-54" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt, exp, log\n", + "# Given data\n", + "Mu_p = 500 # in cm**2/v-s\n", + "kT = 0.0259 \n", + "Toh_p = 10**-10 # in sec\n", + "p_o = 10**17 # in cm**-3\n", + "q= 1.6*10**-19 # in C\n", + "A=0.5 # in square meter\n", + "del_p = 5 * 10**16 # in cm**-3\n", + "n_i= 1.5*10**10 # in cm**-3 \n", + "D_p = kT * Mu_p # in cm/s\n", + "L_p = sqrt(D_p * Toh_p) # in cm\n", + "x = 10**-5 # in cm\n", + "p = p_o+del_p* exp(x/L_p) # in cm**-3\n", + "# p= n_i*%e**(Eip)/kT where Eip=E_i-F_p\n", + "Eip= log(p/n_i)*kT # in eV\n", + "Ecp= 1.1/2-Eip # value of E_c-E_p in eV\n", + "Ip= q*A*D_p/L_p*del_p*exp(x/L_p) # in A\n", + "print \"The hole current = %0.2e A \" %Ip\n", + "Qp= q*A*del_p*L_p # in C\n", + "print \"The value of Qp = %0.2e C \" %Qp\n", + "\n", + "# Note: There is a calculation error or miss print to evalaute the value of hole current but they putted correct \n", + "# value of it to evaluate the value of Qp.Hence the value of hole current in the book is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The hole current = 1.90e+03 A \n", + "The value of Qp = 1.44e-07 C \n" + ] + } + ], + "prompt_number": 23 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_4.ipynb b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_4.ipynb new file mode 100644 index 00000000..21949b99 --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_4.ipynb @@ -0,0 +1,962 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:05740426f73b9605877bfd0b7708432621382112013a8d4f8751c47309a06737" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter : 4 - Junction Properties" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.1 - Page No : 4-69" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import log\n", + "# Given data\n", + "t = 4.4 * 10**22 # total number of Ge atoms/cm**3\n", + "n = 1 * 10**8 # number of impurity atoms\n", + "N_A = t/n # in atoms/cm**3\n", + "N_A = N_A * 10**6 # in atoms/m**3\n", + "N_D = N_A * 10**3 # in atoms/m**3\n", + "n_i = 2.5 * 10**13 # in atoms/cm**3\n", + "n_i = n_i * 10**6 # in atoms/m**3\n", + "V_T = 26 #in mV\n", + "V_T= V_T*10**-3 # in V\n", + "V_J = V_T * log((N_A * N_D)/(n_i)**2) # in V\n", + "print \"Part (a) : The contact potential = %0.3f V \" %V_J\n", + "# Part (b)\n", + "t = 5* 10**22 # total number of Si atoms/cm**3\n", + "N_A = t/n # in atoms/cm**3\n", + "N_A = N_A * 10**6 # in atoms/m**3\n", + "N_D = N_A * 10**3 # in atoms/m**3\n", + "n_i = 1.5 * 10**10 # in atoms/cm**3\n", + "n_i = n_i * 10**6 # in atoms/m**3\n", + "V_T = 26 #in mV\n", + "V_T= V_T*10**-3 # in V\n", + "V_J = V_T * log((N_A * N_D)/(n_i)**2) # in V\n", + "print \"Part (b) : The contact potential = %0.3f V \" %V_J" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (a) : The contact potential = 0.329 V \n", + "Part (b) : The contact potential = 0.721 V \n" + ] + } + ], + "prompt_number": 33 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.2 - Page No : 4-71" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "from __future__ import division\n", + "# Given data\n", + "V_T = 26 # in mV\n", + "V_T=V_T*10**-3 # in V\n", + "n_i = 2.5 * 10**13 \n", + "Sigma_p = 1 \n", + "Sigma_n = 1 \n", + "Mu_n = 3800 \n", + "q = 1.6 * 10**-19 # in C\n", + "Mu_p = 1800 \n", + "N_A = Sigma_p/(2* q * Mu_p) # in /cm**3\n", + "N_D = Sigma_n /(q * Mu_n) # in /cm**3\n", + "V_J = V_T * log((N_A * N_D)/(n_i)**2) # in V\n", + "print \"For Ge the height of the energy barrier = %0.2f V \" %V_J\n", + "# For Si p-n juction\n", + "n_i = 1.5 * 10**10 \n", + "Mu_n = 1300 \n", + "Mu_p = 500 \n", + "N_A = Sigma_p/(2* q * Mu_p) # in /cm**3\n", + "N_D = Sigma_n /(q * Mu_n) # in /cm**3\n", + "V_J = V_T * log((N_A * N_D)/(n_i)**2) # in V\n", + "print \"For Si p-n junction the height of the energy barrier = %0.3f V \" %V_J" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "For Ge the height of the energy barrier = 0.22 V \n", + "For Si p-n junction the height of the energy barrier = 0.666 V \n" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.16.3 - Page No : 4-72" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "Eta = 1 \n", + "V_T = 26 # in mV\n", + "V_T= V_T*10**-3 # in V\n", + "# I = I_o * (exp(V/(Eta*V_T)) - 1) and I = -(0.9) * I_o \n", + "V= log(1-0.9)*V_T # in V\n", + "print \"The voltage = %0.2f volts \" %V\n", + "# Part (ii)\n", + "V1=0.05 # in V\n", + "V2= -0.05 # in V\n", + "ratio= (exp(V1/(Eta*V_T))-1)/(exp(V2/(Eta*V_T))-1)\n", + "print \"The ratio of the current for a forward bias to reverse bias = %0.2f\" %ratio\n", + "# Part (iii)\n", + "Io= 10 # in \u00b5A\n", + "Io=Io*10**-3 # in mA\n", + "#For \n", + "V=0.1 # in V\n", + "I = Io * (exp(V/(Eta*V_T)) - 1) # in mA\n", + "print \"For v=0.1 V , the value of I = %0.3f mA \" %I\n", + "#For \n", + "V=0.2 # in V\n", + "I = Io * (exp(V/(Eta*V_T)) - 1) # in mA\n", + "print \"For v=0.2 V , the value of I = %0.1f mA \" %I\n", + "#For \n", + "V=0.3 # in V\n", + "I = Io * (exp(V/(Eta*V_T)) - 1) # in mA\n", + "print \"For v=0.3 V , the value of I = %0.2f A \" %(I*10**-3)\n", + "print \"From three value of I, for small rise in forward voltage, the diode current increase rapidly\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The voltage = -0.06 volts \n", + "The ratio of the current for a forward bias to reverse bias = -6.84\n", + "For v=0.1 V , the value of I = 0.458 mA \n", + "For v=0.2 V , the value of I = 21.9 mA \n", + "For v=0.3 V , the value of I = 1.03 A \n", + "From three value of I, for small rise in forward voltage, the diode current increase rapidly\n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.16.4 - Page No : 4-73" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "# Part (i)\n", + "T1= 25 # in \u00b0C\n", + "T2= 80 # in \u00b0C\n", + "# Formula Io2= Io1*2**((T2-T1)/10)\n", + "AntiFactor= 2**((T2-T1)/10) \n", + "print \"Anticipated factor for Ge = %0.f \" %AntiFactor\n", + "# Part (ii)\n", + "T1= 25 # in \u00b0C\n", + "T2= 150 # in \u00b0C\n", + "AntiFactor= 2**((T2-T1)/10) \n", + "print \"Anticipated factor for Si = %0.f \" %AntiFactor" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Anticipated factor for Ge = 45 \n", + "Anticipated factor for Si = 5793 \n" + ] + } + ], + "prompt_number": 36 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.16.5 - Page No : 4-74" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "I=5 # in \u00b5A\n", + "V=10 # in V\n", + "T1= 0.11 # in \u00b0C**-1\n", + "T2= 0.07 # in \u00b0C**-1\n", + "# Io+I_R=I (i)\n", + "# dI_by_dT= dIo_by_dT (ii)\n", + "# 1/Io*dIo_by_dT = T1 and 1/I*dI_by_dT = T2, So\n", + "Io= T2*I/T1 # in \u00b5A\n", + "I_R= I-Io # in \u00b5A\n", + "R= V/I_R # in M\u03a9\n", + "print \"The leakage resistance = %0.1f M\u03a9 \" %R" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The leakage resistance = 5.5 M\u03a9 \n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.16.6 - Page No : 4-75" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "Eta = 1 \n", + "T = 125 # in \u00b0C\n", + "T = T + 273 # in K\n", + "V_T = 8.62 * 10**-5 * 398 # in V\n", + "I_o = 30 # in \u00b5A\n", + "I_o= I_o*10**-6 # in A\n", + "v = 0.2 # in V\n", + "r_f = (Eta * V_T)/(I_o * exp(v/(Eta* V_T))) # in ohm\n", + "print \"The dynamic resistance in the forward direction = %0.2f ohm \" %r_f\n", + "r_r = (Eta * V_T)/(I_o * exp(-v/(Eta* V_T))) # in ohm\n", + "print \"The dynamic resistance in the reverse direction = %0.2f kohm \" %(r_r*10**-3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The dynamic resistance in the forward direction = 3.36 ohm \n", + "The dynamic resistance in the reverse direction = 389.08 kohm \n" + ] + } + ], + "prompt_number": 38 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.7 - Page No : 4-76" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi\n", + "# Given data\n", + "epsilon = 16/(36 * pi * 10**11) # in F/cm\n", + "A = 1 * 10**-2 \n", + "W = 2 * 10**-4 \n", + "C_T = (epsilon * A)/W # in F\n", + "print \"The barrier capacitance = %0.2f pF \" %(C_T*10**12)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The barrier capacitance = 70.74 pF \n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.16.8 - Page No : 4-76" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "A = 1 # in mm**2\n", + "A = A * 10**-6 # in m**2\n", + "N_A = 3 * 10**20 # in atoms/m**3\n", + "q = 1.6 *10**-19 # in C\n", + "V_o = 0.2 # in V\n", + "epsilon_r=16 \n", + "epsilon_o= 8.854*10**-12 # in F/m\n", + "epsilon=epsilon_r*epsilon_o \n", + "# Part (a)\n", + "V=-10 # in V\n", + "# V_o - V = 1/2*((q * N_A )/epsilon) * W**2\n", + "W = sqrt(((V_o - V) * 2 * epsilon)/(q * N_A)) # m\n", + "C_T1 = (epsilon * A)/W # in F\n", + "print \"The width of the depletion layer for an applied reverse voltage of 10V = %0.2f \u00b5m \" %(W*10**6)\n", + "# Part (b)\n", + "V=-0.1 # in V\n", + "W = sqrt(((V_o - V) * 2 * epsilon)/(q * N_A)) # m\n", + "C_T2 = (epsilon * A)/W # in F\n", + "print \"The width of the depletion layer for an applied reverse voltage of 0.1V = %0.2f \u00b5m \" %(W*10**6)\n", + "# Part (c)\n", + "V=0.1 # in V\n", + "W = sqrt(((V_o - V) * 2 * epsilon)/(q * N_A)) # m\n", + "print \"The width of the depletion layer for an applied for a forward bias of 0.1V = %0.3f \u00b5m \" %(W*10**6)\n", + "# Part (d)\n", + "print \"The space charge capacitance for an applied reverse voltage of 10V = %0.2f pF \" %(C_T1*10**12)\n", + "print \"The space charge capacitance for an applied reverse voltage of 0.1V = %0.2f pF \" %(C_T2*10**12)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The width of the depletion layer for an applied reverse voltage of 10V = 7.76 \u00b5m \n", + "The width of the depletion layer for an applied reverse voltage of 0.1V = 1.33 \u00b5m \n", + "The width of the depletion layer for an applied for a forward bias of 0.1V = 0.768 \u00b5m \n", + "The space charge capacitance for an applied reverse voltage of 10V = 18.26 pF \n", + "The space charge capacitance for an applied reverse voltage of 0.1V = 106.46 pF \n" + ] + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.9 - Page No : 4-78" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "I_o = 1.8 * 10**-9 # A\n", + "v = 0.6 # in V\n", + "Eta = 2 \n", + "V_T = 26 # in mV\n", + "V_T=V_T*10**-3 # in V\n", + "I = I_o *(exp(v/(Eta * V_T))) # in A\n", + "print \"The current in the junction = %0.3f mA \" %(I*10**3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The current in the junction = 0.185 mA \n" + ] + } + ], + "prompt_number": 41 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.10 - Page No : 4-78" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Given data\n", + "I_o = 2.4 * 10**-14 \n", + "I = 1.5 # in mA\n", + "I=I*10**-3 # in A\n", + "Eta = 1\n", + "V_T = 26 # in mV\n", + "V_T= V_T*10**-3 # in V\n", + "v =log((I + I_o)/I_o) * V_T # in V\n", + "print \"The forward biasing voltage across the junction = %0.4f V \" %v" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The forward biasing voltage across the junction = 0.6463 V \n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.11 - Page No : 4-79" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "I_o = 10 # in nA\n", + "# I = I_o * ((e**(v/(Eta * V_T))) - 1)\n", + "# e**(v/(Eta * V_T)<< 1, so neglecting it\n", + "I = I_o * (-1) # in nA\n", + "print \"The Diode current = %0.f nA \" %I" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Diode current = -10 nA \n" + ] + } + ], + "prompt_number": 43 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.12 - Page No : 4-79" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "R = 4.5 # in ohm\n", + "I = 44.4 # in mA\n", + "I=I*10**-3 # in A\n", + "V = R * I # in V\n", + "Eta = 1 \n", + "V_T = 26 #in mV\n", + "V_T=V_T*10**-3 # in V\n", + "I_o = I/((exp(V/(Eta * V_T))) -1) # in A\n", + "# At\n", + "V = 0.1 # in V\n", + "r_f = (Eta * V_T)/(I_o * ((exp(V/(Eta * V_T)))-1)) # in ohm\n", + "print \"The diode dynamic resistance = %0.2f \u03a9 \" %r_f" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diode dynamic resistance = 27.78 \u03a9 \n" + ] + } + ], + "prompt_number": 44 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.13 - Page No : 4-80" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "%matplotlib inline\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "# Given data\n", + "V_D = 10 # in V\n", + "# V_S = i*R_L + V_D\n", + "V_S = V_D # in V (i * R_L = 0)\n", + "print \"when diode is OFF, the voltage = %0.f volts \" %V_S\n", + "R_L = 250 # in ohm\n", + "I = V_S/R_L # in A\n", + "print \"when diode is ON, the current = %0.f mA \" %(I*10**3)\n", + "V_D= np.arange(0,10,0.1) # in V\n", + "I= (V_S-V_D)/R_L*1000 # in mA\n", + "plt.plot(V_D,I)\n", + "plt.xlabel('V_D in volts') \n", + "plt.ylabel('Current in mA')\n", + "plt.title('DC load line')\n", + "plt.axis([0, 12, 0, 50])\n", + "plt.show()\n", + "print \"DC load line shown in figure\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when diode is OFF, the voltage = 10 volts \n", + "when diode is ON, the current = 40 mA \n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "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\nCsYkQESkYP8HqYZH+eX0mvAAAAAASUVORK5CYII=\n", + "text": [ + "<matplotlib.figure.Figure at 0x7f8f05aa88d0>" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "DC load line shown in figure\n" + ] + } + ], + "prompt_number": 45 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.14 - Page No : 4-81" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "V = 0.25 # in V\n", + "I_o = 1.2 # in \u00b5A\n", + "I_o = I_o * 10**-6 # in A\n", + "V_T = 26 # in mV\n", + "V_T = V_T * 10**-3 # in V\n", + "Eta = 1 \n", + "r = (Eta * V_T)/(I_o * (exp(V/(Eta * V_T)))) # in ohm\n", + "print \"The ac resistance of the diode = %0.3f ohm \" %r" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ac resistance of the diode = 1.445 ohm \n" + ] + } + ], + "prompt_number": 46 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.15 - Page No : 4-82" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Given data\n", + "t = 4.4 * 10**22 # in total number of atoms/cm**3\n", + "n = 1 * 10**8 # number of impurity\n", + "N_A = t/n # in atoms/cm**3\n", + "N_A = N_A * 10**6 # in atoms/m**3\n", + "N_D = N_A * 10**3 # in atoms/m**3\n", + "V_T = 26 # in mV\n", + "V_T = V_T * 10**-3 # in V\n", + "n_i = 2.5 * 10**19 # in /cm**3\n", + "V_J = V_T * log((N_A * N_D)/(n_i)**2) # in V\n", + "print \"The junction potential = %0.3f V \"%V_J" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The junction potential = 0.329 V \n" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.16 - Page No : 4-82" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "Eta = 1 \n", + "I_o = 30 # in MuA\n", + "I_o = I_o * 10**-6 # in A\n", + "v = 0.2 # in V\n", + "K = 1.381 * 10**-23 # in J/degree K \n", + "T = 125 # in \u00b0C\n", + "T = T + 273 # in K\n", + "q = 1.6 * 10**-19 # in C\n", + "V_T = (K*T)/q # in V\n", + "r_f = (Eta * V_T)/(I_o * (exp(v/(Eta * V_T)))) # in ohm\n", + "print \"The forward dynamic resistance = %0.3f ohm \" %r_f\n", + "r_f1 = (Eta * V_T)/(I_o * (exp(-(v)/(Eta * V_T)))) # in ohm\n", + "print \"The Reverse dynamic resistance = %0.2f k\u03a9 \" %(r_f1*10**-3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The forward dynamic resistance = 3.391 ohm \n", + "The Reverse dynamic resistance = 386.64 k\u03a9 \n" + ] + } + ], + "prompt_number": 48 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.17 - Page No : 4-83" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "q = 1.6 * 10**-19 # in C\n", + "N_A = 3 * 10**20 # in /m**3\n", + "A = 1 # in \u00b5m**2\n", + "A = A * 10**-6 # in m**2\n", + "V = -10 # in V\n", + "V_J = 0.25 # in V\n", + "V_B = V_J - V # in V\n", + "epsilon_o = 8.854 # in pF/m\n", + "epsilon_o = epsilon_o * 10**-12 # in F/m\n", + "epsilon_r = 16 \n", + "epsilon = epsilon_o * epsilon_r \n", + "W = sqrt((V_B * 2 * epsilon)/(q * N_A)) # in m \n", + "print \"The width of depletion layer = %0.2f \u00b5m \" %(W*10**6)\n", + "C_T = (epsilon * A)/W # in pF\n", + "print \"The space charge capacitance = %0.4f pF \" %(C_T*10**12)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The width of depletion layer = 7.78 \u00b5m \n", + "The space charge capacitance = 18.2127 pF \n" + ] + } + ], + "prompt_number": 49 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.18 - Page No : 4-84" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "W = 2 * 10**-4 # in cm\n", + "W = W * 10**-2 # in m\n", + "A = 1 # in mm**2\n", + "A = A * 10**-6 # in m**2\n", + "epsilon_r = 16 \n", + "epsilon_o = 8.854 * 10**-12 # in F/m\n", + "epsilon = epsilon_r * epsilon_o \n", + "C_T = (epsilon * A)/W # in F\n", + "print \"The barrier capacitance = %0.3f pF \" %(C_T*10**12)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The barrier capacitance = 70.832 pF \n" + ] + } + ], + "prompt_number": 50 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.19 - Page No : 4-85" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt, pi\n", + "# Given data\n", + "C_T = 100 # in pF\n", + "C_T=C_T*10**-12 # in F\n", + "epsilon_r = 12 \n", + "epsilon_o = 8.854 * 10**-12 # in F/m\n", + "epsilon = epsilon_r * epsilon_o \n", + "Rho_p = 5 # in ohm-cm\n", + "Rho_p = Rho_p * 10**-2 # in ohm-m\n", + "V_j = 0.5 # in V\n", + "V = -4.5 # in V\n", + "Mu_p = 500 # in cm**2\n", + "Mu_p = Mu_p * 10**-4 # in m**2\n", + "Sigma_p = 1/Rho_p # in per ohm-m\n", + "qN_A = Sigma_p/ Mu_p \n", + "V_B = V_j - V \n", + "W = sqrt((V_B * 2 * epsilon)/qN_A) # in m\n", + "#C_T = (epsilon * A)/W \n", + "A = (C_T * W)/ epsilon # in m\n", + "D = sqrt(A * (4/pi)) # in m\n", + "D = D * 10**3 # in mm\n", + "print \"The value of diameter = %0.3f mm \" %D\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of diameter = 1.398 mm \n" + ] + } + ], + "prompt_number": 51 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.20 - Page No : 4-20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Given data\n", + "q = 1.6 * 10**-19 # in C\n", + "Mu_p = 500 # in cm**2/V-sec\n", + "Rho_p = 3.5 # in ohm-cm\n", + "Mu_n = 1500 # in cm**2/V-sec\n", + "Rho_n = 10 # in ohm-cm\n", + "N_A = 1/(Rho_p * Mu_p * q) # in /cm**3\n", + "N_D = 1/(Rho_n * Mu_n * q) # in /cm**3\n", + "V_J = 0.56 # in V\n", + "n_i = 1.5 * 10**10 # in /cm**3\n", + "V_T = V_J/log((N_A * N_D)/(n_i)**2) # in V\n", + "# V_T = T/11600\n", + "T = V_T * 11600 # in K\n", + "T = T /19.78 # in \u00b0C ( 1 degree K = 19.78 degree C)\n", + "print \"The Temperature of junction = %0.3f \u00b0C \" %T" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Temperature of junction = 14.524 \u00b0C \n" + ] + } + ], + "prompt_number": 52 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.21 - Page No : 4-88" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Given data\n", + "V_T = 26 # in mV\n", + "V_T = V_T * 10**-3 # in V\n", + "Eta = 1 \n", + "# I = -90% for Io, so\n", + "IbyIo= 0.1 \n", + "# I = I_o * ((e**(v/(Eta * V_T)))-1)\n", + "V = log(IbyIo) * V_T # in V\n", + "print \"The reverse bias voltage = %0.5f volts \" %V" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The reverse bias voltage = -0.05987 volts \n" + ] + } + ], + "prompt_number": 53 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 4.16.22 - Page No : 4-89" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "R = 5 # in ohm\n", + "I = 50 # in mA\n", + "I=I*10**-3 # in A\n", + "V = R * I # in V\n", + "Eta = 1 \n", + "V_T = 26 # in mV\n", + "V_T=V_T*10**-3 # in V\n", + "I_o = I/((exp(V/(Eta * V_T))) - 1) # in A\n", + "print \"Reverse saturation current = %0.2f \u00b5A \" %(I_o*10**6)\n", + "v1 = 0.2 # in V\n", + "r = (Eta * V_T)/(I_o * (exp(v1/(Eta * V_T)))) # in ohm\n", + "print \"Dynamic resistance of the diode = %0.3f \u03a9 \" %r" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reverse saturation current = 3.33 \u00b5A \n", + "Dynamic resistance of the diode = 3.558 \u03a9 \n" + ] + } + ], + "prompt_number": 54 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_5.ipynb b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_5.ipynb new file mode 100644 index 00000000..bc6149d5 --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_5.ipynb @@ -0,0 +1,834 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:f580dc14cd164012c93f758d593e5fbb20692db2a4830c462cc2ecc139c62a4a" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter : 5 - Bipolar Junction Transistors (BJTs)" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.9.1 - Page No : 5-22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "V_EE = 8 # in V\n", + "V_BE = 0.7 # in V\n", + "R_E = 1.5 # in k ohm\n", + "I_E = (V_EE - V_BE)/R_E # in mA\n", + "I_C = I_E # in mA\n", + "print \"The value of I_C = %0.2f mA \" %I_C\n", + "V_CC = 18 # in V\n", + "R_C = 1.2 # in k\u03a9\n", + "V_CB = V_CC - (I_C * R_C) # in V\n", + "print \"The value of V_CB = %0.2f V \" %V_CB" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of I_C = 4.87 mA \n", + "The value of V_CB = 12.16 V \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.9.2 - Page No : 5-23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "alpha = 0.9 \n", + "I_E = 1 # mA\n", + "I_C = alpha * I_E # in mA\n", + "I_B = I_E - I_C # in mA\n", + "print \"The value of base current = %0.1f mA \" %I_B" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of base current = 0.1 mA \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.11.1 - Page No : 5-41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "bita = 50 \n", + "I_B= 20 # in \u00b5A\n", + "I_B=I_B*10**-6 # in A\n", + "I_C= bita*I_B # in A\n", + "I_E= I_C+I_B # in A\n", + "I_E = I_E * 10**3 # in mA\n", + "print \"The Emitter current = %0.2f mA \" %I_E" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Emitter current = 1.02 mA \n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.11.1(a) - Page No : 5-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "beta_dc = 90 \n", + "I_C = 15 # in mA\n", + "I_C = I_C * 10**-3 # in A\n", + "I_B = I_C/beta_dc # in A\n", + "print \"The base current = %0.2f \u00b5A \" %(I_B*10**6)\n", + "I_E = I_C + I_B # in A\n", + "I_E = I_E * 10**3 # in mA\n", + "print \"The Emitter current = %0.3f mA \" %I_E\n", + "alpha_dc = beta_dc/(1+beta_dc) \n", + "print \"The value of alpha_dc = %0.3f\" %alpha_dc" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The base current = 166.67 \u00b5A \n", + "The Emitter current = 15.167 mA \n", + "The value of alpha_dc = 0.989\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.11.3 - Page No : 5-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "del_ic = 1.8 # in mA\n", + "del_ie = 1.89 # in mA\n", + "alpha = del_ic / del_ie \n", + "bita = alpha/(1 - alpha) \n", + "del_ib = del_ic/bita # in mA\n", + "del_ib = del_ib * 10**3 # in \u00b5A\n", + "print \"The change in I_B = %0.f \u00b5A \" %del_ib" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The change in I_B = 90 \u00b5A \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.11.4 - Page No : 5-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "V_CC = 10 # in V\n", + "R_C = 3 # in k \u03a9\n", + "R_C= R_C*10**3 # in \u03a9\n", + "bita = 100 \n", + "I_CO = 20 # in nA\n", + "I_CO = I_CO * 10**-9 # in A\n", + "V_BB = 5 # in V\n", + "R_B = 200 # in k\u03a9\n", + "R_B= R_B*10**3 # in \u03a9\n", + "V_BE = 0.7 # in V\n", + "# Applying KVL to the base circuit, V_BB= I_B*R_B+V_BE\n", + "I_B = (V_BB - V_BE)/R_B # in A\n", + "print \"The base current = %0.1f \u00b5A \" %(I_B*10**6)\n", + "I_C = (bita * I_B) + I_CO # in A\n", + "print \"The collector current = %0.5f mA \" %(I_C*10**3)\n", + "I_E = I_C + I_B # in A\n", + "print \"Emitter current = %0.5f mA \" %(I_E*10**3)\n", + "V_CE = V_CC - (I_C * R_C) # in V\n", + "print \"Collector emitter voltage = %0.4f V \" %(V_CE)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The base current = 21.5 \u00b5A \n", + "The collector current = 2.15002 mA \n", + "Emitter current = 2.17152 mA \n", + "Collector emitter voltage = 3.5499 V \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.11.5 - Page No : 5-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "bita = 100 \n", + "I_CBO = 4 # in \u00b5A\n", + "I_B = 40 # in \u00b5A\n", + "I_C = (bita * I_B) + ((1+bita) * I_CBO) # in \u00b5A\n", + "I_C = I_C * 10**-3 # in msA\n", + "print \"The collector current = %0.3f mA \" %I_C" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The collector current = 4.404 mA \n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.11.6 - Page No : 5-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "%matplotlib inline\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "from __future__ import division\n", + "# Given data\n", + "del_IC = 1 * 10**-3 # in A\n", + "del_IB = 10 * 10**-6 # in A\n", + "CurrentGain= del_IC/del_IB \n", + "print \"The current gain = %0.f\" %CurrentGain\n", + "del_IC= del_IC*10**3 # in mA\n", + "del_IB= del_IB*10**6 # in \u00b5A\n", + "I_B=np.arange(0,50,0.1) # in \u00b5A\n", + "I_C= I_B/del_IB+del_IC # in mA\n", + "plt.plot(I_B,I_C)\n", + "plt.xlabel('Base current in micro A')\n", + "plt.ylabel('Collector current in mA')\n", + "plt.title('Transfer Characteristics')\n", + "plt.axis([0, 60, 0, 7])\n", + "plt.show()\n", + "print \"Transfer Characteristics is shown in figure\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The current gain = 100\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "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\n", + "text": [ + "<matplotlib.figure.Figure at 0x7f309c1c7050>" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Transfer Characteristics is shown in figure\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.14.1 - Page No : 5-51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "I_CBO = 3 #in \u00b5A\n", + "I_CBO= I_CBO*10**-3 # in mA \n", + "I_C= 15 # in mA\n", + "# But it is given that I_C= 99.5% of I_E, SO\n", + "I_E= I_C/99.5*100 # in mA\n", + "alpha_dc= I_C/I_E \n", + "print \"The value of alpha_dc = %0.3f\" %alpha_dc\n", + "print \"The value of I_E = %0.2f mA \" %I_E" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of alpha_dc = 0.995\n", + "The value of I_E = 15.08 mA \n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.14.2 - Page No : 5-52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given data\n", + "alpha_dc = 0.99 \n", + "I_CBO = 10 # in \u00b5A\n", + "I_CBO= I_CBO*10**-6 # in A\n", + "I_E = 10 # in mA\n", + "I_E= I_E*10**-3 # in A\n", + "I_C = (alpha_dc * I_E) + I_CBO # in A\n", + "print \"The value of I_C = %0.2f mA \" %(I_C*10**3)\n", + "I_B = I_E - I_C # in A\n", + "I_B = I_B * 10**6 # in \u00b5A\n", + "print \"The value of I_B = %0.f \u00b5A \" %I_B" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of I_C = 9.91 mA \n", + "The value of I_B = 90 \u00b5A \n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.14.3 - Page No : 5-52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "alpha_dc = 0.99 \n", + "I_C = 6 # in mA\n", + "I_C= I_C*10**-3 # in A\n", + "I_CBO = 15 # in \u00b5A\n", + "I_CBO= I_CBO*10**-6 # in A\n", + "I_E = (I_C - I_CBO)/alpha_dc # in A\n", + "I_B = I_E - I_C # in A \n", + "print \"The value of I_B = %0.f \u00b5A \" %(I_B*10**6)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of I_B = 45 \u00b5A \n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.14.5 - Page No : 5-53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "alpha_dc = 0.98 \n", + "I_CBO = 12 # in \u00b5A\n", + "I_CBO = I_CBO * 10**-6 # in A\n", + "I_B = 120 # in \u00b5A\n", + "I_B = I_B * 10**-6 # in A\n", + "beta_dc = alpha_dc/(1-alpha_dc) \n", + "I_E = ((1 + beta_dc) * I_B) + ((1 + beta_dc) * I_CBO) #in A\n", + "I_E = I_E * 10**3 # in mA\n", + "print \"The value of I_E = %0.1f mA \" %I_E" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of I_E = 6.6 mA \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.14.6 - Page No : 5-53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "bita= 100 \n", + "V_BEsat= 0.8 # in V\n", + "V_CEsat= 0.2 # in V\n", + "V_BEact= 0.7 # in V\n", + "V_CC = 10 # in V\n", + "V_BB=5 # in V\n", + "R_E = 2 # in k\u03a9\n", + "R_C = 3 # in k\u03a9\n", + "R_B= 50 # in k\u03a9\n", + "# Applying KVL to collector loop\n", + "# V_CC= I_Csat*R_C +V_CEsat +I_E*R_E and I_E= I_Csat+I_B, So\n", + "#I_B= ((V_CC-V_CEsat)-(R_C+R_E)*I_Csat)/R_E (i)\n", + "# Applying KVL to base loop\n", + "# V_BB-I_B*R_B -V_BEsat-I_E*R_E =0 and I_E= I_Csat+I_B, So\n", + "#V_BB-V_BEsat= R_E*I_Csat + (R_B+R_E)*I_B (ii)\n", + "# From eq (i) and (ii)\n", + "I_B = ((V_BB-V_BEsat)*5- (V_CC-V_CEsat)*2) / ((R_B+R_E)*5 - R_E*2) # in mA\n", + "I_Csat= ((V_CC-V_CEsat)-R_E*I_B)/(R_C+R_E) # in mA\n", + "I_Bmin= I_Csat/bita # in mA\n", + "if I_B<I_Bmin :\n", + " print \"Since the value of I_B (\",round(I_B*10**3,2),\"\u00b5A) is less than the value of I_Bmin (\",round(I_Bmin*10**3,1),\"\u00b5A)\" \n", + " print \"So the transistor is not in the saturation region. But it is conducting hence it can not be in cutoff.\"\n", + " print \"Therefore the transistor is in the active region\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Since the value of I_B ( 5.47 \u00b5A) is less than the value of I_Bmin ( 19.6 \u00b5A)\n", + "So the transistor is not in the saturation region. But it is conducting hence it can not be in cutoff.\n", + "Therefore the transistor is in the active region\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.14.7 - Page No : 5-55" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "bita= 100 \n", + "V_BEsat= 0.8 # in V\n", + "V_CEsat= 0.2 # in V\n", + "V_BEact= 0.7 # in V\n", + "V_CC = 10 # in V\n", + "V_BB=5 # in V\n", + "R_E = 2 # in k\u03a9\n", + "R_C = 3 # in k\u03a9\n", + "R_B= 50 # in k\u03a9\n", + "# Applying KVL to input loop\n", + "# V_BB= I_B*R_B+(1+bita)*I_B*R_E+V_BEact or \n", + "I_B= (V_BB-V_BEact)/(R_B+(1+bita)*R_E) # in mA\n", + "I_C= bita*I_B # in mA\n", + "# Applying KVL to collector circuit\n", + "# V_CC= I_Csat*R_C +V_CEsat +(I_C+I_B)*R_E\n", + "V_CEact= V_CC-I_B*R_E-I_C*(R_C+R_E) # in V\n", + "print \"The value of I_B = %0.f \u00b5A \" %(I_B*10**3)\n", + "print \"The value of I_C = %0.1f mA \" %I_C\n", + "print \"The value of V_CE = %0.3f volts \" %V_CEact" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of I_B = 17 \u00b5A \n", + "The value of I_C = 1.7 mA \n", + "The value of V_CE = 1.434 volts \n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.14.8 - Page No : 5-55" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "bita = 100 \n", + "V_CEsat = 0.2 # in V\n", + "R_B = 150 # in kohm\n", + "R_C = 2 # in kohm\n", + "V_CC = 10 # in V\n", + "V_BEsat = 0.8 # in V\n", + "I_B = (V_CC - V_BEsat)/R_B # in mA\n", + "I_C = (V_CC - V_CEsat)/R_C # in mA\n", + "I_Bmin = I_C/bita # in mA\n", + "if I_B>I_Bmin :\n", + " print \"Since the value of I_B (\",round(I_B*10**3,2),\"\u00b5A) is greater than the value of I_Bmin (\",int(I_Bmin*10**3),\"\u00b5A)\" \n", + " print \"So the transistor is in the saturation region.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Since the value of I_B ( 61.33 \u00b5A) is greater than the value of I_Bmin ( 49 \u00b5A)\n", + "So the transistor is in the saturation region.\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.14.9 - Page No : 5-57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "bita = 100 \n", + "V_CE = 0.2 #in V\n", + "V_BE = 0.8 # in V\n", + "R_C= 500 # in \u03a9\n", + "R_B= 44*10**3 # in \u03a9\n", + "R_E= 1*10**3 # in \u03a9\n", + "V_CC= 15 # in V\n", + "V_GE= -15 # in V\n", + "# Applying KVL to collector circuit\n", + "# V_CC-V_GE - I_Csat*R_C-V_CE-I_E*R_E=0, but I_Csat= bita*I_Bmin and I_E= 1+bita\n", + "I_Bmin= (V_CC-V_GE-V_CE)/(R_C*bita+(1+bita)*R_E) # in A\n", + "# Applying KVL to the base emitter circuit\n", + "# V_BB-I_Bmin*R_B-V_BE-I_E*R_E + V_CC=0\n", + "V_BB= I_Bmin*R_B + V_BE + (1+bita)*I_Bmin*R_E-V_CC # in V\n", + "print \"The value of I_B(min) = %0.3f mA \" %(I_Bmin*10**3)\n", + "print \"The value of V_BB = %0.1f volts \" %V_BB" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of I_B(min) = 0.197 mA \n", + "The value of V_BB = 14.4 volts \n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.14.10 - Page No : 5-58" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "V_ECsat= 0.2 # in V\n", + "V_CC= 10 # in V\n", + "V_EBsat= 0.8 # in V\n", + "\n", + "# Part (i)\n", + "bita= 100 \n", + "R_B= 220 # in k\u03a9\n", + "# Applying KVL to collector circuit, V_CC= V_EC+ICRC\n", + "ICRC= V_CC-V_ECsat # in V\n", + "# Applying KVL to input loop, V_CC= V_EBsat+I_B*R_B (i)\n", + "I_B= (V_CC-V_EBsat)/R_B # in mA\n", + "I_C= bita*I_B # in mA\n", + "R_Cmin= ICRC/I_C # in k\u03a9\n", + "print \"The minimum value of R_C = %0.3f k\u03a9 \" %R_Cmin\n", + "# Part (ii)\n", + "R_C= 1.2 # in k\u03a9\n", + "I_Csat= ICRC/R_C # in mA\n", + "I_B= I_Csat/bita # in mA\n", + "# From eq (i)\n", + "R_B= (V_CC-V_EBsat)/I_B # in k\u03a9\n", + "print \"The maximum value of R_B = %0.2f k\u03a9 \" %R_B" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The minimum value of R_C = 2.343 k\u03a9 \n", + "The maximum value of R_B = 112.65 k\u03a9 \n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.14.11 - Page No : 5-60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "bita= 100 \n", + "V_BEsat= 0.8 # in V\n", + "V_CEsat= 0.2 # in V\n", + "V_BEact= 0.7 # in V\n", + "V_CC = 10 # in V\n", + "R_E = 1 # in k\u03a9\n", + "R_C = 2 # in k\u03a9\n", + "R_B= 100 # in k\u03a9\n", + "bita=100 \n", + "alpha= bita/(1+bita) \n", + "# Applying KVL to collector circuit\n", + "# V_CC= I_Csat*R_C +V_CE +R_E*I_E\n", + "# but I_E= alpha*I_Csat\n", + "I_Csat= (V_CC-V_CEsat)/(R_C+R_E*alpha) # in mA\n", + "I_Bmin= I_Csat/bita # in mA\n", + "# Applying KVL to base loop\n", + "# V_CC= I_B*R_B +V_BEsat +I_E*R_E\n", + "# but I_E= I_Csat+I_B\n", + "I_B= (V_CC-V_BEsat-I_Csat*R_E)/(R_B+R_E) # in mA\n", + "print \"The value of I_B = %0.2f \u00b5A \" %(I_B*10**3)\n", + "print \"The minimum value of I_B = %0.1f \u00b5A \" %(I_Bmin*10**3)\n", + "if I_B>I_Bmin :\n", + " print \"Since the value of I_B is greater than the value of I_Bmin\"\n", + " print \"Hence the transistor is in saturation .\"\n", + "I_E= (1+bita)*I_Bmin # in mA\n", + "R_E= (V_CC-V_BEact-I_Bmin*R_B)/I_E # in k\u03a9\n", + "print \"The value of R_E = %0.3f k\u03a9 \" %R_E\n", + "print \"So R_E should be greater than this value in order to bring the transistor just out of saturation \"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of I_B = 58.64 \u00b5A \n", + "The minimum value of I_B = 32.8 \u00b5A \n", + "Since the value of I_B is greater than the value of I_Bmin\n", + "Hence the transistor is in saturation .\n", + "The value of R_E = 1.819 k\u03a9 \n", + "So R_E should be greater than this value in order to bring the transistor just out of saturation \n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 5.14.12 - Page No : 5-62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "V_CC = 9 # in V\n", + "V_BE = 0.8 # in V\n", + "V_CE = 0.2 # in V\n", + "R_B = 50 # in k\u03a9\n", + "R_C=2 # in k\u03a9\n", + "R_E = 1 # in k\u03a9\n", + "bita=70 \n", + "# Applying KVL to input loop, V_CC= I_B*R_B +V_BE +I_E*R_E\n", + "# V_CC- V_BE= (R_B+R_E)*I_B + R_E*I_C (i)\n", + "# Applying KVL to output loop, V_CC= R_C*I_C +V_CE +I_C*R_E +I_B*R_E\n", + "#I_B = ((V_CC- V_CE)-(R_C+R_E)*I_C)/R_E (ii)\n", + "# From eq (i) and (ii)\n", + "I_C= ( (V_CC- V_BE)-(R_B+R_E)* (V_CC- V_CE)/R_E)/(1-(R_B+R_E)*(R_C+R_E)) # in mA\n", + "I_B = ((V_CC- V_CE)-(R_C+R_E)*I_C)/R_E# in mA\n", + "I_Bmin= I_C/bita # in mA\n", + "if I_B>I_Bmin :\n", + " print \"Since the value of I_B (\",round(I_B,3),\" mA) is greater than the value of I_Bmin (\",round(I_Bmin,4),\" mA)\"\n", + " print \"So the transistor is in saturation \"\n", + "V_C= V_CC-I_C*R_C # in V\n", + "print \"The value of collector voltage = %0.3f volts \" %V_C\n", + "bita= I_C/I_B \n", + "print \"The minimum value of bita that will change the state of the trasistor = %0.3f\" %bita" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Since the value of I_B ( 0.104 mA) is greater than the value of I_Bmin ( 0.0414 mA)\n", + "So the transistor is in saturation \n", + "The value of collector voltage = 3.203 volts \n", + "The minimum value of bita that will change the state of the trasistor = 27.886\n" + ] + } + ], + "prompt_number": 18 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_6.ipynb b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_6.ipynb new file mode 100644 index 00000000..316e7e2d --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_6.ipynb @@ -0,0 +1,209 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter : 6 - Field Effect Transistors" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 6.9.1 - Page No : 6-26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from numpy import pi\n", + "# Given data\n", + "q = 1.6 * 10**-19;# in C\n", + "N_D = 10**15;# in electrons/cm**3\n", + "N_D = N_D * 10**6;# in electrons/m**3\n", + "epsilon_r = 12;\n", + "epsilon_o = (36 * pi * 10**9)**-1;\n", + "epsilon = epsilon_o * epsilon_r;\n", + "a = 3 * 10**-4;# in cm\n", + "a = a * 10**-2;# in m\n", + "V_P = (q * N_D * a**2)/( 2 * epsilon);# in V\n", + "print \"The Pinch off voltage = %0.1f V\" %V_P\n", + "# V_GS = V_P * (1-(b/a))**2\n", + "b = (1-0.707) *a;# in m\n", + "print \"The value of b = %0.3f \u00b5m\" %(b*10**6)\n", + "print \"Hence the channel width has been reduced to about one third of its value for V_GS = 0\"\n", + "# Note : The unit of b in the book is wrong since the value of b is calculated in \u00b5m." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Pinch off voltage = 6.8 V\n", + "The value of b = 0.879 \u00b5m\n", + "Hence the channel width has been reduced to about one third of its value for V_GS = 0\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 6.9.2 - Page No : 6-26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "# Given data\n", + "I_DSS = 8;# in mA\n", + "V_P = -4;# in V\n", + "I_D = 3;# in mA\n", + "V_GS = V_P * (1 - sqrt(I_D/I_DSS));# in V\n", + "print \"The value of V_GS = %0.2f V\" %V_GS\n", + "V_DS = V_GS - V_P;# in V\n", + "print \"The value of V_DS = %0.2f V\" %V_DS" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of V_GS = -1.55 V\n", + "The value of V_DS = 2.45 V\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 6.9.3 - Page No : 6-27" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "V_P = -4;# in V\n", + "I_DSS = 9;# in mA\n", + "I_DSS = I_DSS * 10**-3;# in A\n", + "V_GS = -2;# in V\n", + "I_D = I_DSS * ((1 - (V_GS/V_P))**2);# in A\n", + "print \"The drain current = %0.2f mA\" %(I_D*10**3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The drain current = 2.25 mA\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 6.9.4 - Page No : 6-27" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "I_DSS = 12;# in mA\n", + "I_DSS = I_DSS * 10**-3;# in A\n", + "V_P = -(6);# in V\n", + "V_GS = -(1);# in V\n", + "g_mo = (-2 * I_DSS)/V_P;# in A/V\n", + "g_m = g_mo * (1 - (V_GS/V_P));# in S\n", + "print \"The value of transconductance = %0.2f mS\" %(g_m*10**3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of transconductance = 3.33 mS\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 6.9.5 - Page No : 6-28" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "I_DSS = 10;# in mA \n", + "I_DSS = I_DSS * 10**-3;# in A\n", + "V_P = -(5);# in V\n", + "V_GS = -(2.5);# in V\n", + "g_m = ((-2 * I_DSS)/V_P) * (1 -(V_GS/V_P));# in S\n", + "g_m = g_m * 10**3;# in mS\n", + "print \"The Transconductance = %0.f mS\" %g_m\n", + "I_D = I_DSS * ((1 - (V_GS/V_P))**2);# in A\n", + "print \"The drain current = %0.1f mA\" %(I_D*10**3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Transconductance = 2 mS\n", + "The drain current = 2.5 mA\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_7.ipynb b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_7.ipynb new file mode 100644 index 00000000..b74775b3 --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_7.ipynb @@ -0,0 +1,143 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter : 7 - Optoelectronic Devices" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.6.1 - Page No : 7-16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "O_V = 5;# output voltage in V\n", + "V_D = 1.5;#voltage drop in V\n", + "R = (O_V - V_D)/O_V;\n", + "R = R * 10**3;# in ohm\n", + "print \"The resistance value = %0.f \u03a9\" %R\n", + "print \"As this is not standard value, use R=680 \u03a9 which is a standard value\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resistance value = 700 \u03a9\n", + "As this is not standard value, use R=680 \u03a9 which is a standard value\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.23.1 - Page No : 7-57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt, log\n", + "# Given data\n", + "N_A = 7.5*10**24;# in atoms/m**3\n", + "N_D = 1.5*10**22;# in atoms/m**3\n", + "I_lembda = 12.5*10**-3;# in A/cm**2\n", + "D_e = 25*10**-4;# in m**2/s\n", + "D_h = 1*10**-3;# in m**2/s\n", + "Torque_eo = 500;# in ns\n", + "Torque_ho = 100;# in ns\n", + "n_i = 1.5*10**16;# in /m**3\n", + "e = 1.6*10**-19;\n", + "P_C = 12.5;# in mA/cm**2\n", + "L_e = sqrt(D_e*Torque_ho*10**-9);# in m\n", + "L_e = L_e * 10**6;# in \u00b5m\n", + "L_h = sqrt(D_h*Torque_ho*10**-9);# in m\n", + "L_h = L_h * 10**6;# in \u00b5m\n", + "J_s = e*((n_i)**2)*( (D_e/(L_e*10**-6*N_A)) + (D_h/(L_h*10**-6*N_D)) );# in A/m**2\n", + "J_s = J_s * 10**-4;# in A/cm**2\n", + "V_T = 26;# in mV\n", + "V_OC = V_T*log( 1+(I_lembda/J_s) );# in mV\n", + "V_OC = V_OC * 10**-3;# in V\n", + "print \"Open circuit voltage = %0.3f V\" %V_OC" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Open circuit voltage = 0.522 V\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.23.2 - Page No : 7-57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Given data\n", + "Phi_o = 1*10**21;# in m**-2s**-1\n", + "Alpha = 1*10**5;# in m**-1\n", + "W = 25;# in \u00b5m\n", + "W =W * 10**-6;# in m\n", + "e = 1.6*10**-19;# in C\n", + "G_L1 = Alpha*Phi_o;# in m**-3s**-1\n", + "G_L2 = Alpha*Phi_o*exp( (-Alpha*W) );# in m**-3s**-1\n", + "J_L = e*Phi_o*(1-exp(-Alpha*W));# in A/m**2\n", + "J_L = J_L * 10**-1;# in mA/cm**2\n", + "print \"Photo current density = %0.2f mA/cm**2\" %J_L" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Photo current density = 14.69 mA/cm**2\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_8.ipynb b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_8.ipynb new file mode 100644 index 00000000..9da031a0 --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_8.ipynb @@ -0,0 +1,96 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter : 8 - Negative Conductance Microwave Devices And Power Devices" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 8.13.1 - Page No : 8-35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "R= 10;# in k\u03a9\n", + "R= R*10**3;# in \u03a9\n", + "# Part (i)\n", + "V=300;# in V\n", + "I_A= V/R;# in A\n", + "print \"Part (i) : For 300 V voltage : \"\n", + "print \"The anode current = %0.f mA\" %(I_A*10**3)\n", + "# Part (ii)\n", + "V=100;# in V\n", + "I_A= V/R;# in A\n", + "print \"Part (ii) : For 100 V voltage : \"\n", + "print \"The anode current = %0.f mA\" %(I_A*10**3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (i) : For 300 V voltage : \n", + "The anode current = 30 mA\n", + "Part (ii) : For 100 V voltage : \n", + "The anode current = 10 mA\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 8.14.1 - Page No : 8-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "t_rr = 10;# in \u00b5s\n", + "Q_rr = 150;# in \u00b5c\n", + "I_rr = (2*Q_rr)/t_rr;# in A\n", + "print \"The peak reverse recovery current = %0.f A\" %I_rr" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The peak reverse recovery current = 30 A\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t6.png b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t6.png Binary files differnew file mode 100644 index 00000000..066b9926 --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t6.png diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t7.png b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t7.png Binary files differnew file mode 100644 index 00000000..6f6f7d61 --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t7.png diff --git a/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t8.png b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t8.png Binary files differnew file mode 100644 index 00000000..c41c48ef --- /dev/null +++ b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t8.png diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/Chapter9_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/Chapter9_6.ipynb new file mode 100644 index 00000000..5520ce18 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/Chapter9_6.ipynb @@ -0,0 +1,419 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:36c7c29426c0c7be14ce2ec6430ec42fa1b0070a30e5ffbe18ec0fb6fd9b8d34"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter09:Numerical Solution of Partial Differential Equations"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.1:pg-350"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#standard five point formula\n",
+ "#example 9.1\n",
+ "#page 350\n",
+ "\n",
+ "u2=5.0;u3=1.0;\n",
+ "for i in range(0,3):\n",
+ " u1=(u2+u3+6.0)/4.0\n",
+ " u2=(u1/2.0)+(5.0/2.0)\n",
+ " u3=(u1/2.0)+(1.0/2.0)\n",
+ " print\" the values are u1=%d\\t u2=%d\\t u3=%d\\t\\n\\n\" %(u1,u2,u3)\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " the values are u1=3\t u2=4\t u3=2\t\n",
+ "\n",
+ "\n",
+ " the values are u1=3\t u2=4\t u3=2\t\n",
+ "\n",
+ "\n",
+ " the values are u1=3\t u2=4\t u3=2\t\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.2:pg-351"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#solution of laplace equation by jacobi method,gauss-seidel method and SOR method\n",
+ "#example 9.2\n",
+ "#page 351\n",
+ "u1=0.25\n",
+ "u2=0.25\n",
+ "u3=0.5\n",
+ "u4=0.5 #initial values\n",
+ "print \"jacobis iteration process\\n\\n\"\n",
+ "print\"u1\\t u2\\t u3\\t u4\\t \\n\\n\"\n",
+ "print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4)\n",
+ "for i in range(0,7):\n",
+ " u11=(0+u2+0+u4)/4\n",
+ " u22=(u1+0+0+u3)/4\n",
+ " u33=(1+u2+0+u4)/4\n",
+ " u44=(1+0+u3+u1)/4\n",
+ " u1=u11\n",
+ " u2=u22\n",
+ " u3=u33\n",
+ " u4=u44\n",
+ " print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u11,u22,u33,u44) \n",
+ "print \" gauss seidel process\\n\\n\"\n",
+ "u1=0.25\n",
+ "u2=0.3125\n",
+ "u3=0.5625\n",
+ "u4=0.46875 #initial values\n",
+ "print \"u1\\t u2\\t u3\\t u4\\t \\n\\n\"\n",
+ "print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4)\n",
+ "for i in range(0,4):\n",
+ "\n",
+ " u1=(0.0+u2+0.0+u4)/4.0\n",
+ " u2=(u1+0.0+0.0+u3)/4.0\n",
+ " u3=(1.0+u2+0.0+u4)/4.0\n",
+ " u4=(1.0+0.0+u3+u1)/4.0\n",
+ " print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4) \n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "jacobis iteration process\n",
+ "\n",
+ "\n",
+ "u1\t u2\t u3\t u4\t \n",
+ "\n",
+ "\n",
+ "0.250000\t 0.250000\t 0.500000\t 0.500000\t \n",
+ "\n",
+ "0.187500\t 0.187500\t 0.437500\t 0.437500\t \n",
+ "\n",
+ "0.156250\t 0.156250\t 0.406250\t 0.406250\t \n",
+ "\n",
+ "0.140625\t 0.140625\t 0.390625\t 0.390625\t \n",
+ "\n",
+ "0.132812\t 0.132812\t 0.382812\t 0.382812\t \n",
+ "\n",
+ "0.128906\t 0.128906\t 0.378906\t 0.378906\t \n",
+ "\n",
+ "0.126953\t 0.126953\t 0.376953\t 0.376953\t \n",
+ "\n",
+ "0.125977\t 0.125977\t 0.375977\t 0.375977\t \n",
+ "\n",
+ " gauss seidel process\n",
+ "\n",
+ "\n",
+ "u1\t u2\t u3\t u4\t \n",
+ "\n",
+ "\n",
+ "0.250000\t 0.312500\t 0.562500\t 0.468750\t \n",
+ "\n",
+ "0.195312\t 0.189453\t 0.414551\t 0.402466\t \n",
+ "\n",
+ "0.147980\t 0.140633\t 0.385775\t 0.383439\t \n",
+ "\n",
+ "0.131018\t 0.129198\t 0.378159\t 0.377294\t \n",
+ "\n",
+ "0.126623\t 0.126196\t 0.375872\t 0.375624\t \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.4:pg-354"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#poisson equation\n",
+ "#exaample 9.4\n",
+ "#page 354\n",
+ "u2=0.0;u4=0.0;\n",
+ "print \" u1\\t u2\\t u3\\t u4\\t\\n\\n\"\n",
+ "for i in range(0,6):\n",
+ " u1=(u2/2.0)+30.0\n",
+ " u2=(u1+u4+150.0)/4.0\n",
+ " u4=(u2/2.0)+45.0\n",
+ " print \"%0.2f\\t %0.2f\\t %0.2f\\t %0.2f\\n\" %(u1,u2,u2,u4)\n",
+ "print \" from last two iterates we conclude u1=67 u2=75 u3=75 u4=83\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " u1\t u2\t u3\t u4\t\n",
+ "\n",
+ "\n",
+ "30.00\t 45.00\t 45.00\t 67.50\n",
+ "\n",
+ "52.50\t 67.50\t 67.50\t 78.75\n",
+ "\n",
+ "63.75\t 73.12\t 73.12\t 81.56\n",
+ "\n",
+ "66.56\t 74.53\t 74.53\t 82.27\n",
+ "\n",
+ "67.27\t 74.88\t 74.88\t 82.44\n",
+ "\n",
+ "67.44\t 74.97\t 74.97\t 82.49\n",
+ "\n",
+ " from last two iterates we conclude u1=67 u2=75 u3=75 u4=83\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 59
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.6:pg-362"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#bender-schmidt formula\n",
+ "#example 9.6\n",
+ "#page 362\n",
+ "def f(x):\n",
+ " return (4*x)-(x*x)\n",
+ "#u=[f(0),f(1),f(2),f(3),f(4)]\n",
+ "u1=f(0);u2=f(1);u3=f(2);u4=f(3);u5=f(4);\n",
+ "u11=(u1+u3)/2\n",
+ "u12=(u2+u4)/2\n",
+ "u13=(u3+u5)/2\n",
+ "print \"u11=%0.2f\\t u12=%0.2f\\t u13=%0.2f\\t \\n\" %(u11,u12,u13)\n",
+ "u21=(u1+u12)/2.0\n",
+ "u22=(u11+u13)/2.0\n",
+ "u23=(u12+0)/2.0\n",
+ "print \"u21=%0.2f\\t u22=%0.2f\\t u23=%0.2f\\t \\n\" %(u21,u22,u23)\n",
+ "u31=(u1+u22)/2.0\n",
+ "u32=(u21+u23)/2.0\n",
+ "u33=(u22+u1)/2.0\n",
+ "print \"u31=%0.2f\\t u32=%0.2f\\t u33=%0.2f\\t \\n\" % (u31,u32,u33)\n",
+ "u41=(u1+u32)/2.0\n",
+ "u42=(u31+u33)/2.0\n",
+ "u43=(u32+u1)/2.0\n",
+ "print \"u41=%0.2f\\t u42=%0.2f\\t u43=%0.2f\\t \\n\" % (u41,u42,u43)\n",
+ "u51=(u1+u42)/2.0\n",
+ "u52=(u41+u43)/2.0\n",
+ "u53=(u42+u1)/2.0\n",
+ "print \"u51=%0.2f\\t u52=%0.2f\\t u53=%0.2f\\t \\n\" % (u51,u52,u53)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "u11=2.00\t u12=3.00\t u13=2.00\t \n",
+ "\n",
+ "u21=1.50\t u22=2.00\t u23=1.50\t \n",
+ "\n",
+ "u31=1.00\t u32=1.50\t u33=1.00\t \n",
+ "\n",
+ "u41=0.75\t u42=1.00\t u43=0.75\t \n",
+ "\n",
+ "u51=0.50\t u52=0.75\t u53=0.50\t \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 77
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.7:pg-363"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#bender-schimdt's formula and crank-nicolson formula\n",
+ "#example 9.7\n",
+ "#page 363\n",
+ "#bender -schimdt's formula\n",
+ "import math\n",
+ "from numpy import matrix\n",
+ "z=math.pi\n",
+ "def f(x,t):\n",
+ " return math.exp(z*z*t*-1)*sin(z*x)\n",
+ "#u=[f(0,0),f(0.2,0),f(0.4,0),f(0.6,0),f(0.8,0),f(1,0)]\n",
+ "u1=f(0,0)\n",
+ "u2=f(0.2,0)\n",
+ "u3=f(0.4,0)\n",
+ "u4=f(0.6,0)\n",
+ "u5=f(0.8,0)\n",
+ "u6=f(1.0,0)\n",
+ "u11=u3/2\n",
+ "u12=(u2+u4)/2\n",
+ "u13=u12\n",
+ "u14=u11\n",
+ "print \"u11=%f\\t u12=%f\\t u13=%f\\t u14=%f\\n\\n\" % (u11,u12,u13,u14)\n",
+ "u21=u12/2\n",
+ "u22=(u12+u14)/2\n",
+ "u23=u22\n",
+ "u24=u21\n",
+ "print \"u21=%f\\t u22=%f\\t u23=%f\\t u24=%f\\n\\n\" % (u21,u22,u23,u24)\n",
+ "print \"the error in the solution is: %f\\n\\n\" % (math.fabs(u22-f(0.6,0.04)))\n",
+ "#crank-nicolson formula\n",
+ "#by putting i=1,2,3,4 we obtain four equation\n",
+ "A=matrix([[4, -1, 0, 0] ,[-1, 4, -1, 0],[0, -1, 4, -1],[0, 0, -1, 4]])\n",
+ "C=matrix([[0.9510],[1.5388],[1.5388],[0.9510]])\n",
+ "X=A.I*C\n",
+ "print \"u00=%f\\t u10=%f\\t u20=%f\\t u30=%f\\t\\n\\n\" %(X[0][0],X[1][0],X[2][0],X[3][0])\n",
+ "print \"the error in the solution is: %f\\n\\n\" %(abs(X[1][0]-f(0.6,0.04)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "u11=0.475528\t u12=0.769421\t u13=0.769421\t u14=0.475528\n",
+ "\n",
+ "\n",
+ "u21=0.384710\t u22=0.622475\t u23=0.622475\t u24=0.384710\n",
+ "\n",
+ "\n",
+ "the error in the solution is: 0.018372\n",
+ "\n",
+ "\n",
+ "u00=0.399255\t u10=0.646018\t u20=0.646018\t u30=0.399255\t\n",
+ "\n",
+ "\n",
+ "the error in the solution is: 0.005172\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.8:pg-364"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#heat equation using crank-nicolson method\n",
+ "#example 9.8\n",
+ "#page 364\n",
+ "from numpy import matrix\n",
+ "import math\n",
+ "z=0.01878\n",
+ "#h=1/2 l=1/8,i=1\n",
+ "u01=0.0\n",
+ "u21=1.0/8.0\n",
+ "u11=(u21+u01)/6.0\n",
+ "print \" u11=%f\\n\\n\" % (u11)\n",
+ "print \"error is %f\\n\\n\" % (math.fabs(u11-z))\n",
+ "#h=1/4,l=1/8,i=1,2,3\n",
+ "A=matrix([[-3.0 ,-1.0 ,0.0],[1.0,-3.0,1.0],[0.0,1.0,-3.0]])\n",
+ "C=matrix([[0.0],[0.0],[-0.125]])\n",
+ "#here we found inverese of A then we multipy it with C\n",
+ "X=A.I*C\n",
+ "print \"u12=%f\\n\\n\" % (X[1][0])\n",
+ "print \"error is %f\\n\\n\" %(math.fabs(X[1][0]-z))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " u11=0.020833\n",
+ "\n",
+ "\n",
+ "error is 0.002053\n",
+ "\n",
+ "\n",
+ "u12=0.013889\n",
+ "\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "error is 0.004891\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter1_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter1_6.ipynb new file mode 100644 index 00000000..29a46a36 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter1_6.ipynb @@ -0,0 +1,625 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:6ce091ab8e1fc1b8237507a6211c6c4c45a07ba8baa4f3364e4633c5bb15666c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter01:Errors in Numerical Calculations"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.1:pg-7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.1\n",
+ "#rounding off\n",
+ "#page 7\n",
+ "a1=1.6583\n",
+ "a2=30.0567\n",
+ "a3=0.859378\n",
+ "a4=3.14159\n",
+ "print \"\\nthe numbers after rounding to 4 significant figures are given below\\n\"\n",
+ "print \" %f %.4g\\n'\" %(a1,a1)\n",
+ "print \" %f %.4g\\n\" %(a2,a2)\n",
+ "print \" %f %.4g\\n\" %(a3,a3)\n",
+ "print \" %f %.4g\\n\" %(a4,a4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "the numbers after rounding to 4 significant figures are given below\n",
+ "\n",
+ " 1.658300 1.658\n",
+ "'\n",
+ " 30.056700 30.06\n",
+ "\n",
+ " 0.859378 0.8594\n",
+ "\n",
+ " 3.141590 3.142\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.2:pg-9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.2\n",
+ "#percentage accuracy\n",
+ "#page 9\n",
+ "import math\n",
+ "x=0.51 # the number given\n",
+ "n=2 #correcting upto 2 decimal places\n",
+ "d=math.pow(10,-n)\n",
+ "d=d/2.0\n",
+ "p=(d/x)*100 #percentage accuracy\n",
+ "print \"the percentage accuracy of %f after correcting to two decimal places is %f\" %(x,p)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the percentage accuracy of 0.510000 after correcting to two decimal places is 0.980392\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.3:pg-9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.3\n",
+ "#absolute and relative errors\n",
+ "#page 9\n",
+ "X=3.1428571 #approximate value of pi\n",
+ "T_X=3.1415926 # true value of pi\n",
+ "A_E=T_X-X #absolute error\n",
+ "R_E=A_E/T_X #relative error\n",
+ "print \"Absolute Error = %0.7f \\n Relative Error = %0.7f\" %(A_E,R_E)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Absolute Error = -0.0012645 \n",
+ " Relative Error = -0.0004025\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.4:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.4\n",
+ "#best approximation\n",
+ "#page 10\n",
+ "X=1/3 #the actual number\n",
+ "X1=0.30\n",
+ "X2=0.33\n",
+ "X3=0.34\n",
+ "E1=abs(X-X1)\n",
+ "E2=abs(X-X2)\n",
+ "E3=abs(X-X3)\n",
+ "if E1<E2:\n",
+ " if E1<E3:\n",
+ " B_A=X1\n",
+ "elif E2<E1:\n",
+ " if E2<E3:\n",
+ " B_A=X2\n",
+ "elif E3<E2:\n",
+ " if E3<E1:\n",
+ " B_A=X3\n",
+ "print \"the best approximation of 1/3 is %f\" %(B_A)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the best approximation of 1/3 is 0.300000\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.5:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#relative error\n",
+ "#example 1.5\n",
+ "#page 10\n",
+ "import math\n",
+ "n=8.6 # the corrected number\n",
+ "N=1 #the no is rounded to one decimal places\n",
+ "E_A=math.pow(10,-N)/2\n",
+ "E_R=E_A/n\n",
+ "print \"the relative error of the number is:%0.4f\" %(E_R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the relative error of the number is:0.0058\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.6:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.6\n",
+ "#absolute error and relative error\n",
+ "#page 10\n",
+ "import math\n",
+ "s=math.sqrt(3)+math.sqrt(5)+math.sqrt(7) #the sum square root of 3,5,7\n",
+ "n=4\n",
+ "Ea=3*(math.pow(10,-n)/2) #absolute error\n",
+ "R_E=Ea/s\n",
+ "print \"the sum of square roots is %0.4g \\n\" %(s)\n",
+ "print \"the absolute error is %f \\n\" %(Ea)\n",
+ "print \"the relative error is %f\" %(R_E)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the sum of square roots is 6.614 \n",
+ "\n",
+ "the absolute error is 0.000150 \n",
+ "\n",
+ "the relative error is 0.000023\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.7:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#absolute error\n",
+ "#example 1.7\n",
+ "#page 10\n",
+ "n=[0.1532, 15.45, 0.0000354, 305.1, 8.12, 143.3, 0.0212, 0.643, 0.1734] #original numbers\n",
+ "#rounding all numbers to 2 decimal places\n",
+ "n=[305.1, 143.3, 0.15,15.45, 0.00, 8.12, 0.02, 0.64, 0.17] \n",
+ "sum=0;\n",
+ "#l=length(n);\n",
+ "for i in range(len(n)):\n",
+ " sum=sum+n[i];\n",
+ "\n",
+ "E_A=2*math.pow(10,-1)/2+7*math.pow(10,-2)/2\n",
+ "print \"the absolute error is:%0.2f\" %(E_A)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the absolute error is:0.14\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.8:pg-11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#difference in 3 significant figures\n",
+ "#example 1.8\n",
+ "#page 11\n",
+ "X1=math.sqrt(6.37)\n",
+ "X2=math.sqrt(6.36)\n",
+ "d=X1-X2 #difference between two numbers\n",
+ "print \"the difference corrected to 3 significant figures is %0.3g\" %(d)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the difference corrected to 3 significant figures is 0.00198\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.9:pg-12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#relative error\n",
+ "#example 1.10\n",
+ "#page 12\n",
+ "a=6.54\n",
+ "b=48.64\n",
+ "c=13.5\n",
+ "da=0.01\n",
+ "db=0.02\n",
+ "dc=0.03\n",
+ "s=math.pow(a,2)*math.sqrt(b)/math.pow(c,3)\n",
+ "#disp(s,'s=')\n",
+ "print \"s=%f\" %(s)\n",
+ "r_err=2*(da/a)+(db/b)/2+3*(dc/c);\n",
+ "print \"the relative error is :%f\" %(r_err)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "s=0.121241\n",
+ "the relative error is :0.009930\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.11:pg-13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#relative error\n",
+ "#example 1.11\n",
+ "#page 13\n",
+ "import math\n",
+ "x=1\n",
+ "y=1\n",
+ "z=1\n",
+ "u=(5*x*math.pow(y,3))/math.pow(z,3)\n",
+ "dx=0.001\n",
+ "dy=0.001\n",
+ "dz=0.001\n",
+ "max=((5*math.pow(y,2))/math.pow(z,3))*dx+((10*x*y)/math.pow(z,3))*dy+((15*x*math.pow(y,2))/math.pow(z,4))*dz\n",
+ "e=max/u\n",
+ "print \" the relative error is :%f\" %(e)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " the relative error is :0.006000\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.12:pg-12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#taylor series\n",
+ "#example 1.12\n",
+ "#page 12\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.pow(x,3)+5*x-10\n",
+ "def f1(x):\n",
+ " return 3*math.pow(x,2)-6*x+5\n",
+ "def f2(x):\n",
+ " return 6*x-6\n",
+ "def f3(x):\n",
+ " return 6\n",
+ "D=[0,f(0), f1(0), f2(0), f3(0)]\n",
+ "S1=0;\n",
+ "h=1;\n",
+ "for i in range(1,5):\n",
+ " S1=S1+math.pow(h,i-1)*D[i]/math.factorial(i-1)\n",
+ " \n",
+ "print \"the third order taylors series approximation of f(1) is :%d\" %(S1)\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the third order taylors series approximation of f(1) is :-7\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.13:pg-16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#taylor series\n",
+ "#example 1.13\n",
+ "#page 16\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.sin(x)\n",
+ "def f1(x):\n",
+ " return math.cos(x)\n",
+ "def f2(x):\n",
+ " return -1*math.sin(x)\n",
+ "def f3(x):\n",
+ " return -1*math.cos(x)\n",
+ "def f4(x):\n",
+ " return math.sin(x)\n",
+ "def f5(x):\n",
+ " return math.cos(x)\n",
+ "def f6(x):\n",
+ " return -1*math.sin(x)\n",
+ "def f7(x):\n",
+ " return -1*math.cos(x)\n",
+ "D=[0,f(math.pi/6), f1(math.pi/6), f2(math.pi/6), f3(math.pi/6), f4(math.pi/6), f5(math.pi/6), f6(math.pi/6), f7(math.pi/6)]\n",
+ "S1=0\n",
+ "h=math.pi/6\n",
+ "print \"order of approximation computed value of sin(pi/3) absolute eror\\n\\n\"\n",
+ "for j in range(1,10):\n",
+ " for i in range(1,j):\n",
+ " S1=S1+math.pow(h,i-1)*D[i]/math.factorial(i-1) \n",
+ " print \"%d %0.9f %0.9f\\n\" %(j,S1,abs(math.sin(math.pi/3)-S1))\n",
+ " S1=0\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "order of approximation computed value of sin(pi/3) absolute eror\n",
+ "\n",
+ "\n",
+ "1 0.000000000 0.866025404\n",
+ "\n",
+ "2 0.500000000 0.366025404\n",
+ "\n",
+ "3 0.953449841 0.087424437\n",
+ "\n",
+ "4 0.884910922 0.018885518\n",
+ "\n",
+ "5 0.864191614 0.001833790\n",
+ "\n",
+ "6 0.865757475 0.000267929\n",
+ "\n",
+ "7 0.866041490 0.000016087\n",
+ "\n",
+ "8 0.866027181 0.000001777\n",
+ "\n",
+ "9 0.866025327 0.000000077\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 32
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.14:pg-18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#maclaurins expansion\n",
+ "#example 1.14\n",
+ "#page 18\n",
+ "n=8 #correct to 8 decimal places\n",
+ "x=1\n",
+ "for i in range(1,50):\n",
+ " if x/math.factorial(i)<math.pow(10,-8)/2:\n",
+ " c=i\n",
+ " break \n",
+ "print \"no. of terms needed to correct to 8 decimal places is : %d \" %(c)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "no. of terms needed to correct to 8 decimal places is : 2 \n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.15:pg-18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#series apprixamation\n",
+ "#example 1.15\n",
+ "#page 18\n",
+ "import math\n",
+ "x=.09090909 # 1/11 =.09090909\n",
+ "S1=0\n",
+ "for i in range(1,5,2):\n",
+ " S1=S1+math.pow(x,i)/i\n",
+ "print \"value of log(1.2) is : %0.8f\\n\\n\" %(2*S1)\n",
+ "c=0\n",
+ "for i in range(1,50):\n",
+ " if math.pow(.09090909,i)/i<2*math.pow(10,-7):\n",
+ " c=i\n",
+ " break\n",
+ "print \"min no of terms needed to get value wuth same accuracy is :%d\" %(c)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of log(1.2) is : 0.18231906\n",
+ "\n",
+ "\n",
+ "min no of terms needed to get value wuth same accuracy is :6\n"
+ ]
+ }
+ ],
+ "prompt_number": 74
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter2_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter2_6.ipynb new file mode 100644 index 00000000..fbc2fddb --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter2_6.ipynb @@ -0,0 +1,2186 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:45d3126b2d35991f370f877f92a5b61aefd68f8c993433101cae150b3ddd204c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter02:Solution of Algebric and Transcendental Equations"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.1:pg-24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.1\n",
+ "#bisection method\n",
+ "#page 24\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.pow(x,3)-x-1\n",
+ "x1=1\n",
+ "x2=2 #f(1) is negative and f(2) is positive\n",
+ "d=0.0001 #for accuracy of root\n",
+ "c=1\n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\tf(m)\\n\"\n",
+ "while abs(x1-x2)>d:\n",
+ " \n",
+ " m=(x1+x2)/2.0\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,f(m))\n",
+ " if f(m)*f(x1)>0.0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1 # to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \tf(m)\n",
+ "\n",
+ " \t1.000000\t2.000000\t1.500000\t0.875000\n",
+ "\n",
+ " \t1.000000\t1.500000\t1.250000\t-0.296875\n",
+ "\n",
+ " \t1.250000\t1.500000\t1.375000\t0.224609\n",
+ "\n",
+ " \t1.250000\t1.375000\t1.312500\t-0.051514\n",
+ "\n",
+ " \t1.312500\t1.375000\t1.343750\t0.082611\n",
+ "\n",
+ " \t1.312500\t1.343750\t1.328125\t0.014576\n",
+ "\n",
+ " \t1.312500\t1.328125\t1.320312\t-0.018711\n",
+ "\n",
+ " \t1.320312\t1.328125\t1.324219\t-0.002128\n",
+ "\n",
+ " \t1.324219\t1.328125\t1.326172\t0.006209\n",
+ "\n",
+ " \t1.324219\t1.326172\t1.325195\t0.002037\n",
+ "\n",
+ " \t1.324219\t1.325195\t1.324707\t-0.000047\n",
+ "\n",
+ " \t1.324707\t1.325195\t1.324951\t0.000995\n",
+ "\n",
+ " \t1.324707\t1.324951\t1.324829\t0.000474\n",
+ "\n",
+ " \t1.324707\t1.324829\t1.324768\t0.000214\n",
+ "\n",
+ "the solution of equation after 15 iteration is 1.32477'\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.2:pg-25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.2\n",
+ "#bisection method\n",
+ "#page 25\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.pow(x,3)-2*x-5\n",
+ "x1=2 \n",
+ "x2=3 #f(2) is negative and f(3) is positive\n",
+ "d=0.0001 #for accuracy of root\n",
+ "c=1\n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\tf(m)\\n\"\n",
+ "while abs(x1-x2)>d:\n",
+ " m=(x1+x2)/2.0\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,f(m))\n",
+ " if f(m)*f(x1)>0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1;# to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %0.4g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \tf(m)\n",
+ "\n",
+ " \t2.000000\t3.000000\t2.500000\t5.625000\n",
+ "\n",
+ " \t2.000000\t2.500000\t2.250000\t1.890625\n",
+ "\n",
+ " \t2.000000\t2.250000\t2.125000\t0.345703\n",
+ "\n",
+ " \t2.000000\t2.125000\t2.062500\t-0.351318\n",
+ "\n",
+ " \t2.062500\t2.125000\t2.093750\t-0.008942\n",
+ "\n",
+ " \t2.093750\t2.125000\t2.109375\t0.166836\n",
+ "\n",
+ " \t2.093750\t2.109375\t2.101562\t0.078562\n",
+ "\n",
+ " \t2.093750\t2.101562\t2.097656\t0.034714\n",
+ "\n",
+ " \t2.093750\t2.097656\t2.095703\t0.012862\n",
+ "\n",
+ " \t2.093750\t2.095703\t2.094727\t0.001954\n",
+ "\n",
+ " \t2.093750\t2.094727\t2.094238\t-0.003495\n",
+ "\n",
+ " \t2.094238\t2.094727\t2.094482\t-0.000771\n",
+ "\n",
+ " \t2.094482\t2.094727\t2.094604\t0.000592\n",
+ "\n",
+ " \t2.094482\t2.094604\t2.094543\t-0.000090\n",
+ "\n",
+ "the solution of equation after 15 iteration is 2.095\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.3:pg-26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.3\n",
+ "#bisection method\n",
+ "#page 26\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.pow(x,3)+math.pow(x,2)+x+7\n",
+ "x1=-3\n",
+ "x2=-2 #f(-3) is negative and f(-2) is positive\n",
+ "d=0.0001 #for accuracy of root\n",
+ "c=1\n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\tf(m)\\n\"\n",
+ "while abs(x1-x2)>d:\n",
+ " m=(x1+x2)/2.0\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,f(m))\n",
+ " if f(m)*f(x1)>0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1 # to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %0.4g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \tf(m)\n",
+ "\n",
+ " \t-3.000000\t-2.000000\t-2.500000\t-4.875000\n",
+ "\n",
+ " \t-2.500000\t-2.000000\t-2.250000\t-1.578125\n",
+ "\n",
+ " \t-2.250000\t-2.000000\t-2.125000\t-0.205078\n",
+ "\n",
+ " \t-2.125000\t-2.000000\t-2.062500\t0.417725\n",
+ "\n",
+ " \t-2.125000\t-2.062500\t-2.093750\t0.111481\n",
+ "\n",
+ " \t-2.125000\t-2.093750\t-2.109375\t-0.045498\n",
+ "\n",
+ " \t-2.109375\t-2.093750\t-2.101562\t0.033315\n",
+ "\n",
+ " \t-2.109375\t-2.101562\t-2.105469\t-0.006010\n",
+ "\n",
+ " \t-2.105469\t-2.101562\t-2.103516\t0.013673\n",
+ "\n",
+ " \t-2.105469\t-2.103516\t-2.104492\t0.003836\n",
+ "\n",
+ " \t-2.105469\t-2.104492\t-2.104980\t-0.001086\n",
+ "\n",
+ " \t-2.104980\t-2.104492\t-2.104736\t0.001376\n",
+ "\n",
+ " \t-2.104980\t-2.104736\t-2.104858\t0.000145\n",
+ "\n",
+ " \t-2.104980\t-2.104858\t-2.104919\t-0.000470\n",
+ "\n",
+ "the solution of equation after 15 iteration is -2.105\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.4:pg-26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.4\n",
+ "#bisection method\n",
+ "#page 26\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x*math.exp(x)-1\n",
+ "x1=0 \n",
+ "x2=1 #f(0) is negative and f(1) is positive\n",
+ "d=0.0005 #maximun tolerance value\n",
+ "c=1\n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\ttol\\t \\tf(m)\\n\"\n",
+ "while abs((x2-x1)/x2)>d:\n",
+ " m=(x1+x2)/2.0 #tolerance value for each iteration\n",
+ " tol=((x2-x1)/x2)*100\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,tol,f(m))\n",
+ " if f(m)*f(x1)>0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1 # to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %0.4g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \ttol\t \tf(m)\n",
+ "\n",
+ " \t0.000000\t1.000000\t0.500000\t100.000000\t-0.175639\n",
+ "\n",
+ " \t0.500000\t1.000000\t0.750000\t50.000000\t0.587750\n",
+ "\n",
+ " \t0.500000\t0.750000\t0.625000\t33.333333\t0.167654\n",
+ "\n",
+ " \t0.500000\t0.625000\t0.562500\t20.000000\t-0.012782\n",
+ "\n",
+ " \t0.562500\t0.625000\t0.593750\t10.000000\t0.075142\n",
+ "\n",
+ " \t0.562500\t0.593750\t0.578125\t5.263158\t0.030619\n",
+ "\n",
+ " \t0.562500\t0.578125\t0.570312\t2.702703\t0.008780\n",
+ "\n",
+ " \t0.562500\t0.570312\t0.566406\t1.369863\t-0.002035\n",
+ "\n",
+ " \t0.566406\t0.570312\t0.568359\t0.684932\t0.003364\n",
+ "\n",
+ " \t0.566406\t0.568359\t0.567383\t0.343643\t0.000662\n",
+ "\n",
+ " \t0.566406\t0.567383\t0.566895\t0.172117\t-0.000687\n",
+ "\n",
+ " \t0.566895\t0.567383\t0.567139\t0.086059\t-0.000013\n",
+ "\n",
+ "the solution of equation after 13 iteration is 0.5671\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.5:pg-27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.5\n",
+ "#bisection method\n",
+ "#page 27\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 4*math.exp(-x)*math.sin(x)-1\n",
+ "x1=0 \n",
+ "x2=0.5 #f(0) is negative and f(1) is positive\n",
+ "d=0.0001 #for accuracy of root\n",
+ "c=1 \n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\t \\tf(m)\\n\"\n",
+ "while abs(x2-x1)>d:\n",
+ " m=(x1+x2)/2.0\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,f(m))\n",
+ " if f(m)*f(x1)>0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1 # to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %0.3g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \t \tf(m)\n",
+ "\n",
+ " \t0.000000\t0.500000\t0.250000\t-0.229286\n",
+ "\n",
+ " \t0.250000\t0.500000\t0.375000\t0.006941\n",
+ "\n",
+ " \t0.250000\t0.375000\t0.312500\t-0.100293\n",
+ "\n",
+ " \t0.312500\t0.375000\t0.343750\t-0.044068\n",
+ "\n",
+ " \t0.343750\t0.375000\t0.359375\t-0.017925\n",
+ "\n",
+ " \t0.359375\t0.375000\t0.367188\t-0.005334\n",
+ "\n",
+ " \t0.367188\t0.375000\t0.371094\t0.000842\n",
+ "\n",
+ " \t0.367188\t0.371094\t0.369141\t-0.002236\n",
+ "\n",
+ " \t0.369141\t0.371094\t0.370117\t-0.000694\n",
+ "\n",
+ " \t0.370117\t0.371094\t0.370605\t0.000075\n",
+ "\n",
+ " \t0.370117\t0.370605\t0.370361\t-0.000310\n",
+ "\n",
+ " \t0.370361\t0.370605\t0.370483\t-0.000118\n",
+ "\n",
+ " \t0.370483\t0.370605\t0.370544\t-0.000022\n",
+ "\n",
+ "the solution of equation after 14 iteration is 0.371\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.6:pg-28"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.6\n",
+ "#false position method\n",
+ "#page 28\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x**3-2*x-5\n",
+ "a=2.0\n",
+ "b=3.0 #f(2) is negative and f(3)is positive\n",
+ "d=0.00001\n",
+ "print \"succesive iterations \\ta\\t b\\t f(a)\\t f(b)\\t\\ x1\\n\"\n",
+ "for i in range(1,25):\n",
+ " x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a))\n",
+ " if(f(a)*f(x1))>0:\n",
+ " b=x1\n",
+ " else:\n",
+ " a=x1\n",
+ " if abs(f(x1))<d:\n",
+ " break\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(a,b,f(a),f(b),x1)\n",
+ "print \"the root of the equation is %f\" %(x1)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "succesive iterations \ta\t b\t f(a)\t f(b)\t\\ x1\n",
+ "\n",
+ " \t2.000000 2.058824 -1.000000 -0.390800 2.058824\n",
+ "\n",
+ " \t2.096559 2.058824 0.022428 -0.390800 2.096559\n",
+ "\n",
+ " \t2.094511 2.058824 -0.000457 -0.390800 2.094511\n",
+ "\n",
+ "the root of the equation is 2.094552\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.7:pg-29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.7\n",
+ "#false position method\n",
+ "#page 29\n",
+ "def f(x):\n",
+ " return x**2.2-69\n",
+ "a=5.0\n",
+ "b=6.0 #f(5) is negative and f(6)is positive\n",
+ "d=0.00001\n",
+ "print \"succesive iterations \\ta\\t b\\t f(a)\\t f(b)\\t\\ x1\\n\"\n",
+ "for i in range(1,25):\n",
+ " x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a));\n",
+ " if(f(a)*f(x1))>0:\n",
+ " b=x1\n",
+ " else:\n",
+ " a=x1\n",
+ " if abs(f(x1))<d:\n",
+ " break\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(a,b,f(a),f(b),x1)\n",
+ "print \"the root of the equation is %f\" %(x1)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "succesive iterations \ta\t b\t f(a)\t f(b)\t\\ x1\n",
+ "\n",
+ " \t7.027228 6.000000 3.933141 -17.485113 7.027228\n",
+ "\n",
+ " \t6.838593 6.000000 -0.304723 -17.485113 6.838593\n",
+ "\n",
+ " \t6.853467 6.000000 0.024411 -17.485113 6.853467\n",
+ "\n",
+ " \t6.852277 6.000000 -0.001950 -17.485113 6.852277\n",
+ "\n",
+ " \t6.852372 6.000000 0.000156 -17.485113 6.852372\n",
+ "\n",
+ " \t6.852365 6.000000 -0.000012 -17.485113 6.852365\n",
+ "\n",
+ "the root of the equation is 6.852365\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.8:pg-29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.8\n",
+ "#false position method\n",
+ "#page 29\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 2*x-log10(x)-7\n",
+ "a=3.0\n",
+ "b=4.0 #f(3) is negative and f(4)is positive\n",
+ "d=0.00001\n",
+ "print \"succesive iterations \\ta \\t b\\t f(a)\\t f(b)\\t x1\\n\"\n",
+ "for i in range(1,25):\n",
+ " x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a))\n",
+ " if(f(a)*f(x1))>0:\n",
+ " b=x1\n",
+ " else:\n",
+ " a=x1\n",
+ " if abs(f(x1))<d:\n",
+ " break\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(a,b,f(a),f(b),x1)\n",
+ "print \"the root of the equation is %0.4g\" %(x1)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "succesive iterations \ta \t b\t f(a)\t f(b)\t x1\n",
+ "\n",
+ " \t3.000000 3.787772 -1.477121 -0.002839 3.787772\n",
+ "\n",
+ " \t3.789289 3.787772 0.000021 -0.002839 3.789289\n",
+ "\n",
+ "the root of the equation is 3.789\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.9:pg-30"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.9\n",
+ "#false position method\n",
+ "#page 30\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 4*math.exp(-x)*math.sin(x)-1\n",
+ "a=0.0\n",
+ "b=0.5 #f(0) is negative and f(0.5)is positive\n",
+ "d=0.00001\n",
+ "print \"succesive iterations \\ta\\t b\\t f(a)\\t f(b)\\t\\ x1\\n\"\n",
+ "for i in range(1,25):\n",
+ " x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a))\n",
+ " if(f(a)*f(x1))>0:\n",
+ " b=x1\n",
+ " else:\n",
+ " a=x1\n",
+ " if abs(f(x1))<d:\n",
+ " break\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(a,b,f(a),f(b),x1)\n",
+ "print \"the root of the equation is %f\" %(x1)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "succesive iterations \ta\t b\t f(a)\t f(b)\t\\ x1\n",
+ "\n",
+ " \t0.429869 0.500000 0.084545 0.163145 0.429869\n",
+ "\n",
+ " \t0.354433 0.500000 -0.026054 0.163145 0.354433\n",
+ "\n",
+ " \t0.374479 0.500000 0.006132 0.163145 0.374479\n",
+ "\n",
+ " \t0.369577 0.500000 -0.001547 0.163145 0.369577\n",
+ "\n",
+ " \t0.370802 0.500000 0.000384 0.163145 0.370802\n",
+ "\n",
+ " \t0.370497 0.500000 -0.000096 0.163145 0.370497\n",
+ "\n",
+ " \t0.370573 0.500000 0.000024 0.163145 0.370573\n",
+ "\n",
+ "the root of the equation is 0.370554\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.10:pg-33"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.10\n",
+ "#iteration method\n",
+ "#page 33\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 1/(math.sqrt(x+1))\n",
+ "x1=0.75\n",
+ "x2=0.0\n",
+ "n=1\n",
+ "d=0.0001 #accuracy opto 10^-4\n",
+ "c=0 #to count no of iterations \n",
+ "print \"successive iterations \\t\\x01\\tf(x1)\\n\"\n",
+ "while abs(x1-x2)>d:\n",
+ " print \" \\t%f %f\\n\" %(x1,f(x1))\n",
+ " x2=x1\n",
+ " x1=f(x1)\n",
+ " c=c+1\n",
+ "print \" the root of the eqaution after %i iteration is %0.4g\" %(c,x1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t\u0001\tf(x1)\n",
+ "\n",
+ " \t0.750000 0.755929\n",
+ "\n",
+ " \t0.755929 0.754652\n",
+ "\n",
+ " \t0.754652 0.754926\n",
+ "\n",
+ " \t0.754926 0.754867\n",
+ "\n",
+ " the root of the eqaution after 4 iteration is 0.7549\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.11:pg-34"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.11\n",
+ "#iteration method\n",
+ "#page34\n",
+ "import math\n",
+ "def f(x):\n",
+ " return cos(x)/2.0+3.0/2.0\n",
+ "x1=1.5 # as roots lies between 3/2 and pi/2\n",
+ "x2=0\n",
+ "d=0.0001 # accuracy opto 10^-4\n",
+ "c=0 # to count no of iterations \n",
+ "print \"successive iterations \\t\\x01\\tf(x1)\\n\"\n",
+ "while abs(x2-x1)>d:\n",
+ " \n",
+ " print \" \\t%f %f\\n\" %(x1,f(x1))\n",
+ " x2=x1\n",
+ " x1=f(x1)\n",
+ " c=c+1\n",
+ "print \" the root of the eqaution after %i iteration is %0.4g\" %(c,x1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t\u0001\tf(x1)\n",
+ "\n",
+ " \t1.500000 1.535369\n",
+ "\n",
+ " \t1.535369 1.517710\n",
+ "\n",
+ " \t1.517710 1.526531\n",
+ "\n",
+ " \t1.526531 1.522126\n",
+ "\n",
+ " \t1.522126 1.524326\n",
+ "\n",
+ " \t1.524326 1.523227\n",
+ "\n",
+ " \t1.523227 1.523776\n",
+ "\n",
+ " \t1.523776 1.523502\n",
+ "\n",
+ " \t1.523502 1.523639\n",
+ "\n",
+ " \t1.523639 1.523570\n",
+ "\n",
+ " the root of the eqaution after 10 iteration is 1.524\n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.12:pg-35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.12\n",
+ "#iteration method\n",
+ "#page 35\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.exp(-x)\n",
+ "x1=1.5 # as roots lies between 0 and 1\n",
+ "x2=0\n",
+ "d=0.0001 # accuracy opto 10^-4\n",
+ "c=0 # to count no of iterations \n",
+ "print \"successive iterations \\t x1 \\t f(x1)\\n\"\n",
+ "while abs(x2-x1)>d:\n",
+ " \n",
+ " print \" \\t%f %f\\n\" %(x1,f(x1))\n",
+ " x2=x1\n",
+ " x1=f(x1)\n",
+ " c=c+1\n",
+ "print \" the root of the eqaution after %i iteration is %0.4g\" %(c,x1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x1 \t f(x1)\n",
+ "\n",
+ " \t1.500000 0.223130\n",
+ "\n",
+ " \t0.223130 0.800011\n",
+ "\n",
+ " \t0.800011 0.449324\n",
+ "\n",
+ " \t0.449324 0.638059\n",
+ "\n",
+ " \t0.638059 0.528317\n",
+ "\n",
+ " \t0.528317 0.589597\n",
+ "\n",
+ " \t0.589597 0.554551\n",
+ "\n",
+ " \t0.554551 0.574330\n",
+ "\n",
+ " \t0.574330 0.563082\n",
+ "\n",
+ " \t0.563082 0.569451\n",
+ "\n",
+ " \t0.569451 0.565836\n",
+ "\n",
+ " \t0.565836 0.567885\n",
+ "\n",
+ " \t0.567885 0.566723\n",
+ "\n",
+ " \t0.566723 0.567382\n",
+ "\n",
+ " \t0.567382 0.567008\n",
+ "\n",
+ " \t0.567008 0.567220\n",
+ "\n",
+ " \t0.567220 0.567100\n",
+ "\n",
+ " \t0.567100 0.567168\n",
+ "\n",
+ " the root of the eqaution after 18 iteration is 0.5672\n"
+ ]
+ }
+ ],
+ "prompt_number": 34
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.13:pg-35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.13\n",
+ "#iteration method\n",
+ "#page 35\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 1+math.sin(x)/10\n",
+ "x1=1.0 # as roots lies between 1 and pi evident from graph\n",
+ "x2=0\n",
+ "d=0.0001 # accuracy opto 10^-4\n",
+ "c=0 # to count no of iterations \n",
+ "print \"successive iterations \\t x1 \\t f(x1)\\n\"\n",
+ "while abs(x2-x1)>d:\n",
+ " print \" \\t%f %f\\n\" %(x1,f(x1))\n",
+ " x2=x1\n",
+ " x1=f(x1)\n",
+ " c=c+1\n",
+ "print \" the root of the eqaution after %i iteration is %0.4g\" %(c,x1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x1 \t f(x1)\n",
+ "\n",
+ " \t1.000000 1.084147\n",
+ "\n",
+ " \t1.084147 1.088390\n",
+ "\n",
+ " \t1.088390 1.088588\n",
+ "\n",
+ " \t1.088588 1.088597\n",
+ "\n",
+ " the root of the eqaution after 4 iteration is 1.089\n"
+ ]
+ }
+ ],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.14:pg-36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.14\n",
+ "#aitken's process\n",
+ "#page 36\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 1.5+math.cos(x)/2.0\n",
+ "x0=1.5\n",
+ "y=0\n",
+ "e=0.0001\n",
+ "c=0\n",
+ "print \"successive iterations \\t x0 \\t x1 \\t x2 \\t x3 \\t y\\n\"\n",
+ "for i in range(1,10):\n",
+ " x1=f(x0)\n",
+ " x2=f(x1)\n",
+ " x3=f(x2)\n",
+ " y=x3-((x3-x2)**2)/(x3-2*x2+x1)\n",
+ " d=y-x0\n",
+ " x0=y\n",
+ " if abs(f(x0))<e:\n",
+ " break\n",
+ " c=c+1\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(x0,x1,x2,x3,y)\n",
+ "print \"the root of the equation after %i iteration is %f\" %(c,y)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t x1 \t x2 \t x3 \t y\n",
+ "\n",
+ " \t1.523592 1.535369 1.517710 1.526531 1.523592\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ "the root of the equation after 9 iteration is 1.523593\n"
+ ]
+ }
+ ],
+ "prompt_number": 42
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.15:pg-39"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.15\n",
+ "#newton-raphson method\n",
+ "#page 39\n",
+ "def f(x):\n",
+ " return x**3-2*x-5\n",
+ "def f1(x):\n",
+ " return 3*x**2-2 # first derivative of the function\n",
+ "x0=2.0 # initial value\n",
+ "d=0.0001\n",
+ "c=0\n",
+ "n=1\n",
+ "print \"successive iterations \\t x0 \\t f(x0) \\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f \\t%f \\t%f \\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break\n",
+ "print \"the root of %i iteration is:%f\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t f(x0) \t f1(x0)\n",
+ "\n",
+ " \t2.000000 \t0.061000 \t11.230000 \n",
+ "\n",
+ " \t2.100000 \t0.000186 \t11.161647 \n",
+ "\n",
+ " \t2.094568 \t0.000000 \t11.161438 \n",
+ "\n",
+ "the root of 3 iteration is:2.094551\n"
+ ]
+ }
+ ],
+ "prompt_number": 44
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.16:pg-40"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.16\n",
+ "#newton-raphson method\n",
+ "#page 40\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x*math.sin(x)+math.cos(x)\n",
+ "def f1(x):\n",
+ " return x*math.cos(x) #first derivation of the function\n",
+ "x0=math.pi # initial value\n",
+ "d=0.0001\n",
+ "c=0 \n",
+ "n=1\n",
+ "print \"successive iterations \\tx0\\t f(x0)\\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f \\t%f \\t%f\\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break\n",
+ "print \"the root of %i iteration is:%f\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \tx0\t f(x0)\t f1(x0)\n",
+ "\n",
+ " \t3.141593 \t-0.066186 \t-2.681457\n",
+ "\n",
+ " \t2.823283 \t-0.000564 \t-2.635588\n",
+ "\n",
+ " \t2.798600 \t-0.000000 \t-2.635185\n",
+ "\n",
+ "the root of 3 iteration is:2.798386\n"
+ ]
+ }
+ ],
+ "prompt_number": 46
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.17:pg-40"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.17\n",
+ "#newton-raphson method\n",
+ "#page 40\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x*math.exp(x)-1\n",
+ "def f1(x):\n",
+ " return math.exp(x)+x*math.exp(x) #first derivative of the function\n",
+ "x0=0 # initial value\n",
+ "d=0.0001 \n",
+ "c=0\n",
+ "n=1\n",
+ "print \"successive iterations \\tx0\\t f(x0)\\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f \\t%f \\t%f\\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break\n",
+ "print \"the root of %i iteration is:%f\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \tx0\t f(x0)\t f1(x0)\n",
+ "\n",
+ " \t0.000000 \t1.718282 \t5.436564\n",
+ "\n",
+ " \t1.000000 \t0.355343 \t3.337012\n",
+ "\n",
+ " \t0.683940 \t0.028734 \t2.810232\n",
+ "\n",
+ " \t0.577454 \t0.000239 \t2.763614\n",
+ "\n",
+ " \t0.567230 \t0.000000 \t2.763223\n",
+ "\n",
+ "the root of 5 iteration is:0.567143\n"
+ ]
+ }
+ ],
+ "prompt_number": 48
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.18:pg-41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.18\n",
+ "#newton-raphson method\n",
+ "#page 41\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.sin(x)-x/2.0\n",
+ "def f1(x):\n",
+ " return math.cos(x)-0.5\n",
+ "x0=math.pi/2.0 # initial value\n",
+ "d=0.0001\n",
+ "c=0\n",
+ "n=1\n",
+ "print \"successive iterations \\t x0 \\t f(x0)\\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f\\t%f\\t%f\\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break\n",
+ "print \"the root of %i iteration is: %0.4g\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t f(x0)\t f1(x0)\n",
+ "\n",
+ " \t1.570796\t-0.090703\t-0.916147\n",
+ "\n",
+ " \t2.000000\t-0.004520\t-0.824232\n",
+ "\n",
+ " \t1.900996\t-0.000014\t-0.819039\n",
+ "\n",
+ "the root of 3 iteration is: 1.896\n"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.19:pg-41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.19\n",
+ "#newton-raphson method\n",
+ "#page 41\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 4*math.exp(-x)*math.sin(x)-1\n",
+ "def f1(x):\n",
+ " return math.cos(x)*4*math.exp(-x)-4*math.exp(-x)*math.sin(x)\n",
+ "x0=0.2 # initial value\n",
+ "d=0.0001\n",
+ "c=0 \n",
+ "n=1\n",
+ "print \"successive iterations \\t x0 \\t f(x0)\\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f \\t%f \\t%f\\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break \n",
+ "print \"the root of %i iteration is: %0.3g\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t f(x0)\t f1(x0)\n",
+ "\n",
+ " \t0.200000 \t-0.056593 \t1.753325\n",
+ "\n",
+ " \t0.336526 \t-0.002769 \t1.583008\n",
+ "\n",
+ " \t0.368804 \t-0.000008 \t1.573993\n",
+ "\n",
+ "the root of 3 iteration is: 0.371\n"
+ ]
+ }
+ ],
+ "prompt_number": 54
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.20:pg-42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.20\n",
+ "#generalized newton-raphson method\n",
+ "#page 42\n",
+ "def f(x):\n",
+ " return x**3-x**2-x+1\n",
+ "def f1(x):\n",
+ " return 3*x**2-2*x-1\n",
+ "def f2(x):\n",
+ " return 6*x-2\n",
+ "x0=0.8 # initial value to finf double root\n",
+ "n=1 \n",
+ "print \"successive iterations \\t x0 \\t x1\\t x2\\n\"\n",
+ "while n==1:\n",
+ " x1=x0-(f(x0)/f1(x0));\n",
+ " x2=x0-(f1(x0)/f2(x0));\n",
+ " if abs(x1-x2)<0.000000001:\n",
+ " x0=(x1+x2)/2.0\n",
+ " break\n",
+ " else:\n",
+ " x0=(x1+x2)/2;\n",
+ " print \" %f\\t %f\\t %f\\n\" %(x0,x1,x2)\n",
+ "print \"\\n \\nthe double root is at: %f\" %(x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t x1\t x2\n",
+ "\n",
+ " 0.974370\t 0.905882\t 1.042857\n",
+ "\n",
+ " 0.993890\t 0.987269\t 1.000512\n",
+ "\n",
+ " 0.998489\t 0.996950\t 1.000028\n",
+ "\n",
+ " 0.999623\t 0.999245\t 1.000002\n",
+ "\n",
+ " 0.999906\t 0.999812\t 1.000000\n",
+ "\n",
+ " 0.999976\t 0.999953\t 1.000000\n",
+ "\n",
+ " 0.999994\t 0.999988\t 1.000000\n",
+ "\n",
+ " 0.999999\t 0.999997\t 1.000000\n",
+ "\n",
+ " 1.000000\t 0.999999\t 1.000000\n",
+ "\n",
+ " 1.000000\t 1.000000\t 1.000000\n",
+ "\n",
+ " 1.000000\t 1.000000\t 1.000000\n",
+ "\n",
+ " 1.000000\t 1.000000\t 1.000000\n",
+ "\n",
+ " 1.000000\t 1.000000\t 1.000000\n",
+ "\n",
+ "\n",
+ " \n",
+ "the double root is at: 1.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 57
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.21:pg-45"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ramanujan's method\n",
+ "#example 2.21\n",
+ "#page 45\n",
+ "def f(x):\n",
+ " return 1-(13.0/12.0)*x-(3.0/8.0)*x**2+(1.0/24.0)*x**3\n",
+ "a1=13.0/12.0\n",
+ "a2=-3.0/8.0\n",
+ "a3=1.0/24.0\n",
+ "b1=1\n",
+ "b2=a1\n",
+ "b3=a1*b2+a2*b1\n",
+ "b4=a1*b3+a2*b2+a3*b1\n",
+ "b5=a1*b4+a2*b3+a3*b2\n",
+ "b6=a1*b5+a2*b4+a3*b3\n",
+ "b7=a1*b6+a2*b5+a3*b4\n",
+ "b8=a1*b7+a2*b6+a3*b5\n",
+ "b9=a1*b8+a2*b7+a3*b6\n",
+ "print \"\\n\\n%f\" %(b1/b2)\n",
+ "print \"\\n%f\" %(b2/b3)\n",
+ "print \"\\n%f\" %(b3/b4)\n",
+ "print \"\\n%f\" %(b4/b5)\n",
+ "print \"\\n%f\" %(b5/b6)\n",
+ "print \"\\n%f\" %(b6/b7)\n",
+ "print \"\\n%f\" %(b7/b8)\n",
+ "print \"\\n%f\" %(b8/b9)\n",
+ "print \"\\n it appears as if the roots are converging at 2\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ "0.923077\n",
+ "\n",
+ "1.356522\n",
+ "\n",
+ "1.595376\n",
+ "\n",
+ "1.738402\n",
+ "\n",
+ "1.828184\n",
+ "\n",
+ "1.886130\n",
+ "\n",
+ "1.924153\n",
+ "\n",
+ "1.949345\n",
+ "\n",
+ " it appears as if the roots are converging at 2\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.22:pg-46"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ramanujan's method\n",
+ "#example 2.22\n",
+ "#page 46\n",
+ "def f(x):\n",
+ " return x+x**2+(x**3)/2.0+(x**4)/6.0+(x**5)/24.0\n",
+ "a1=1.0\n",
+ "a2=1.0\n",
+ "a3=1.0/2.0\n",
+ "a4=1.0/6.0\n",
+ "a5=1.0/24.0\n",
+ "b1=1\n",
+ "b2=a2\n",
+ "b3=a1*b2+a2*b1\n",
+ "b4=a1*b3+a2*b2+a3*b1\n",
+ "b5=a1*b4+a2*b3+a3*b2\n",
+ "b6=a1*b5+a2*b4+a3*b3\n",
+ "print \"\\n%f\" %(b1/b2)\n",
+ "print \"\\n%f\" %(b2/b3)\n",
+ "print \"\\n%f\" %(b3/b4)\n",
+ "print \"\\n%f\" %(b4/b5)\n",
+ "print \"\\n%f\" %(b5/b6)\n",
+ "print \"\\n it appears as if the roots are converging at around %f\" %(b5/b6)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "1.000000\n",
+ "\n",
+ "0.500000\n",
+ "\n",
+ "0.571429\n",
+ "\n",
+ "0.583333\n",
+ "\n",
+ "0.571429\n",
+ "\n",
+ " it appears as if the roots are converging at around 0.571429\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.23:pg-47"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ramanujan's method\n",
+ "#example 2.23\n",
+ "#page 47\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return 1-2*((3*x/2.0+(x**2)/4.0-(x**4)/48.0+(x**6)/1440.0)-(x**8)*2/80640.0)\n",
+ "a1=3/2\n",
+ "a2=1/4\n",
+ "a3=0\n",
+ "a4=1/48\n",
+ "a5=0\n",
+ "a6=1/1440\n",
+ "a7=0\n",
+ "a8=-1/80640\n",
+ "b1=1\n",
+ "b2=a1\n",
+ "b3=a1*b2+a2*b1\n",
+ "b4=a1*b3+a2*b2+a3*b1\n",
+ "b5=a1*b4+a2*b3+a3*b2\n",
+ "b6=a1*b5+a2*b4+a3*b3\n",
+ "b7=a1*b6+a2*b5+a3*b4\n",
+ "b8=a1*b7+a2*b6+a3*b5\n",
+ "b9=a1*b8+a2*b7+a3*b6\n",
+ "print \"\\n%f\" %(b1/b2)\n",
+ "print \"\\n%f\" %(b2/b3)\n",
+ "print \"\\n%f\" %(b3/b4)\n",
+ "print \"\\n%f\" %(b4/b5)\n",
+ "print \"\\n%f\" %(b5/b6)\n",
+ "print \"\\n%f\" %(b6/b7)\n",
+ "print \"\\n%f\" %(b7/b8)\n",
+ "print \"\\n it appears as if the roots are converging at around %f\" %(b7/b8)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "0.666667\n",
+ "\n",
+ "0.600000\n",
+ "\n",
+ "0.606061\n",
+ "\n",
+ "0.605505\n",
+ "\n",
+ "0.605556\n",
+ "\n",
+ "0.605551\n",
+ "\n",
+ "0.605551\n",
+ "\n",
+ " it appears as if the roots are converging at around 0.605551\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.24:pg-47"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ramanujan's method\n",
+ "#example 2.24\n",
+ "#page 47\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 1-(x-x**2.0/math.factorial(2.0)**2.0+x**3.0/math.factorial(3.0)**2.0-x**4.0/math.factorial(4.0)**2.0)\n",
+ "a1=1\n",
+ "a2=-1/math.factorial(2.0)**2.0\n",
+ "a3=1/math.factorial(3.0)**2.0\n",
+ "a4=-1/math.factorial(4.0)**2.0\n",
+ "a5=-1/math.factorial(5.0)**2.0\n",
+ "a6=1/math.factorial(6.0)**2.0\n",
+ "b1=1\n",
+ "b2=a1\n",
+ "b3=a1*b2+a2*b1\n",
+ "b4=a1*b3+a2*b2+a3*b1\n",
+ "b5=a1*b4+a2*b3+a3*b2\n",
+ "print \"\\n\\n%f\" %(b1/b2)\n",
+ "print \"\\n\\n%f\" %(b2/b3)\n",
+ "print \"\\n%f\" %(b3/b4)\n",
+ "print \"\\n%f\" %(b4/b5)\n",
+ "print \"\\n it appears as if the roots are converging at around %f\" %(b4/b5)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ "1.000000\n",
+ "\n",
+ "\n",
+ "1.333333\n",
+ "\n",
+ "1.421053\n",
+ "\n",
+ "1.433962\n",
+ "\n",
+ " it appears as if the roots are converging at around 1.433962\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.25:pg-49"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.25\n",
+ "#secant method\n",
+ "#page 49\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return x**3-2*x-5\n",
+ "x1=2\n",
+ "x2=3 # initial values\n",
+ "n=1\n",
+ "c=0\n",
+ "print \"successive iterations \\t x1 \\t x2 \\t x3 \\t f(x3)\\n\"\n",
+ "while n==1:\n",
+ " x3=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1)) \n",
+ " print \" \\t%f \\t%f \\t%f \\t%f\\n\" %(x1,x2,x3,f(x3))\n",
+ " if f(x3)*f(x1)>0:\n",
+ " x2=x3;\n",
+ " else:\n",
+ " x1=x3 \n",
+ " if abs(f(x3))<0.000001: \n",
+ " break\n",
+ " c=c+1\n",
+ "print \"the root of the equation after %i iteration is: %f\" %(c,x3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x1 \t x2 \t x3 \t f(x3)\n",
+ "\n",
+ " \t2.000000 \t3.000000 \t2.058824 \t-0.390800\n",
+ "\n",
+ " \t2.000000 \t2.058824 \t2.096559 \t0.022428\n",
+ "\n",
+ " \t2.096559 \t2.058824 \t2.094511 \t-0.000457\n",
+ "\n",
+ " \t2.094511 \t2.058824 \t2.094552 \t0.000009\n",
+ "\n",
+ " \t2.094552 \t2.058824 \t2.094551 \t-0.000000\n",
+ "\n",
+ "the root of the equation after 4 iteration is: 2.094551\n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.26:pg-50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.26\n",
+ "#secant method\n",
+ "#page 50\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return x*math.exp(x)-1\n",
+ "x1=0\n",
+ "x2=1 # initial values\n",
+ "n=1\n",
+ "c=0 \n",
+ "print \"successive iterations \\t x1 \\t x2 \\t x3 \\t f(x3)\\n\"\n",
+ "while n==1:\n",
+ " x3=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1)) \n",
+ " print \" \\t%f \\t%f \\t%f \\t%f\\n\" %(x1,x2,x3,f(x3))\n",
+ " if f(x3)*f(x1)>0:\n",
+ " x2=x3\n",
+ " else:\n",
+ " x1=x3 \n",
+ " if abs(f(x3))<0.0001:\n",
+ " break\n",
+ " c=c+1\n",
+ "print \"the root of the equation after %i iteration is: %0.4g\" %(c,x3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x1 \t x2 \t x3 \t f(x3)\n",
+ "\n",
+ " \t0.000000 \t1.000000 \t0.367879 \t-0.468536\n",
+ "\n",
+ " \t0.000000 \t0.367879 \t0.692201 \t0.383091\n",
+ "\n",
+ " \t0.692201 \t0.367879 \t0.546310 \t-0.056595\n",
+ "\n",
+ " \t0.546310 \t0.367879 \t0.570823 \t0.010200\n",
+ "\n",
+ " \t0.570823 \t0.367879 \t0.566500 \t-0.001778\n",
+ "\n",
+ " \t0.566500 \t0.367879 \t0.567256 \t0.000312\n",
+ "\n",
+ " \t0.567256 \t0.367879 \t0.567124 \t-0.000055\n",
+ "\n",
+ "the root of the equation after 6 iteration is: 0.5671\n"
+ ]
+ }
+ ],
+ "prompt_number": 31
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.27:pg-52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# example 2.27\n",
+ "#mulller's method\n",
+ "#page 52\n",
+ "from __future__ import division\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x**3-x-1\n",
+ "x0=0\n",
+ "x1=1\n",
+ "x2=2 # initial values\n",
+ "n=1\n",
+ "c=0\n",
+ "print \"successive iterations \\t x0 \\t x1 \\t x2 \\t f(x0)\\t f(x1)\\t f(x2)\\n\"\n",
+ "while n==1: \n",
+ " c=c+1\n",
+ " y0=f(x0)\n",
+ " y1=f(x1)\n",
+ " y2=f(x2)\n",
+ " h2=x2-x1\n",
+ " h1=x1-x0\n",
+ " d2=f(x2)-f(x1)\n",
+ " d1=f(x1)-f(x0)\n",
+ " print \" \\t%f\\t %f\\t %f\\t %f\\t %f\\t %f\\n\" %(x0,x1,x2,f(x0),f(x1),f(x2))\n",
+ " A=(d2/h2-d1/h1)/(h1+h2)\n",
+ " B=d2/h2+A*h2\n",
+ " S=math.sqrt(B**2-4*A*f(x2))\n",
+ " x3=x2-(2*f(x2))/(B+S)\n",
+ " E=abs((x3-x2)/x2)*100\n",
+ " if E<0.003:\n",
+ " break\n",
+ " else:\n",
+ " if c==1:\n",
+ " x2=x3\n",
+ " if c==2:\n",
+ " x1=x2\n",
+ " x2=x3\n",
+ " if c==3:\n",
+ " x0=x1\n",
+ " x1=x2\n",
+ " x2=x3\n",
+ " if c==3:\n",
+ " c=0\n",
+ "print \"the required root is : %0.4f\" %(x3)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t x1 \t x2 \t f(x0)\t f(x1)\t f(x2)\n",
+ "\n",
+ " \t0.000000\t 1.000000\t 2.000000\t -1.000000\t -1.000000\t 5.000000\n",
+ "\n",
+ " \t0.000000\t 1.000000\t 1.263763\t -1.000000\t -1.000000\t -0.245412\n",
+ "\n",
+ " \t0.000000\t 1.263763\t 1.331711\t -1.000000\t -0.245412\t 0.030015\n",
+ "\n",
+ " \t1.263763\t 1.331711\t 1.324583\t -0.245412\t 0.030015\t -0.000574\n",
+ "\n",
+ " \t1.263763\t 1.331711\t 1.324718\t -0.245412\t 0.030015\t -0.000000\n",
+ "\n",
+ "the required root is : 1.3247\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.28:pg-55"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#graeffe's method\n",
+ "#example 2.28\n",
+ "#page 55\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return x**3-6*(x**2)+11*x-6\n",
+ "#x=poly(0,'x')\n",
+ "#g=f(-x)\n",
+ "print \"the equation is:\\n\"\n",
+ "A=[1, 14, 49, 36] #coefficients of the above equation\n",
+ "print \"%0.4g\\n\" %(math.sqrt(A[3]/A[2]))\n",
+ "print \"%0.4g\\n\" %(math.sqrt(A[2]/A[1]))\n",
+ "print \"%0.4g\\n\" %(math.sqrt(A[1]/A[0]))\n",
+ "print \"the equation is:\\n\"\n",
+ "#disp(g*(-1*g));\n",
+ "B=[1, 98, 1393, 1296]\n",
+ "print \"%0.4g\\n\" %((B[3]/B[2])**(1/4))\n",
+ "print \"%0.4g\\n\" %((B[2]/B[1])**(1/4))\n",
+ "print \"%0.4g\\n\" %((B[1]/B[0])**(1/4))\n",
+ "print \"It is apparent from the outputs that the roots converge at 1 2 3\"\n",
+ "\n",
+ "\n",
+ "\n",
+ "#INCOMPLETE"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the equation is:\n",
+ "\n",
+ "0.8571\n",
+ "\n",
+ "1.871\n",
+ "\n",
+ "3.742\n",
+ "\n",
+ "the equation is:\n",
+ "\n",
+ "0.9821\n",
+ "\n",
+ "1.942\n",
+ "\n",
+ "3.146\n",
+ "\n",
+ "It is apparent from the outputs that the roots converge at 1 2 3\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.29:pg-57"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#quadratic factor by lin's--bairsttow method\n",
+ "#example 2.29\n",
+ "#page 57\n",
+ "from numpy import matrix\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return x**3-x-1\n",
+ "a=[-1, -1, 0, 1]\n",
+ "r1=1\n",
+ "s1=1\n",
+ "b4=a[3]\n",
+ "def f3(r):\n",
+ " return a[2]-r*a[3]\n",
+ "def f2(r,s):\n",
+ " return a[1]-r*a[2]+r**2*a[3]-s*a[3]\n",
+ "def f1(r,s):\n",
+ " return a[0]-s*a[2]+s*r*a[3]\n",
+ "A=matrix([[1,1],[2,-1]])\n",
+ "C=matrix([[0],[1]])\n",
+ "X=A.I*C\n",
+ "X1=[[ 0.33333333],[-0.33333333]]\n",
+ "dr=X1[0][0]\n",
+ "ds=X1[1][0]\n",
+ "r2=r1+dr\n",
+ "s2=s1+ds\n",
+ "#second pproximation\n",
+ "r1=r2\n",
+ "s1=s2\n",
+ "b11=f1(r2,s2)\n",
+ "b22=f2(r2,s2)\n",
+ "h=0.001\n",
+ "dr_b1=(f1(r1+h,s1)-f1(r1,s1))/h\n",
+ "ds_b1=(f1(r1,s1+h)-f1(r1,s1))/h\n",
+ "dr_b2=(f2(r1+h,s1)-f2(r1,s1))/h\n",
+ "ds_b2=(f2(r1,s1+h)-f2(r1,s1))/h\n",
+ "A=matrix([[dr_b1,ds_b1],[dr_b2,ds_b2]])\n",
+ "C=matrix([[-f1(r1,s1)],[-f2(r1,s2)]])\n",
+ "X=A.I*C\n",
+ "r2=r1+X[0][0]\n",
+ "s2=s1+X[1][0]\n",
+ "print \"roots correct to 3 decimal places are : %0.3f %0.3f\" %(r2,s2)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "roots correct to 3 decimal places are : 1.325 0.754\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.31:pg-62"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#method of iteration\n",
+ "#example 2.31\n",
+ "#page 62\n",
+ "from __future__ import division\n",
+ "def f(x,y):\n",
+ " return (3*y*x**2+7)/10\n",
+ "def g(x,y):\n",
+ " return (y**2+4)/5\n",
+ "h=0.0001\n",
+ "x0=0.5\n",
+ "y0=0.5\n",
+ "f1_dx=(f(x0+h,y0)-f(x0,y0))/h\n",
+ "f1_dy=(f(x0,y0+h)-f(x0,y0))/h\n",
+ "g1_dx=(g(x0+h,y0)-g(x0,y0))/h\n",
+ "g1_dy=(g(x0+h,y0)-g(x0,y0))/h\n",
+ "if (f1_dx+f1_dy<1) and (g1_dx+g1_dy<1): \n",
+ " print \"coditions for convergence is satisfied\\n\\n\"\n",
+ "print \"X \\t Y\\t\\n\\n\"\n",
+ "for i in range(0,10):\n",
+ " X=(3*y0*x0**2+7)/10\n",
+ " Y=(y0**2+4)/5\n",
+ " print \"%f\\t %f\\t\\n\" %(X,Y)\n",
+ " x0=X\n",
+ " y0=Y\n",
+ "print \"\\n\\n CONVERGENCE AT (1 1) IS OBVIOUS\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "coditions for convergence is satisfied\n",
+ "\n",
+ "\n",
+ "X \t Y\t\n",
+ "\n",
+ "\n",
+ "0.737500\t 0.850000\t\n",
+ "\n",
+ "0.838696\t 0.944500\t\n",
+ "\n",
+ "0.899312\t 0.978416\t\n",
+ "\n",
+ "0.937391\t 0.991460\t\n",
+ "\n",
+ "0.961360\t 0.996598\t\n",
+ "\n",
+ "0.976320\t 0.998642\t\n",
+ "\n",
+ "0.985572\t 0.999457\t\n",
+ "\n",
+ "0.991247\t 0.999783\t\n",
+ "\n",
+ "0.994707\t 0.999913\t\n",
+ "\n",
+ "0.996807\t 0.999965\t\n",
+ "\n",
+ "\n",
+ "\n",
+ " CONVERGENCE AT (1 1) IS OBVIOUS\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.32:pg-65"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#newton raphson method\n",
+ "#example 2.32\n",
+ "#page 65\n",
+ "def f(x,y):\n",
+ " return 3*y*x**2-10*x+7\n",
+ "def g(y):\n",
+ " return y**2-5*y+4\n",
+ "hh=0.0001\n",
+ "x0=0.5\n",
+ "y0=0.5 #initial values\n",
+ "f0=f(x0,y0)\n",
+ "g0=g(y0)\n",
+ "df_dx=(f(x0+hh,y0)-f(x0,y0))/hh\n",
+ "df_dy=(f(x0,y0+hh)-f(x0,y0))/hh\n",
+ "dg_dx=(g(y0)-g(y0))/hh\n",
+ "dg_dy=(g(y0+hh)-g(y0))/hh\n",
+ "d=[[df_dx,df_dy],[dg_dx,dg_dy]]\n",
+ "D1=det(d)\n",
+ "dd=[[-f0,df_dy],[-g0,dg_dy]]\n",
+ "h=det(dd)/D1\n",
+ "ddd=[[df_dx,-f0],[dg_dx,-g0]]\n",
+ "k=det(ddd)/D1;\n",
+ "x1=x0+h\n",
+ "y1=y0+k\n",
+ "f0=f(x1,y1)\n",
+ "g0=g(y1)\n",
+ "df_dx=(f(x1+hh,y1)-f(x1,y1))/hh\n",
+ "df_dy=(f(x1,y1+hh)-f(x1,y1))/hh\n",
+ "dg_dx=(g(y1)-g(y1))/hh\n",
+ "dg_dy=(g(y1+hh)-g(y1))/hh\n",
+ "dddd=[[df_dx,df_dy],[dg_dx,dg_dy]]\n",
+ "D2=det(dddd)\n",
+ "ddddd=[[-f0,df_dy],[-g0,dg_dy]]\n",
+ "h=det(ddddd)/D2\n",
+ "d6=[[df_dx,-f0],[dg_dx,-g0]]\n",
+ "k=det(d6)/D2\n",
+ "x2=x1+h\n",
+ "y2=y1+k\n",
+ "print \" the roots of the equation are x2=%f and y2=%f\" %(x2,y2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " the roots of the equation are x2=0.970803 and y2=0.998752\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.33:pg-66"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#newton raphson method\n",
+ "#example 2.33\n",
+ "#page 66\n",
+ "import math\n",
+ "def f(x,y):\n",
+ " return x**2+y**2-1\n",
+ "def g(x,y):\n",
+ " return y-x**2\n",
+ "hh=0.0001\n",
+ "x0=0.7071\n",
+ "y0=0.7071 #initial values\n",
+ "f0=f(x0,y0)\n",
+ "g0=g(x0,y0)\n",
+ "df_dx=(f(x0+hh,y0)-f(x0,y0))/hh\n",
+ "df_dy=(f(x0,y0+hh)-f(x0,y0))/hh\n",
+ "dg_dx=(g(x0+hh,y0)-g(x0,y0))/hh\n",
+ "dg_dy=(g(x0,y0+hh)-g(x0,y0))/hh\n",
+ "D1=det([[df_dx,df_dy],[dg_dx,dg_dy]])\n",
+ "h=det([[-f0,df_dy],[-g0,dg_dy]])/D1\n",
+ "k=det([[df_dx,-f0],[dg_dx,-g0]])/D1\n",
+ "x1=x0+h\n",
+ "y1=y0+k\n",
+ "f0=f(x1,y1)\n",
+ "g0=g(x1,y1)\n",
+ "df_dx=(f(x1+hh,y1)-f(x1,y1))/hh\n",
+ "df_dy=(f(x1,y1+hh)-f(x1,y1))/hh\n",
+ "dg_dx=(g(x1+hh,y1)-g(x1,y1))/hh\n",
+ "dg_dy=(g(x1,y1+hh)-g(x1,y1))/hh\n",
+ "D2=det([[df_dx,df_dy],[dg_dx,dg_dy]])\n",
+ "h=det([[-f0,df_dy],[-g0,dg_dy]])/D2\n",
+ "k=det([[df_dx,-f0],[dg_dx,-g0]])/D2\n",
+ "x2=x1+h\n",
+ "y2=y1+k\n",
+ "print \"the roots of the equation are x2=%f and y2=%f \" %(x2,y2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the roots of the equation are x2=0.786184 and y2=0.618039 \n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.34:pg-67"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#newton raphson method\n",
+ "#example 2.34\n",
+ "#page 67\n",
+ "import math\n",
+ "def f(x,y):\n",
+ " return math.sin(x)-y+0.9793\n",
+ "def g(x,y):\n",
+ " return math.cos(y)-x+0.6703\n",
+ "hh=0.0001\n",
+ "x0=0.5\n",
+ "y0=1.5 #initial values\n",
+ "f0=f(x0,y0)\n",
+ "g0=g(x0,y0)\n",
+ "df_dx=(f(x0+hh,y0)-f(x0,y0))/hh\n",
+ "df_dy=(f(x0,y0+hh)-f(x0,y0))/hh\n",
+ "dg_dx=(g(x0+hh,y0)-g(x0,y0))/hh\n",
+ "dg_dy=(g(x0,y0+hh)-g(x0,y0))/hh\n",
+ "d1=[[df_dx,df_dy],[dg_dx,dg_dy]]\n",
+ "D1=det(d1)\n",
+ "d2=[[-f0,df_dy],[-g0,dg_dy]]\n",
+ "h=det(d2)/D1\n",
+ "d3=[[df_dx,-f0],[dg_dx,-g0]]\n",
+ "k=det(d3)/D1\n",
+ "x1=x0+h\n",
+ "y1=y0+k\n",
+ "f0=f(x1,y1)\n",
+ "g0=g(x1,y1)\n",
+ "df_dx=(f(x1+hh,y1)-f(x1,y1))/hh\n",
+ "df_dy=(f(x1,y1+hh)-f(x1,y1))/hh\n",
+ "dg_dx=(g(x1+hh,y1)-g(x1,y1))/hh\n",
+ "dg_dy=(g(x1,y1+hh)-g(x1,y1))/hh\n",
+ "d4=[[df_dx,df_dy],[dg_dx,dg_dy]]\n",
+ "D2=det(d4)\n",
+ "h=det([[-f0,df_dy],[-g0,dg_dy]])/D2\n",
+ "k=det([[df_dx,-f0],[dg_dx,-g0]])/D2\n",
+ "x2=x1+h\n",
+ "y2=y1+k\n",
+ "print \"the roots of the equation are x2=%0.4f and y2=%0.4f\" %(x2,y2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the roots of the equation are x2=0.6537 and y2=1.5874\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter3_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter3_6.ipynb new file mode 100644 index 00000000..fbba6967 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter3_6.ipynb @@ -0,0 +1,1126 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:0755817d9df79392f0a505cb49e15463e2d17b0d0bd1a381990227b29ae2b639"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter03:Interpolation"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.4:pg-86"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.4\n",
+ "#interpolation\n",
+ "#page 86\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "x=[1, 3, 5, 7]\n",
+ "y=[24, 120, 336, 720]\n",
+ "d1=[0,0,0]\n",
+ "d2=[0,0,0]\n",
+ "d3=[0,0,0]\n",
+ "h=2 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "d=[0,d1[0],d2[0],d3[0]]\n",
+ "x0=8 #value at 8\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-1)/2\n",
+ "for i in range(1,4):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%f\" %(x0,y_x)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of function at 8.000000 is :990.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.6:pg-87"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.6\n",
+ "#interpolation\n",
+ "#page 87\n",
+ "x=[15, 20, 25, 30, 35, 40]\n",
+ "y=[0.2588190, 0.3420201, 0.4226183, 0.5, 0.5735764, 0.6427876]\n",
+ "d1=[0,0,0,0,0]\n",
+ "d2=[0,0,0,0]\n",
+ "d3=[0,0,0]\n",
+ "d4=[0,0]\n",
+ "d5=[0]\n",
+ "h=5 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d5[c]=d4[i+1]-d4[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "d=[0,d1[0], d2[0], d3[0], d4[0], d5[0]]\n",
+ "x0=38 #value at 38 degree\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,6):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+((pp*d[i])/math.factorial(i));\n",
+ "print \"value of function at %i is :%f\" %(x0,y_x)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of function at 38 is :0.615661\n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.7:pg-89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.7\n",
+ "#interpolation\n",
+ "#page 89\n",
+ "x=[0, 1, 2, 4]\n",
+ "y=[1, 3, 9, 81]\n",
+ "#equation is y(5)-4*y(4)+6*y(2)-4*y(2)+y(1)\n",
+ "y3=(y[3]+6*y[2]-4*y[1]+y[0])/4\n",
+ "print \"the value of missing term of table is :%d\" %(y3)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of missing term of table is :31\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.8:pg-89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.8\n",
+ "#interpolation\n",
+ "#page 89\n",
+ "import math\n",
+ "x=[0.10, 0.15, 0.20, 0.25, 0.30]\n",
+ "y=[0.1003, 0.1511, 0.2027, 0.2553, 0.3093]\n",
+ "d1=[0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0,0]\n",
+ "d4=[0,0,0,0,0]\n",
+ "h=0.05 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "d=[0,d1[0], d2[0], d3[0], d4[0]]\n",
+ "x0=0.12 #value at 0.12;\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,5):\n",
+ " pp=1;\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%0.4g\\n \\n\" %(x0,y_x)\n",
+ "x0=0.26 #value at 0.26;\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,5):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i);\n",
+ "print \"value of function at %f is :%0.4g\\n \\n\" %(x0,y_x)\n",
+ "x0=0.40 #value at 0.40;\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,5):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%0.4g\\n \\n\" %(x0,y_x)\n",
+ "x0=0.50 #value at 0.50;\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,5):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%0.5g\\n \\n\" %(x0,y_x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of function at 0.120000 is :0.1205\n",
+ " \n",
+ "\n",
+ "value of function at 0.260000 is :0.266\n",
+ " \n",
+ "\n",
+ "value of function at 0.400000 is :0.4241\n",
+ " \n",
+ "\n",
+ "value of function at 0.500000 is :0.5543\n",
+ " \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 33
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.9:pg-93"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.9\n",
+ "#Gauss' forward formula\n",
+ "#page 93\n",
+ "x=[1.0, 1.05, 1.10, 1.15, 1.20, 1.25, 1.30];\n",
+ "y=[2.7183, 2.8577, 3.0042, 3.1582, 3.3201, 3.4903, 3.66693]\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "d5=[0,0]\n",
+ "d6=[0]\n",
+ "h=0.05 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d5[c]=d4[i+1]-d4[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d6[c]=d5[i+1]-d5[i]\n",
+ " c=c+1\n",
+ "d=[0,d1[3], d2[2], d3[2], d4[1], d5[0], d6[0]]\n",
+ "x0=1.17 #value at 1.17;\n",
+ "pp=1\n",
+ "y_x=y[3]\n",
+ "p=(x0-x[3])/h\n",
+ "for i in range(1,6):\n",
+ " pp=1;\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%0.4g\\n \\n\" %(x0,y_x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of function at 1.170000 is :3.222\n",
+ " \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.10:pg-97"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#practical interpolation\n",
+ "#example 3.10\n",
+ "#page 97\n",
+ "import math\n",
+ "x=[0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67]\n",
+ "y=[1.840431, 1.858928,1.877610, 1.896481, 1.915541, 1.934792, 1.954237]\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "h=0.01 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i];\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i];\n",
+ " c=c+1\n",
+ "d=[d1[0], d2[0], d3[0], d4[0]]\n",
+ "x0=0.644\n",
+ "p=(x0-x[3])/h;\n",
+ "y_x=y[3]\n",
+ "y_x=y_x+p*(d1[2]+d1[3])/2+p**2*(d2[1])/2 #stirling formula\n",
+ "print \"the value at %f by stirling formula is : %f\\n\\n\" %(x0,y_x)\n",
+ "y_x=y[3]\n",
+ "y_x=y_x+p*d1[3]+p*(p-1)*(d2[2]+d2[3])/2\n",
+ "print \" the value at %f by bessels formula is : %f\\n\\n\" %(x0,y_x)\n",
+ "y_x=y[3]\n",
+ "q=1-p\n",
+ "y_x=q*y[3]+q*(q**2-1)*d2[2]/2+p*y[4]+p*(q**2-1)*d2[4]/2\n",
+ "print \"the value at %f by everrets formula is : %f\\n\\n\" %(x0,y_x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value at 0.644000 by stirling formula is : 1.904082\n",
+ "\n",
+ "\n",
+ " the value at 0.644000 by bessels formula is : 1.904059\n",
+ "\n",
+ "\n",
+ "the value at 0.644000 by everrets formula is : 1.904044\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.11:pg-99"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#practical interpolation\n",
+ "#example 3.11\n",
+ "#page 99\n",
+ "x=[0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67]\n",
+ "y=[1.840431, 1.858928, 1.877610, 1.896481, 1.915541, 1.934792, 1.954237]\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "h=0.01 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "d=[d1[0], d2[0], d3[0], d4[0]]\n",
+ "x0=0.638\n",
+ "p=(x0-x[3])/h\n",
+ "y_x=y[3]\n",
+ "y_x=y_x+p*(d1[2]+d1[3])/2+p**2*(d2[1])/2 #stirling formula\n",
+ "print \"value at %f by stirling formula is : %f\\n\\n\" %(x0,y_x)\n",
+ "y_x=y[2]\n",
+ "p=(x0-x[2])/h\n",
+ "y_x=y_x+p*d1[2]+p*(p-1)*(d2[1])/2\n",
+ "print \"the value at %f by bessels formula is : %f\\n\\n\" %(x0,y_x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value at 0.638000 by stirling formula is : 1.892692\n",
+ "\n",
+ "\n",
+ "the value at 0.638000 by bessels formula is : 1.892692\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 39
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.12:pg-99"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#practical interpolation\n",
+ "#example 3.12\n",
+ "#page 99\n",
+ "x=[1.72, 1.73, 1.74, 1.75, 1.76, 1.77, 1.78]\n",
+ "y=[0.1790661479, 0.1772844100, 0.1755204006, 0.1737739435, 0.1720448638, 0.1703329888, 0.1686381473]\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "h=0.01 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "x0=1.7475\n",
+ "y_x=y[2]\n",
+ "p=(x0-x[2])/h\n",
+ "y_x=y_x+p*d1[2]+p*(p-1)*((d2[1]+d2[2])/2)/2\n",
+ "print \"the value at %f by bessels formula is : %0.10f\\n\\n\" %(x0,y_x)\n",
+ "y_x=y[3]\n",
+ "q=1-p\n",
+ "y_x=q*y[2]+q*(q**2-1)*d2[1]/6+p*y[3]+p*(p**2-1)*d2[1]/6\n",
+ "print \"the value at %f by everrets formula is : %0.10f\\n\\n\" %(x0,y_x)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value at 1.747500 by bessels formula is : 0.1742089204\n",
+ "\n",
+ "\n",
+ "the value at 1.747500 by everrets formula is : 0.1742089122\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 41
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.13:pg-104"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.13\n",
+ "#lagrange's interpolation formula\n",
+ "#page 104\n",
+ "x=[300, 304, 305, 307]\n",
+ "y=[2.4771, 2.4829, 2.4843, 2.4871]\n",
+ "x0=301\n",
+ "log_301=(-3*-4*-6*2.4771)/(-4*-5*-7)+(-4*-6*2.4829)/(4*-1*-3)+(-3*-6*2.4843)/(5*-2)+(-3*-4*2.4871)/(7*3*2)\n",
+ "print \"valie of log x at 301 is =%f\" %(log_301)\n",
+ "\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "valie of log x at 301 is =2.478597\n"
+ ]
+ }
+ ],
+ "prompt_number": 43
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.14:pg-105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.14\n",
+ "#lagrange's interpolation formula\n",
+ "#page 105\n",
+ "y=[4, 12, 19]\n",
+ "x=[1, 3, 4];\n",
+ "y_x=7\n",
+ "Y_X=(-5*-12)/(-8*-15)+(3*3*-12)/(8*-7)+(3*-5*4)/(15*7)\n",
+ "print \"values is %f\" %(Y_X)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "values is 1.857143\n"
+ ]
+ }
+ ],
+ "prompt_number": 44
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.15:pg-105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.15\n",
+ "#lagrange's interpolation formula\n",
+ "#page 105\n",
+ "x=[2, 2.5, 3.0]\n",
+ "y=[0.69315, 0.91629, 1.09861]\n",
+ "def l0(x):\n",
+ " return (x-2.5)*(x-3.0)/(-0.5)*(-1.0)\n",
+ "def l1(x):\n",
+ " return ((x-2.0)*(x-3.0))/((0.5)*(-0.5))\n",
+ "def l2(x):\n",
+ " return ((x-2.0)*(x-2.5))/((1.0)*(0.5))\n",
+ "f_x=l0(2.7)*y[0]+l1(2.7)*y[1]+l2(2.7)*y[2];\n",
+ "print \"the calculated value is %f:\" %(f_x)\n",
+ "print \"\\n\\n the error occured in the value is %0.9f\" %(abs(f_x-log(2.7)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the calculated value is 0.994116:\n",
+ "\n",
+ "\n",
+ " the error occured in the value is 0.000864627\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.16:pg-106"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.16\n",
+ "#lagrange's interpolation formula\n",
+ "#page 106\n",
+ "import math\n",
+ "x=[0, math.pi/4,math.pi/2]\n",
+ "y=[0, 0.70711, 1.0];\n",
+ "x0=math.pi/6\n",
+ "sin_x0=0\n",
+ "for i in range(0,3):\n",
+ " p=y[i]\n",
+ " for j in range(0,3):\n",
+ " if j!=i:\n",
+ " p=p*((x0-x[j])/( x[i]-x[j]))\n",
+ " sin_x0=sin_x0+p\n",
+ "print \"sin_x0=%f\" %(sin_x0)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "sin_x0=0.517431\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.18:pg-107"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#error in lagrange's interpolation formula\n",
+ "#example 3.18\n",
+ "#page 107\n",
+ "import math\n",
+ "x=[2, 2.5, 3.0]\n",
+ "y=[0.69315, 0.91629, 1.09861]\n",
+ "def l0(x):\n",
+ " return (x-2.5)*(x-3.0)/(-0.5)*(-1.0)\n",
+ "def l1(x):\n",
+ " return ((x-2.0)*(x-3.0))/((0.5)*(-0.5))\n",
+ "def l2(x):\n",
+ " return ((x-2.0)*(x-2.5))/((1.0)*(0.5))\n",
+ "f_x=l0(2.7)*y[0]+l1(2.7)*y[1]+l2(2.7)*y[2]\n",
+ "print \"the calculated value is %f:\" %(f_x)\n",
+ "err=math.fabs(f_x-math.log10(2.7))\n",
+ "def R_n(x):\n",
+ " return (((x-2)*(x-2.5)*(x-3))/6)\n",
+ "est_err=abs(R_n(2.7)*(2/8))\n",
+ "if est_err<err:\n",
+ " print \"\\n\\n the error agrees with the actual error\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the calculated value is 0.994116:\n",
+ "\n",
+ "\n",
+ " the error agrees with the actual error\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.19:pg-107"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#error in lagrenge's interpolation\n",
+ "#example 3.19\n",
+ "#page 107\n",
+ "import math\n",
+ "x=[0, math.pi/4 ,math.pi/2]\n",
+ "y=[0, 0.70711, 1.0]\n",
+ "def l0(x):\n",
+ " return ((x-0)*(x-math.pi/2))/((math.pi/4)*(-1*math.pi/4))\n",
+ "def l1(x):\n",
+ " return ((x-0)*(x-math.pi/4))/((math.pi/2)*(math.pi/4))\n",
+ "f_x=l0(math.pi/6)*y[1]+l1(math.pi/6)*y[2]\n",
+ "err=abs(f_x-math.sin(math.pi/6))\n",
+ "def f(x):\n",
+ " return ((x-0)*(x-math.pi/4)*(x-math.pi/2))/6\n",
+ "if abs(f(math.pi/6))>err:\n",
+ " print \"\\n\\n the error agrees with the actual error\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ " the error agrees with the actual error\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.21:pg-110"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#hermite's interpolation formula\n",
+ "#exammple 3.21\n",
+ "#page 110\n",
+ "from __future__ import division\n",
+ "import math\n",
+ "x=[2.0, 2.5, 3.0]\n",
+ "y=[0.69315, 0.91629, 1.09861]\n",
+ "y1=[0,0,0]\n",
+ "def f(x):\n",
+ " return math.log(x)\n",
+ "h=0.0001\n",
+ "for i in range(0,3):\n",
+ " y1[i]=(f(x[i]+h)-f(x[i]))/h\n",
+ "def l0(x):\n",
+ " return (x-2.5)*(x-3.0)/(-0.5)*(-1.0)\n",
+ "def l1(x):\n",
+ " return ((x-2.0)*(x-3.0))/((0.5)*(-0.5))\n",
+ "def l2(x):\n",
+ " return ((x-2.0)*(x-2.5))/((1.0)*(0.5))\n",
+ "dl0=(l0(x[0]+h)-l0(x[0]))/h\n",
+ "dl1=(l1(x[1]+h)-l1(x[1]))/h\n",
+ "dl2=(l2(x[2]+h)-l2(x[2]))/h\n",
+ "x0=2.7\n",
+ "u0=(1-2*(x0-x[0])*dl0)*(l0(x0))**2\n",
+ "u1=(1-2*(x0-x[1])*dl1)*(l1(x0))**2\n",
+ "u2=(1-2*(x0-x[2])*dl2)*(l2(x0))**2\n",
+ "v0=(x0-x[0])*l0(x0)**2\n",
+ "v1=(x0-x[1])*l1(x0)**2\n",
+ "v2=(x0-x[2])*l2(x0)**2\n",
+ "H=u0*y[0]+u1*y[1]+u2*y[2]+v0*y1[0]+v1*y1[1]+v2*y1[2]\n",
+ "print \"the approximate value of ln(%0.2f) is %f:\" %(x0,H)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the approximate value of ln(2.70) is 0.993362:\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.22:pg-114"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#newton's general interpolation formula\n",
+ "#example 3.22\n",
+ "#page 114\n",
+ "x=[300, 304, 305, 307]\n",
+ "y=[2.4771, 2.4829, 2.4843, 2.4871]\n",
+ "d1=[0,0,0]\n",
+ "d2=[0,0]\n",
+ "for i in range(0,3):\n",
+ " d1[i]=(y[i+1]-y[i])/(x[i+1]-x[i])\n",
+ "for i in range(0,2):\n",
+ " d2[i]=(d1[i+1]-d1[i])/(x[i+2]-x[i])\n",
+ "x0=301\n",
+ "log301=y[0]+(x0-x[0])*d1[0]+(x0-x[1])*d2[0]\n",
+ "print \"valure of log(%d) is :%0.4f\" %(x0,log301)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "valure of log(301) is :2.4786\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.23:pg-114"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.23\n",
+ "#newton's divided formula\n",
+ "#page 114\n",
+ "x=[-1, 0, 3, 6, 7]\n",
+ "y=[3, -6, 39, 822, 1611]\n",
+ "d1=[0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0,0]\n",
+ "d4=[0,0,0,0,0]\n",
+ "X=0\n",
+ "for i in range(0,3):\n",
+ " d1[i]=(y[i+1]-y[i])/(x[i+1]-x[i])\n",
+ "for i in range(0,3):\n",
+ " d2[i]=(d1[i+1]-d1[i])/(x[i+2]-x[i])\n",
+ "for i in range(0,2):\n",
+ " d3[i]=(d2[i+1]-d2[i])/(x[i+3]-x[i])\n",
+ "for i in range(0,1):\n",
+ " d4[i]=(d3[i+1]-d3[i])/(x[i+4]-x[i])\n",
+ "f_x=y[0]+(X-x[0])*d1[0]+(X-x[1])*(X-x[0])*d2[0]+(X-x[0])*(X-x[1])*(X-x[2])*d3[0]+(X-x[0])*(X-x[1])*(X-x[2])*(X-x[3])*d4[0]\n",
+ "print \"the polynomial equation is = -6 + 5X^2 -3X^3 +X^4\" "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the polynomial equation is = -6 + 5X^2 -3X^3 +X^4\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.24:pg-116"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#interpolation by iteration\n",
+ "#example 3.24\n",
+ "#page 116\n",
+ "x=[300, 304, 305, 307]\n",
+ "y=[2.4771, 2.4829, 2.4843, 2.4871]\n",
+ "x0=301\n",
+ "d1=[0,0,0]\n",
+ "d2=[0,0]\n",
+ "d3=[0]\n",
+ "for i in range(0,3):\n",
+ " a=y[i]\n",
+ " b=x[i]-x0\n",
+ " c=y[i+1]\n",
+ " e=x[i+1]-x0\n",
+ " d=matrix([[a,b],[c,e]])\n",
+ " d11=det(d)\n",
+ " d1[i]=d11/(x[i+1]-x[i])\n",
+ "for i in range(0,2):\n",
+ " a=d1[i]\n",
+ " b=x[i+1]-x0\n",
+ " c=d1[i+1]\n",
+ " e=x[i+2]-x0\n",
+ " d=matrix([[a,b],[c,e]])\n",
+ " d22=det(d)\n",
+ " f=(x[i+2]-x[i+1])\n",
+ " d2[i]=d22/f\n",
+ "for i in range(0,1):\n",
+ " a=d2[i]\n",
+ " b=x[i+2]-x0\n",
+ " c=d2[i+1]\n",
+ " e=x[i+3]-x0\n",
+ " d=matrix([[a,b],[c,e]])\n",
+ " d33=det(d)\n",
+ " d3[i]=d33/(x[i+3]-x[i+2])\n",
+ "print \"the value of log(%d) is : %f\" %(x0,d3[0])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of log(301) is : 2.476900\n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.25:pg-118"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#inverse intrpolation\n",
+ "#example 3.25\n",
+ "#page 118\n",
+ "from __future__ import division\n",
+ "x=[2, 3, 4, 5]\n",
+ "y=[8, 27, 64, 125]\n",
+ "d1=[0,0,0]\n",
+ "d2=[0,0]\n",
+ "d3=[0]\n",
+ "for i in range(0,3):\n",
+ " d1[i]=y[i+1]-y[i]\n",
+ "for i in range(0,2):\n",
+ " d2[i]=d1[i+1]-d1[i]\n",
+ "for i in range(0,1):\n",
+ " d3[i]=d2[i+1]-d2[i]\n",
+ "yu=10 #square rooot of 10\n",
+ "y0=y[0]\n",
+ "d=[d1[0], d2[0] ,d3[0]]\n",
+ "u1=(yu-y0)/d1[0]\n",
+ "u2=((yu-y0-u1*(u1-1)*d2[0]/2)/d1[0])\n",
+ "u3=(yu-y0-u2*(u2-1)*d2[0]/2-u2*(u2-1)*(u2-2)*d3[0]/6)/d1[0]\n",
+ "u4=(yu-y0-u3*(u3-1)*d2[0]/2-u3*(u3-1)*(u3-2)*d3[0]/6)/d1[0]\n",
+ "u5=(yu-y0-u4*(u4-1)*d2[0]/2-u4*(u4-1)*(u4-2)*d3[0]/6)/d1[0]\n",
+ "print \"%f \\n %f \\n %f \\n %f \\n %f \\n \" %(u1,u2,u3,u4,u5)\n",
+ "print \"the approximate square root of %d is: %0.3f\" %(yu,x[0]+u5)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "0.105263 \n",
+ " 0.149876 \n",
+ " 0.153210 \n",
+ " 0.154107 \n",
+ " 0.154347 \n",
+ " \n",
+ "the approximate square root of 10 is: 2.154\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.26:pg-119"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#double interpolation \n",
+ "#example 3.26\n",
+ "#page 119\n",
+ "y=[0, 1, 2, 3, 4]\n",
+ "z=[0,0,0,0,0]\n",
+ "x=[[0, 1, 4, 9, 16],[2, 3, 6, 11, 18],[6, 7, 10, 15, 22],[12, 13, 16, 21, 28],[18, 19, 22, 27, 34]]\n",
+ "print \"X=\"\n",
+ "print x\n",
+ "#for x=2.5\n",
+ "for i in range(0,5):\n",
+ " z[i]=(x[i][2]+x[i][3])/2\n",
+ "#y=1.5\n",
+ "Z=(z[1]+z[2])/2\n",
+ "print \"the interpolated value when x=2.5 and y=1.5 is : %f\" %(Z)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "X=\n",
+ "[[0, 1, 4, 9, 16], [2, 3, 6, 11, 18], [6, 7, 10, 15, 22], [12, 13, 16, 21, 28], [18, 19, 22, 27, 34]]\n",
+ "the interpolated value when x=2.5 and y=1.5 is : 10.500000\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter4_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter4_6.ipynb new file mode 100644 index 00000000..3cc767e6 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter4_6.ipynb @@ -0,0 +1,880 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:4bd129a1095a40e7b77ec9dd303e159b079be83a90556977b8afeff8b76637f9"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter04:Least Squares and Fourier Transforms"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.1:pg-128"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 4.1\n",
+ "#least square curve fitting procedure\n",
+ "#page 128\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "x=[0,1, 2, 3, 4, 5]\n",
+ "x_2=[0,0,0,0,0,0]\n",
+ "x_y=[0,0,0,0,0,0]\n",
+ "y=[0,0.6, 2.4, 3.5, 4.8, 5.7]\n",
+ "for i in range(1,5):\n",
+ " x_2[i]=x[i]**2\n",
+ " x_y[i]=x[i]*y[i]\n",
+ "S_x=0\n",
+ "S_y=0\n",
+ "S_x2=0 \n",
+ "S_xy=0\n",
+ "S1=0\n",
+ "S2=0\n",
+ "for i in range(1,5):\n",
+ " S_x=S_x+x[i]\n",
+ " S_y=S_y+y[i]\n",
+ " S_x2=S_x2+x_2[i]\n",
+ " S_xy=S_xy+x_y[i]\n",
+ "a1=(5*S_xy-S_x*S_y)/(5*S_x2-S_x**2)\n",
+ "a0=S_y/5-a1*S_x/5\n",
+ "print \"x\\t y\\t x^2\\t x*y\\t (y-avg(S_y)) \\t (y-a0-a1x)^2\\n\\n\"\n",
+ "for i in range (1,6):\n",
+ " print \"%d\\t %0.2f\\t %d\\t %0.2f\\t %0.2f\\t %.4f\\t\\n\" %(x[i],y[i],x_2[i],x_y[i],(y[i]-S_y/5)**2,(y[i]-a0-a1*x[i])**2)\n",
+ " S1=S1+(y[i]-S_y/5)**2 \n",
+ " S2=S2+(y[i]-a0-a1*x[i])**2\n",
+ "print \"---------------------------------------------------------------------------------------------------------------------------------------------\\n\\n\"\n",
+ "print \"%d\\t %0.2f\\t %d\\t %0.2f\\t %0.2f\\t %0.4f\\t\\n\\n\" %(S_x,S_y,S_x2,S_xy,S1,S2)\n",
+ "cc=math.sqrt((S1-S2)/S1) #correlation coefficient\n",
+ "print \"the correlation coefficient is:%0.4f\" %(cc)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x\t y\t x^2\t x*y\t (y-avg(S_y)) \t (y-a0-a1x)^2\n",
+ "\n",
+ "\n",
+ "1\t 0.60\t 1\t 0.60\t 2.76\t 0.1681\t\n",
+ "\n",
+ "2\t 2.40\t 4\t 4.80\t 0.02\t 0.0196\t\n",
+ "\n",
+ "3\t 3.50\t 9\t 10.50\t 1.54\t 0.0001\t\n",
+ "\n",
+ "4\t 4.80\t 16\t 19.20\t 6.45\t 0.0016\t\n",
+ "\n",
+ "5\t 5.70\t 0\t 0.00\t 11.83\t 0.0961\t\n",
+ "\n",
+ "---------------------------------------------------------------------------------------------------------------------------------------------\n",
+ "\n",
+ "\n",
+ "10\t 11.30\t 30\t 35.10\t 22.60\t 0.2855\t\n",
+ "\n",
+ "\n",
+ "the correlation coefficient is:0.9937\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.2:pg-129"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 4.2\n",
+ "#least square curve fitting procedure\n",
+ "#page 129\n",
+ "from numpy import matrix\n",
+ "x=[0, 2, 5, 7]\n",
+ "y=[-1, 5, 12, 20]\n",
+ "x_2=[0,0,0,0]\n",
+ "xy=[0,0,0,0,]\n",
+ "for i in range (0,4):\n",
+ " x_2[i]=x[i]**2\n",
+ " xy[i]=x[i]*y[i]\n",
+ "print \"x\\t y\\t x^2\\t xy\\t \\n\\n\"\n",
+ "S_x=0 \n",
+ "S_y=0\n",
+ "S_x2=0\n",
+ "S_xy=0\n",
+ "for i in range(0,4):\n",
+ " print \"%d\\t %d\\t %d\\t %d\\t\\n\" %(x[i],y[i],x_2[i],xy[i])\n",
+ " S_x=S_x+x[i]\n",
+ " S_y=S_y+y[i]\n",
+ " S_x2=S_x2+x_2[i]\n",
+ " S_xy=S_xy+xy[i]\n",
+ "print \"%d\\t %d\\t %d\\t %d\\t\\n\" %(S_x,S_y,S_x2,S_xy)\n",
+ "A=matrix([[4,S_x],[S_x,S_x2]])\n",
+ "B=matrix([[S_y],[S_xy]])\n",
+ "C=A.I*B\n",
+ "print \"Best straight line fit Y=%.4f+x(%.4f)\" %(C[0][0],C[1][0])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x\t y\t x^2\t xy\t \n",
+ "\n",
+ "\n",
+ "0\t -1\t 0\t 0\t\n",
+ "\n",
+ "2\t 5\t 4\t 10\t\n",
+ "\n",
+ "5\t 12\t 25\t 60\t\n",
+ "\n",
+ "7\t 20\t 49\t 140\t\n",
+ "\n",
+ "14\t 36\t 78\t 210\t\n",
+ "\n",
+ "Best straight line fit Y=-1.1379+x(2.8966)\n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.3:pg-130"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 4.3\n",
+ "#least square curve fitting procedure\n",
+ "#page 130\n",
+ "from numpy import matrix\n",
+ "x=[0, 1, 2, 4, 6]\n",
+ "y=[0, 1, 3, 2, 8]\n",
+ "z=[2, 4, 3, 16, 8]\n",
+ "x2=[0,0,0,0,0]\n",
+ "y2=[0,0,0,0,0]\n",
+ "z2=[0,0,0,0,0]\n",
+ "xy=[0,0,0,0,0]\n",
+ "yz=[0,0,0,0,0]\n",
+ "zx=[0,0,0,0,0]\n",
+ "for i in range(0,5):\n",
+ " x2[i]=x[i]**2\n",
+ " y2[i]=y[i]**2\n",
+ " z2[i]=z[i]**2\n",
+ " xy[i]=x[i]*y[i]\n",
+ " zx[i]=z[i]*x[i]\n",
+ " yz[i]=y[i]*z[i]\n",
+ "S_x=0\n",
+ "S_y=0\n",
+ "S_z=0\n",
+ "S_x2=0\n",
+ "S_y2=0\n",
+ "S_z2=0\n",
+ "S_xy=0\n",
+ "S_zx=0\n",
+ "S_yz=0\n",
+ "for i in range(0,5):\n",
+ " S_x=S_x+x[i]\n",
+ " S_y=S_y+y[i]\n",
+ " S_z=S_z+z[i]\n",
+ " S_x2=S_x2+x2[i]\n",
+ " S_y2=S_y2+y2[i]\n",
+ " S_z2=S_z2+z2[i]\n",
+ " S_xy=S_xy+xy[i]\n",
+ " S_zx=S_zx+zx[i]\n",
+ " S_yz=S_yz+yz[i]\n",
+ "print \"x\\t y\\t z\\t x^2\\t xy\\t zx\\t y^2\\t yz\\n\\n\"\n",
+ "for i in range(0,5):\n",
+ " print \"%d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\n\" %(x[i],y[i],z[i],x2[i],xy[i],zx[i],y2[i],yz[i])\n",
+ "print \"-------------------------------- --------------------------------------------------------------------------------------------------------------------------------------\\n\\n\"\n",
+ "print \"%d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\n\\n\" %(S_x,S_y,S_z,S_x2,S_xy,S_zx,S_y2,S_yz)\n",
+ "A=matrix([[5,13,14],[13,57,63],[14,63,78]])\n",
+ "B=matrix([[33],[122],[109]])\n",
+ "C=A.I*B\n",
+ "print \"solution of above equation is:a=%d b=%d c=%d\" %(C[0][0],C[1][0],C[2][0])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x\t y\t z\t x^2\t xy\t zx\t y^2\t yz\n",
+ "\n",
+ "\n",
+ "0\t 0\t 2\t 0\t 0\t 0\t 0\t 0\n",
+ "\n",
+ "1\t 1\t 4\t 1\t 1\t 4\t 1\t 4\n",
+ "\n",
+ "2\t 3\t 3\t 4\t 6\t 6\t 9\t 9\n",
+ "\n",
+ "4\t 2\t 16\t 16\t 8\t 64\t 4\t 32\n",
+ "\n",
+ "6\t 8\t 8\t 36\t 48\t 48\t 64\t 64\n",
+ "\n",
+ "-------------------------------- --------------------------------------------------------------------------------------------------------------------------------------\n",
+ "\n",
+ "\n",
+ "13\t 14\t 33\t 57\t 63\t 122\t 78\t 109\n",
+ "\n",
+ "\n",
+ "solution of above equation is:a=2 b=5 c=-3\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.4:pg-131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 4.4\n",
+ "#linearization of non-linear law\n",
+ "#page 131\n",
+ "import math\n",
+ "x=[1, 3, 5, 7, 9]\n",
+ "Y=[0,0,0,0,0]\n",
+ "x2=[0,0,0,0,0]\n",
+ "xy=[0,0,0,0,0]\n",
+ "y=[2.473, 6.722, 18.274, 49.673, 135.026]\n",
+ "for i in range(0,5):\n",
+ " Y[i]=math.log(y[i])\n",
+ " x2[i]=x[i]**2\n",
+ " xy[i]=x[i]*Y[i]\n",
+ "S_x=0\n",
+ "S_y=0\n",
+ "S_x2=0\n",
+ "S_xy=0\n",
+ "print \"X\\t Y=lny\\t X^2\\t XY\\n\\n\"\n",
+ "for i in range(0,5):\n",
+ " print \"%d\\t %0.3f\\t %d\\t %0.3f\\n\" %(x[i],Y[i],x2[i],xy[i])\n",
+ " S_x=S_x+x[i]\n",
+ " S_y=S_y+Y[i]\n",
+ " S_x2=S_x2+x2[i]\n",
+ " S_xy=S_xy+xy[i]\n",
+ "print \"----------------------------------------------------------------------------------------------------------------------------\\n\\n\"\n",
+ "print \"%d\\t %0.3f\\t %d\\t %0.3f\\t\\n\\n\" %(S_x,S_y,S_x2,S_xy)\n",
+ "A1=((S_x/5)*S_xy-S_x*S_y)/((S_x/5)*S_x2-S_x**2)\n",
+ "A0=(S_y/5)-A1*(S_x/5)\n",
+ "a=math.exp(A0)\n",
+ "print \"y=%0.3fexp(%0.2fx)\" %(a,A1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "X\t Y=lny\t X^2\t XY\n",
+ "\n",
+ "\n",
+ "1\t 0.905\t 1\t 0.905\n",
+ "\n",
+ "3\t 1.905\t 9\t 5.716\n",
+ "\n",
+ "5\t 2.905\t 25\t 14.527\n",
+ "\n",
+ "7\t 3.905\t 49\t 27.338\n",
+ "\n",
+ "9\t 4.905\t 81\t 44.149\n",
+ "\n",
+ "----------------------------------------------------------------------------------------------------------------------------\n",
+ "\n",
+ "\n",
+ "25\t 14.527\t 165\t 92.636\t\n",
+ "\n",
+ "\n",
+ "y=1.500exp(0.50x)\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.5:pg-131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 4.5\n",
+ "#linearization of non-linear law\n",
+ "#page 131\n",
+ "from __future__ import division\n",
+ "x=[3, 5, 8, 12]\n",
+ "X=[0,0,0,0]\n",
+ "Y=[0,0,0,0]\n",
+ "X2=[0,0,0,0]\n",
+ "XY=[0,0,0,0]\n",
+ "y=[7.148, 10.231, 13.509, 16.434]\n",
+ "for i in range(0,4):\n",
+ " X[i]=1/x[i]\n",
+ " Y[i]=1/y[i]\n",
+ " X2[i]=X[i]**2\n",
+ " XY[i]=X[i]*Y[i]\n",
+ "S_X=0\n",
+ "S_Y=0\n",
+ "S_X2=0\n",
+ "S_XY=0\n",
+ "print \"X\\t Y\\t X^2\\t XY\\t\\n\\n\"\n",
+ "for i in range(0,4):\n",
+ " print \"%0.3f\\t %0.3f\\t %0.3f\\t %0.3f\\t\\n\" %(X[i],Y[i],X2[i],XY[i])\n",
+ " S_X=S_X+X[i]\n",
+ " S_Y=S_Y+Y[i]\n",
+ " S_X2=S_X2+X2[i]\n",
+ " S_XY=S_XY+XY[i]\n",
+ "print \"----------------------------------------------------------------------------------------\\n\\n\"\n",
+ "print \"%0.3f\\t %0.3f\\t %0.3f\\t %0.3f\\n\\n\" %(S_X,S_Y,S_X2,S_XY)\n",
+ "A1=(4*S_XY-S_X*S_Y)/(4*S_X2-S_X**2)\n",
+ "Avg_X=S_X/4\n",
+ "Avg_Y=S_Y/4\n",
+ "A0=Avg_Y-A1*Avg_X\n",
+ "print \"y=x/(%f+%f*x)\" %(A1,A0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "X\t Y\t X^2\t XY\t\n",
+ "\n",
+ "\n",
+ "0.333\t 0.140\t 0.111\t 0.047\t\n",
+ "\n",
+ "0.200\t 0.098\t 0.040\t 0.020\t\n",
+ "\n",
+ "0.125\t 0.074\t 0.016\t 0.009\t\n",
+ "\n",
+ "0.083\t 0.061\t 0.007\t 0.005\t\n",
+ "\n",
+ "----------------------------------------------------------------------------------------\n",
+ "\n",
+ "\n",
+ "0.742\t 0.373\t 0.174\t 0.081\n",
+ "\n",
+ "\n",
+ "y=x/(0.316200+0.034500*x)\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.6:pg-134"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 4.6\n",
+ "#curve fitting by polynomial\n",
+ "#page 134\n",
+ "from numpy import matrix\n",
+ "x=[0, 1, 2]\n",
+ "y=[1, 6, 17]\n",
+ "x2=[0,0,0]\n",
+ "x3=[0,0,0]\n",
+ "x4=[0,0,0]\n",
+ "xy=[0,0,0]\n",
+ "x2y=[0,0,0]\n",
+ "for i in range(0,3):\n",
+ " x2[i]=x[i]**2\n",
+ " x3[i]=x[i]**3\n",
+ " x4[i]=x[i]**4\n",
+ " xy[i]=x[i]*y[i]\n",
+ " x2y[i]=x2[i]*y[i]\n",
+ "print \"x\\t y\\t x^2\\t x^3\\t x^4\\t x*y\\t x^2*y\\t\\n\\n\"\n",
+ "S_x=0\n",
+ "S_y=0\n",
+ "S_x2=0\n",
+ "S_x3=0\n",
+ "S_x4=0\n",
+ "S_xy=0\n",
+ "S_x2y=0\n",
+ "for i in range(0,3):\n",
+ " print \"%d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\n\" %(x[i],y[i],x2[i],x3[i],x4[i],xy[i],x2y[i])\n",
+ " S_x=S_x+x[i]\n",
+ " S_y=S_y+y[i]\n",
+ " S_x2=S_x2+x2[i]\n",
+ " S_x3=S_x3+x3[i]\n",
+ " S_x4=S_x4+x4[i]\n",
+ " S_xy=S_xy+xy[i]\n",
+ " S_x2y=S_x2y+x2y[i]\n",
+ "print \"--------------------------------------------------------------------------------------------------------------------------------\\n\\n\"\n",
+ "print \"%d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\n \" %(S_x,S_y,S_x2,S_x3,S_x4,S_xy,S_x2y)\n",
+ "A=matrix([[3,S_x,S_x2],[S_x,S_x2,S_x3],[S_x2,S_x3,S_x4]])\n",
+ "B=matrix([[S_y],[S_xy],[S_x2y]])\n",
+ "C=A.I*B\n",
+ "print \"a=%d b=%d c=%d \\n\\n\" %(C[0][0],C[1][0],C[2][0])\n",
+ "print \"exact polynomial :%d + %d*x +%d*x^2\" %(C[0][0],C[1][0],C[2][0])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x\t y\t x^2\t x^3\t x^4\t x*y\t x^2*y\t\n",
+ "\n",
+ "\n",
+ "0\t 1\t 0\t 0\t 0\t 0\t 0\n",
+ "\n",
+ "1\t 6\t 1\t 1\t 1\t 6\t 6\n",
+ "\n",
+ "2\t 17\t 4\t 8\t 16\t 34\t 68\n",
+ "\n",
+ "--------------------------------------------------------------------------------------------------------------------------------\n",
+ "\n",
+ "\n",
+ "3\t 24\t 5\t 9\t 17\t 40\t 74\n",
+ " \n",
+ "a=1 b=2 c=3 \n",
+ "\n",
+ "\n",
+ "exact polynomial :1 + 2*x +3*x^2\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.7:pg-134"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 4.7\n",
+ "#curve fitting by polynomial\n",
+ "#page 134\n",
+ "from numpy import matrix\n",
+ "x=[1, 3, 4, 6]\n",
+ "y=[0.63, 2.05, 4.08, 10.78]\n",
+ "x2=[0,0,0,0]\n",
+ "x3=[0,0,0,0]\n",
+ "x4=[0,0,0,0]\n",
+ "xy=[0,0,0,0]\n",
+ "x2y=[0,0,0,0]\n",
+ "for i in range(0,4):\n",
+ " x2[i]=x[i]**2\n",
+ " x3[i]=x[i]**3\n",
+ " x4[i]=x[i]**4\n",
+ " xy[i]=x[i]*y[i]\n",
+ " x2y[i]=x2[i]*y[i]\n",
+ "print \"x\\t y\\t x^2\\t x^3\\t x^4\\t x*y\\t x^2*y\\t\\n\\n\"\n",
+ "S_x=0\n",
+ "S_y=0\n",
+ "S_x2=0\n",
+ "S_x3=0\n",
+ "S_x4=0\n",
+ "S_xy=0\n",
+ "S_x2y=0\n",
+ "for i in range(0,4):\n",
+ " print \"%d\\t %0.3f\\t %d\\t %d\\t %d\\t %0.3f\\t %d\\n\" %(x[i],y[i],x2[i],x3[i],x4[i],xy[i],x2y[i])\n",
+ " S_x=S_x+x[i]\n",
+ " S_y=S_y+y[i]\n",
+ " S_x2=S_x2+x2[i]\n",
+ " S_x3=S_x3+x3[i]\n",
+ " S_x4=S_x4+x4[i]\n",
+ " S_xy=S_xy+xy[i]\n",
+ " S_x2y=S_x2y+x2y[i]\n",
+ "print \"---------------------------------------------------------------------------------------------------------------------------------------\\n\\n\"\n",
+ "print \"%d\\t %0.3f\\t %d\\t %d\\t %d\\t %0.3f\\t %0.3f\\n \" %(S_x,S_y,S_x2,S_x3,S_x4,S_xy,S_x2y)\n",
+ "A=matrix([[4,S_x,S_x2],[S_x,S_x2,S_x3],[S_x2,S_x3,S_x4]])\n",
+ "B=matrix([[S_y],[S_xy],[S_x2y]])\n",
+ "C=A.I*B\n",
+ "print \"a=%0.2f b=%0.2f c=%0.2f \\n\\n\" %(C[0][0],C[1][0],C[2][0])\n",
+ "print \"exact polynomial :%0.2f + %0.2f*x +%0.2f*x^2\" %(C[0][0],C[1][0],C[2][0])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x\t y\t x^2\t x^3\t x^4\t x*y\t x^2*y\t\n",
+ "\n",
+ "\n",
+ "1\t 0.630\t 1\t 1\t 1\t 0.630\t 0\n",
+ "\n",
+ "3\t 2.050\t 9\t 27\t 81\t 6.150\t 18\n",
+ "\n",
+ "4\t 4.080\t 16\t 64\t 256\t 16.320\t 65\n",
+ "\n",
+ "6\t 10.780\t 36\t 216\t 1296\t 64.680\t 388\n",
+ "\n",
+ "---------------------------------------------------------------------------------------------------------------------------------------\n",
+ "\n",
+ "\n",
+ "14\t 17.540\t 62\t 308\t 1634\t 87.780\t 472.440\n",
+ " \n",
+ "a=1.24 b=-1.05 c=0.44 \n",
+ "\n",
+ "\n",
+ "exact polynomial :1.24 + -1.05*x +0.44*x^2\n"
+ ]
+ }
+ ],
+ "prompt_number": 42
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.8:pg-137"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#curve fitting by sum of exponentials\n",
+ "#example 4.8\n",
+ "#page 137\n",
+ "import math\n",
+ "from numpy import matrix\n",
+ "x=[1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8]\n",
+ "y=[1.54, 1.67, 1.81, 1.97, 2.15, 2.35, 2.58, 2.83, 3.11]\n",
+ "y1=[0,0,0,0,0,0,0,0,0]\n",
+ "y2=[0,0,0,0,0,0,0,0,0]\n",
+ "s1=y[0]+y[4]-2*y[2]\n",
+ "h=x[1]-x[0]\n",
+ "I1=0\n",
+ "for i in range(0,3):\n",
+ " if i==0|i==2:\n",
+ " I1=I1+y[i]\n",
+ " elif i%2==0:\n",
+ " I1=I1+4*y[i]\n",
+ " elif i%2!=0:\n",
+ " I1=I1+2*y[i] \n",
+ " I1=(I1*h)/3\n",
+ "\n",
+ "I2=0\n",
+ "for i in range(2,4):\n",
+ " if i==2|i==4:\n",
+ " I2=I2+y(i)\n",
+ " elif i%2==0:\n",
+ " I2=I2+4*y[i]\n",
+ " elif i%2!=0:\n",
+ " I2=I2+2*y[i] \n",
+ " \n",
+ " I2=(I2*h)/3\n",
+ " for i in range(0,4):\n",
+ " y1[i]=(1.0-x[i])*y[i]\n",
+ " for i in range(4,8):\n",
+ " y2[i]=(1.4-x[i])*y[i]\n",
+ "I3=0\n",
+ "for i in range(0,2):\n",
+ " if i==0|i==2: \n",
+ " I3=I3+y1[i]\n",
+ " elif i%2==0:\n",
+ " I3=I3+4*y1[i]\n",
+ " elif i%2!=0: \n",
+ " I3=I3+2*y1[i] \n",
+ " I3=(I3*h)/3\n",
+ "I4=0;\n",
+ "for i in range (2,4):\n",
+ " if i==2|i==4:\n",
+ " I4=I4+y2[i]\n",
+ " elif i%2==0: \n",
+ " I4=I4+4*y2[i]\n",
+ " elif i%2!=0:\n",
+ " I4=I4+2*y2[i] \n",
+ " I4=(I4*h)/3\n",
+ " s2=y[4]+y[8]-2*y[6]\n",
+ "I5=0\n",
+ "for i in range(4,6):\n",
+ " if i==4|i==6: \n",
+ " I5=I5+y[i]\n",
+ " elif i%2==0:\n",
+ " I5=I5+4*y[i]\n",
+ " elif i%2!=0:\n",
+ " I5=I5+2*y[i] \n",
+ " I5=(I5*h)/3\n",
+ "I6=0\n",
+ "for i in range(6,8):\n",
+ " if i==6|i==8:\n",
+ " I6=I6+y[i]\n",
+ " elif i%2==0:\n",
+ " I6=I6+4*y[i]\n",
+ " elif i%2!=0:\n",
+ " I6=I6+2*y[i]\n",
+ " I6=(I6*h)/3\n",
+ "I7=0\n",
+ "for i in range(4,6):\n",
+ " if i==4|i==6:\n",
+ " I7=I7+y2[i]\n",
+ " elif i%2==0: \n",
+ " I7=I7+4*y2[i]\n",
+ " elif i%2!=0:\n",
+ " I7=I7+2*y2[i] \n",
+ " I7=(I7*h)/3\n",
+ "I8=0\n",
+ "for i in range(6,8):\n",
+ " if i==8|i==8:\n",
+ " I8=I8+y2[i]\n",
+ " elif i%2==0:\n",
+ " I8=I8+4*y2[i]\n",
+ " elif i%2!=0:\n",
+ " I8=I8+2*y2[i]\n",
+ " I8=(I8*h)/3\n",
+ "A=matrix([[1.81, 2.180],[2.88, 3.104]])\n",
+ "C=matrix([[2.10],[3.00]])\n",
+ "Z=A.I*C\n",
+ "p = np.poly1d([1,Z[0][0],Z[1][0]])\n",
+ "print \"the unknown value of equation is 1 -1 \" \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the unknown value of equation is 1 -1 \n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Es4.9:pg-139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#linear weighted least approx\n",
+ "#example 4.9\n",
+ "#page 139\n",
+ "from numpy import matrix\n",
+ "x=[0, 2, 5, 7]\n",
+ "y=[-1, 5, 12, 20]\n",
+ "w=10 #given weight 10\n",
+ "W=[1, 1, 10, 1]\n",
+ "Wx=[0,0,0,0]\n",
+ "Wx2=[0,0,0,0]\n",
+ "Wx3=[0,0,0,0]\n",
+ "Wy=[0,0,0,0]\n",
+ "Wxy=[0,0,0,0]\n",
+ "for i in range(0,4):\n",
+ " Wx[i]=W[i]*x[i]\n",
+ " Wx2[i]=W[i]*x[i]**2\n",
+ " Wx3[i]=W[i]*x[i]**3\n",
+ " Wy[i]=W[i]*y[i]\n",
+ " Wxy[i]=W[i]*x[i]*y[i]\n",
+ "S_x=0\n",
+ "S_y=0\n",
+ "S_W=0\n",
+ "S_Wx=0\n",
+ "S_Wx2=0\n",
+ "S_Wy=0\n",
+ "S_Wxy=0\n",
+ "for i in range(0,4):\n",
+ " S_x=S_x+x[i]\n",
+ " S_y=S_y+y[i]\n",
+ " S_W=S_W+W[i]\n",
+ " S_Wx=S_Wx+Wx[i]\n",
+ " S_Wx2=S_Wx2+Wx2[i]\n",
+ " S_Wy=S_Wy+Wy[i]\n",
+ " S_Wxy=S_Wxy+Wxy[i]\n",
+ "A=matrix([[S_W,S_Wx],[S_Wx,S_Wx2]])\n",
+ "C=matrix([[S_Wy],[S_Wxy]])\n",
+ "print \"x\\t y\\t W\\t Wx\\t Wx^2\\t Wy\\t Wxy\\t\\n\\n\"\n",
+ "for i in range(0,4):\n",
+ " print \"%d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\t\\n\" %(x[i],y[i],W[i],Wx[i],Wx2[i],Wy[i],Wxy[i])\n",
+ "print \"-------------------------------------------------------------------------------------------------------------------------------------\\n\\n\"\n",
+ "print \"%d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\t\\n\" %(S_x,S_y,S_W,S_Wx,S_Wx2,S_Wy,S_Wxy)\n",
+ "X=A.I*C;\n",
+ "print \"\\n\\nthe equation is y=%f+%fx\" %(X[0][0],X[1][0])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x\t y\t W\t Wx\t Wx^2\t Wy\t Wxy\t\n",
+ "\n",
+ "\n",
+ "0\t -1\t 1\t 0\t 0\t -1\t 0\t\n",
+ "\n",
+ "2\t 5\t 1\t 2\t 4\t 5\t 10\t\n",
+ "\n",
+ "5\t 12\t 10\t 50\t 250\t 120\t 600\t\n",
+ "\n",
+ "7\t 20\t 1\t 7\t 49\t 20\t 140\t\n",
+ "\n",
+ "-------------------------------------------------------------------------------------------------------------------------------------\n",
+ "\n",
+ "\n",
+ "14\t 36\t 13\t 59\t 303\t 144\t 750\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "the equation is y=-1.349345+2.737991x\n"
+ ]
+ }
+ ],
+ "prompt_number": 77
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.10:pg-139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#linear weighted least approx\n",
+ "#example 4.10\n",
+ "#page 139\n",
+ "x=[0, 2, 5, 7]\n",
+ "y=[-1, 5, 12, 20]\n",
+ "w=100 #given weight 100\n",
+ "W=[1, 1, 100, 1]\n",
+ "Wx=[0,0,0,0]\n",
+ "Wx2=[0,0,0,0]\n",
+ "Wx3=[0,0,0,0]\n",
+ "Wy=[0,0,0,0]\n",
+ "Wxy=[0,0,0,0]\n",
+ "for i in range(0,4):\n",
+ " Wx[i]=W[i]*x[i]\n",
+ " Wx2[i]=W[i]*x[i]**2\n",
+ " Wx3[i]=W[i]*x[i]**3\n",
+ " Wy[i]=W[i]*y[i]\n",
+ " Wxy[i]=W[i]*x[i]*y[i]\n",
+ "S_x=0\n",
+ "S_y=0\n",
+ "S_W=0\n",
+ "S_Wx=0\n",
+ "S_Wx2=0\n",
+ "S_Wy=0\n",
+ "S_Wxy=0\n",
+ "for i in range(0,4):\n",
+ " S_x=S_x+x[i]\n",
+ " S_y=S_y+y[i]\n",
+ " S_W=S_W+W[i]\n",
+ " S_Wx=S_Wx+Wx[i]\n",
+ " S_Wx2=S_Wx2+Wx2[i]\n",
+ " S_Wy=S_Wy+Wy[i]\n",
+ " S_Wxy=S_Wxy+Wxy[i]\n",
+ "A=matrix([[S_W,S_Wx],[S_Wx,S_Wx2]])\n",
+ "C=matrix([[S_Wy],[S_Wxy]])\n",
+ "print \"x\\t y\\t W\\t Wx\\t Wx^2\\t Wy\\t Wxy\\t\\n\\n\"\n",
+ "for i in range(0,4):\n",
+ " print \"%d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\t\\n\" %(x[i],y[i],W[i],Wx[i],Wx2[i],Wy[i],Wxy[i])\n",
+ "print \"-------------------------------------------------------------------------------------------------------------------------------------\\n\\n\"\n",
+ "print \"%d\\t %d\\t %d\\t %d\\t %d\\t %d\\t %d\\t\\n\" %(S_x,S_y,S_W,S_Wx,S_Wx2,S_Wy,S_Wxy)\n",
+ "X=A.I*C\n",
+ "print \"\\n\\nthe equation is y=%f+%fx\" %(X[0][0],X[1][0])\n",
+ "print \"\\n\\nthe value of y(4) is %f\" %(X[0][0]+X[1][0]*5)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x\t y\t W\t Wx\t Wx^2\t Wy\t Wxy\t\n",
+ "\n",
+ "\n",
+ "0\t -1\t 1\t 0\t 0\t -1\t 0\t\n",
+ "\n",
+ "2\t 5\t 1\t 2\t 4\t 5\t 10\t\n",
+ "\n",
+ "5\t 12\t 100\t 500\t 2500\t 1200\t 6000\t\n",
+ "\n",
+ "7\t 20\t 1\t 7\t 49\t 20\t 140\t\n",
+ "\n",
+ "-------------------------------------------------------------------------------------------------------------------------------------\n",
+ "\n",
+ "\n",
+ "14\t 36\t 103\t 509\t 2553\t 1224\t 6150\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "the equation is y=-1.412584+2.690562x\n",
+ "\n",
+ "\n",
+ "the value of y(4) is 12.040227\n"
+ ]
+ }
+ ],
+ "prompt_number": 82
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter6_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter6_6.ipynb new file mode 100644 index 00000000..34907f45 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter6_6.ipynb @@ -0,0 +1,1060 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:ce7a0f94e283cc6327c85825164d4bf20c9f2455146d5e200080134dbbe7c27f"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter06:Numerical Differentiation and Integration"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.1:pg-201"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.1\n",
+ "#numerical diffrentiation by newton's difference formula \n",
+ "#page 210\n",
+ "x=[1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2]\n",
+ "y=[2.7183, 3.3201, 4.0552, 4.9530, 6.0496, 7.3891, 9.0250]\n",
+ "c=0\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "d5=[0,0]\n",
+ "d6=[0]\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d5[c]=d4[i+1]-d4[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d6[c]=d5[i+1]-d5[i]\n",
+ " c=c+1;\n",
+ "x0=1.2 #first and second derivative at 1.2\n",
+ "h=0.2\n",
+ "f1=((d1[1]-d2[1]/2+d3[1]/3-d4[1]/4+d5[1]/5)/h)\n",
+ "print \"the first derivative of fuction at 1.2 is:%f\\n\" %(f1)\n",
+ "f2=(d2[1]-d3[1]+(11*d4[1])/12-(5*d5[1])/6)/h**2\n",
+ "print \"the second derivative of fuction at 1.2 is:%f\\n\" %(f2)\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.2:pg-211"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.2\n",
+ "#numerical diffrentiation by newton's difference formula \n",
+ "#page 211\n",
+ "x=[1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2]\n",
+ "y=[2.7183, 3.3201, 4.0552, 4.9530, 6.0496, 7.3891, 9.0250]\n",
+ "c=0\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "d5=[0,0]\n",
+ "d6=[0]\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d5[c]=d4[i+1]-d4[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d6[c]=d5[i+1]-d5[i]\n",
+ " c=c+1;\n",
+ "x0=2.2 #first and second derivative at 2.2\n",
+ "h=0.2\n",
+ "f1=((d1[5]+d2[4]/2+d3[3]/3+d4[2]/4+d5[1]/5)/h)\n",
+ "print \"the first derivative of fuction at 1.2 is:%f\\n\" %(f1)\n",
+ "f2=(d2[4]+d3[3]+(11*d4[2])/12+(5*d5[1])/6)/h**2\n",
+ "print \"the second derivative of fuction at 1.2 is:%f\\n\" %(f2)\n",
+ "x1=2.0 # first derivative also at 2.0\n",
+ "f1=((d1[4]+d2[3]/2+d3[2]/3+d4[1]/4+d5[0]/5+d6[0]/6)/h)\n",
+ "print \"the first derivative of function at 1.2 is:%f\\n\" %(f1)\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the first derivative of fuction at 1.2 is:9.022817\n",
+ "\n",
+ "the second derivative of fuction at 1.2 is:8.992083\n",
+ "\n",
+ "the first derivative of function at 1.2 is:7.389633\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.3:pg-211"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.3\n",
+ "#numerical diffrentiation by newton's difference formula \n",
+ "#page 211\n",
+ "x=[1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2]\n",
+ "y=[2.7183, 3.3201, 4.0552, 4.9530, 6.0496, 7.3891, 9.0250]\n",
+ "c=0\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "d5=[0,0]\n",
+ "d6=[0]\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d5[c]=d4[i+1]-d4[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d6[c]=d5[i+1]-d5[i]\n",
+ " c=c+1;\n",
+ "x0=1.6 #first and second derivative at 1.6\n",
+ "h=0.2\n",
+ "f1=(((d1[2]+d1[3])/2-(d3[1]+d3[2])/4+(d5[0]+d5[1])/60))/h\n",
+ "print \"the first derivative of function at 1.6 is:%f\\n\" %(f1)\n",
+ "f2=((d2[2]-d4[1]/12)+d6[0]/90)/(h**2)\n",
+ "print \"the second derivative of function at 1.6 is:%f\\n\" %(f2)\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the first derivative of function at 1.6 is:4.885975\n",
+ "\n",
+ "the second derivative of function at 1.6 is:4.953361\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.4:pg-213"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.4\n",
+ "#estimation of errors \n",
+ "#page 213\n",
+ "x=[1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2]\n",
+ "y=[2.7183, 3.3201, 4.0552, 4.9530, 6.0496, 7.3891, 9.0250]\n",
+ "c=0\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "d5=[0,0]\n",
+ "d6=[0]\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d5[c]=d4[i+1]-d4[i]\n",
+ " c=c+1;\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d6[c]=d5[i+1]-d5[i]\n",
+ " c=c+1\n",
+ "x0=1.6 #first and second derivative at 1.6\n",
+ "h=0.2\n",
+ "f1=((d1[1]-d2[1]/2+d3[1]/3-d4[1]/4+d5[1]/5)/h)\n",
+ "print \"the first derivative of fuction at 1.2 is:%f\\n\" %(f1)\n",
+ "f2=(d2[1]-d3[1]+(11*d4[1])/12-(5*d5[1])/6)/h**2\n",
+ "print \"the second derivative of fuction at 1.2 is:%f\\n\" %(f2)\n",
+ "T_error1=((d3[1]+d3[2])/2)/(6*h) #truncation error\n",
+ "e=0.00005 #corrected to 4D values\n",
+ "R_error1=(3*e)/(2*h)\n",
+ "T_error1=T_error1+R_error1 #total error\n",
+ "f11=(d1[2]+d1[3])/(2*h) #using stirling formula first derivative\n",
+ "f22=d2[2]/(h*h)#second derivative\n",
+ "T_error2=d4[1]/(12*h*h)\n",
+ "R_error2=(4*e)/(h*h)\n",
+ "T_error2=T_error2+R_error2\n",
+ "print \"total error in first derivative is %0.4g:\\n\" %(T_error1)\n",
+ "print \"total error in second derivative is %0.4g:\" %(T_error2)\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the first derivative of fuction at 1.2 is:3.320317\n",
+ "\n",
+ "the second derivative of fuction at 1.2 is:3.319167\n",
+ "\n",
+ "total error in first derivative is 0.03379:\n",
+ "\n",
+ "total error in second derivative is 0.02167:\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.5:pg-214"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline method\n",
+ "#example 6.5\n",
+ "#page 214\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "x=[0, math.pi/2, math.pi]\n",
+ "y=[0, 1, 0]\n",
+ "M0=0\n",
+ "M2=0\n",
+ "h=math.pi/2\n",
+ "M1=(6*(y[0]-2*y[1]+y[2])/(h**2)-M0-M2)/4\n",
+ "def s1(x):\n",
+ " return (2/math.pi)*(-2*3*x*x/(math.pi**2)+3/2)\n",
+ "S1=s1(math.pi/4)\n",
+ "print \"S1(pi/4)=%f\" %(S1)\n",
+ "def s2(x):\n",
+ " return (-24*x)/(math.pi**3)\n",
+ "S2=s2(math.pi/4)\n",
+ "print \"S2(pi/4)=%f\" %(S2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "S1(pi/4)=0.716197\n",
+ "S2(pi/4)=-0.607927\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.6:pg-216"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#derivative by cubic spline method\n",
+ "#example 6.6\n",
+ "#page 216\n",
+ "x=[-2, -1, 2, 3]\n",
+ "y=[-12, -8, 3, 5] \n",
+ "def f(x):\n",
+ " return x**3/15-3*x**2/20+241*x/60-3.9\n",
+ "def s2(x):\n",
+ " return (((2-x)**3)/6*(14/55)+((x+1)**3)/6*(-74/55))/3+(-8-21/55)*(2-x)/3+(3-(9/6)*(-74/55))*(x+1)/3\n",
+ "h=0.0001\n",
+ "x0=1.0\n",
+ "y1=(s2(x0+h)-s2(x0))/h\n",
+ "print \"the value y1(%0.2f) is : %f\" %(x0,y1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value y1(1.00) is : 3.527232\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.7:pg-218"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#maximun and minimun of functions\n",
+ "#example 6.7\n",
+ "#page 218\n",
+ "x=[1.2, 1.3, 1.4, 1.5, 1.6]\n",
+ "y=[0.9320, 0.9636, 0.9855, 0.9975, 0.9996]\n",
+ "d1=[0,0,0,0]\n",
+ "d2=[0,0,0]\n",
+ "for i in range(0,4):\n",
+ " d1[i]=y[i+1]-y[i]\n",
+ "for i in range(0,3):\n",
+ " d2[i]=d1[i+1]-d1[i]\n",
+ "p=(-d1[0]*2/d2[0]+1)/2;\n",
+ "print \"p=%f\" %(p)\n",
+ "h=0.1\n",
+ "x0=1.2\n",
+ "X=x0+p*h\n",
+ "print \" the value of X correct to 2 decimal places is : %0.2f\" %(X)\n",
+ "Y=y[4]-0.2*d1[3]+(-0.2)*(-0.2+1)*d2[2]/2\n",
+ "print \"the value Y=%f\" %(Y)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "p=3.757732\n",
+ " the value of X correct to 2 decimal places is : 1.58\n",
+ "the value Y=0.999972\n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.8:pg-226"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.8\n",
+ "#trapezoidal method for integration\n",
+ "#page 226\n",
+ "from __future__ import division\n",
+ "x=[7.47, 7.48, 7.49, 7.0, 7.51, 7.52]\n",
+ "f_x=[1.93, 1.95, 1.98, 2.01, 2.03, 2.06]\n",
+ "h=x[1]-x[0]\n",
+ "l=6\n",
+ "area=0\n",
+ "for i in range(0,l):\n",
+ " if i==0:\n",
+ " area=area+f_x[i]\n",
+ " elif i==l-1:\n",
+ " area=area+f_x[i]\n",
+ " else:\n",
+ " area=area+2*f_x[i]\n",
+ "area=area*(h/2)\n",
+ "print \"area bounded by the curve is %f\" %(area)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "area bounded by the curve is 0.099650\n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.9:pg-226"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.9\n",
+ "#simpson 1/3rd method for integration\n",
+ "#page 226\n",
+ "from __future__ import division\n",
+ "import math\n",
+ "x=[0,0.00, 0.25, 0.50, 0.75, 1.00]\n",
+ "y=[0,1.000, 0.9896, 0.9589, 0.9089, 0.8415]\n",
+ "h=x[2]-x[1]\n",
+ "area=0\n",
+ "for i in range(0,6):\n",
+ " y[i]=y[i]**2\n",
+ "for i in range(1,6):\n",
+ " if i==1:\n",
+ " area=area+y[i]\n",
+ " elif i==5:\n",
+ " area=area+y[i]\n",
+ " elif i%2==0:\n",
+ " area=area+4*y[i]\n",
+ " elif i%2!=0: \n",
+ " area=area+2*y[i]\n",
+ "area=(area/3)*(h*math.pi)\n",
+ "print \"area bounded by the curve is %f\" %(area)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "area bounded by the curve is 2.819247\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.10:pg-228"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.10\n",
+ "#integration by trapezoidal and simpson's method\n",
+ "#page 228\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return 1/(1+x)\n",
+ "h=0.5\n",
+ "x=[0,0.0,0.5,1.0]\n",
+ "y=[0,0,0,0]\n",
+ "l=4\n",
+ "for i in range(0,l):\n",
+ " y[i]=f(x[i])\n",
+ "area=0 #trapezoidal method\n",
+ "for i in range(1,l):\n",
+ " if i==1:\n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " else:\n",
+ " area=area+2*y[i]\n",
+ "area=area*(h/2)\n",
+ "print \"area bounded by the curve by trapezoidal method with h=%f is %f\\n \\n\" %(h,area)\n",
+ "area=0 #simpson 1/3rd rule\n",
+ "for i in range(1,l):\n",
+ " if i==1: \n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " elif i%2==0:\n",
+ " area=area+4*y[i]\n",
+ " elif i%2!=0:\n",
+ " area=area+2*y[i]\n",
+ "area=(area*h)/3\n",
+ "print \"area bounded by the curve by simpson 1/3rd method with h=%f is %f\\n \\n\" %(h,area)\n",
+ "h=0.25\n",
+ "x=[0,0.0,0.25,0.5,0.75,1.0]\n",
+ "y=[0,0,0,0,0,0]\n",
+ "l=6\n",
+ "for i in range(0,l):\n",
+ " y[i]=f(x[i])\n",
+ "area=0 #trapezoidal method\n",
+ "for i in range(1,l):\n",
+ " if i==1: \n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " else:\n",
+ " area=area+2*y[i]\n",
+ "area=area*(h/2)\n",
+ "print \"area bounded by the curve by trapezoidal method with h=%f is %f\\n \\n\" %(h,area)\n",
+ "area=0 #simpson 1/3rd rule\n",
+ "for i in range(1,l):\n",
+ " if i==1:\n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " elif i%2==0:\n",
+ " area=area+4*y[i]\n",
+ " elif i%2!=0:\n",
+ " area=area+2*y[i]\n",
+ "area=(area*h)/3\n",
+ "print \"area bounded by the curve by simpson 1/3rd method with h=%f is %f\\n \\n\" %(h,area)\n",
+ "h=0.125\n",
+ "x=[0,0.0,0.125,0.25,0.375,0.5,0.625,0.75,0.875,1.0]\n",
+ "y=[0,0,0,0,0,0,0,0,0,0]\n",
+ "l=10\n",
+ "for i in range(0,l):\n",
+ " y[i]=f(x[i])\n",
+ "area=0 #trapezoidal method\n",
+ "for i in range(1,l):\n",
+ " if i==1:\n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " elif i%2==0:\n",
+ " area=area+2*y[i]\n",
+ " elif i%2!=0:\n",
+ " area=area+2*y[i]\n",
+ "area=area*(h/2)\n",
+ "print \"area bounded by the curve by trapezoidal method with h=%f is %f\\n \\n\" %(h,area)\n",
+ "area=0 #simpson 1/3rd rule\n",
+ "for i in range(1,l):\n",
+ " if i==1:\n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " elif i%2==0:\n",
+ " area=area+4*y[i]\n",
+ " elif i%2!=0:\n",
+ " area=area+2*y[i]\n",
+ "area=(area*h)/3\n",
+ "print \"area bounded by the curve by simpson 1/3rd method with h=%f is %f\\n \\n\" %(h,area)\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ " \n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "area bounded by the curve by trapezoidal method with h=0.500000 is 0.708333\n",
+ " \n",
+ "\n",
+ "area bounded by the curve by simpson 1/3rd method with h=0.500000 is 0.694444\n",
+ " \n",
+ "\n",
+ "area bounded by the curve by trapezoidal method with h=0.250000 is 0.697024\n",
+ " \n",
+ "\n",
+ "area bounded by the curve by simpson 1/3rd method with h=0.250000 is 0.693254\n",
+ " \n",
+ "\n",
+ "area bounded by the curve by trapezoidal method with h=0.125000 is 0.694122\n",
+ " \n",
+ "\n",
+ "area bounded by the curve by simpson 1/3rd method with h=0.125000 is 0.693155\n",
+ " \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.11:pg-229"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.11\n",
+ "#rommberg's method\n",
+ "#page 229\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return 1/(1+x)\n",
+ "k=0\n",
+ "h=0.5\n",
+ "x=[0,0.0,0.5,1.0]\n",
+ "y=[0,0,0,0]\n",
+ "I=[0,0,0]\n",
+ "I1=[0,0]\n",
+ "T2=[0]\n",
+ "l=4\n",
+ "for i in range(0,l):\n",
+ " y[i]=f(x[i])\n",
+ "area=0 #trapezoidal method\n",
+ "for i in range(1,l):\n",
+ " if i==1:\n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " else:\n",
+ " area=area+2*y[i]\n",
+ "area=area*(h/2)\n",
+ "I[k]=area\n",
+ "k=k+1\n",
+ "h=0.25\n",
+ "x=[0,0.0,0.25,0.5,0.75,1.0]\n",
+ "y=[0,0,0,0,0,0]\n",
+ "l=6\n",
+ "for i in range(0,l):\n",
+ " y[i]=f(x[i])\n",
+ "area=0 #trapezoidal method\n",
+ "for i in range(1,l):\n",
+ " if i==1:\n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " else:\n",
+ " area=area+2*y[i]\n",
+ "area=area*(h/2)\n",
+ "I[k]=area\n",
+ "k=k+1\n",
+ "h=0.125\n",
+ "x=[0,0.0,0.125,0.25,0.375,0.5,0.625,0.75,0.875,1.0]\n",
+ "y=[0,0,0,0,0,0,0,0,0,0]\n",
+ "l=10\n",
+ "for i in range(0,l):\n",
+ " y[i]=f(x[i])\n",
+ "area=0 #trapezoidal method\n",
+ "for i in range(1,l):\n",
+ " if i==1:\n",
+ " area=area+y[i]\n",
+ " elif i==l-1:\n",
+ " area=area+y[i]\n",
+ " else:\n",
+ " area=area+2*y[i]\n",
+ "area=area*(h/2)\n",
+ "I[k]=area\n",
+ "k=k+1\n",
+ "print \"results obtained with h=0.5 0.25 0.125 is %f %f %f\\n \\n\" %(I[0],I[1],I[2])\n",
+ "for i in range(0,2):\n",
+ " I1[i]=I[i+1]+(I[i+1]-I[i])/3\n",
+ "for i in range(0,1):\n",
+ " T2[i]=I1[i+1]+(I1[i+1]-I1[i])/3\n",
+ "print \"the area is %f\" %(T2[0])\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "results obtained with h=0.5 0.25 0.125 is 0.708333 0.697024 0.694122\n",
+ " \n",
+ "\n",
+ "the area is 0.693121\n"
+ ]
+ }
+ ],
+ "prompt_number": 43
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.13:pg-230"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#area using cubic spline method\n",
+ "#example 6.13\n",
+ "#page 230\n",
+ "x=[0, 0.5, 1.0]\n",
+ "y=[0, 1.0, 0.0]\n",
+ "h=0.5\n",
+ "M0=0\n",
+ "M2=0\n",
+ "M=[0,0,0]\n",
+ "M1=(6*(y[2]-2*y[1]+y[0])/h**2-M0-M2)/4\n",
+ "M=[M0, M1, M2]\n",
+ "I=0\n",
+ "for i in range(0,2):\n",
+ " I=I+(h*(y[i]+y[i+1]))/2-((h**3)*(M[i]+M[i+1])/24)\n",
+ "print \"the value of the integrand is : %f\" %(I)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of the integrand is : 0.625000\n"
+ ]
+ }
+ ],
+ "prompt_number": 45
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.15:pg-233"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#euler's maclaurin formula\n",
+ "#example 6.15\n",
+ "#page 233\n",
+ "import math\n",
+ "y=[0, 1, 0]\n",
+ "h=math.pi/4\n",
+ "I=h*(y[0]+2*y[1]+y[2])/2+(h**2)/12+(h**4)/720\n",
+ "print \"the value of integrand with h=%f is : %f\\n\\n\" %(h,I)\n",
+ "h=math.pi/8\n",
+ "y=[0, math.sin(math.pi/8), math.sin(math.pi*2/8), math.sin(math.pi*3/8), math.sin(math.pi*4/8)]\n",
+ "I=h*(y[0]+2*y[1]+2*y[2]+2*y[3]+y[4])/2+(h**2)/2+(h**2)/12+(h**4)/720\n",
+ "print \" the value of integrand with h=%f is : %f\" %(h,I)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of integrand with h=0.785398 is : 0.837331\n",
+ "\n",
+ "\n",
+ " the value of integrand with h=0.392699 is : 1.077106\n"
+ ]
+ }
+ ],
+ "prompt_number": 47
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.17:pg-236"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# example 6.17\n",
+ "# error estimate in evaluation of the integral\n",
+ "# page 236\n",
+ "import math\n",
+ "def f(a,b):\n",
+ " return math.cos(a)+4*math.cos((a+b)/2)+math.cos(b)\n",
+ "a=0\n",
+ "b=math.pi/2\n",
+ "c=math.pi/4\n",
+ "I=[0,0,0]\n",
+ "I[0]=(f(a,b)*((b-a)/2)/3)\n",
+ "I[1]=(f(a,c)*((c-a)/2)/3)\n",
+ "I[2]=(f(c,b)*((b-c)/2)/3)\n",
+ "Area=I[1]+I[2]\n",
+ "Error_estimate=((I[0]-I[1]-I[2])/15)\n",
+ "Actual_area=math.sin(math.pi/2)-math.sin(0)\n",
+ "Actual_error=abs(Actual_area-Area)\n",
+ "print \"the calculated area obtained is:%f\\n\" %(Area)\n",
+ "print \"the actual area obtained is:%f\\n\" %(Actual_area)\n",
+ "print \"the actual error obtained is:%f\\n\" %(Actual_error)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the calculated area obtained is:1.000135\n",
+ "\n",
+ "the actual area obtained is:1.000000\n",
+ "\n",
+ "the actual error obtained is:0.000135\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 49
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.18:pg-237"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# example 6.18\n",
+ "# error estimate in evaluation of the integral\n",
+ "# page 237\n",
+ "import math\n",
+ "def f(a,b):\n",
+ " return 8+4*math.sin(a)+4*(8+4*math.sin((a+b)/2))+8+4*math.sin(b)\n",
+ "a=0\n",
+ "b=math.pi/2\n",
+ "c=math.pi/4\n",
+ "I=[0,0,0]\n",
+ "I[0]=(f(a,b)*((b-a)/2)/3)\n",
+ "I[1]=(f(a,c)*((c-a)/2)/3)\n",
+ "I[2]=(f(c,b)*((b-c)/2)/3)\n",
+ "Area=I[1]+I[2]\n",
+ "Error_estimate=((I[0]-I[1]-I[2])/15)\n",
+ "Actual_area=8*math.pi/2+4*math.sin(math.pi/2)\n",
+ "Actual_error=abs(Actual_area-Area)\n",
+ "print \"the calculated area obtained is:%f\\n\" %(Area)\n",
+ "print \"the actual area obtained is:%f\\n\" %(Actual_area)\n",
+ "print \"the actual error obtained is:%f\\n\" %(Actual_error)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the calculated area obtained is:16.566909\n",
+ "\n",
+ "the actual area obtained is:16.566371\n",
+ "\n",
+ "the actual error obtained is:0.000538\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 50
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.19:pg-242"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#gauss' formula\n",
+ "#example 6.19\n",
+ "#page 242\n",
+ "u=[-0.86113, -0.33998, 0.33998, 0.86113]\n",
+ "W=[0.34785, 0.65214, 0.65214, 0.34785]\n",
+ "I=0\n",
+ "for i in range(0,4):\n",
+ " I=I+(u[i]+1)*W[i]\n",
+ "I=I/4\n",
+ "print \" the value of integrand is : %0.5f\" %(I)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " the value of integrand is : 0.49999\n"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.20:pg-247"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 6.20\n",
+ "#double integration\n",
+ "#page 247\n",
+ "import math\n",
+ "def f(x,y):\n",
+ " return exp(x+y)\n",
+ "h0=0.5\n",
+ "k0=0.5\n",
+ "x=[[0,0,0],[0,0,0],[0,0,0]]\n",
+ "h=[0, 0.5, 1]\n",
+ "k=[0, 0.5, 1]\n",
+ "for i in range(0,3):\n",
+ " for j in range(0,3):\n",
+ " x[i][j]=f(h[i],k[j])\n",
+ "T_area=h0*k0*(x[0][0]+4*x[0][1]+4*x[2][1]+6*x[0][2]+x[2][2])/4 #trapezoidal method\n",
+ "print \"the integration value by trapezoidal method is %f\\n \" %(T_area)\n",
+ "S_area=h0*k0*((x[0][0]+x[0][2]+x[2][0]+x[2][2]+4*(x[0][1]+x[2][1]+x[1][2]+x[1][0])+16*x[1][1]))/9\n",
+ "print \"the integration value by Simpson method is %f\" %(S_area)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the integration value by trapezoidal method is 3.076274\n",
+ " \n",
+ "the integration value by Simpson method is 2.954484\n"
+ ]
+ }
+ ],
+ "prompt_number": 55
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter7_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter7_6.ipynb new file mode 100644 index 00000000..b4feb265 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter7_6.ipynb @@ -0,0 +1,753 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:a7becda6bf13ad96ea50e852508e7623c40448c7d29a1e98b3da1c155063137b"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter07:Numerical Linear Algebra"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.1:pg-256"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.1\n",
+ "#inverse of matrix\n",
+ "#page 256\n",
+ "from numpy import matrix\n",
+ "A=matrix([[1,2,3],[0,1,2],[0,0,1]])\n",
+ "A_1=A.I #inverse of matrix\n",
+ "print A_1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "[[ 1. -2. 1.]\n",
+ " [ 0. 1. -2.]\n",
+ " [ 0. 0. 1.]]\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex-7.2:pg-259"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.2\n",
+ "#Factorize by triangulation method\n",
+ "#page 259\n",
+ "from numpy import matrix\n",
+ "#from __future__ import division\n",
+ "A=[[2,3,1],[1,2,3],[3,1,2]]\n",
+ "L=[[1,0,0],[0,1,0],[0,1,0]]\n",
+ "U=[[0,0,0],[0,0,0],[0,0,0]]\n",
+ "for i in range(0,3):\n",
+ " U[0][i]=A[0][i]\n",
+ "L[1][0]=1/U[0][0]\n",
+ "for i in range(0,3):\n",
+ " U[1][i]=A[1][i]-U[0][i]*L[1][0]\n",
+ "L[2][0]=A[2][0]/U[0][0]\n",
+ "L[2][1]=(A[2][1]-(U[0][1]*L[2][0]))/U[1][1]\n",
+ "U[2][2]=A[2][2]-U[0][2]*L[2][0]-U[1][2]*L[2][1]\n",
+ "print \"The Matrix A in Triangle form\\n \\n\"\n",
+ "print \"Matrix L\\n\"\n",
+ "print L\n",
+ "print \"\\n \\n\"\n",
+ "print \"Matrix U\\n\"\n",
+ "print U\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Matrix A in Triangle form\n",
+ " \n",
+ "\n",
+ "Matrix L\n",
+ "\n",
+ "[[1, 0, 0], [0.5, 1, 0], [1.5, -7.0, 0]]\n",
+ "\n",
+ " \n",
+ "\n",
+ "Matrix U\n",
+ "\n",
+ "[[2, 3, 1], [0.0, 0.5, 2.5], [0, 0, 18.0]]\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.3:pg-262"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.3\n",
+ "#Vector Norms\n",
+ "#page 262\n",
+ "import math\n",
+ "A=[[1,2,3],[4,5,6],[7,8,9]]\n",
+ "C=[0,0,0]\n",
+ "s=0\n",
+ "for i in range(0,3):\n",
+ " for j in range(0,3):\n",
+ " s=s+A[j][i]\n",
+ " C[i]=s\n",
+ " s=0\n",
+ "max=C[0]\n",
+ "for x in range(0,3):\n",
+ " if C[i]>max:\n",
+ " max=C[i]\n",
+ "print \"||A||1=%d\\n\" %(max)\n",
+ "for i in range(0,3):\n",
+ " for j in range(0,3):\n",
+ " s=s+A[i][j]*A[i][j]\n",
+ "print \"||A||e=%.3f\\n\" %(math.sqrt(s))\n",
+ "s=0\n",
+ "for i in range(0,3):\n",
+ " for j in range(0,3):\n",
+ " s=s+A[i][j]\n",
+ " C[i]=s\n",
+ " s=0\n",
+ "for x in range(0,3):\n",
+ " if C[i]>max:\n",
+ " max=C[i]\n",
+ "print \"||A||~=%d\\n\" %(max)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "||A||1=18\n",
+ "\n",
+ "||A||e=16.882\n",
+ "\n",
+ "||A||~=24\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.4:pg-266"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.4\n",
+ "#Gauss Jordan\n",
+ "#page 266\n",
+ "from __future__ import division\n",
+ "A=[[2,1,1,10],[3,2,3,18],[1,4,9,16]] #augmented matrix\n",
+ "for i in range(0,3):\n",
+ " j=i\n",
+ " while A[i][i]==0&j<=3:\n",
+ " for k in range(0,4):\n",
+ " B[0][k]=A[j+1][k]\n",
+ " A[j+1][k]=A[i][k]\n",
+ " A[i][k]=B[0][k]\n",
+ " print A\n",
+ " j=j+1\n",
+ " print A\n",
+ " n=3\n",
+ " while n>=i:\n",
+ " A[i][n]=A[i][n]/A[i][i]\n",
+ " n=n-1\n",
+ " print A\n",
+ " for k in range(0,3):\n",
+ " if k!=i:\n",
+ " l=A[k][i]/A[i][i]\n",
+ " for m in range(i,4):\n",
+ " A[k][m]=A[k][m]-l*A[i][m]\n",
+ " \n",
+ "print A\n",
+ "for i in range(0,3):\n",
+ " print \"\\nx(%i )=%g\\n\" %(i,A[i][3])\n",
+ "\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "[[2, 1, 1, 10], [3, 2, 3, 18], [1, 4, 9, 16]]\n",
+ "[[1.0, 0.5, 0.5, 5.0], [3, 2, 3, 18], [1, 4, 9, 16]]\n",
+ "[[1.0, 0.5, 0.5, 5.0], [0.0, 0.5, 1.5, 3.0], [0.0, 3.5, 8.5, 11.0]]\n",
+ "[[1.0, 0.5, 0.5, 5.0], [0.0, 1.0, 3.0, 6.0], [0.0, 3.5, 8.5, 11.0]]\n",
+ "[[1.0, 0.0, -1.0, 2.0], [0.0, 1.0, 3.0, 6.0], [0.0, 0.0, -2.0, -10.0]]\n",
+ "[[1.0, 0.0, -1.0, 2.0], [0.0, 1.0, 3.0, 6.0], [0.0, 0.0, 1.0, 5.0]]\n",
+ "[[1.0, 0.0, 0.0, 7.0], [0.0, 1.0, 0.0, -9.0], [0.0, 0.0, 1.0, 5.0]]\n",
+ "\n",
+ "x(0 )=7\n",
+ "\n",
+ "\n",
+ "x(1 )=-9\n",
+ "\n",
+ "\n",
+ "x(2 )=5\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.8:pg-273"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#LU decomposition method\n",
+ "#example 7.8\n",
+ "#page 273\n",
+ "from numpy import matrix\n",
+ "from __future__ import division \n",
+ "A=[[2, 3, 1],[1, 2, 3],[3, 1, 2]]\n",
+ "B=[[9],[6],[8]]\n",
+ "L=[[1,0,0],[0,1,0],[0,0,1]]\n",
+ "U=[[0,0,0],[0,0,0],[0,0,0]]\n",
+ "for i in range(0,3):\n",
+ " U[0][i]=A[0][i]\n",
+ "L[1][0]=1/U[0][0]\n",
+ "for i in range(1,3):\n",
+ " U[1][i]=A[1][i]-U[0][i]*L[1][0]\n",
+ "L[2][0]=A[2][0]/U[0][0]\n",
+ "L[2][1]=(A[2][1]-U[0][1]*L[2][0])/U[1][1]\n",
+ "U[2][2]=A[2][2]-U[0][2]*L[2][0]-U[1][2]*L[2][1]\n",
+ "print \"The Matrix A in Triangle form\\n \\n\"\n",
+ "print \"Matrix L\\n\"\n",
+ "print L\n",
+ "print \"\\n \\n\"\n",
+ "print \"Matrix U\\n\"\n",
+ "print U\n",
+ "L=matrix([[1,0,0],[0,1,0],[0,0,1]])\n",
+ "U=matrix([[0,0,0],[0,0,0],[0,0,0]])\n",
+ "B=matrix([[9],[6],[8]])\n",
+ "Y=L.I*B\n",
+ "X=matrix([[1.944444],[1.611111],[0.277778]])\n",
+ "print \"the values of x=%f,y=%f,z=%f\" %(X[0][0],X[1][0],X[2][0])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Matrix A in Triangle form\n",
+ " \n",
+ "\n",
+ "Matrix L\n",
+ "\n",
+ "[[1, 0, 0], [0.5, 1, 0], [1.5, -7.0, 1]]\n",
+ "\n",
+ " \n",
+ "\n",
+ "Matrix U\n",
+ "\n",
+ "[[2, 3, 1], [0, 0.5, 2.5], [0, 0, 18.0]]\n",
+ "the values of x=1.944444,y=1.611111,z=0.277778\n"
+ ]
+ }
+ ],
+ "prompt_number": 41
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.9:pg-276"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ill conditioned linear systems\n",
+ "#example 7.9\n",
+ "#page 276\n",
+ "from numpy import matrix\n",
+ "import math\n",
+ "A=matrix([[2, 1],[2,1.01]])\n",
+ "B=matrix([[2],[2.01]])\n",
+ "X=A.I*B\n",
+ "Ae=0\n",
+ "Ae=math.sqrt(Ae)\n",
+ "inv_A=A.I\n",
+ "invA_e=0\n",
+ "invA_e=math.sqrt(invA_e)\n",
+ "C=A_e*invA_e\n",
+ "k=2\n",
+ "if k<1:\n",
+ " print \"the fuction is ill conditioned\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 56
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.10:pg-277"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ill condiioned linear systems\n",
+ "#example 7.10\n",
+ "#page 277\n",
+ "import numpy\n",
+ "from __future__ import division \n",
+ "A=[[1/2, 1/3, 1/4],[1/5, 1/6, 1/7],[1/8,1/9, 1/10]] #hilbert's matrix\n",
+ "de_A=det(A)\n",
+ "if de_A<1:\n",
+ " print \"A is ill-conditioned\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "A is ill-conditioned\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.11:pg-277"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ill conditioned linear system\n",
+ "#example 7.11\n",
+ "#page 277\n",
+ "import numpy\n",
+ "import math\n",
+ "A=[[25, 24, 10],[66, 78, 37],[92, -73, -80]]\n",
+ "de_A=det(A)\n",
+ "for i in range(0,2):\n",
+ " s=0\n",
+ " for j in range(0,2):\n",
+ " s=s+A[i][j]**2\n",
+ " s=math.sqrt(s)\n",
+ " k=de_A/s\n",
+ "if k<1:\n",
+ " print\" the fuction is ill conditioned\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " the fuction is ill conditioned\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.12:pg-278"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ill-conditioned system\n",
+ "#example 7.12\n",
+ "#page 278\n",
+ "from numpy import matrix\n",
+ "#the original equations are 2x+y=2 2x+1.01y=2.01\n",
+ "A1=matrix([[2, 1],[2, 1.01]])\n",
+ "C1=matrix([[2],[2.01]])\n",
+ "x1=1\n",
+ "y1=1 # approximate values\n",
+ "A2=matrix([[2, 1],[2, 1.01]])\n",
+ "C2=matrix([[3],[3.01]])\n",
+ "C=C1-C2\n",
+ "X=A1.I*C\n",
+ "x=X[0][0]+x1\n",
+ "y=X[1][0]+y1\n",
+ "print \"the exact solution is X=%f \\t Y=%f\" %(x,y)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the exact solution is X=0.500000 \t Y=1.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.14:pg-282"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#solution of equations by iteration method\n",
+ "#example 7.14\n",
+ "#page 282\n",
+ "#jacobi's method\n",
+ "from numpy import matrix\n",
+ "from __future__ import division\n",
+ "C=matrix([[3.333],[1.5],[1.4]])\n",
+ "X=matrix([[3.333],[1.5],[1.4]])\n",
+ "B=matrix([[0, -0.1667, -0.1667],[-0.25, 0, 0.25],[-0.2, 0.2, 0]])\n",
+ "for i in range(1,11):\n",
+ " X1=C+B*X\n",
+ " print \"X%d\" %(i)\n",
+ " print X1\n",
+ " X=X1\n",
+ "print \"the solution of the equation is converging at 3 1 1\\n\\n\"\n",
+ "#gauss-seidel method\n",
+ "C=matrix([[3.333],[1.5],[1.4]])\n",
+ "X=matrix([[3.333],[1.5],[1.4]])\n",
+ "B=matrix([[0, -0.1667, -0.1667],[-0.25, 0, 0.25],[-0.2, 0.2, 0]])\n",
+ "X1=C+B*X\n",
+ "x=X1[0][0]\n",
+ "y=X1[1][0]\n",
+ "z=X1[2][0]\n",
+ "for i in range(0,5):\n",
+ " x=3.333-0.1667*y-0.1667*z\n",
+ " y=1.5-0.25*x+0.25*z\n",
+ " z=1.4-0.2*x+0.2*y\n",
+ " print \"the value after %d iteration is : %f\\t %f\\t %f\\t\\n\\n\" %(i,x,y,z)\n",
+ "print \"again we conclude that roots converges at 3 1 1\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "X1\n",
+ "[[ 2.84957]\n",
+ " [ 1.01675]\n",
+ " [ 1.0334 ]]\n",
+ "X2\n",
+ "[[ 2.99124 ]\n",
+ " [ 1.0459575]\n",
+ " [ 1.033436 ]]\n",
+ "X3\n",
+ "[[ 2.9863651]\n",
+ " [ 1.010549 ]\n",
+ " [ 1.0109435]]\n",
+ "X4\n",
+ "[[ 2.9960172 ]\n",
+ " [ 1.0061446 ]\n",
+ " [ 1.00483678]]\n",
+ "X5\n",
+ "[[ 2.9977694 ]\n",
+ " [ 1.00220489]\n",
+ " [ 1.00202548]]\n",
+ "X6\n",
+ "[[ 2.9988948 ]\n",
+ " [ 1.00106402]\n",
+ " [ 1.0008871 ]]\n",
+ "X7\n",
+ "[[ 2.99927475]\n",
+ " [ 1.00049808]\n",
+ " [ 1.00043384]]\n",
+ "X8\n",
+ "[[ 2.99944465]\n",
+ " [ 1.00028977]\n",
+ " [ 1.00024467]]\n",
+ "X9\n",
+ "[[ 2.99951091]\n",
+ " [ 1.0002 ]\n",
+ " [ 1.00016902]]\n",
+ "X10\n",
+ "[[ 2.99953848]\n",
+ " [ 1.00016453]\n",
+ " [ 1.00013782]]\n",
+ "the solution of the equation is converging at 3 1 1\n",
+ "\n",
+ "\n",
+ "the value after 0 iteration is : 2.991240\t 1.010540\t 1.003860\t\n",
+ "\n",
+ "\n",
+ "the value after 1 iteration is : 2.997200\t 1.001665\t 1.000893\t\n",
+ "\n",
+ "\n",
+ "the value after 2 iteration is : 2.999174\t 1.000430\t 1.000251\t\n",
+ "\n",
+ "\n",
+ "the value after 3 iteration is : 2.999486\t 1.000191\t 1.000141\t\n",
+ "\n",
+ "\n",
+ "the value after 4 iteration is : 2.999545\t 1.000149\t 1.000121\t\n",
+ "\n",
+ "\n",
+ "again we conclude that roots converges at 3 1 1\n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.15:pg-285"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#eigenvalues and eigenvectors\n",
+ "#example 7.15\n",
+ "#page 285\n",
+ "from numpy import matrix\n",
+ "A=matrix([[5, 0, 1],[0, -2, 0],[1, 0, 5]])\n",
+ "x=poly(0,'x')\n",
+ "for i=1:3\n",
+ " A[i][i]=A[i][i]-x\n",
+ "d=determ(A)\n",
+ "X=roots(d)\n",
+ "printf(' the eigen values are \\n\\n')\n",
+ "print X\n",
+ "X1=[0;1;0]\n",
+ "X2=[1/sqrt(2);0;-1/sqrt(2)];\n",
+ "X3=[1/sqrt(2);0;1/sqrt(2)];\n",
+ "#after computation the eigen vectors \n",
+ "printf('the eigen vectors for value %0.2g is',X(3));\n",
+ "disp(X1);\n",
+ "printf('the eigen vectors for value %0.2g is',X(2));\n",
+ "disp(X2);\n",
+ "printf('the eigen vectors for value %0.2g is',X(1));\n",
+ "disp(X3);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.16:pg-286"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#largest eigenvalue and eigenvectors\n",
+ "#example 7.16\n",
+ "#page 286\n",
+ "from numpy import matrix\n",
+ "A=matrix([[1,6,1],[1,2,0],[0,0,3]])\n",
+ "I=matrix([[1],[0],[0]]) #initial eigen vector\n",
+ "X0=A*I\n",
+ "print \"X0=\"\n",
+ "print X0\n",
+ "X1=A*X0\n",
+ "print \"X1=\"\n",
+ "print X1\n",
+ "X2=A*X1\n",
+ "print \"X2=\"\n",
+ "print X2\n",
+ "X3=X2/3\n",
+ "print \"X3=\"\n",
+ "print X3\n",
+ "X4=A*X3\n",
+ "X5=X4/4\n",
+ "print \"X5=\"\n",
+ "print X5\n",
+ "X6=A*X5;\n",
+ "X7=X6/(4*4)\n",
+ "print \"X7=\"\n",
+ "print X7\n",
+ "print \"as it can be seen that highest eigen value is 4 \\n\\n the eigen vector is %d %d %d\" %(X7[0],X7[1],X7[2])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "X0=\n",
+ "[[1]\n",
+ " [1]\n",
+ " [0]]\n",
+ "X1=\n",
+ "[[7]\n",
+ " [3]\n",
+ " [0]]\n",
+ "X2=\n",
+ "[[25]\n",
+ " [13]\n",
+ " [ 0]]\n",
+ "X3=\n",
+ "[[8]\n",
+ " [4]\n",
+ " [0]]\n",
+ "X5=\n",
+ "[[8]\n",
+ " [4]\n",
+ " [0]]\n",
+ "X7=\n",
+ "[[2]\n",
+ " [1]\n",
+ " [0]]\n",
+ "as it can be seen that highest eigen value is 4 \n",
+ "\n",
+ " the eigen vector is 2 1 0\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.17:pg-290"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#housrholder's method\n",
+ "#example 7.17\n",
+ "#page 290\n",
+ "from numpy import matrix\n",
+ "from __future__ import division\n",
+ "import math\n",
+ "A=[[1, 3, 4],[3, 2, -1],[4, -1, 1]]\n",
+ "print A[1][1]\n",
+ "S=math.sqrt(A[0][1]**2+A[0][2]**2)\n",
+ "v2=math.sqrt((1+A[0][1]/S)/2)\n",
+ "v3=A[0][2]/(2*S)\n",
+ "v3=v3/v2\n",
+ "V=matrix([[0],[v2],[v3]])\n",
+ "P1=matrix([[1, 0, 0],[0, 1-2*v2**2, -2*v2*v3],[0, -2*v2*v3, 1-2*v3**2]])\n",
+ "A1=P1*A*P1\n",
+ "print \"the reduced matrix is \\n\\n\"\n",
+ "print A1\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n",
+ "the reduced matrix is \n",
+ "\n",
+ "\n",
+ "[[ 1.00000000e+00 -5.00000000e+00 -8.88178420e-16]\n",
+ " [ -5.00000000e+00 4.00000000e-01 2.00000000e-01]\n",
+ " [ -8.88178420e-16 2.00000000e-01 2.60000000e+00]]\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter8_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter8_6.ipynb new file mode 100644 index 00000000..096975e3 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter8_6.ipynb @@ -0,0 +1,1090 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:3a982f2a12061f576aa7809dc18f7d12a7589044372f56c0ffeb093648d01eff"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter08:Numerical Solution of Ordinary Differential Equations"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.1:pg-304"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.1\n",
+ "#taylor's method\n",
+ "#page 304\n",
+ "import math\n",
+ "f=1 #value of function at 0\n",
+ "def f1(x):\n",
+ " return x-f**2\n",
+ "def f2(x):\n",
+ " return 1-2*f*f1(x)\n",
+ "def f3(x):\n",
+ " return -2*f*f2(x)-2*f2(x)**2\n",
+ "def f4(x):\n",
+ " return -2*f*f3(x)-6*f1(x)*f2(x)\n",
+ "def f5(x):\n",
+ " return -2*f*f4(x)-8*f1(x)*f3(x)-6*f2(x)**2\n",
+ "h=0.1 #value at 0.1\n",
+ "k=f \n",
+ "for j in range(1,5):\n",
+ " if j==1:\n",
+ " k=k+h*f1(0);\n",
+ " elif j==2:\n",
+ " k=k+(h**j)*f2(0)/math.factorial(j)\n",
+ " elif j ==3:\n",
+ " k=k+(h**j)*f3(0)/math.factorial(j)\n",
+ " elif j ==4:\n",
+ " k=k+(h**j)*f4(0)/math.factorial(j)\n",
+ " elif j==5:\n",
+ " k=k+(h**j)*f5(0)/math.factorial(j)\n",
+ "print \"the value of the function at %.2f is :%0.4f\" %(h,k)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of the function at 0.10 is :0.9113\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.2:pg-304"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#taylor's method\n",
+ "#example 8.2\n",
+ "#page 304\n",
+ "import math\n",
+ "f=1 #value of function at 0\n",
+ "f1=0 #value of first derivatie at 0\n",
+ "def f2(x):\n",
+ " return x*f1+f\n",
+ "def f3(x):\n",
+ " return x*f2(x)+2*f1\n",
+ "def f4(x):\n",
+ " return x*f3(x)+3*f2(x)\n",
+ "def f5(x):\n",
+ " return x*f4(x)+4*f3(x)\n",
+ "def f6(x):\n",
+ " return x*f5(x)+5*f4(x)\n",
+ "h=0.1 #value at 0.1\n",
+ "k=f\n",
+ "for j in range(1,6):\n",
+ " if j==1:\n",
+ " k=k+h*f1\n",
+ " elif j==2:\n",
+ " k=k+(h**j)*f2(0)/math.factorial(j)\n",
+ " elif j ==3:\n",
+ " k=k+(h**j)*f3(0)/math.factorial(j)\n",
+ " elif j ==4:\n",
+ " k=k+(h**j)*f4(0)/math.factorial(j)\n",
+ " elif j==5:\n",
+ " k=k+(h**j)*f5(0)/math.factorial(j)\n",
+ " else:\n",
+ " k=k+(h**j)*f6(0)/math.factorial (j)\n",
+ "print \"the value of the function at %.2f is :%0.7f\" %(h,k)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of the function at 0.10 is :1.0050125\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.3:pg-306"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.3\n",
+ "#picard's method\n",
+ "#page 306\n",
+ "from scipy import integrate\n",
+ "from __future__ import division\n",
+ "def f(x,y):\n",
+ " return x+y**2\n",
+ "y=[0,0,0,0]\n",
+ "y[1]=1\n",
+ "for i in range(1,3):\n",
+ " a=integrate.quad(lambda x:x+y[i]**2,0,i/10)\n",
+ " y[i+1]=a[0]+y[1]\n",
+ " print \"\\n y (%g) = %g\\n\" %(i/10,y[i+1])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y (0.1) = 1.105\n",
+ "\n",
+ "\n",
+ " y (0.2) = 1.26421\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.4:pg-306"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.4\n",
+ "#picard's method\n",
+ "#page 306\n",
+ "from scipy import integrate\n",
+ "y=[0,0,0,0] #value at 0\n",
+ "c=0.25\n",
+ "for i in range(0,3):\n",
+ " a=integrate.quad(lambda x:(x**2/(y[i]**2+1)),0,c)\n",
+ " y[i+1]=y[0]+a[0]\n",
+ " print \"\\n y(%0.2f) = %g\\n\" %(c,y[i+1])\n",
+ " c=c*2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y(0.25) = 0.00520833\n",
+ "\n",
+ "\n",
+ " y(0.50) = 0.0416655\n",
+ "\n",
+ "\n",
+ " y(1.00) = 0.332756\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.5:pg-308"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.5\n",
+ "#euler's method\n",
+ "#page 308\n",
+ "def f(y):\n",
+ " return -1*y\n",
+ "y=[0,0,0,0,0]\n",
+ "y[0]=1 #value at 0\n",
+ "h=0.01\n",
+ "c=0.01\n",
+ "for i in range(0,4):\n",
+ " y[i+1]=y[i]+h*f(y[i])\n",
+ " print \"\\ny(%g)=%g\\n\" %(c,y[i+1])\n",
+ " c=c+0.01\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "y(0.01)=0.99\n",
+ "\n",
+ "\n",
+ "y(0.02)=0.9801\n",
+ "\n",
+ "\n",
+ "y(0.03)=0.970299\n",
+ "\n",
+ "\n",
+ "y(0.04)=0.960596\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.6:pg-308"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.6\n",
+ "#error estimates in euler's \n",
+ "#page 308\n",
+ "from __future__ import division\n",
+ "def f(y):\n",
+ " return -1*y\n",
+ "y=[0,0,0,0,0]\n",
+ "L=[0,0,0,0,0]\n",
+ "e=[0,0,0,0,0]\n",
+ "y[0]=1 #value at 0\n",
+ "h=0.01\n",
+ "c=0.01;\n",
+ "for i in range(0,4):\n",
+ " y[i+1]=y[i]+h*f(y[i])\n",
+ " print \"\\ny(%g)=%g\\n\" %(c,y[i+1])\n",
+ " c=c+0.01\n",
+ "for i in range(0,4):\n",
+ " L[i]=abs(-(1/2)*(h**2)*y[i+1])\n",
+ " print \"L(%d) =%f\\n\\n\" %(i,L[i])\n",
+ "e[0]=0\n",
+ "for i in range(0,4):\n",
+ " e[i+1]=abs(y[1]*e[i]+L[0])\n",
+ " print \"e(%d)=%f\\n\\n\" %(i,e[i])\n",
+ "Actual_value=math.exp(-0.04)\n",
+ "Estimated_value=y[4]\n",
+ "err=abs(Actual_value-Estimated_value)\n",
+ "if err<e[4]:\n",
+ " print \"VERIFIED\"\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "y(0.01)=0.99\n",
+ "\n",
+ "\n",
+ "y(0.02)=0.9801\n",
+ "\n",
+ "\n",
+ "y(0.03)=0.970299\n",
+ "\n",
+ "\n",
+ "y(0.04)=0.960596\n",
+ "\n",
+ "L(0) =0.000050\n",
+ "\n",
+ "\n",
+ "L(1) =0.000049\n",
+ "\n",
+ "\n",
+ "L(2) =0.000049\n",
+ "\n",
+ "\n",
+ "L(3) =0.000048\n",
+ "\n",
+ "\n",
+ "e(0)=0.000000\n",
+ "\n",
+ "\n",
+ "e(1)=0.000050\n",
+ "\n",
+ "\n",
+ "e(2)=0.000099\n",
+ "\n",
+ "\n",
+ "e(3)=0.000147\n",
+ "\n",
+ "\n",
+ "VERIFIED\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.7:pg-310"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.7\n",
+ "#modified euler's method\n",
+ "#page 310\n",
+ "h=0.05\n",
+ "f=1\n",
+ "def f1(x,y):\n",
+ " return x**2+y\n",
+ "x=[0,0.05,0.1]\n",
+ "y1=[0,0,0,0]\n",
+ "y2=[0,0,0,0]\n",
+ "y1[0]=f+h*f1(x[0],f);\n",
+ "y1[1]=f+h*(f1(x[0],f)+f1(x[1],y1[0]))/2\n",
+ "y1[2]=f+h*(f1(x[0],f)+f1(x[2],y1[1]))/2\n",
+ "y2[0]=y1[1]+h*f1(x[1],y1[1])\n",
+ "y2[1]=y1[1]+h*(f1(x[1],y1[1])+f1(x[2],y2[0]))/2\n",
+ "y2[2]=y1[1]+h*(f1(x[1],y1[1])+f1(x[2],y2[1]))/2\n",
+ "print \"y1(0)\\t y1(1)\\t y1(2)\\t y2(0)\\t y2(1)\\t y3(2)\\n\\n\"\n",
+ "print \" %f\\t %f\\t %f\\t %f\\t %f\\t %f\\n\" %(y1[0],y1[1],y1[2],y2[0],y2[1],y2[2])\n",
+ "print \"\\n\\n the value of y at %0.2f is : %0.4f\" %(x[2],y2[2])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "y1(0)\t y1(1)\t y1(2)\t y2(0)\t y2(1)\t y3(2)\n",
+ "\n",
+ "\n",
+ " 1.050000\t 1.051313\t 1.051533\t 1.104003\t 1.105508\t 1.105546\n",
+ "\n",
+ "\n",
+ "\n",
+ " the value of y at 0.10 is : 1.1055\n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.8:pg-313"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.8\n",
+ "#runge-kutta formula\n",
+ "#page 313\n",
+ "from __future__ import division\n",
+ "def f(x,y):\n",
+ " return y-x\n",
+ "y=2\n",
+ "x=0\n",
+ "h=0.1\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h,y+K1)\n",
+ "y1=y+( K1+K2)/2\n",
+ "print \"\\n y(0.1) by second order runge kutta method:%0.4f\" %(y1)\n",
+ "y=y1\n",
+ "x=0.1\n",
+ "h=0.1\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h,y+K1)\n",
+ "y1=y+( K1+K2)/2\n",
+ "print \"\\n y(0.2) by second order runge kutta method:%0.4f\" %(y1)\n",
+ "y=2\n",
+ "x=0\n",
+ "h=0.1\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.1) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=y1\n",
+ "x=0.1\n",
+ "h=0.1\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.1) by fourth order runge kutta method:%0.4f \" %(y1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y(0.1) by second order runge kutta method:2.2050\n",
+ "\n",
+ " y(0.2) by second order runge kutta method:2.4210\n",
+ "\n",
+ " y(0.1) by fourth order runge kutta method:2.2052\n",
+ "\n",
+ " y(0.1) by fourth order runge kutta method:2.4214 \n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.9:pg-315"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.9\n",
+ "#runge kutta method\n",
+ "#page 315\n",
+ "from __future__ import division\n",
+ "def f(x,y):\n",
+ " return 1+y**2\n",
+ "y=0\n",
+ "x=0\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.2) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=y1\n",
+ "x=0.2\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.4) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=2\n",
+ "x=0\n",
+ "h=0.1\n",
+ "y=y1\n",
+ "x=0.4\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.6) by fourth order runge kutta method:%0.4f\" %(y1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y(0.2) by fourth order runge kutta method:0.2027\n",
+ "\n",
+ " y(0.4) by fourth order runge kutta method:0.4228\n",
+ "\n",
+ " y(0.6) by fourth order runge kutta method:0.6841\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.10:pg-315"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.10\n",
+ "#initial value problems\n",
+ "#page 315\n",
+ "from __future__ import division\n",
+ "def f1(x,y):\n",
+ " return 3*x+y/2\n",
+ "y=[1,0,0]\n",
+ "h=0.1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " y[i+1]=y[i]+h*f1(c,y[i])\n",
+ " print \"\\ny(%g)=%g\\n\" %(c,y[i])\n",
+ " c=c+0.1\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "y(0)=1\n",
+ "\n",
+ "\n",
+ "y(0.1)=1.05\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.11:pg-316"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.11\n",
+ "#adam's moulton method\n",
+ "#page 316\n",
+ "def f(x,y):\n",
+ " return 1+y**2\n",
+ "y=0\n",
+ "x=0\n",
+ "h=0.2\n",
+ "f1=[0,0,0]\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[0]=y1\n",
+ "print \"\\n y(0.2) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=y1\n",
+ "x=0.2\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[1]=y1\n",
+ "print \"\\n y(0.4) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=2\n",
+ "x=0\n",
+ "h=0.1\n",
+ "y=y1\n",
+ "x=0.4\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[2]=y1\n",
+ "print \"\\n y(0.6) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y_p=y1+h*(55*(1+f1[2]**2)-59*(1+f1[1]**2)+37*(1+f1[0]**2)-9)/24\n",
+ "y_c=y1+h*(9*(1+(y_p-1)**2)+19*(1+f1[2]**2)-5*(1+f1[1]**2)+(1+f1[0]**2))/24\n",
+ "print \"\\nthe predicted value is:%0.4f:\\n\" %(y_p)\n",
+ "print \" the computed value is:%0.4f:\" %(y_c)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y(0.2) by fourth order runge kutta method:0.2027\n",
+ "\n",
+ " y(0.4) by fourth order runge kutta method:0.4228\n",
+ "\n",
+ " y(0.6) by fourth order runge kutta method:0.6841\n",
+ "\n",
+ "the predicted value is:1.0234:\n",
+ "\n",
+ " the computed value is:0.9512:\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.12:pg-320"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.12\n",
+ "#milne's method\n",
+ "#page 320\n",
+ "def f(x,y):\n",
+ " return 1+y**2\n",
+ "y=0\n",
+ "f1=[0,0,0]\n",
+ "Y1=[0,0,0,0]\n",
+ "x=0\n",
+ "h=0.2\n",
+ "f1[0]=0\n",
+ "print \"x y y1=1+y^2\\n\\n\"\n",
+ "Y1[0]=1+y**2\n",
+ "print \"%0.4f %0.4f %0.4f\\n\" %(x,y,(1+y**2))\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[0]=y1\n",
+ "Y1[1]=1+y1**2\n",
+ "print \"%0.4f %0.4f %0.4f\\n\" %(x+h,y1,(1+y1**2))\n",
+ "y=y1\n",
+ "x=0.2\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[1]=y1\n",
+ "Y1[2]=1+y1**2\n",
+ "print \"%0.4f %0.4f %0.4f\\n\" %(x+h,y1,(1+y1**2))\n",
+ "y=y1\n",
+ "x=0.4\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[2]=y1\n",
+ "Y1[3]=1+y1**2;\n",
+ "print \"%0.4f %0.4f %0.4f\\n\" %(x+h,y1,(1+y1**2))\n",
+ "Y_4=4*h*(2*Y1[1]-Y1[2]+2*Y1[3])/3\n",
+ "print \"y(0.8)=%f\\n\" %(Y_4)\n",
+ "Y=1+Y_4**2\n",
+ "Y_4=f1[1]+h*(Y1[2]+4*Y1[3]+Y)/3 #more correct value\n",
+ "print \"y(0.8)=%f\\n\" %(Y_4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x y y1=1+y^2\n",
+ "\n",
+ "\n",
+ "0.0000 0.0000 1.0000\n",
+ "\n",
+ "0.2000 0.2027 1.0411\n",
+ "\n",
+ "0.4000 0.4228 1.1788\n",
+ "\n",
+ "0.6000 0.6841 1.4680\n",
+ "\n",
+ "y(0.8)=1.023869\n",
+ "\n",
+ "y(0.8)=1.029403\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.13:pg-320"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.13\n",
+ "#milne's method\n",
+ "#page 320\n",
+ "def f1(x,y):\n",
+ " return x**2+y**2-2\n",
+ "x=[-0.1, 0, 0.1, 0.2]\n",
+ "y=[1.0900, 1.0, 0.8900, 0.7605]\n",
+ "Y1=[0,0,0,0]\n",
+ "h=0.1\n",
+ "for i in range(0,4):\n",
+ " Y1[i]=f1(x[i],y[i])\n",
+ "print \" x y y1=x^2+y^2-2 \\n\\n\"\n",
+ "for i in range(0,4):\n",
+ " print \" %0.2f %f %f \\n\" %(x[i],y[i],Y1[i])\n",
+ "Y_3=y[0]+(4*h/3)*(2*Y1[1]-Y1[2]+2*Y1[3])\n",
+ "print \"y(0.3)=%f\\n\" %(Y_3)\n",
+ "Y1_3=f1(0.3,Y_3)\n",
+ "Y_3=y[2]+h*(Y1[2]+4*Y1[3]+Y1_3)/3 #corrected value\n",
+ "print \"corrected y(0.3)=%f\" %(Y_3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " x y y1=x^2+y^2-2 \n",
+ "\n",
+ "\n",
+ " -0.10 1.090000 -0.801900 \n",
+ "\n",
+ " 0.00 1.000000 -1.000000 \n",
+ "\n",
+ " 0.10 0.890000 -1.197900 \n",
+ "\n",
+ " 0.20 0.760500 -1.381640 \n",
+ "\n",
+ "y(0.3)=0.614616\n",
+ "\n",
+ "corrected y(0.3)=0.614776\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.14:pg322"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.14\n",
+ "#initial-value problem\n",
+ "#page 322\n",
+ "from __future__ import division\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 13*math.exp(x/2)-6*x-12\n",
+ "s1=1.691358\n",
+ "s3=3.430879\n",
+ "print \"the erorr in the computed values are %0.7g %0.7g\" %(abs(f(0.5)-s1),abs(f(1)-s3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the erorr in the computed values are 0.0009724169 0.002497519\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.15:pg-328"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#boundary value problem using finite difference method\n",
+ "#example 8.15\n",
+ "#page 328\n",
+ "import math\n",
+ "from numpy import matrix\n",
+ "def f(x):\n",
+ " return math.cos(x)+((1-math.cos(1))/math.sin(1))*math.sin(x)-1\n",
+ "h1=1/2\n",
+ "Y=f(0.5)\n",
+ "y0=0\n",
+ "y2=0\n",
+ "y1=4*(1/4+y0+y2)/7\n",
+ "print \"computed value with h=%f of y(0.5) is %f\\n\" %(h1,y1)\n",
+ "print \"error in the result with actual value %f\\n\" %(abs(Y-y1))\n",
+ "h2=1/4\n",
+ "y0=0\n",
+ "y4=0\n",
+ "#solving the approximated diffrential equation\n",
+ "A=matrix([[-31/16, 1, 0],[1, -31/16, 1],[0, 1, -31/16]])\n",
+ "X=matrix([[-1/16],[-1/16],[-1/16]])\n",
+ "C=A.I*X\n",
+ "print \"computed value with h=%f of y(0.5) is %f\\n\" %(h2,C[1][0])\n",
+ "print \"error in the result with actual value %f\\n\" %(abs(Y-C[1][0]))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "computed value with h=0.500000 of y(0.5) is 0.142857\n",
+ "\n",
+ "error in the result with actual value 0.003363\n",
+ "\n",
+ "computed value with h=0.250000 of y(0.5) is 0.140312\n",
+ "\n",
+ "error in the result with actual value 0.000818\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.16:pg-329"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#boundary value problem using finite difference method\n",
+ "#example 8.16\n",
+ "#page 329\\\n",
+ "from numpy import matrix\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.sinh(x)\n",
+ "y0=0 #y(0)=0\n",
+ "y4=3.62686 #y(2)=3.62686\n",
+ "h1=0.5\n",
+ "Y=f(0.5)\n",
+ "#arranging and calculating the values\n",
+ "A=matrix([[-9, 4, 0],[4, -9, 4],[0, 4, -9]])\n",
+ "C=matrix([[0],[0],[-14.50744]])\n",
+ "X=A.I*C\n",
+ "print \"computed value with h=%f of y(0.5) is %f\\n\" %(h1,X[0][0])\n",
+ "print \"error in the result with actual value %f\\n\" %(abs(Y-X[0][0]))\n",
+ "h2=1.0\n",
+ "y0=0 #y(0)=0\n",
+ "y2=3.62686 #y(2)=3.62686\n",
+ "y1=(y0+y2)/3\n",
+ "Y=(4*X[1][0]-y1)/3\n",
+ "print \"with better approximation error is reduced to %f\" %(abs(Y-f(1.0)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "computed value with h=0.500000 of y(0.5) is 0.526347\n",
+ "\n",
+ "error in the result with actual value 0.005252\n",
+ "\n",
+ "with better approximation error is reduced to 0.000855\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.17:pg-330"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline method\n",
+ "#example 8.17\n",
+ "#page 330\n",
+ "def f(x):\n",
+ " return math.cos(x)+((1-math.cos(1))/math.sin(1))*math.sin(x)-1\n",
+ "y=[f(0), f(0.5), f(1)]\n",
+ "h=1/2\n",
+ "Y=f(0.5)\n",
+ "y0=0\n",
+ "y2=0\n",
+ "M0=-1\n",
+ "M1=-22/25\n",
+ "M2=-1\n",
+ "s1_0=47/88\n",
+ "s1_1=-47/88\n",
+ "s1_05=0\n",
+ "print \"the cubic spline value is %f\" %(Y)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the cubic spline value is 0.139494\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.18:pg-331"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline method\n",
+ "#example 8.18\n",
+ "#page 331\n",
+ "from numpy import matrix\n",
+ "from __future__ import division\n",
+ "#after arranging and forming equation \n",
+ "A=matrix([[10, -1, 0, 24],[0, 16, -1, -32],[1, 20, 0, 16],[0, 1, 26, -24]])\n",
+ "C=matrix([[36],[-12],[24],[-9]])\n",
+ "X=A.I*C;\n",
+ "print \" Y1=%f\\n\\n\" %(X[3][0])\n",
+ "print \" the error in the solution is :%f\" %(abs((2/3)-X[3][0]))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Y1=0.653890\n",
+ "\n",
+ "\n",
+ " the error in the solution is :0.012777\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.19:pg-331"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#boundary value problem by cubisc spline nethod\n",
+ "#example 8.18\n",
+ "#page 331\n",
+ "from numpy import matrix\n",
+ "h=1/2\n",
+ "#arranging in two subintervals we get\n",
+ "A=matrix([[10, -1, 0,24],[0, 16, -1, -32],[1, 20, 0, 16],[0, 1, 26, -24]])\n",
+ "C=matrix([[36],[-12],[24],[-9]])\n",
+ "X=A.I*C\n",
+ "print \"the computed value of y(1.5) is %f \"%(X[3][0])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the computed value of y(1.5) is 0.653890 \n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter_5_6.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter_5_6.ipynb new file mode 100644 index 00000000..f7ae1b31 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter_5_6.ipynb @@ -0,0 +1,358 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:d6c77d0644ce8c4a3cef684a9d4884ca9577630ae40ac3764bbf1d6682f47c3d"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter05:Spline Functions"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.1:pg-182"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#linear splines\n",
+ "#example 5.1\n",
+ "#page 182\n",
+ "from numpy import matrix\n",
+ "X=matrix([[1],[2], [3]])\n",
+ "y=matrix([[-8],[-1],[18]])\n",
+ "m1=(y[1][0]-y[0][0])/(X[1][0]-X[0][0])\n",
+ "m2=(y[2][0]-y[1][0])/(X[2][0]-X[1][0])\n",
+ "def s1(x):\n",
+ " return y[0][0]+(x-X[0][0])*m1\n",
+ "def s2(x):\n",
+ " return y[1][0]+(x-X[1][0])*m2\n",
+ "print \"the value of function at 2.5 is %0.2f: \" %(s2(2.5))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of function at 2.5 is 8.50: \n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.3:pg-188"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic splines\n",
+ "#example 5.3\n",
+ "#page 188\n",
+ "from numpy import matrix\n",
+ "import math\n",
+ "X=matrix([[1],[2],[3]])\n",
+ "y=matrix([[-8],[-1],[18]])\n",
+ "M1=0\n",
+ "M2=8\n",
+ "M3=0\n",
+ "h=1\n",
+ "#deff('y=s1(x)','y=3*(x-1)^3-8*(2-x)-4*(x-1)')\n",
+ "def s1(x):\n",
+ " return 3*math.pow(x-1,3)-8*(2-x)-4*(x-1)\n",
+ "#deff('y=s2(x)','y=3*(3-x)^3+22*x-48');\n",
+ "def s2(x):\n",
+ " return 3*math.pow(3-x,3)+22*x-48\n",
+ "h=0.0001\n",
+ "n=2.0\n",
+ "D=(s2(n+h)-s2(n))/h;\n",
+ "print \" y(2.5)=%f\" %(s2(2.5))\n",
+ "print \"y1(2.0)=%f\" %(D)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " y(2.5)=7.375000\n",
+ "y1(2.0)=13.000900\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.4:pg-189"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline\n",
+ "#example 5.4\n",
+ "#page 189\n",
+ "from numpy import matrix\n",
+ "import math\n",
+ "x=matrix([[0],[math.pi/2],[math.pi]])\n",
+ "y=matrix([[0],[1],[0]])\n",
+ "h=x[1][0]-x[0][0]\n",
+ "M0=0\n",
+ "M2=0\n",
+ "M1=((6*(y[0][0]-2*y[1][0]+y[2][0])/math.pow(h,2))-M0-M2)/4\n",
+ "X=math.pi/6.0\n",
+ "s1=(math.pow(x[1][0]-X,3)*(M0/6)+math.pow(X-x[0][0],3)*M1/6+(y[0][0]-math.pow(h,2)*M0/6)*(x[1][0]-X)+(y[1][0]-math.pow(h,2)*M1/6)*(X-x[0][0]))/h;\n",
+ "x=matrix([[0],[math.pi/4], [math.pi/2], [3*math.pi/4], [math.pi]])\n",
+ "y=matrix([[0], [1.414], [1] ,[1.414]])\n",
+ "M0=0\n",
+ "M4=0\n",
+ "A=matrix([[4, 1, 0],[1, 4, 1],[0 ,1 ,4]]) #calculating value of M1 M2 M3 by matrix method\n",
+ "C=matrix([[-4.029],[-5.699],[-4.029]])\n",
+ "B=A.I*C\n",
+ "print \"M0=%f\\t M1=%f\\t M2=%f\\t M3=%f\\t M4=%f\\t\\n\\n\" %(M0,B[0][0],B[1][0],B[2][0],M4)\n",
+ "h=math.pi/4;\n",
+ "X=math.pi/6;\n",
+ "s1=(-0.12408*math.pow(X,3)+0.7836*X)/h;\n",
+ "print \"the value of sin(pi/6) is:%f\" %(s1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "M0=0.000000\t M1=-0.744071\t M2=-1.052714\t M3=-0.744071\t M4=0.000000\t\n",
+ "\n",
+ "\n",
+ "the value of sin(pi/6) is:0.499722\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.5:pg-191"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline\n",
+ "#example 5.5\n",
+ "#page 191\n",
+ "import math\n",
+ "from numpy import matrix\n",
+ "x=[1,2,3]\n",
+ "y=[6,18,42]\n",
+ "m0=40\n",
+ "s1=0\n",
+ "m1=(3*(y[2]-y[0])-m0)/4\n",
+ "X=0\n",
+ "s1=m0*((x[1]-X)**2)*(X-x[0])-m1*((X-x[0])**2)*(x[1]-X)+y[0]*((x[1]-X)**2)*(2*(X-x[0])+1)+y[1]*((X-x[0])**2)*(2*(x[1]-X)+1)\n",
+ "print \"s1= %f+261*x-160X^2+33X^3\" %(s1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "s1= -128.000000+261*x-160X^2+33X^3\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.7:pg-195"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#surface fitting by cubic spline\n",
+ "#example 5.7\n",
+ "#page 195\n",
+ "from numpy import matrix\n",
+ "def L0(y):\n",
+ " return math.pow(y,3)/4-5*y/4+1\n",
+ "def L1(y):\n",
+ " return (math.pow(y,3)/2)*-1+3*y/2\n",
+ "def L2(y):\n",
+ " return math.pow(y,3)/4-y/4\n",
+ "A=[ [1,2,9], [2,3,10], [9,10,17] ]\n",
+ "x=0.5\n",
+ "y=0.5\n",
+ "S=0.0\n",
+ "S=S+L0(x)*(L0(x)*A[0][0]+L1(x)*A[0][1]+L2(x)*A[0][2])\n",
+ "S=S+L1(x)*(L0(x)*A[1][0]+L1(x)*A[1][1]+L2(x)*A[1][2])\n",
+ "S=S+L2(x)*(L0(x)*A[2][0]+L1(x)*A[2][1]+L2(x)*A[2][2])\n",
+ "print \"approximated value of z(0.5 0.5)=%f\\n\\n\" %(S)\n",
+ "print \" error in the approximated value : %f\" %((abs(1.25-S)/1.25)*100)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "approximated value of z(0.5 0.5)=0.875000\n",
+ "\n",
+ "\n",
+ " error in the approximated value : 30.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.8:pg-200"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic B-splines\n",
+ "#example 5.8\n",
+ "#page 200\n",
+ "import math\n",
+ "k=[0.0, 1, 2, 3, 4]\n",
+ "pi=[0.0, 0, 4, -6, 24]\n",
+ "x=1\n",
+ "S=0\n",
+ "for i in range(2,5):\n",
+ " S=S+math.pow(k[i]-x,3)/(pi[i])\n",
+ "print \"the cubic splines for x=1 is %f\\n\\n\" %(S)\n",
+ "S=0\n",
+ "x=2\n",
+ "for i in range(2,5):\n",
+ " S=S+math.pow(k[i]-x,3)/(pi[i])\n",
+ "print \"the cubic splines for x=2 is %f\\n\\n\" %(S)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the cubic splines for x=1 is 0.041667\n",
+ "\n",
+ "\n",
+ "the cubic splines for x=2 is 0.166667\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 39
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.9:pg-201"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic B-spline\n",
+ "#example 5.9\n",
+ "#page 201\n",
+ "k=[0, 1, 2, 3, 4];\n",
+ "x=1 #for x=1\n",
+ "s11=0\n",
+ "s13=0\n",
+ "s14=0\n",
+ "s24=0 \n",
+ "s12=1/(k[2]-k[1])\n",
+ "s22=((x-k[0])*s11+(k[2]-x)*s12)/2.0 #k[2]-k[0]=2\n",
+ "s23=((x-k[1])*s11+(k[3]-x)*s13)/(k[3]-k[1])\n",
+ "s33=((x-k[0])*s22+(k[3]-x)*s23)/(k[3]-k[0])\n",
+ "s34=((x-k[1])*s23+(k[4]-x)*s24)/(k[4]-k[1])\n",
+ "s44=((x-k[0])*s33+(k[4]-x)*s34)/(k[4]-k[0])\n",
+ "print \"s11=%f\\t s22=%f\\t s23=%f\\t s33=%f\\t s34=%f\\t s44=%f\\n\\n\" %(s11,s22,s23,s33,s34,s44)\n",
+ "x=2 #for x=2\n",
+ "s11=0\n",
+ "s12=0\n",
+ "s14=0\n",
+ "s22=0\n",
+ "s13=1/(k[3]-k[2])\n",
+ "s23=((x-k[1])*s12+(k[3]-x)*s13)/2.0 # k[3]-k[1]=2\n",
+ "s24=((x-k[2])*s13+(k[4]-x)*s14)/(k[2]-k[0])\n",
+ "s33=((x-k[0])*s22+(k[3]-x)*s23)/(k[3]-k[0])\n",
+ "s34=((x-k[1])*s23+(k[4]-x)*s24)/(k[4]-k[1])\n",
+ "s44=((x-k[0])*s33+(k[4]-x)*s34)/(k[4]-k[0])\n",
+ "print \"s13=%f\\t s23=%f\\t s24=%f\\t s33=%f\\t s34=%f\\t s44=%f\\n\\n\" %(s13,s23,s24,s33,s34,s44)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "s11=0.000000\t s22=0.500000\t s23=0.000000\t s33=0.166667\t s34=0.000000\t s44=0.041667\n",
+ "\n",
+ "\n",
+ "s13=1.000000\t s23=0.500000\t s24=0.000000\t s33=0.166667\t s34=0.166667\t s44=0.166667\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/1.2_1.png b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/1.2_1.png Binary files differnew file mode 100644 index 00000000..2af775d8 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/1.2_1.png diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/3.7_1.png b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/3.7_1.png Binary files differnew file mode 100644 index 00000000..30f2ed11 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/3.7_1.png diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/6.7_1.png b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/6.7_1.png Binary files differnew file mode 100644 index 00000000..524c2a6a --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/6.7_1.png diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter11_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter11_4.ipynb new file mode 100644 index 00000000..0bf83b2e --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter11_4.ipynb @@ -0,0 +1,76 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:732d8b53b905e9628a3915cdb529a16e94d453d40d081213ccbffa2aa86b0393"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 11: Transducers as Input Elements to Instrumentation Systems"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex11.1:pg-317"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find change in resistance\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 11-1 in Page 317\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "K =2 #Gauge factor \n",
+ "s = 1050 #stress in kg/cm**2\n",
+ "E = 2.1*10**6 #modulus of elasticity of steel in kg/cm**2\n",
+ "\n",
+ "#Calculations\n",
+ "strain = s/E #Hooke's law\n",
+ "change_in_resistance = K*strain\n",
+ "percentchange = change_in_resistance * 100\n",
+ "\n",
+ "print \"The change in resistance = \",round(change_in_resistance,3)\n",
+ "print \"The percentage change in resistance = \",round(percentchange,1),\"%\"\n",
+ "\n",
+ "#Result\n",
+ "# The change in resistance = 0.001\n",
+ "# The percentage change in resistance = 0.1 % \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The change in resistance = 0.001\n",
+ "The percentage change in resistance = 0.1 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter12_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter12_4.ipynb new file mode 100644 index 00000000..ba4c5524 --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter12_4.ipynb @@ -0,0 +1,80 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:ab1af8c906dca7a8603fae32bb19352b76cb16633983b0c27f5e885cd15f2c9d"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 12:Analog and Digital Data Acquisition Systems"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex12.1:pg-360"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find percentage error\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 12-1 in Page 360\n",
+ "\n",
+ "\n",
+ "\n",
+ "import math\n",
+ "\n",
+ "# Given data\n",
+ "R = 1 #Resistance of the wire in ohm\n",
+ "R_L = 10*10**3 #Load resistance in ohm\n",
+ "I_supply = 50*10**-3 #power supply current in A\n",
+ "V_out = 1 #output of the amplifier in V\n",
+ "\n",
+ "#Calculations\n",
+ "V_L = (V_out+(I_supply*R))*R_L/(2*R+R_L)\n",
+ "print \"The load voltage calculated = \",round(V_L,2)\n",
+ "\n",
+ "percenterror = math.ceil((V_L -V_out)/V_L*100)\n",
+ "print \"The percentage error is about \",round(percenterror),\"%, which is unacceptable in most systems\"\n",
+ "\n",
+ "#Result\n",
+ "# The load voltage calculated = 1.05\n",
+ "# The percentage error is about 5 %, which is unacceptable in most systems \n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The load voltage calculated = 1.05\n",
+ "The percentage error is about 5.0 %, which is unacceptable in most systems\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter14_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter14_4.ipynb new file mode 100644 index 00000000..50e462df --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter14_4.ipynb @@ -0,0 +1,238 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:7da8fa256cdbc53a73e82048dec92ae378065cdecb2b93cd68e82575348dba15"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 14:Fiber Optics Measurements"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex14.1:pg-392"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find acceptance angle and numerical aperture\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 14-1 in Page 392\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "n_2 = 1.45 #Core index of refraction\n",
+ "n_1 = 1.47 #Cladding index of refraction\n",
+ "\n",
+ "#Calculation\n",
+ "theta_c = math.acos(n_2/n_1)\n",
+ "theta_A = 2*math.asin(n_1*math.sin(theta_c))\n",
+ "NA = math.sqrt(n_1**2 -n_2**2)\n",
+ "\n",
+ "print \"The critical angle of the fiber =\",round(theta_c*180/math.pi,2),\"degree\\n\"\n",
+ "print \"The acceptance angle of the fiber =\",round(theta_A*180/math.pi,2),\" degree\\n\"\n",
+ "print \"The numerical aperture of the fiber = \",round(NA,3)\n",
+ "\n",
+ "#Result\n",
+ "# The critical angle of the fiber = 9.46 degree\n",
+ "# The acceptance angle of the fiber = 27.97 degree\n",
+ "# The numerical aperture of the fiber = 0.242 \n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The critical angle of the fiber = 9.46 degree\n",
+ "\n",
+ "The acceptance angle of the fiber = 27.97 degree\n",
+ "\n",
+ "The numerical aperture of the fiber = 0.242\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex14.2:pg-393"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find loss in the fiber\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 14-2 in Page 393\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "NA_1 = 0.3 # numerical apertures of Source fiber\n",
+ "NA_2 = 0.242 #numerical apertures of receiving fiber\n",
+ "\n",
+ "#Calculations\n",
+ "loss = 20*math.log10(NA_1/NA_2)\n",
+ "print \"The energy that is lost through the cladding of the receiving fiber = \",round(loss,2),\" dB\"\n",
+ "\n",
+ "#Result\n",
+ "# The energy that is lost through the cladding of the receiving fiber = 1.87 dB \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The energy that is lost through the cladding of the receiving fiber = 1.87 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex14.3:pg-395"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find current developed in photodiode\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 14-3 in Page 395\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "h = 6.63*10**-34 #Planck's constant\n",
+ "c = 3*10**8 #Speed of light in m/s\n",
+ "Lambda = 1.3*10**-6 # photon wavelength in m\n",
+ "QE = 0.82 #Quantum efficiency\n",
+ "p = 75*10**-6 #Power in W\n",
+ "q = 1.6*10**-19 #Charge of an electron\n",
+ "\n",
+ "#Calculations\n",
+ "e = h*c/Lambda\n",
+ "N = p/e\n",
+ "N_QE= QE*N\n",
+ "I = N_QE*q\n",
+ "print \"The current developed in a PIN photodiode = \",round(I,7),\" A\"\n",
+ "\n",
+ "#Result\n",
+ "# The current developed in a PIN photodiode = 6.43e-05 A \n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The current developed in a PIN photodiode = 6.43e-05 A\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex14.4:pg-401"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find elapsed time\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 14-4 in Page 401\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "n = 1.55 #index of refraction \n",
+ "c = 3*10**8 #speed of light in m/s\n",
+ "d = 1.4*10**3 #Distance in m\n",
+ "\n",
+ "#Calculations\n",
+ "v = c/n\n",
+ "t = d/v\n",
+ "print \"t = \",round(t,7),\"s\"\n",
+ "print \"Since twice the time to reach the break is required for the reflection to arrive at the reflectometer,\"\n",
+ "print \"Hence the total elapsed time = \",round(2*t,8),\"s\"\n",
+ "\n",
+ "#Result\n",
+ "# t = 7.2e-06 s \n",
+ "# Since twice the time to reach the break is required for the reflection to arrive at the reflectometer, \n",
+ "# Hence the total elapsed time = 1.447e-005 s \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "t = 7.2e-06 s\n",
+ "Since twice the time to reach the break is required for the reflection to arrive at the reflectometer,\n",
+ "Hence the total elapsed time = 1.447e-05 s\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter1_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter1_4.ipynb new file mode 100644 index 00000000..5edf29c5 --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter1_4.ipynb @@ -0,0 +1,861 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:8ce07967ae5b6dd561257d03fd753fc6700a96afdde0b7e95c82ed0afca454d4"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 01: Measurement and Error"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.1:pg-3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Average voltage Range of error\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-1 in Page 3\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "E_1 = 117.02 # Voltage observed by 1st observer is 117.02V\n",
+ "E_2 = 117.11 # Voltage observed by 2nd observer is 117.11V\n",
+ "E_3 = 117.08 # Voltage observed by 3rd observer is 117.08V\n",
+ "E_4 = 117.03 # Voltage observed by 4th observer is 117.03V\n",
+ "\n",
+ "#Calculations\n",
+ "E_av = (E_1+E_2+E_3+E_4)/4\n",
+ "print \"(a) The average voltage, E_av =\",E_av,\"V\"\n",
+ "\n",
+ "E_max = max (E_1,E_2,E_3,E_4) # Maximum value among the 4 nos\n",
+ "E_min = min (E_1,E_2,E_3,E_4) # Minimum value among the 4 nos\n",
+ "\n",
+ "range_1 = E_max - E_av # Range calculated using two different formulae\n",
+ "range_2 = E_av - E_min # Range calculated using two different formulae\n",
+ "\n",
+ "avg_range = (range_1+range_2)/2\n",
+ "print \"(b) The average range of error = +/-\",round(avg_range,2),\"V\"\n",
+ "\n",
+ "#Result\n",
+ "# (a) The average voltage, E_av = 117.06 V\n",
+ "# (b) The average range of error = +/- 0.05 V \n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) The average voltage, E_av = 117.06 V\n",
+ "(b) The average range of error = +/- 0.05 V\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.2:pg-4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Total resistance\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-2 in Page 4\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "R_1 = 18.7 # The first resistance is 18.7ohm\n",
+ "R_2 = 3.624 # The second resistance is 3.624ohm\n",
+ "\n",
+ "# Calculations\n",
+ "R_T = R_1 + R_2 # formula to calculate total resistance in series\n",
+ "print \"The total resistance connected in series =\",R_T,\" ohm\\n\"\n",
+ "print \"As one of the resistance is accurate to only tenths of an ohm, The result should be reduced to the nearest tenth. \\n Hence \"\n",
+ "print \"the total resistance is =\",round(R_T,1),\" ohm\"\n",
+ "\n",
+ "#Result\n",
+ "# The total resistance connected in series = 22.324 ohm\n",
+ "# As one of the resistance is accurate to only tenths of an ohm, The result should be reduced to the nearest tenth. \n",
+ "# Hence the total resistance is = 22.3 ohm \n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total resistance connected in series = 22.324 ohm\n",
+ "\n",
+ "As one of the resistance is accurate to only tenths of an ohm, The result should be reduced to the nearest tenth. \n",
+ " Hence \n",
+ "the total resistance is = 22.3 ohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.3:pg-4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find voltage drop across resistor\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-3 in Page 4\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "I = 3.18 #Current flowing through the resistor = 3.18A\n",
+ "R = 35.68 # The value of resistor = 35.68ohm\n",
+ "\n",
+ "# Calculations\n",
+ "E = I*R\n",
+ "print \"The voltage drop across the resistor = \",E,\"volts\"\n",
+ "print \"Since there are 3 significant figures involved in the multiplication, the result can be written only to a max of 3 significant figures\"\n",
+ "print \"Hence the voltage drop across the resistor = \",round(E),\" volts\"\n",
+ "\n",
+ "#Result\n",
+ "# The voltage drop across the resistor = 113.4624 volts \n",
+ "# Since there are 3 significant figures involved in the multiplication, the result can be written only to a max of 3 significant figures \n",
+ "# Hence the voltage drop across the resistor = 113 volts \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The voltage drop across the resistor = 113.4624 volts\n",
+ "Since there are 3 significant figures involved in the multiplication, the result can be written only to a max of 3 significant figures\n",
+ "Hence the voltage drop across the resistor = 113.0 volts\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.4:pg-5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find sum with range of doubt\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-4 in Page 5\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# let N_1 = X_1 +/- Y_1\n",
+ "# N_2 = X_2 +/- Y_2\n",
+ "X_1 = 826.0\n",
+ "Y_1 = 5\n",
+ "X_2 = 628.0\n",
+ "Y_2 = 3\n",
+ "\n",
+ "#Calculations\n",
+ "X = (X_1 + X_2)\n",
+ "Y = (Y_1 + Y_2)\n",
+ "print \"SUM = \",X,\" +/- \",Y\n",
+ "doubt = Y/X*100\n",
+ "print \"The percentage range of doubt = +/-\",round(doubt,3)\n",
+ "\n",
+ "#Result\n",
+ "# SUM = 1454 +/- 8\n",
+ "# The percentage range of doubt = +/-0.55% \n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "SUM = 1454.0 +/- 8\n",
+ "The percentage range of doubt = +/- 0.55\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.5:pg-5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find difference with range of doubt\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-5 in Page 5\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# let N_1 = X_1 +/- Y_1\n",
+ "# N_2 = X_2 +/- Y_2\n",
+ "X_1 = 826.0\n",
+ "Y_1 = 5\n",
+ "X_2 = 628\n",
+ "Y_2 = 3\n",
+ "\n",
+ "X = (X_1 - X_2)\n",
+ "Y = (Y_1 + Y_2)\n",
+ "print \"SUM = \",X,\" +/- \",Y\n",
+ "doubt = Y/X*100\n",
+ "print \"The percentage range of doubt = +/-\",round(doubt,3)\n",
+ "#Result\n",
+ "# Difference = 198 +/- 8\n",
+ "# The percentage range of doubt = +/-4.04% \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "SUM = 198.0 +/- 8\n",
+ "The percentage range of doubt = +/- 4.04\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.6:pg-5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find difference with range of doubt\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-6 in Page 5\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# let N_1 = X_1 +/- Y_1\n",
+ "# N_2 = X_2 +/- Y_2\n",
+ "X_1 = 462.0\n",
+ "Y_1 = 4\n",
+ "X_2 = 437.0\n",
+ "Y_2 = 4\n",
+ "\n",
+ "#Calculations\n",
+ "X = (X_1 - X_2)\n",
+ "Y = (Y_1 + Y_2)\n",
+ "print \"SUM = \",X,\" +/- \",Y\n",
+ "doubt = Y/X*100\n",
+ "print \"The percentage range of doubt = +/-\",round(doubt,3)\n",
+ "\n",
+ "#Result\n",
+ "# Difference = 25 +/- 8\n",
+ "# The percentage range of doubt = +/-32.00% \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "SUM = 25.0 +/- 8\n",
+ "The percentage range of doubt = +/- 32.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.7:pg-6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Apparent and actual resistance \n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-7 in Page 6\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "I_T = 5*(10**-3) # Reading of the milliammeter in ampere\n",
+ "V_T = 100 # Reading of the voltmeter in volt\n",
+ "sensitivity = 1000 # sensitivity of voltmeter in ohm/volt\n",
+ "scale = 150 # scale of the voltmeter\n",
+ "\n",
+ "#Calculations\n",
+ "R_T = V_T / I_T # formula to calculate total circuit resistance\n",
+ "print \"(a) The apparent circuit resistance neglecting the resistance of milliammeter, R_T = \",R_T,\" ohm\\n\"\n",
+ "\n",
+ "R_V = sensitivity * scale # calculating resistance of voltmeter\n",
+ "R_X = (R_T * R_V)/(R_V - R_T) # effective circuit resistance due to loading effect\n",
+ "print \"(b) The actual circuit resistance with the loading effect of voltmeter, R_X = \",round(R_X,2),\" ohm\\n\"\n",
+ "\n",
+ "percentage_error = (R_X - R_T)*100/ R_X\n",
+ "# %error = (actual-apparent)/ actual\n",
+ "print \"(c) The percentage error due to loading effect of voltmeter = \",round(percentage_error,2),\"%\"\n",
+ "\n",
+ "#result\n",
+ "# (a) The apparent circuit resistance neglecting the resistance of milliammeter, R_T = 20000 ohm\n",
+ "# (b) The actual circuit resistance with the loading effect of voltmeter, R_X = 23076.92 ohm\n",
+ "# (c) The percentage error due to loading effect of voltmeter = 13.33% \n",
+ "\n",
+ "\n",
+ "# The result shown in the textbook is printed incorrectly and does not match with the correct result\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) The apparent circuit resistance neglecting the resistance of milliammeter, R_T = 20000.0 ohm\n",
+ "\n",
+ "(b) The actual circuit resistance with the loading effect of voltmeter, R_X = 23076.92 ohm\n",
+ "\n",
+ "(c) The percentage error due to loading effect of voltmeter = 13.33 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.8:pg-7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Apparent and actual resistance \n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-8 in Page 7\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "I_T = 800*(10**-3) # Reading of the milliammeter in ampere\n",
+ "V_T = 40 # Reading of the voltmeter in volt\n",
+ "sensitivity = 1000 # sensitivity of voltmeter in ohm/volt\n",
+ "scale = 150 # scale of the voltmeter\n",
+ "\n",
+ "#Calculations\n",
+ "R_T = V_T / I_T # formula to calculate total circuit resistance\n",
+ "print \"(a) The apparent circuit resistance neglecting the resistance of milliammeter, R_T = \",R_T,\" ohm\\n\"\n",
+ "\n",
+ "R_V = sensitivity * scale # calculating resistance of voltmeter\n",
+ "R_X = (R_T * R_V)/(R_V - R_T) # effective circuit resistance due to loading effect\n",
+ "print \"(b) The actual circuit resistance with the loading effect of voltmeter, R_X = \",round(R_X,2),\" ohm\\n\"\n",
+ "\n",
+ "percentage_error = (R_X - R_T)*100/ R_X\n",
+ "# %error = (actual-apparent)/ actual\n",
+ "print \"(c) The percentage error due to loading effect of voltmeter = \",round(percentage_error,2),\"%\"\n",
+ "\n",
+ "#result\n",
+ "# (a) The apparent circuit resistance neglecting the resistance of milliammeter, R_T = 50.00 ohm\n",
+ "# (b) The actual circuit resistance with the loading effect of voltmeter, R_X = 50.02 ohm\n",
+ "# (c) The percentage error due to loading effect of voltmeter = 0.03% \n",
+ "\n",
+ "\n",
+ "# The result shown in the textbook is printed incorrectly and does not match with the correct result\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) The apparent circuit resistance neglecting the resistance of milliammeter, R_T = 50.0 ohm\n",
+ "\n",
+ "(b) The actual circuit resistance with the loading effect of voltmeter, R_X = 50.02 ohm\n",
+ "\n",
+ "(c) The percentage error due to loading effect of voltmeter = 0.03 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.9:pg-9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Arithmatic mean and deviation from mean\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-9 in Page 9\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# Independent current measurements taken by six observers\n",
+ "I_1 = 12.8*(10**-3)\n",
+ "I_2 = 12.2*(10**-3)\n",
+ "I_3 = 12.5*(10**-3)\n",
+ "I_4 = 13.1*(10**-3)\n",
+ "I_5 = 12.9*(10**-3)\n",
+ "I_6 = 12.4*(10**-3)\n",
+ "\n",
+ "#Calculations\n",
+ "arithmatic_mean = (I_1 +I_2 +I_3 +I_4 +I_5 +I_6)/6\n",
+ "print \"(a) The arithmatic mean of the observations =\",arithmatic_mean,\"A\"\n",
+ "\n",
+ "d_1 = I_1 - arithmatic_mean\n",
+ "d_2 = I_2 - arithmatic_mean\n",
+ "d_3 = I_3 - arithmatic_mean\n",
+ "d_4 = I_4 - arithmatic_mean\n",
+ "d_5 = I_5 - arithmatic_mean\n",
+ "d_6 = I_6 - arithmatic_mean\n",
+ "\n",
+ "#deviation calculated using the formula d_n = x_n - arithmatic_mean\n",
+ "disp('(b) The deviations from the mean are:' )\n",
+ "print \"d_1 = \",d_1,\" A\\n d_2 = \",d_2,\" A\\n d_3 = \",d_3,\" A\\n d_4 = \", d_4,\" A\\n d_5 = \",d_5,\" A\\n d_6 =\",d_6,\" A\"\n",
+ "\n",
+ "#Result\n",
+ "# (a) The arithmatic mean of the observations =0.01265 A \n",
+ "# (b) The deviations from the mean are: \n",
+ "# d_1 = 0.00015 A\n",
+ "# d_2 = -0.00045 A\n",
+ "# d_3 = -0.00015 A\n",
+ "# d_4 = 0.00045 A\n",
+ "# d_5 = 0.00025 A\n",
+ "# d_6 = -0.00025 A\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) The arithmatic mean of the observations = 0.01265 A\n",
+ "(b) The deviations from the mean are:\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "d_1 = 0.00015 A\n",
+ " d_2 = -0.00045 A\n",
+ " d_3 = -0.00015 A\n",
+ " d_4 = 0.00045 A\n",
+ " d_5 = 0.00025 A\n",
+ " d_6 = -0.00025 A\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.10:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Average deviation\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-10 in Page 10\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# These are the data found out from the example_1-9\n",
+ "d_1 = 0.000150\n",
+ "d_2 = -0.000450\n",
+ "d_3 = -0.000150\n",
+ "d_4 = 0.000450\n",
+ "d_5 = 0.000250\n",
+ "d_6 = -0.000250\n",
+ "\n",
+ "#Calculation\n",
+ "D = (abs(d_1) +abs(d_2) +abs(d_3) +abs(d_4) +abs(d_5) +abs(d_6))/6\n",
+ "print \"The average deviation, D = \",round(D,6),\"A\"\n",
+ "\n",
+ "#Result\n",
+ "# The average deviation, D = 2.83e-004 A \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The average deviation, D = 0.000283 A\n"
+ ]
+ }
+ ],
+ "prompt_number": 32
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.11:pg-14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Std deviation and Probable error \n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-11 in Page 14\n",
+ "\n",
+ "import numpy\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# let the 10 resistance measurements in ohm be taken as elements of matrix\n",
+ "x = [101.2,101.7,101.3,101.0,101.5,101.3,101.2,101.4,101.3,101.1]\n",
+ "\n",
+ "#Calculations\n",
+ "arithmatic_mean = numpy.mean(x)\n",
+ "sigma = numpy.std(x)\n",
+ "probable_error = 0.6745 * sigma\n",
+ "print \"(a) The arithmatic mean of the readings = \",arithmatic_mean,\" ohm\\n\"\n",
+ "print \"(b) The standard deviation of the readings = \",round(sigma,1),\" ohm\\n\"\n",
+ "print \"(c) The probable error of the readings = \",round(probable_error,2),\"ohm\"\n",
+ "\n",
+ "#Result\n",
+ "# (a) The arithmatic mean of the readings = 101.3 ohm\n",
+ "# (b) The standard deviation of the readings = 0.2 ohm\n",
+ "# (c) The probable error of the readings = 0.13 ohm \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) The arithmatic mean of the readings = 101.3 ohm\n",
+ "\n",
+ "(b) The standard deviation of the readings = 0.2 ohm\n",
+ "\n",
+ "(c) The probable error of the readings = 0.13 ohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.12:pg-14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Limiting error \n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-12 in Page 14\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "scale = 150\n",
+ "percentage_accuracy = 1.0/100# accuracy of 1% full scale reading\n",
+ "V = 83 #voltage measured by instrument = 83 volt \n",
+ "\n",
+ "#Calculations\n",
+ "limiting_error = percentage_accuracy * scale\n",
+ "print \"The magnitude of the limiting error = \",limiting_error,\" V\\n\"\n",
+ "\n",
+ "percentage_error = limiting_error/V * 100\n",
+ "print \"The percentage limiting error = \",round(percentage_error,2),\" percent\"\n",
+ "\n",
+ "#Result\n",
+ "# The magnitude of the limiting error = 1.5 V\n",
+ "# The percentage limiting error = 1.81 percent \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The magnitude of the limiting error = 1.5 V\n",
+ "\n",
+ "The percentage limiting error = 1.81 percent\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.13:pg-15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find the maximum error\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-13 in Page 15\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# For the given tolerence of 0.1% \n",
+ "# highest value of resistor is 1.001 times the nominal value\n",
+ "# lowest value of resistor is 0.999 times the nominal value\n",
+ "\n",
+ "#Calculations\n",
+ "V_out_max = 1.001 * 1.001/ 0.999\n",
+ "V_out_min = 0.999 * 0.999/ 1.003\n",
+ "total_var = 0.1 * 3 # total variation of the resultant voltage is sum of tolerences\n",
+ "print \"The total variation of the resultant voltage = +/- \",total_var,\"%\"\n",
+ "\n",
+ "#Result\n",
+ "# The total variation of the resultant voltage = +/- 0.3 %\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The total variation of the resultant voltage = +/- 0.3 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 38
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.14:pg-16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find limiting error\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 1-14 in Page 16\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# let I = X_1 +/- Y_1\n",
+ "# R = X_2 +/- Y_2\n",
+ "X_1 = 2.00\n",
+ "Y_1 = 0.5\n",
+ "X_2 = 100\n",
+ "Y_2 = 0.2\n",
+ "\n",
+ "#Calculations\n",
+ "P_1 = ((1+0.005)**2)*(1+0.002)\n",
+ "print \"For the worst possible combination of the values of current and resistance,\\nThe highest power dissipation becomes,\\n\"\n",
+ "print \"P = \",round(P_1,3),\" (I**2)*R Watts\"\n",
+ "P_2 = ((1-0.005)**2)*(1-0.002)\n",
+ "print \"For the lowest power dissipation.\\nP = \",round(P_2,3),\" (I**2)*R Watts\\n\"\n",
+ "lim_error = 2 * Y_1 + Y_2\n",
+ "print \"The limiting error = +/- \",lim_error,\"%\"\n",
+ "\n",
+ "#Result\n",
+ "# For the worst possible combination of the values of current and resistance,\n",
+ "# The highest power dissipation becomes,\n",
+ "# P = 1.012 (I**2)*R Watts\n",
+ "# For the lowest power dissipation.\n",
+ "# P = 0.988 (I**2)*R Watts\n",
+ "# The limiting error = +/- 1.2% \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "For the worst possible combination of the values of current and resistance,\n",
+ "The highest power dissipation becomes,\n",
+ "\n",
+ "P = 1.012 (I**2)*R Watts\n",
+ "For the lowest power dissipation.\n",
+ "P = 0.988 (I**2)*R Watts\n",
+ "\n",
+ "The limiting error = +/- 1.2 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 41
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter2_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter2_4.ipynb new file mode 100644 index 00000000..d6153f2a --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter2_4.ipynb @@ -0,0 +1,262 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:3fb09c0fd0a89152f5948cdf5eed31775a718eb29c5fc9edfb34ed6af2984184"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 02:Systems of Units of Measurement"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.1:pg-29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To convert area in metre to feet\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 2-1 in Page 29\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "A_m = 5000 # area in metre**2 unit\n",
+ "\n",
+ "#Calculation\n",
+ "A_ft = A_m * (1/0.3048)**2 # As 1ft = 0.3048m\n",
+ "print \"The area in feet = \",round(A_ft),\" sq.ft\"\n",
+ "\n",
+ "#Result\n",
+ "# The area in feet = 53820 sq.ft \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The area in feet = 53820.0 sq.ft\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.2:pg-29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To convert flux density to different units\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 2-2 in Page 29\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "B_cm = 20 # flux density in maxwell/sq.cm\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "B_in = B_cm *2.54**2 # converting to lines/sq.inch\n",
+ "print \"The flux density in lines/sq.in =\",round(B_in),\" lines/(in**2)\"\n",
+ "\n",
+ "#Result\n",
+ "# The flux density in lines/sq.in = 129 lines/(in**2) \n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The flux density in lines/sq.in = 129.0 lines/(in**2)\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.3:pg-29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To convert velocity to a different unit\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 2-3 in Page 29\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "c_s = 2.997925 * 10**8 # velocity in m/s\n",
+ "\n",
+ "#Calculations\n",
+ "c_hr = 2.997925 *10**8* 1/10**3* 3.6*10**3 # velocity in km/hr\n",
+ "print \"The velocity of light in km/hr = \",\"{:.3E}\".format(c_hr),\" km/hr\"\n",
+ "\n",
+ "#Result \n",
+ "# The velocity of light in km/hr = 1.079e+009 km/hr "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The velocity of light in km/hr = 1.079E+09 km/hr\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.4:pg-29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To convert density to a different unit\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 2-4 in Page 29\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "Density_ft = 62.5\n",
+ "\n",
+ "#Calcualtions\n",
+ "Density_in = 62.5 * (1/12.0)**3\n",
+ "Density_cm = Density_in * 453.6 * (1/2.54)**3\n",
+ "print \"(a) The density of water in lb/cubic inch = \",round(Density_in,6),\" lb/(in**3).\\n\"\n",
+ "print \"(b) The density of water in g/cubic cm = \",round(Density_cm,6), \"g/(cm**3).\"\n",
+ "\n",
+ "#Result\n",
+ "# (a) The density of water in lb/cubic inch = 0.036169 lb/(in**3).\n",
+ "# (b) The density of water in g/cubic cm = 1.001171 g/(cm**3). \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) The density of water in lb/cubic inch = 0.036169 lb/(in**3).\n",
+ "\n",
+ "(b) The density of water in g/cubic cm = 1.001171 g/(cm**3).\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.5:pg-30"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To convert speed limit to a different unit\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 2-5 in Page 30\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "speed_km = 60 # speed limit in km/hr\n",
+ "\n",
+ "#Calculations\n",
+ "speed_m = 60 *10**3 *10**2 *(1/2.54) *(1/12.0)*(1.0/5280)\n",
+ "speed_ft = 37.3 *5280 *(1/(3.6*10**3))\n",
+ "\n",
+ "print \"(a) The speed limit in m/hr = \",round(speed_m,1),\" mi/hr\\n\"\n",
+ "print \"(b) The speed limit in ft/s = \",round(speed_ft,1),\" ft/s\"\n",
+ "\n",
+ "#Result\n",
+ "# (a) The speed limit in m/hr = 37.3 mi/hr\n",
+ "# (b) The speed limit in ft/s = 54.7 ft/s \n",
+ "\n",
+ "\n",
+ "#The answer given in textbook is printed incorrectly and does not match with calculated answer\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) The speed limit in m/hr = 37.3 mi/hr\n",
+ "\n",
+ "(b) The speed limit in ft/s = 54.7 ft/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter4_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter4_4.ipynb new file mode 100644 index 00000000..9cf22584 --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter4_4.ipynb @@ -0,0 +1,240 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:122a31de547475cc4aadab2eac419ec88d91c65017876c6ee98e7639ab9ef3a9"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 04:Electromechanical Indicating Instruments"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.1:pg-56"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find Shunt resistance required\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 4-1 in Page 56\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "I_m = 1*(10.0**-3) #Full scale deflection of the movement in ampere\n",
+ "R_m = 100.0 #Internal resistance of the movement(the coil) in ohm\n",
+ "I = 100.0*(10**-3) #Full scale of the ammeter including the shunt in Ampere\n",
+ "\n",
+ "#Calculations\n",
+ "I_s = I - I_m # calculating current through shunt\n",
+ "R_s = I_m * R_m/ I_s #calculating shunt to be added\n",
+ "print \"The value of the shunt resistance required, R_s =\",round(R_s,2),\"ohm\"\n",
+ "\n",
+ "#Result\n",
+ "# The value of the shunt resistance required, R_s = 1.01 ohm\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of the shunt resistance required, R_s = 1.01 ohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.2:pg-57"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To design Ayrton shunt\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 4-2 in Page 57\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "I_1 = 1 #Full scale currents of the ammeter in amp\n",
+ "I_2 = 5\n",
+ "I_3 = 10\n",
+ "R_m = 50 #Internal resistance of the movement(the coil) in ohm\n",
+ "I_m = 1*(10**-3) #Full scale deflection of the movement in ampere\n",
+ "\n",
+ "#Calculations\n",
+ "# On the 1-A range: \n",
+ "I_s1 = I_1 - I_m # calculating current through shunt\n",
+ "#Using the eq. R_s = I_m * R_m/ I_s\n",
+ "#1 R_a +R_b +R_c = I_m * R_m/ I_s # As (R_a +R_b +R_c) are parallel with R_m\n",
+ "\n",
+ "# On the 5-A range\n",
+ "I_s2 = I_2 - I_m\n",
+ "#2 R_a +R_b = I_m * (R_c +R_m)/ I_s # As (R_a+R_b) in parallel with (R_c+R_m)\n",
+ "\n",
+ "# On the 10-A range\n",
+ "I_s3 = I_3 - I_m\n",
+ "#3 R_a = I_m * (R_b +R_c +R_m)/ I_s # As R_a is parallel with (R_b +R_c +R_m)\n",
+ "\n",
+ "\n",
+ "import numpy as np\n",
+ "a = np.array([[1,4999,-9999],[1,4999,1],[1,-1,1]])\n",
+ "b = np.array([0.05005,50,-50])\n",
+ "answer = np.linalg.solve(a.T, b)\n",
+ "\n",
+ "\n",
+ "\n",
+ "R_a = answer[0]\n",
+ "R_b = answer[1]\n",
+ "R_c = answer[2]\n",
+ "\n",
+ "disp('The different resistors used for the ayrton shunt for different ranges are:')\n",
+ "print \"R_a = \",round(R_a,7),\" ohm\\n\"\n",
+ "print \"R_b = \",round(R_b,7),\" ohm\\n\"\n",
+ "print \"R_c = \",round(R_c,6),\" ohm\"\n",
+ "\n",
+ "#Result\n",
+ "# The different resistors used for the ayrton shunt for different ranges are: \n",
+ "# R_a = 0.005005 ohm\n",
+ "# R_b = 0.005005 ohm\n",
+ "# R_c = 0.040040 ohm \n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The different resistors used for the ayrton shunt for different ranges are:\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "R_a = 0.005005 ohm\n",
+ "\n",
+ "R_b = 0.005005 ohm\n",
+ "\n",
+ "R_c = 0.04004 ohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex4.3:pg-60"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To design multirange dc voltmeter\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 4-3 in Page 60\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "R_m = 100 # internal resistance of movement\n",
+ "I_fsd = 1*(10**-3) #full-scale current in Amp\n",
+ "V_1 = 10 #different ranges in volt\n",
+ "V_2 = 50\n",
+ "V_3 = 250\n",
+ "V_4 = 500\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "#For the 10-V range\n",
+ "R_T = V_1 / I_fsd\n",
+ "R_4 = R_T - R_m\n",
+ "print \"The value of the resistance R_4 = \",R_4,\" ohm\\n\"\n",
+ "\n",
+ "#For the 50-V range\n",
+ "R_T = V_2 / I_fsd\n",
+ "R_3 = R_T - (R_4 +R_m)\n",
+ "print \"The value of the resistance R_3 = \",R_3/1000,\"K ohm\\n\"\n",
+ "\n",
+ "#For the 250-V range\n",
+ "R_T = V_3 / I_fsd\n",
+ "R_2 = R_T -(R_3 +R_4 +R_m)\n",
+ "print \"The value of the resistance R_2 =\",R_2/1000,\"k ohm\\n\"\n",
+ "\n",
+ "#For the 500-V range\n",
+ "R_T = V_4 / I_fsd\n",
+ "R_1 = R_T - (R_2 +R_3 +R_4 +R_m)\n",
+ "print \"The value of the resistance R_1 =\",R_1/1000,\"K ohm\"\n",
+ "\n",
+ "#Result\n",
+ "# The value of the resistance R_4 = 9900 ohm\n",
+ "# The value of the resistance R_3 = 40k ohm\n",
+ "# The value of the resistance R_2 = 200k ohm\n",
+ "# The value of the resistance R_1 = 250k ohm \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of the resistance R_4 = 9900.0 ohm\n",
+ "\n",
+ "The value of the resistance R_3 = 40.0 K ohm\n",
+ "\n",
+ "The value of the resistance R_2 = 200.0 k ohm\n",
+ "\n",
+ "The value of the resistance R_1 = 250.0 K ohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter5_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter5_4.ipynb new file mode 100644 index 00000000..203a765e --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter5_4.ipynb @@ -0,0 +1,398 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:e254c8288fbd2f2cd14434e82e95f71176cc32f312efb578ff8980e82a33844f"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 5:Bridge Measurements"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.1:Pg-101"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find deflection caused by the given unbalance\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 5-1 in Page 101\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# Resistances of the 4 arms in ohm\n",
+ "R_1 = 1000.0\n",
+ "R_2 = 100.0\n",
+ "R_3 = 200.0\n",
+ "R_4 = 2005.0\n",
+ "\n",
+ "E = 5 # battery EMF in volt\n",
+ "S_I = 10*(10**-3)/(10**-6) #Current sensitivity in m/A\n",
+ "R_g = 100.0 #Internal resistance of galvanometer in ohm\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "#Calculations are made wrt fig 5-3 in page 103\n",
+ "#Bridge balance occurs if arm BC has a resistance of 2000 ohm. The diagram shows arm BC has as a resistance of 2005 ohm\n",
+ "\n",
+ "#To calculate the current in the galvanometer, the ckt is thevenised wrt terminals B and D.\n",
+ "#The potenttial from B to D, with the galvanometer removed is the Thevenin voltage\n",
+ "\n",
+ "# E_TH = E_AD - E_AB \n",
+ "\n",
+ "E_TH = E * ((R_2/(R_2+R_3)) - (R_1/ (R_1+R_4)))\n",
+ "R_TH = ((R_2 * R_3/(R_2+R_3)) + (R_1 * R_4/ (R_1+R_4)))\n",
+ "\n",
+ "#When the galvanometer is now connected to the output terminals, The current through the galvanometer is\n",
+ "\n",
+ "I_g = E_TH /(R_TH +R_g)\n",
+ "d = I_g * S_I\n",
+ "print \"The deflection of the galvanometer = \",round(d*1000,2),\" mm\"\n",
+ "\n",
+ "#Result\n",
+ "# The deflection of the galvanometer = 33.26 mm \n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The deflection of the galvanometer = 33.26 mm\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.2:pg-102"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To check the capability of detecting unbalance\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 5-2 in Page 102\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# Resistances of the 4 arms in ohm\n",
+ "R_1 = 1000.0\n",
+ "R_2 = 100.0\n",
+ "R_3 = 200.0\n",
+ "R_4 = 2005\n",
+ "\n",
+ "E = 5 # battery EMF in volt\n",
+ "S_I = 1*(10**-3)/(10**-6) #Current sensitivity in m/A\n",
+ "R_g = 500 #Internal resistance of galvanometer in ohm\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "#Calculations are made wrt fig 5-3 in page 103\n",
+ "#Bridge balance occurs if arm BC has a resistance of 2000 ohm. The diagram shows arm BC has as a resistance of 2005 ohm\n",
+ "\n",
+ "#To calculate the current in the galvanometer, the ckt is thevenised wrt terminals B and D.\n",
+ "#The potenttial from B to D, with the galvanometer removed is the Thevenin voltage\n",
+ "\n",
+ "# E_TH = E_AD - E_AB \n",
+ "\n",
+ "E_TH = E * ((R_2/(R_2+R_3)) - (R_1/ (R_1+R_4)))\n",
+ "R_TH = ((R_2 * R_3/(R_2+R_3)) + (R_1 * R_4/ (R_1+R_4)))\n",
+ "\n",
+ "#When the galvanometer is now connected to the output terminals, The current through the galvanometer is\n",
+ "\n",
+ "I_g = E_TH /(R_TH +R_g)\n",
+ "d = I_g * S_I\n",
+ "print \"The deflection of the galvanometer = \",round(d*1000,2),\" mm\"\n",
+ "print 'Given that galvanometer is capable of detecting a deflection of 1mm'\n",
+ "print 'Hence looking at the result,it can be seen that this galvanometer produces a deflection that can be easily observed'\n",
+ "\n",
+ "#Result\n",
+ "# The deflection of the galvanometer = 2.247 mm \n",
+ "# Given that galvanometer is capable of detecting a deflection of 1mm \n",
+ " \n",
+ "# Hence looking at the result,it can be seen that this galvanometer produces a deflection that can be easily observed \n",
+ " \n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The deflection of the galvanometer = 2.25 mm\n",
+ "Given that galvanometer is capable of detecting a deflection of 1mm\n",
+ "Hence looking at the result,it can be seen that this galvanometer produces a deflection that can be easily observed\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.3:Pg-111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "# To find the unknown impedence\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 5-3 in Page 111\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# The given polar forms in textbook is represented in rect form\n",
+ "Z_1 = 17.36482 +1j *98.48078\n",
+ "Z_2 = 250\n",
+ "Z_3 = 346.4102 +1j *200\n",
+ "\n",
+ "#Calculations\n",
+ "#The first condition for bridge balance is Z_1*Z_4 = Z_2*Z_3\n",
+ "mod_Z_4 = (abs(Z_2)*abs(Z_3))/abs(Z_1)\n",
+ "\n",
+ "#The second condition for bridge balance requires that sum of the phase angles of opposite arms be equal\n",
+ "theta_Z_4 = math.atan(Z_2.imag)+math.atan(Z_3.imag)-math.atan(Z_1.imag)*180/math.pi\n",
+ "\n",
+ "print \"The impedence of the unknown arm =\",round(mod_Z_4),\" ohm /_ \",round(theta_Z_4),\" deg\\n\"\n",
+ "print \"Here the magnitude of impedence is 1000 and phase angle is 50 in degrees\\n\"\n",
+ "print \"The above value indicates that we are dealing with a capacitive element, possibly consisting of a series combination of a resistor and capacitance\"\n",
+ "#Result\n",
+ "# The impedence of the unknown arm = 1000 ohm /_ -50 deg\n",
+ "# Here the magnitude of impedence is 1000 and phase angle is 50 in degrees\n",
+ "# The above value indicates that we are dealing with a capacitive element, possibly consisting of a series combination of a resistor and capacitance \n",
+ " \n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The impedence of the unknown arm = 1000.0 ohm /_ -88.0 deg\n",
+ "\n",
+ "Here the magnitude of impedence is 1000 and phase angle is 50 in degrees\n",
+ "\n",
+ "The above value indicates that we are dealing with a capacitive element, possibly consisting of a series combination of a resistor and capacitance\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.4:pg-112"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find the unknown impedence\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 5-4 in Page 112\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# The notations are wrt to the figure 5-10 in page 109\n",
+ "\n",
+ "#Arm AB\n",
+ "R_1 = 450\n",
+ "#Arm BC\n",
+ "R_2 = 300\n",
+ "C = 0.265 *(10**-6)\n",
+ "#Arm DA\n",
+ "R_3 = 200\n",
+ "L = 15.9*(10**-3)\n",
+ "f = 1000\n",
+ "\n",
+ "#Calculations\n",
+ "w = 2*math.pi*f\n",
+ "Z_1 = 450\n",
+ "Z_2 = R_2 - 1j *floor(1/(w*C))\n",
+ "Z_3 = R_3 + 1j*ceil(w*L)\n",
+ "\n",
+ "Z_4 = Z_1*Z_3/Z_2\n",
+ "print \"The impedence of the unknown arm = \",round(imag(Z_4)),\" ohm\\n\"\n",
+ "print \"The result indicates that Z_4 is a pure inductance with an inductive reactance of 150 ohm at a frequency of 1 khz.\\n\"\n",
+ "\n",
+ "L_ans = imag(Z_4)/w\n",
+ "print \"The inductance present in the arm CD = \",round(L_ans*1000,1),\"m H\"\n",
+ "\n",
+ "#Result\n",
+ "# The impedence of the unknown arm = 150i ohm\n",
+ "# The result indicates that Z_4 is a pure inductance with an inductive reactance of 150 ohm at a frequency of 1 khz.\n",
+ "# The inductance present in the arm CD = 23.9m H \n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The impedence of the unknown arm = 150.0 ohm\n",
+ "\n",
+ "The result indicates that Z_4 is a pure inductance with an inductive reactance of 150 ohm at a frequency of 1 khz.\n",
+ "\n",
+ "The inductance present in the arm CD = 23.9 m H\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.5:pg-119"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To balance the unbalanced bridge\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 5-5 in Page 119\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "Z_1 = -1000j\n",
+ "Z_2 = 500\n",
+ "Z_3 = 1000\n",
+ "Z_4 = 100+500j\n",
+ "\n",
+ "# The balance is not possible with this condition as theta_1+theta_4 will be slightly negative than theta_2+theta3\n",
+ "# Balance can be achieved by 2 methods:\n",
+ "print \"First option is to modify Z_1 so that its phase angle is decreased to less than 90deg by placing a resistor in parallel with the capacitor.\"\n",
+ "# The resistance R_1 can be determined by the standard approach\n",
+ "\n",
+ "#Calculations\n",
+ "Y_1 = Z_4/(Z_2*Z_3)\n",
+ "#Also,\n",
+ "# Y_1 = (1/R) + %i/1000\n",
+ "# equating both the equations and solving for R_1\n",
+ "\n",
+ "R_1 = 1/(Y_1-(1j/1000 ))\n",
+ "print \"The value of the resistor R_1 in parallel with capacitor = \",R_1.real,\" ohm\\n\",\n",
+ "\n",
+ "# It should be noted that the addition of R_1 upsets the first balance condition as the magnitude of Z_1 is changed\n",
+ "# Hence the variable R_3 should be adjusted to compensate this effect\n",
+ "\n",
+ "print 'The second option is to modify the phase angle of arm 2 or arm 3 by adding series capacitor'\n",
+ "Z_3_1 = Z_1 *Z_4/Z_2\n",
+ "# substituting for the component values and solving for X_C yeilds\n",
+ "\n",
+ "X_C = abs(1000- Z_3_1)/-1j\n",
+ "print \"The value of the reactance of the capacitor used, X_C = \",X_C.imag,\" ohm\"\n",
+ "\n",
+ "\n",
+ "#In this case the magnitude of the Z_3 is increased so that the first balance condition is changed\n",
+ "#A small adjustment of R_3 is necessary to restore balance\n",
+ "\n",
+ "#Result\n",
+ "# First option is to modify Z_1 so that its phase angle is decreased to less than 90deg by placing a resistor in parallel with the capacitor. \n",
+ "# The value of the resistor R_1 in parallel with capacitor = 5000 ohm\n",
+ " \n",
+ "# The second option is to modify the phase angle of arm 2 or arm 3 by adding series capacitor \n",
+ "# The value of the reactance of the capacitor used, X_C = 200 ohm \n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "First option is to modify Z_1 so that its phase angle is decreased to less than 90deg by placing a resistor in parallel with the capacitor.\n",
+ "The value of the resistor R_1 in parallel with capacitor = 5000.0 ohm\n",
+ "The second option is to modify the phase angle of arm 2 or arm 3 by adding series capacitor\n",
+ "The value of the reactance of the capacitor used, X_C = 200.0 ohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter6_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter6_4.ipynb new file mode 100644 index 00000000..c47588e7 --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter6_4.ipynb @@ -0,0 +1,321 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:bf5e1ba8fe50db5d826f3aa4aa6f0fbfe2110f01141414923f54b110cd4d507c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 6:Electronic Instruments for Measuring Basic Parameters"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.3:pg-144"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find the maximum time \n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 6-3 in Page 144\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "R = 100*(10**3) # Value of resistance in ohm\n",
+ "C = 0.1*(10**-6) # The value of integrating capacitor in F\n",
+ "V_ref = 2 # The reference voltage in V\n",
+ "V_out = 10 # The maximum limit of the output in V\n",
+ "\n",
+ "#Calculations\n",
+ "T = R*C\n",
+ "print \"The integrator time constant = \",T,\" s\"\n",
+ "V_s = V_ref/T #Unit is V/s\n",
+ "V = 1/V_s\n",
+ "print \"Therefore the integrator output = \",V,\" s/V \\nTherefore to integrate 10V \"\n",
+ "T_max = V*V_out #The max time the ref voltage can be integrated\n",
+ "print \"The time required = \",T_max,\" s\"\n",
+ "\n",
+ "#Result\n",
+ "# The integrator time constant = 0.010 s\n",
+ "# Therefore the integrator output = 0.005 s/V \n",
+ "# Therefore to integrate 10V \n",
+ "# The time required = 0.0500 s \n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The integrator time constant = 0.01 s\n",
+ "Therefore the integrator output = 0.005 s/V \n",
+ "Therefore to integrate 10V \n",
+ "The time required = 0.05 s\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.4:pg-162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find the distributed capacitance\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 6-4 in Page 162\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# Frequency measurements in Hz\n",
+ "f_1 = 2*10**6\n",
+ "f_2 = 4*10**6\n",
+ "# Value of tuning capacitor in F\n",
+ "C_1 = 460*10**-12\n",
+ "C_2 = 100*10**-12\n",
+ "\n",
+ "#Calculations\n",
+ "C_d = (C_1-(4*C_2))/3\n",
+ "print \"C_d = \",round(C_d,13),\" F\\n\"\n",
+ "print \"i.e The value of the distributed capacitance = \",round(C_d*10**12,1),\" pF\"\n",
+ "\n",
+ "#Result\n",
+ "# C_d = 2E-011 F\n",
+ "# i.e The value of the distributed capacitance = 20 pF \n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "C_d = 2e-11 F\n",
+ "\n",
+ "i.e The value of the distributed capacitance = 20.0 pF\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.5:pg-162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find the self capacitance\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 6-5 in Page 162\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "# Values of frequencies in Hz\n",
+ "f_1 = 2*10**6\n",
+ "f_2 = 5*10**6\n",
+ "# Values of the tuning capacitors in F\n",
+ "C_1 = 450*10**-12\n",
+ "C_2 = 60*10**-12\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "#Using the equation f = 1/(2*%pi*sqrt(L*(C_2+C_d)))\n",
+ "#Since f_2 = 2.5*f_1\n",
+ "#Equating & reducing the equations\n",
+ "# 1/(C_2 +C_d) = 6.25/(C_1 +C_d)\n",
+ "\n",
+ "C_d = (C_1 -6.25*C_2)/5.25\n",
+ "print \"C_d = \",round(C_d,13),\" F\\n\"\n",
+ "print \"i.e The value of the distributed capacitance = \",round(C_d*10**12,1),\" pF\"\n",
+ "\n",
+ "#Result\n",
+ "# C_d = 1.43E-011 F\n",
+ "# i.e The value of the distributed capacitance = 14.3 pF \n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "C_d = 1.43e-11 F\n",
+ "\n",
+ "i.e The value of the distributed capacitance = 14.3 pF\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.6:pg-163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find percentage error\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 6-6 in Page 163\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "R = 10 #Resistance of the coil in ohm\n",
+ "f = 1*10**6 #The oscillator frequency in Hz\n",
+ "C = 65*10**-12 #The value of resonating capacitor in F\n",
+ "R_i = 0.02 #The value of the insertion resistor in ohm\n",
+ "\n",
+ "#Calculations\n",
+ "w = 2*math.pi*f\n",
+ "Q_e = 1/(w*C*R)\n",
+ "print \"The effective Q of the coil = \",round(Q_e,1),\"\\n\"\n",
+ "Q_i = 1/(w*C*(R+R_i))\n",
+ "print \"The indicated Q of the coil = \",round(Q_i,1),\"\\n\"\n",
+ "percenterror = (Q_e - Q_i)/Q_e*100\n",
+ "print \"The percentage error is = \",round(percenterror,1),\" %\"\n",
+ "\n",
+ "#Result\n",
+ "# The effective Q of the coil = 244.9\n",
+ "# The indicated Q of the coil = 244.4\n",
+ "# The percentage error is = 0.2 % \n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The effective Q of the coil = 244.9 \n",
+ "\n",
+ "The indicated Q of the coil = 244.4 \n",
+ "\n",
+ "The percentage error is = 0.2 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex6.7:pg-163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find percentage error\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 6-7 in Page 163\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "R = 0.1 #Resistance of the coil in ohm\n",
+ "f = 40*10**6 #The frequency at resonance in Hz\n",
+ "C = 135*10**-12 #The value of tuning capacitor in F\n",
+ "R_i = 0.02 #The value of the insertion resistor in ohm\n",
+ "\n",
+ "\n",
+ "#Calculations\n",
+ "w = 2*math.pi*f\n",
+ "Q_e = 1/(w*C*R)\n",
+ "print \"The effective Q of the coil = \",ceil(Q_e),\"\\n\"\n",
+ "Q_i = 1/(w*C*(R+R_i))\n",
+ "print \"The indicated Q of the coil = \",ceil(Q_i),\"\\n\"\n",
+ "percenterror = (Q_e - Q_i)/Q_e*100\n",
+ "print \"The percentage error is = \",ceil(percenterror),\" %\"\n",
+ "\n",
+ "#Result\n",
+ "# The effective Q of the coil = 295\n",
+ "# The indicated Q of the coil = 246\n",
+ "# The percentage error is = 17 % \n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The effective Q of the coil = 295.0 \n",
+ "\n",
+ "The indicated Q of the coil = 246.0 \n",
+ "\n",
+ "The percentage error is = 17.0 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter7_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter7_4.ipynb new file mode 100644 index 00000000..88aa47b3 --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter7_4.ipynb @@ -0,0 +1,76 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:e7340f8f28dc1125639b884b427c98c7b76b7b5253f0bd98a418a9d51e4810f2"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 7:Oscilloscopes\n"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex7.1:pg-184"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find minimum distance\n",
+ "# Modern Electronic Instrumentation And Measurement Techniques\n",
+ "# By Albert D. Helfrick, William D. Cooper\n",
+ "# First Edition Second Impression, 2009\n",
+ "# Dorling Kindersly Pvt. Ltd. India\n",
+ "# Example 7-1 in Page 184\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "# Given data\n",
+ "D = 4*10**-2 #Deflection on the screen in m\n",
+ "G = 100*100 # Deflection factor in V/m\n",
+ "E_a = 2000 #Accelarating potential in V\n",
+ "\n",
+ "#Calculations\n",
+ "# wkt. L = 2*d*E_a/(G*I_d)\n",
+ "\n",
+ "#Also L/D = I_d / d\n",
+ "#Therefore\n",
+ "\n",
+ "L = math.sqrt(2*D*E_a/G)\n",
+ "print \"The distance from the deflection plates to the oscilloscope tube screen = \",round(L,3),\"m\"\n",
+ "\n",
+ "#Result\n",
+ "# The distance from the deflection plates to the oscilloscope tube screen = 0.126 m \n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The distance from the deflection plates to the oscilloscope tube screen = 0.126 m\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter9_4.ipynb b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter9_4.ipynb new file mode 100644 index 00000000..0655eef8 --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter9_4.ipynb @@ -0,0 +1,144 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:349ae7afdee1d1b3c3dc4037b8dc3bb200738707d16369e5edfee0d065859f9b"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 9: Signal Analysis"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.1:pg-277"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find dynamic range of spectrum analyser\n",
+ "\n",
+ "# Given data\n",
+ "I_p = +25.0; #Third order intercept point in dBm\n",
+ "MDS = -85.0; #noise level in dBm\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "dynamic_range = 2/3.0*(I_p -MDS);\n",
+ "print \"The dynamic range of the spectrum analyser =\",int(dynamic_range),\" dB\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The dynamic range of the spectrum analyser = 73 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.2:pg-277"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find minimum detectable signal\n",
+ "\n",
+ "import math\n",
+ "\n",
+ "# Given data\n",
+ "NF = 20.0; #Noise figure in dB\n",
+ "BW = 1*10.0**3; #Bandwidth in Hz\n",
+ "\n",
+ "#Calculations\n",
+ "MDS=-114+10*math.log10((BW/(1*10.0**6)))+NF\n",
+ "print \"The minimum detectable signal of the spectrum analyser = \",int(MDS),\" dBm\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The minimum detectable signal of the spectrum analyser = -124 dBm\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex9.3:pg-285"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# To find dynamic range and total frequency display\n",
+ "\n",
+ "import math\n",
+ "# Given data\n",
+ "T = 4.0; #Sample window in s\n",
+ "f_s = 20*10.0**3; # sample frequency in Hz\n",
+ "N = 10.0; #no of bits\n",
+ "\n",
+ "#Calculations\n",
+ "f_r = 1/T;\n",
+ "f_h = f_s/2.0; \n",
+ "R_d = 20*math.log10(2.0**N);\n",
+ "\n",
+ "print \"The ratio of the spectral calculation = \",round(f_r,2),\" Hz\\n\"\n",
+ "print \"The maximum calculated spectral frequency = \",int(f_h),\" Hz\\n\"\n",
+ "print \"The dynamic range = \",int(R_d),\" dB\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The ratio of the spectral calculation = 0.25 Hz\n",
+ "\n",
+ "The maximum calculated spectral frequency = 10000 Hz\n",
+ "\n",
+ "The dynamic range = 60 dB\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/11.1new_3.png b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/11.1new_3.png Binary files differnew file mode 100644 index 00000000..3c6f12aa --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/11.1new_3.png diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.1new_3.png b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.1new_3.png Binary files differnew file mode 100644 index 00000000..4128c87a --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.1new_3.png diff --git a/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.4new_2.png b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.4new_2.png Binary files differnew file mode 100644 index 00000000..19cdbc25 --- /dev/null +++ b/Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.4new_2.png diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter2.ipynb b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter2.ipynb new file mode 100644 index 00000000..66f08f5f --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter2.ipynb @@ -0,0 +1,1027 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cb1d3e018e4d7d09647d7c5ade60c15ce847002c6fe7d7460044d34deec7819c" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-2 Optical Fibers & Fiber Cables" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 Page no 31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sqrt, pi\n", + "# Calculation of core diameter\n", + "# Given data\n", + "n1=1.5# # Refractive index of core\n", + "n2=1.48# # Refractive index of cladding\n", + "N=1000# # No of modes\n", + "lamda=1.3# # Light wavelength\n", + "V=sqrt(2*N)# # Mode parameter\n", + "\n", + "#core diameter\n", + "d=(lamda*V)/(2*pi*sqrt(n1**2-n2**2))# \n", + "\n", + "print\"Mode parameter = %0.2f \"%(V)#\n", + "print\"Core diameter = %0.0f micrometer \"%(d)#\n", + "\n", + "# Answer is wrong in the book." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mode parameter = 44.72 \n", + "Core diameter = 38 micrometer \n" + ] + } + ], + "prompt_number": 67 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 Page no 35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import asin, sin, degrees\n", + "# Calculation of (a) critical angle (b) acceptance angle and oblique angle (c) numerical aperature \n", + "# (d) percentage of light collected by the fiber and (e) diameter of fiber\n", + "\n", + "# Given data\n", + "n1=1.5# # Refractive index of core\n", + "n2=1.45# # Refractive index of cladding\n", + "V=2.405# # Mode parameter\n", + "lamda=1.55 # Wavelength of fiber\n", + "\n", + "# (a) Critical angle of the\n", + "theatha=degrees(asin(n2/n1))# \n", + "\n", + "# (b) Oblique angle\n", + "oa=90-theatha# \n", + " #Acceptance angle \n", + "t1=n1*sin(oa*pi/180)# \n", + "th1=degrees(asin(t1))# \n", + "\n", + "# (c) Numerical aperature \n", + "NA=sqrt(n1**2-n2**2)# \n", + "\n", + "# (d) Percentage of light collected in fiber\n", + "P=(NA)**2*100# \n", + "\n", + "#(e) Diameter of fiber\n", + "d=V*lamda/pi*(1/sqrt(n1**2-n2**2))# \n", + "\n", + "\n", + "print\"Critical angle = %0.0f degrees \"%(theatha)#\n", + "print\"Oblique angle = %0.0f degrees \"%(oa)#\n", + "print\"Acceptance angle = %0.0f degrees \"%(th1)#\n", + "print\"Numerical aperature = %0.4f \"%(NA)#\n", + "print\"Percentage of light collected in fiber = %0.1f \"%(P)#\n", + "print\"Diameter of fiber = %0.2f micrometer \"%(d)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Critical angle = 75 degrees \n", + "Oblique angle = 15 degrees \n", + "Acceptance angle = 23 degrees \n", + "Numerical aperature = 0.3841 \n", + "Percentage of light collected in fiber = 14.7 \n", + "Diameter of fiber = 3.09 micrometer \n" + ] + } + ], + "prompt_number": 68 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 Page no 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of (a) critical angle (b) numerical aperature and (c) acceptance angle\n", + "\n", + "# Given data\n", + "n1=1.5# # Refractive index of core\n", + "n2=1.47# # Refractive index of cladding)\n", + "\n", + "# (a) Critical angle\n", + "theatha=degrees(asin(n2/n1))# \n", + "# (b) Numerical aperature\n", + "NA=sqrt(n1**2-n2**2)# \n", + "# (c) Acceptance angle\n", + "theatha1=degrees(asin(NA))# \n", + "\n", + "\n", + "print\"Critical angle = %0.1f degrees \"%(theatha)#\n", + "print\"Numerical aperature = %0.2f \"%(NA)#\n", + "print\"Acceptance angle = %0.1f degrees \"%(theatha1)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Critical angle = 78.5 degrees \n", + "Numerical aperature = 0.30 \n", + "Acceptance angle = 17.4 degrees \n" + ] + } + ], + "prompt_number": 69 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 Page no 46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of output power\n", + "\n", + "# Given data\n", + "Pi=1# # Input power\n", + "A=0.5# # Atteuation\n", + "L=15# # Fiber link length\n", + "\n", + "# Output Power\n", + "Po=Pi*10**((-A*L)/10)# \n", + "\n", + "\n", + "print\"Output Power = %0.3f mW \"%(Po)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Output Power = 0.178 mW \n" + ] + } + ], + "prompt_number": 70 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 Page no 47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log10\n", + "# Calculation of maximum transmission distance\n", + "\n", + "\n", + "# Given data\n", + "Pi=1*10**-3# # Input power\n", + "A=0.5# # Atteuation\n", + "Po=50*10**-6# # Output Power\n", + "\n", + "# Maximum transmission distance\n", + "L=(10/A)*log10(Pi/Po)# \n", + "\n", + "\n", + "print\"Maximum transmission distance = %0.0f km \"%(L)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum transmission distance = 26 km \n" + ] + } + ], + "prompt_number": 71 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 Page no 48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of output power\n", + "\n", + "# Given data\n", + "Pin=1*10**-3# # Input power\n", + "AL1=10# # Attenuation 1\n", + "AL2=20# # Attenuation 2 \n", + "#Output power 1 and 2\n", + "Po1=Pin/10# \n", + "Po2=Pin/20# \n", + "Po1=Po1*10**3#\n", + "Po2=Po2*10**6#\n", + "\n", + "print\"Output power = %0.1f mW\"%(Po1)#\n", + "print\"Output power = %0.0f uW\"%(Po2)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Output power = 0.1 mW\n", + "Output power = 50 uW\n" + ] + } + ], + "prompt_number": 72 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 Page no 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "\n", + "# Calculation of attenuation and Rayleigh scattering coefficient for fiber\n", + "\n", + "\n", + "# Given data\n", + "n=1.46# # Refractive index\n", + "p=0.286# # Average photoelastic coefficient\n", + "B=7.25*10**-11# # Isothermal compressibility\n", + "k=1.38*10**-23# # Boltzmann's constant\n", + "T=1350# # Fictive temperature\n", + "l1=1*10**-6# # Wavelength 1\n", + "l2=1.3*10**-6# # Wavelength 2\n", + "L=10**3# # Length\n", + "\n", + "# Rayleigh scattering coefficient for length 1\n", + "y1=8*(pi)**3*(n)**8*(p)**2*B*k*T/(3*(l1)**4)# \n", + "# Rayleigh scattering coefficient for length 2\n", + "y2=8*(pi)**3*(n)**8*(p)**2*B*k*T/(3*(l2)**4)# \n", + "y1=y1#\n", + "y2=y2#\n", + "#Attenuation 1\n", + "T1=exp(-(y1*L))# \n", + "#Attenuation 2\n", + "T2=exp(-(y2*L))# \n", + "\n", + "\n", + "print\"First Rayleigh scattering coefficient = %0.6f m**-1 \"%(y1)#\n", + "print\"Second Rayleigh scattering coefficient = %0.6f m**-1 \"%(y2)#\n", + "\n", + "print\"Attenuation (@ Length 1) = %0.2f dB/km\"%(T1)#\n", + "print\"Attenuation (@ Length 2) = %0.2f dB/km\"%(T2)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "First Rayleigh scattering coefficient = 0.000189 m**-1 \n", + "Second Rayleigh scattering coefficient = 0.000066 m**-1 \n", + "Attenuation (@ Length 1) = 0.83 dB/km\n", + "Attenuation (@ Length 2) = 0.94 dB/km\n" + ] + } + ], + "prompt_number": 73 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8 Page no 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of threshold power of stimulated Brillouin scattering and Raman Scattering\n", + "\n", + "\n", + "\n", + "# Given data\n", + "A=0.5# # Attenuation\n", + "d=5# # Core diameter\n", + "lamda=1.3# # Operating wavelength\n", + "v=0.7# # Bandwith of laser diode\n", + "\n", + "# Threshold power of stimulated Brillouin scattering\n", + "Pb=4.4*10**-3*d**2*lamda**2*A*v#\n", + "Pb=Pb*10**3#\n", + "\n", + "#Threshold power stimulated Raman Scattering\n", + "Pr=5.9*10**-2*d**2*lamda*A# \n", + "\n", + "\n", + "print\"Threshold power of stimulated Brillouin scattering = %0.2f mW\"%(Pb)#\n", + "print\"Threshold power stimulated Raman Scattering = %0.2f W\"%(Pr)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Threshold power of stimulated Brillouin scattering = 65.06 mW\n", + "Threshold power stimulated Raman Scattering = 0.96 W\n" + ] + } + ], + "prompt_number": 74 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 Page no. 479" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Compuatation of mode parameter\n", + "\n", + "\n", + "\n", + "#Given data\n", + "n1=1.503# # refractive index of core\n", + "n2=1.50# # refractive index of cladding\n", + "a=4*10**-6# # core radius\n", + "lamda=1*10**-6# # light wavelength\n", + "\n", + "# Mode parameter computation\n", + "V=(2*pi*a*sqrt(n1**2-n2**2))/(lamda)#\n", + "\n", + "#Displaying the result in command window\n", + "print\"Mode parameter is = %0.3f \"%(V)#\n", + "\n", + "# The answer vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mode parameter is = 2.385 \n" + ] + } + ], + "prompt_number": 75 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 Page no. 479" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of numerical aperature\n", + "\n", + "\n", + "\n", + "#Given data\n", + "v=2.111# # Mode parameter\n", + "a=4.01*10**-6# # Core radius in m\n", + "lamda=1.3*10**-6# # Wavelength of laser light m\n", + "\n", + "#Numerical aperture computation\n", + "NA=(v*lamda)/(2*pi*a)# \n", + "\n", + "#Displaying the result in command window\n", + "print\"Numerical aperature = %0.2f\"%(NA)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerical aperature = 0.11\n" + ] + } + ], + "prompt_number": 76 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 Page no 480" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Calculation of potential difference\n", + "\n", + "\n", + "\n", + "# Given data\n", + "na=10**24# # Accepter impurity level\n", + "nd=10**22# # Donor impurity level\n", + "ni=2.4*10**19# # Intrinsic electron \n", + "T=290# # Room temperature\n", + "e=1.602*10**-19# # Electric charge\n", + "K=1.38*10**-23# # Boltzmann constant\n", + "\n", + "\n", + "#Potential difference\n", + "V=(K*T)/e*(log(na*nd/(ni)**2))#\n", + "\n", + "\n", + "print\"Potential difference = %0.2f V \"%(V)#\n", + "# The potential difference varies with the variation of Na, Nd and ni" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Potential difference = 0.42 V \n" + ] + } + ], + "prompt_number": 77 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 Page no 480" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of (a) Numerical aperature and (b) critical angle\n", + "\n", + "\n", + "\n", + "# Given data\n", + "n1=1.5# # Refractive index of core\n", + "n2=1.47# # Refractive index of cladding\n", + "\n", + "# (a) Numerical aperature\n", + "NA= sqrt(n1**2-n2**2)# \n", + "\n", + "# (b) Critical angle\n", + "theatha=degrees(asin(n2/n1))# \n", + "\n", + "\n", + "print\"Numerical aperature = %0.2f \"%(NA)#\n", + "print\"Critical angle = %0.1f degrees \"%(theatha)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerical aperature = 0.30 \n", + "Critical angle = 78.5 degrees \n" + ] + } + ], + "prompt_number": 78 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 Page no 480" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "# Computation of (a) normalized frequency and (b) no. of guided modes\n", + "\n", + "\n", + "\n", + "#Given data\n", + "lamda=0.85*10**-6# # wavelength of fiber\n", + "a=40*10**-6# # core diameter of fiber\n", + "delta=0.015# # relative refractive index \n", + "n1=1.48# # refractive index of core\n", + "\n", + "# (a) Normalized frequency \n", + "v=(2*pi*a*n1*(2*delta)**(1/2))/lamda# \n", + "#(b) Number of guided modes\n", + "m=v**2/2# \n", + "m=math.ceil(m)#\n", + "#Displaying results in the command window \n", + "print\"Normalized frequency is = %0.1f \"%(v)#\n", + "print\"Number of guided modes = %0.0f \"%(m)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Normalized frequency is = 75.8 \n", + "Number of guided modes = 2873 \n" + ] + } + ], + "prompt_number": 79 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 Page no 480" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of normalized frequency and no of guided modes\n", + "\n", + "\n", + "#Given data\n", + "lamda=1.30*10**-6# # Wavelength of fiber\n", + "a=25*10**-6# # Core diameter of fiber\n", + "delta=0.01# # Relative refractive index \n", + "n1=1.50# # Refractive index of core\n", + "\n", + "# (a) Normalized frequency \n", + "v=((2*pi*a*n1)/(lamda))*((2*delta)**(1/2))# \n", + "#(b) Number of guided modes\n", + "m=v**2/2# \n", + "#m=ceil(m)#\n", + "\n", + "#Displaying results in the command window \n", + "print\"Normalized frequency = %0.2f \"%(v)#\n", + "print\"Number of guided modes = %0.0f \"%(m)#\n", + "\n", + "#Answer varies due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Normalized frequency = 25.63 \n", + "Number of guided modes = 329 \n" + ] + } + ], + "prompt_number": 80 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 Page no 481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of normalized frequency and no of guided modes\n", + "\n", + "\n", + "\n", + "#Given data\n", + "lamda=1.55*10**-6# # Wavelength of fiber\n", + "a=30*10**-6# # Core diameter of fiber\n", + "delta=0.015# # Relative refractive index \n", + "n1=1.48# # Refractive index of core\n", + "\n", + "# (a) Normalized frequency \n", + "v=(2*pi*a*n1*(2*delta)**(1/2))/lamda# \n", + "#(b) Number of guided modes\n", + "m=v**2/2# \n", + "\n", + "#Displaying results in the command window \n", + "print\"Normalized frequency = %0.2f \"%(v)#\n", + "print\"Number of guided modes = %0.0f \"%(m)#\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Normalized frequency = 31.17 \n", + "Number of guided modes = 486 \n" + ] + } + ], + "prompt_number": 81 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8 Page no 481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of normalized frequency and no of guided modes\n", + "\n", + "\n", + "#Given data\n", + "lamda=1.55*10**-6# # Wavelength of fiber\n", + "a=4*10**-6# # Core diameter of fiber\n", + "delta=0.01# # Relative refractive index \n", + "n1=1.48# # Refractive index of core\n", + "# (a) Normalized frequency \n", + "v=(2*pi*a*n1*(2*delta)**(1/2))/lamda# \n", + "#(b) Number of guided modes\n", + "m=v**2/2# \n", + "\n", + "#Displaying results in the command window \n", + "print\"Normalized frequency = %0.3f \"%(v)#\n", + "print\"Number of guided modes = %0.0f \"%(m)#\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Normalized frequency = 3.394 \n", + "Number of guided modes = 6 \n" + ] + } + ], + "prompt_number": 82 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.9 Page no 481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of Core radius\n", + "\n", + "#Given data\n", + "lamda=0.85*10**-6# # Wavelength of fiber\n", + "delta=0.015# # Relative refractive index \n", + "n1=1.48# # Refractive index of core\n", + "v=2.403# # Normalized frequency for single mode fiber\n", + "# Computation of core radius\n", + "a=v*lamda/(2*pi*n1*sqrt(2*delta))#\n", + "a=a*10**6#\n", + "\n", + "print\"Radius of core = %0.1f micrometer \"%(a)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Radius of core = 1.3 micrometer \n" + ] + } + ], + "prompt_number": 83 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.10 Page no 482" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of Cut off wavelength\n", + "\n", + "# Given data\n", + "V=2.403# # Normalized frequency\n", + "delta=0.25# # Refractive index of core\n", + "n1=1.46# # Relative refractive index\n", + "a=4.5*10**-6# # Radius of core\n", + "\n", + "# Cut off wavelenth\n", + "lamda=(2*pi*a*n1*(sqrt(2*delta)))/V# \n", + "\n", + "\n", + "print\"Cut off wavelenth = %0.0f nm \"%(lamda*10**8)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Cut off wavelenth = 1215 nm \n" + ] + } + ], + "prompt_number": 84 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.11 Page no 482" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Calculation of (a) reflection and (b) loss of light signal at joint areas.\n", + "\n", + "\n", + "\n", + "# Given data\n", + "n1=1.5# # Refractive index of core\n", + "n=1# # Refractive index of air\n", + "\n", + "# (a) Reflection at the fiber air interface \n", + "R=((n1-n)/(n1+n))**2# \n", + "\n", + "# (b) Light loss due to fiber air interface\n", + "l= -10*log10(1-R)#\n", + "\n", + "\n", + "print\"Reflection at the fiber air interface = %0.2f \"%(R)#\n", + "print\"Light loss due to fiber air interface = %0.2f dB \"%(l)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reflection at the fiber air interface = 0.04 \n", + "Light loss due to fiber air interface = 0.18 dB \n" + ] + } + ], + "prompt_number": 85 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.12 Page no 482" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of (a) numerical aperature and (b) maximum angle of entrance\n", + "\n", + "#Given data\n", + "n1=1.48# # Refractive index of core\n", + "n2=1.46# # Refractive index of cladding\n", + "\n", + "# (a) Numerical Aperture \n", + "NA=sqrt(n1**2-n2**2)#\n", + "\n", + "#(b) Maximum angle of entrance\n", + "theata=degrees(asin(NA))\n", + "\n", + "#Displaying result in the command window \n", + "print\"Numerical Aperture = %0.3f \"%(NA)#\n", + "print\"Maximum angle of entrance = %0.0f degress \"%(theata)#\n", + "\n", + "# Final answer in the book is wrong. Please refer example 2.11 of \n", + "# Fiber Optic Communication by Gerd Keiser book.\n", + "\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerical Aperture = 0.242 \n", + "Maximum angle of entrance = 14 degress \n" + ] + } + ], + "prompt_number": 86 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.13 Page no 483" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of (a) core radius and (b) maximum value of angle of acceptance of the fiber\n", + "\n", + "#Given data\n", + "lamda=1320*10**-9# # Wavelength of fiber\n", + "delta=0.077# # Relative refractive index \n", + "n1=1.48# # Refractive index of core\n", + "n2=1.478# # Refractive index of cladding\n", + "v=2.403# # Normalized frequency\n", + "\n", + "# (a) Core radius\n", + "a=v*lamda/(2*pi*delta)#\n", + "a=a*10**6#\n", + "\n", + "#Numerical Aperture\n", + "NA=sqrt(n1**2-n2**2)#\n", + "\n", + "# (b) Angle of acceptance\n", + "theata = degrees(asin(NA))\n", + "\n", + "\n", + "print\"Radius of core = %0.1f micrometer \"%(a)#\n", + "print\"Numerical aperture = %0.5f \"%(NA)#\n", + "print\"Angle of acceptance = %0.0f degrees \"%(theata)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Radius of core = 6.6 micrometer \n", + "Numerical aperture = 0.07692 \n", + "Angle of acceptance = 4 degrees \n" + ] + } + ], + "prompt_number": 87 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.14 Page no 483" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of critical wavelength\n", + "\n", + "\n", + "\n", + "#Given data\n", + "a=3*10**-6# # Core diameter of fiber\n", + "delta=0.15# # Relative refractive index \n", + "v=2.405# # Normalized frequency\n", + "\n", + "# Critical wavelength\n", + "lamda=(2*pi*a*delta)/v#\n", + "lamda*=10**9#\n", + "\n", + "\n", + "print\"Critical wavelength = %0.0f nm \"%(lamda)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Critical wavelength = 1176 nm \n" + ] + } + ], + "prompt_number": 88 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter3.ipynb b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter3.ipynb new file mode 100644 index 00000000..d5306fc3 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter3.ipynb @@ -0,0 +1,295 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:616b9c2eaabca1b44dc6f6ace1a50916fb1cc256a6807c0919f4e5df6cd01cf7" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-3 Electroluminescent Sources" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.1 Page no 80" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import log\n", + "#Calculation of barrier potential\n", + "#Given data\n", + "p=5# # Resistivity of p-region\n", + "n=2# # Resistivity of n-region\n", + "mu=3900#\n", + "k=0.026# #Boltzmann constant\n", + "ni=2.5*10**13# #Density of the electron hole pair\n", + "e=1.6*10**-19# #charge of electron\n", + " \n", + "#Barrier potential calculation\n", + "r0=(1/p)# # Reflection at the fiber air interface \n", + "r1=(1/n)#\n", + "m=r1/(mu*e)#\n", + "p=6.5*10**14# #Density of hole in p -region\n", + "Vb=k*log(p*m/ni**2)#\n", + "print \"Barrier potential = %0.3f V\"%Vb\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Barrier potential = 0.175 V\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.15 Page no 484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of external efficiency \n", + "#Given data\n", + "ne1=0.20# #Total efficiency \n", + "V=3# # Voltage applied\n", + "Eg=1.43# # Bandgap energy\n", + "\n", + "# External efficiency\n", + "ne=(ne1*Eg/V)*100#\n", + "print \"External efficiency of the device = %0.1f %% \"%(ne)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "External efficiency of the device = 9.5 % \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.16 Page no 484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "# Calculation of ratio of threshold current densities\n", + "# Given data\n", + "To1=160# # Device temperature\n", + "To2=55# # Device temperature\n", + "T1=293#\n", + "T2=353#\n", + "J81=exp(T1/To1)# # Threshold current density \n", + "J21=exp(T2/To1)#\n", + "J82=exp(T1/To2)## \n", + "J22=exp(T2/To2)## \n", + "cd1=J21/J81# # Ratio of threshold current densities\n", + "cd2=J22/J82#\n", + "\n", + "print\"Ratio of threshold current densities= %0.2f \"%(cd1)\n", + "print\"Ratio of threshold current densities= %0.2f \"%(cd2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Ratio of threshold current densities= 1.45 \n", + "Ratio of threshold current densities= 2.98 \n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.17 Page no 484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Computation of conversion efficiency \n", + "#Given data\n", + "i=10*10**-6# # Device current\n", + "p=5# # Electrical power\n", + "op=50 *10**-6# # Optical power\n", + "ip=5*10*10**-3# # Input power\n", + "\n", + "#Conversion efficiency\n", + "c=op/ip*100# \n", + "print \"Conversion efficiency = %0.1f %% \"%(c)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Conversion efficiency = 0.1 % \n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.18 Page no 485" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of total power emitted\n", + "#Given data\n", + "r=0.7# # Emissivity\n", + "r0=5.67*10**-8# # Stephen's constant\n", + "A=10**-4# # Surface area\n", + "T=2000# # Temperature\n", + "\n", + "# Total power emitted\n", + "P=r*r0*A*T**4# \n", + "\n", + "print\"Total power emitted = %0.1f Watts \"%P" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total power emitted = 63.5 Watts \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.19 Page no 485" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of total energy\n", + "#Given data\n", + "h=6.63*10**-34# # Planck constant\n", + "v=5*10**14# # Bandgap frequency of laser\n", + "N=10**24# # Population inversion density\n", + "V=10**-5# # Volume of laser medium\n", + "\n", + "# Total energy\n", + "E=(1/2)*h*v*(N)*V# \n", + "\n", + "print \"Total energy = %0.1f J \"%E" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total energy = 1.7 J \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.20 Page no 485" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of pulse power\n", + "# Given data\n", + "L=0.1# # Length of laser\n", + "R=0.8# # Mirror reflectance of end mirror\n", + "E=1.7# # Laser pulse energy\n", + "c=3*10**8# # Velocity of light\n", + "t=L/((1-R)*c)# # Cavity life time\n", + "\n", + "# Pulse power\n", + "p=E/t# \n", + "\n", + "print\"Pulse power = %0.0f W \"%p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Pulse power = 1020000000 W \n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter4.ipynb b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter4.ipynb new file mode 100644 index 00000000..557fdce3 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter4.ipynb @@ -0,0 +1,142 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:ff9656e3741890c1b84f87cd6c76097007b957d4fa78f0c44f653f7087be4952" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-4 Optical Fiber Transmitter" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.21 Page no 486" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sqrt, pi\n", + "\n", + "# Calculation of wavelength seperation between longitudinal modes.\n", + "\n", + "\n", + "#Given data\n", + "lamda=0.85# # Wavelength\n", + "n1=3.6# # Refractive index of GaAs\n", + "L=200*10**-6# # Length of cavity\n", + "\n", + "# Wavelength seperation between longitudinal modes.\n", + "lambda1=((lamda)**2)*(10**-12)/(2*n1*L)# \n", + "lambda1=lambda1*10**9#\n", + "\n", + "#Displaying results in the command window\n", + "print\"Wavelength seperation = %0.1f nm**2\"%(lambda1)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Wavelength seperation = 0.5 nm**2\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.22 Page no 486" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of overall external efficiency\n", + "\n", + "#Given data\n", + "eg=1.43# # Bandgap energy\n", + "v=2.5# # Electrical supply Voltage\n", + "nd=0.18# # Optical efficiency of laser diode\n", + "\n", + "# Computation of overall external efficiency\n", + "ne=(nd*eg/v)*100# \n", + "\n", + "\n", + "print\"Overall external efficiency = %0.0f %%\"%(ne)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Overall external efficiency = 10 %\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.23 Page no 486" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of overall external efficiency of a Laser diode\n", + "\n", + "#Given data\n", + "eg=1.43# # Bandgap energy\n", + "v=2.5# # Voltage applied\n", + "nd=0.30# # Optical efficiency of laser diode\n", + "\n", + "## Overall external efficiency \n", + "ne=(nd*eg/v)*100# \n", + "\n", + "\n", + "print\"Overall external efficiency = %0.0f %%\"%(ne)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Overall external efficiency = 17 %\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter5.ipynb b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter5.ipynb new file mode 100644 index 00000000..02e2ca22 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter5.ipynb @@ -0,0 +1,344 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:55496805e1c8c4093a6f120824db813e444ecbc634f90cfa8cb9e3e10e547069" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-5 Optical Detector" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.24 Page no 487" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sqrt, pi\n", + "\n", + "# Calculation of (a) wavelength (b) resposivity and (c) incident power\n", + "\n", + "#Given data\n", + "e=0.7# # Efficiency\n", + "c=3*10**8# # Speed of light\n", + "h=6.62*10**-34 # Planck constant\n", + "E=2.2*10**-19# # Energy of photons\n", + "e1=1.6*10**-19# # Electron charge \n", + "# (a) Wavelength computation\n", + "lamda=h*c/E # Wavelength of laser source\n", + "f=c/lamda# \n", + "\n", + "# (b) Responsivity\n", + "R=e*(lamda*e1)/(h*c)# \n", + "\n", + "# (c) Incident power\n", + "Ip=2*10**-6# # Photocurrent\n", + "P=Ip/R#\n", + "\n", + "\n", + "print\"Wavelength of operation = %0.1f micrometer \"%(lamda*10**6)#\n", + "print\"Responsivity R = %0.2f A/W \"%(R)#\n", + "print\"output power P = %0.2f microwWatt \"%(P*10**6)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Wavelength of operation = 0.9 micrometer \n", + "Responsivity R = 0.51 A/W \n", + "output power P = 3.93 microwWatt \n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.25 Page no 487" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of (a) quantum efficiency and (b) resposivity\n", + "\n", + "#Given data\n", + "nh=1.5*10**12# # No. of hole pairs generated\n", + "np=2.5*10**12# # No. of incident photons\n", + "lamda=0.85*10**-6# # Wavelength of laser source \n", + "c=3*10**8# # Speed of light\n", + "h=6.62*10**-34 # Planck constant\n", + "e1=1.6*10**-19# # Electronic charge\n", + "\n", + "# (a) Quantum efficiency\n", + "e=nh/np# \n", + "\n", + "# (b) Responsivity\n", + "R=e*(lamda*e1)/(h*c)# #\n", + "\n", + "\n", + "print\"Quantum efficiency = %0.1f \"%(e)#\n", + "print\"Responsivity R = %0.3f A/W \"%(R)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Quantum efficiency = 0.6 \n", + "Responsivity R = 0.411 A/W \n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.26 Page no 488" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of (a) wavelength (b) power and (c) resposivity\n", + "\n", + "#Given data\n", + "e=0.7# # Quantum efficiency\n", + "c=3*10**8# # Speed of light\n", + "h=6.62*10**-34 # Planck constant\n", + "E=1.5*10**-19# # Energy of photons\n", + "e1=1.6*10**-19# # Electronic charge\n", + "I=4*10**-6# # Diode photocurrent\n", + "# (a) Wavelength of operation\n", + "lamda=h*c/E# \n", + "\n", + "# (b) Responsivity\n", + "R=e*(lamda*e1)/(h*c)# #\n", + "\n", + "# (c) Incident optical power \n", + "p=I/R# #power\n", + "\n", + "\n", + "print\"Wavelength of operation = %0.3f micrometer \"%(lamda*10**6)#\n", + "print\"Responsivity R = %0.3f A/W \"%(R)#\n", + "print\"output power P = %0.3f microwWatt \"%(p*10**6)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Wavelength of operation = 1.324 micrometer \n", + "Responsivity R = 0.747 A/W \n", + "output power P = 5.357 microwWatt \n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.27 Page no 488" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of (a)resposivity (b)output current and (c)multiplication factor\n", + "\n", + "\n", + "\n", + "#Given data\n", + "e=0.7# # Quantum efficiency\n", + "c=3*10**8# # Speed of light\n", + "h=6.62*10**-34 # Planck constant\n", + "E=1.5*10**-19# # Energy of photons\n", + "lamda=0.85*10**-6 # Wavelength of laser source\n", + "P=0.6*10**-6# # Incident light power\n", + "e1=1.6*10**-19# # Electronic charge\n", + "I=10*10**-6# # Output current of the device \n", + "\n", + "# (a) Responsivity\n", + "R=e*(lamda*e1)/(h*c)# \n", + "\n", + "# (b) Photocurrent\n", + "Ip=R*P#\n", + "\n", + "# (c) Multiplication factor\n", + "M=I/Ip\n", + "\n", + "\n", + "print\"Responsivity R = %0.3f A/W \"%(R)#\n", + "print\"Output current Ip = %0.3f microA \"%(Ip*10**6)#\n", + "print\"Multiplication factor M = %0.0f \"%(M)#\n", + "\n", + "#Calculation mistake in (b)Phtocurrent in the book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Responsivity R = 0.479 A/W \n", + "Output current Ip = 0.288 microA \n", + "Multiplication factor M = 35 \n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.28 Page no 488" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of cut off wavelength\n", + "\n", + "# Given data\n", + "h=6.626*10**-34# # Planck constant.\n", + "c=3*10**8# # Speed of light\n", + "Eg= 1.43*1.602*10**-19# # Bandgap energy\n", + "\n", + "# Cut off wavelength \n", + "lamda= h*c/Eg# \n", + "\n", + "\n", + "print\"Cut off wavelength = %0.3f micrometer \"%(lamda*10**6)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Cut off wavelength = 0.868 micrometer \n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.29 Page no 489" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of cut off wavelength\n", + "\n", + "\n", + "\n", + "# Given data\n", + "h=6.626*10**-34# # Planck constant\n", + "c=3*10**8# # Speed of light\n", + "Eg= 0.7*1.602*10**-19# # Bandgap energy\n", + "\n", + "# Cut off wavelength \n", + "lamda= h*c/Eg# \n", + "\n", + "print\"Cut off wavelength = %0.2f micrometer \"%(lamda*10**6)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Cut off wavelength = 1.77 micrometer \n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.30 Page no 489" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Computation of value of reflectance \n", + "\n", + "# Given data\n", + "n1=3.5# # Refractive index of silicon\n", + "n2=1# # Refractive index of photodiode\n", + "\n", + "#Value of reflectance\n", + "R=((n1-n2)/(n1+n2))**2#\n", + " \n", + "\n", + "print\"Value of reflectance, R = %0.2f \"%(R)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of reflectance, R = 0.31 \n" + ] + } + ], + "prompt_number": 22 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter6.ipynb b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter6.ipynb new file mode 100644 index 00000000..990d7208 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter6.ipynb @@ -0,0 +1,571 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:57dd400e6a371fc942ebeb713efb17a63987abe7cc9d200458344eee3c619616" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-6 Optical Receiver Systems" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.31 Page no 489" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sqrt, pi\n", + "\n", + "\n", + "# Calculation of a)peak photocurrent , b)shot noise and c)mean square shot noise current\n", + "\n", + "#Given data\n", + "n=0.7# # Efficiency\n", + "lamda=0.9*10**-6# # Wavelength\n", + "R=5*10**3# # Load resistance\n", + "I=2*10**-9# # Dark current\n", + "P=300*10**-6# # Incident power\n", + "B=15*10**6# # Bandwidth\n", + "T=298# # Room temperature\n", + "h=6.62*10**-34#\n", + "c=3*10**8#\n", + "e=1.602*10**-19# # Charge of an electron\n", + "k=1.381*10**-23# # Boltzman constant\n", + "\n", + "# a)Peak photocurrent\n", + "I=(n*P*e*lamda)/(h*c)#\n", + "I=I*10**6#\n", + "\n", + "#b) Shot noise and mean square shot noise current\n", + "s=2*e*B*(2+I)#\n", + "s=s*10**11#\n", + "\n", + "#c) mean square shot noise current\n", + "t=(4*k*T*B)/R#\n", + "t=t*10**17#\n", + " \n", + "print\"Peak photocurrent = %0.3f nA \"%(I)#\n", + "print\"Shot noise = %0.1f 10**-20 A \"%(s)#\n", + "print\"Mean square shot noise current = %0.2f*10**-17 A \"%(t)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Peak photocurrent = 152.456 nA \n", + "Shot noise = 74.2 10**-20 A \n", + "Mean square shot noise current = 4.94*10**-17 A \n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.32 Page no 495" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log10\n", + "# Calculation of signal to noise ratio\n", + "\n", + "#Given data\n", + "I=152.3*10**-9# # Peak photocurrent\n", + "s=74.15*10**-20# # Shot noise \n", + "t=4.94*10**-17# # Mean square shot noise current\n", + "F=10*log10(3)# # Noise figure\n", + "B=15*10**6# # Bandwidth\n", + "T=298# # Room temperature\n", + "k=1.381*10**-23# # Boltzman constant\n", + "R=5*10**3# # Load resistance\n", + "e=1.602*10**-19# # Charge of an electron\n", + "\n", + "\n", + "# Signal to noise ratio\n", + "S=(I**2)/((2*e*B*(2+I))+(4*k*T*B*F)/R)#\n", + "S=S*10**3#\n", + " \n", + "print\"Signal to noise ratio = %0.2f \"%(S)#\n", + "\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Signal to noise ratio = 2.41 \n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.33 Page no 495" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a)load resistance and b)bandwidth\n", + "\n", + "#Given data\n", + "Cd=5*10**-12 # Capacitance of pin photodiode\n", + "B=10*10**6# # Bandwidth\n", + "Ca=10*10**-12# # Input capacitance\n", + "\n", + "\n", + "# a)Load resistance\n", + "R=1/(2*pi*B*Cd)#\n", + "R=R*10**-3#\n", + "# b)Bandwidth\n", + "Bm=1/(2*pi*(Cd+Ca)*R)#\n", + "Bm=Bm*10**-9#\n", + " \n", + "print\"Wavelength of photodiode = %0.2f kohm \"%(R)#\n", + "print\"Bandwidth = %0.3f MHz \"%(Bm)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Wavelength of photodiode = 3.18 kohm \n", + "Bandwidth = 3.333 MHz \n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.34 Page no 491" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of signal to noise ratio.\n", + "\n", + "#Given data\n", + "\n", + "h=6.62*10**-34# # Planck constant\n", + "c=5*10**-12# # capacitor\n", + "lamda=1.55*10**-6# # Wavelength\n", + "B=50*10**6# # Speed of communication\n", + "s=2*10**-9#\n", + "I=10**-7#\n", + "k=1.381*10**-23#\n", + "T=291#\n", + "x=0.3#\n", + "e=1.602*10**-19#\n", + "\n", + "# Maximum load resistance is\n", + "R=1/(2*pi*c*B)#\n", + "\n", + "S=I**2/((2*e*B*I)+(4*k*T*B/R))#\n", + "M=((4*k*T)/(e*x*R*I))**(0.435)#\n", + "S1=((((M**2)*(I**2))/(2*e*B*I*M**2.3))+((4*k*T*B)/R))#\n", + "S1=10*log10(S1)#\n", + " \n", + "print\"Load resistor = %0.1f ohm \"%(R)#\n", + "print\"S/N = %0.2f dB \"%(S)#\n", + "print\"M = %0.2f \"%(M)#\n", + "print\"S/N = %0.2f dB \"%(S1)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Load resistor = 636.6 ohm \n", + "S/N = 7.91 dB \n", + "M = 41.53 \n", + "S/N = 33.10 dB \n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.35 Page no 493" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a) responsivity b)incident optical power\n", + "\n", + "#Given data\n", + "n=0.6# # Quantum efficiency\n", + "e=1.602*10**-19# # Charge of electron\n", + "lamda=0.9*10**-6# # Wavelength \n", + "h=6.626*10**-34# # Planck constant \n", + "c=3*10**8# # Velocity of light\n", + "I=2*10**-6# # Photocurrent\n", + "\n", + "# a)Responsivity\n", + "R= (n*e*lamda)/(h*c)#\n", + "\n", + "# b)Incident power\n", + "P=I/R#\n", + "P=P*10**6#\n", + "\n", + "print\"Responsivity = %0.3f A/W \"%(R)#\n", + "print\"Incident power = %0.3f microwatt \"%(P)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Responsivity = 0.435 A/W \n", + "Incident power = 4.596 microwatt \n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.36 Page no 493" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a) responsivity b)Multiplication factor\n", + "\n", + "#Given data\n", + "n=0.8# # Quantum efficiency\n", + "e=1.602*10**-19# # Charge of an electron\n", + "lamda=0.9*10**-6# # Wavelength \n", + "h=6.626*10**-34# # Planck constant \n", + "c=3*10**8# # Velocity of light\n", + "I=15*10**-6# # Photocurrent\n", + "P=0.6*10**-6#\n", + "\n", + "# a)Responsivity\n", + "R= (n*e*lamda)/(h*c)#\n", + "# b)Multiplication factor\n", + "Ip=P*R#\n", + "M=I/Ip#\n", + " \n", + "print\"Responsivity = %0.3f A/W \"%(R)#\n", + "print\"Multiplication factor = %0.2f \"%(M)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Responsivity = 0.580 A/W \n", + "Multiplication factor = 43.08 \n" + ] + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.37 Page no 494" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a) quantum efficiency b) responsivity \n", + "\n", + "#Given data\n", + "e5=500# # No of incident photons\n", + "e8=800# # No of incident electrons\n", + "e=1.602*10**-19# # Charge of an electron\n", + "lamda=1.3*10**-6# # Wavelength \n", + "h=6.626*10**-34# # Planck constant \n", + "c=3*10**8# # Velocity of light\n", + "I=15*10**-6# # Photocurrent\n", + "P=0.6*10**-6#\n", + "\n", + "# a)Quantum efficiency\n", + "n=e5/e8#\n", + "# b)Responsivity\n", + "R=(n*e*lamda)/(h*c)#\n", + "\n", + "print\"Quantum efficiency = %0.1f %% \"%(n*100)#\n", + "print\"Responsivity = %0.3f A/W \"%(R)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Quantum efficiency = 62.5 % \n", + "Responsivity = 0.655 A/W \n" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.38 Page no 494" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a) quantum efficiency b) responsivity\n", + "\n", + "#Given data\n", + "e5=1.2*10**11# # No of electrons collected\n", + "e8=3.6*10**11# # No of incident photon\n", + "e=1.602*10**-19# # Charge of an electron\n", + "lamda=0.85*10**-6# # Wavelength \n", + "h=6.626*10**-34# # Planck constant \n", + "c=3*10**8# # Velocity of light\n", + "I=15*10**-6# # Photocurrent\n", + "P=0.6*10**-6# \n", + "\n", + "# a)Quantum efficiency\n", + "n=e5/e8#\n", + "# b)Responsivity\n", + "R=(n*e*lamda)/(h*c)#\n", + " \n", + "print\"Quantum efficiency = %0.2f \"%(n)#\n", + "print\"Responsivity = %0.3f A/W\"%(R)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Quantum efficiency = 0.33 \n", + "Responsivity = 0.228 A/W\n" + ] + } + ], + "prompt_number": 31 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.39 Page no 495" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a) operating wavelength b) incidence optical power\n", + "\n", + "#Given data\n", + "n=0.60 # Quantum efficiency\n", + "E=1.5*10**-19# # Photons of energy\n", + "e=1.602*10**-19# # Charge of an electron\n", + "h=6.626*10**-34# # Planck constant \n", + "c=3*10**8# # Velocity of light\n", + "I=2*10**-6# # Photocurrent\n", + "\n", + "\n", + "# a)Operating wavelength\n", + "lamda=(h*c)/E#\n", + "lamda=lamda*10**6#\n", + "\n", + "# b)Incident optical power\n", + "R=(n*e)/E#\n", + "P=I/R#\n", + "P=P*10**6#\n", + " \n", + "print\"Wavelength of photodiode = %0.2f micrometer \"%(lamda)#\n", + "print\"Incident optical power = %0.2f microWatt \"%(P)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Wavelength of photodiode = 1.33 micrometer \n", + "Incident optical power = 3.12 microWatt \n" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.40 Page no 495" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of load resistance and bandwidth\n", + "\n", + "\n", + "\n", + "#Given data\n", + "Cd=6*10**-12 # Capacitance of pin photodiode\n", + "B=20*10**6# # Bandwidth\n", + "Ca=6*10**-12# # Input capacitance\n", + "\n", + "\n", + "# a)Load resistance\n", + "R=1/(2*pi*B*Cd)#\n", + "R=R*10**-3#\n", + "# b)Bandwidth\n", + "Bm=1/(2*pi*(Ca+Ca)*R)#\n", + "Bm=Bm*10**-9#\n", + "\n", + " \n", + "print\"Load resistance = %0.2f kohm \"%(R)#\n", + "print\"Bandwidth = %0.0f MHz \"%(Bm)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Load resistance = 1.33 kohm \n", + "Bandwidth = 10 MHz \n" + ] + } + ], + "prompt_number": 33 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.41 Page no 496" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of maximum bandwidth\n", + "\n", + "#Given data\n", + "t=5*10**-12 # Electron transit time\n", + "G=70# # Gain of the device\n", + "\n", + "# Maximum bandwidth\n", + "Bm=1/(2*pi*t*G)#\n", + "Bm=Bm*10**-6#\n", + " \n", + "print\"Bandwidth = %0.1f MHz \"%(Bm)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Bandwidth = 454.7 MHz \n" + ] + } + ], + "prompt_number": 34 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter7.ipynb b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter7.ipynb new file mode 100644 index 00000000..e7672ce7 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter7.ipynb @@ -0,0 +1,196 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:e4b22987004f66ce05a1748c9336b9665c2c2c84b03bd5f7cd9eb7faf9ca353a" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-7 Optical Fiber Connectors & Optical Amplification" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.42 Page no 496" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sqrt, pi, log10\n", + "\n", + "# Calculation of a)excess loss,b)insertion loss,c)crosstalk and d)split ratio for the device.\n", + "\n", + "#Given data\n", + "P1=60*10**-6# # Power launched in port 1\n", + "P2=0.004*10**-6# # Power launched in port 2\n", + "P3=26*10**-6# # Power launched in port 3 \n", + "P4=27.5*10**-6# # Power launched in port 4\n", + "\n", + "# a)Excess loss\n", + "E=10*log10(P1/(P3+P4))# \n", + "\n", + "#b)Insertion loss\n", + "I1=10*log10(P1/P3)#\n", + "I2=10*log10(P1/P4)#\n", + "\n", + "#c)Crosstalk\n", + "C=10*log10(P2/P1)#\n", + "\n", + "#d)Split ratio\n", + "S=(P3/(P3+P4))*100#\n", + "\n", + "\n", + "\n", + "print\"Excess loss = %0.1f dB \"%(E)#\n", + "print\"Insertion loss = %0.2f dB \"%(I1)#\n", + "print\"Insertion loss = %0.2f dB \"%(I2)#\n", + "print\"Crosstalk = %0.1f dB \"%(C)#\n", + "print\"Split ratio = %0.1f %% \"%(S)#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Excess loss = 0.5 dB \n", + "Insertion loss = 3.63 dB \n", + "Insertion loss = 3.39 dB \n", + "Crosstalk = -41.8 dB \n", + "Split ratio = 48.6 % \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.43 Page no 497" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a)excess loss,b)insertion loss,c)crosstalk and d)split ratio for the device.\n", + "\n", + "#Given data\n", + "P1=100*10**-6# # Power launched in port 1\n", + "P2=0.005*10**-6# # Power launched in port 2\n", + "P3=30*10**-6# # Power launched in port 3 \n", + "P4=35*10**-6# # Power launched in port 4\n", + "\n", + "# a)Excess loss\n", + "E=10*log10(P1/(P3+P4))# \n", + "# b)Insertion loss\n", + "I1=10*log10(P1/P3)#\n", + "I2=10*log10(P1/P4)#\n", + "\n", + "#c)Crosstalk\n", + "C=10*log10(P2/P1)#\n", + "\n", + "#d)Split ratio\n", + "S=(P3/(P3+P4))*100#\n", + "\n", + "print\"Excess loss = %0.2f dB \"%(E)#\n", + "print\"Insertion loss = %0.3f dB \"%(I1)#\n", + "print\"Insertion loss = %0.2f dB \"%(I2)#\n", + "print\"Crosstalk = %0.1f dB \"%(C)#\n", + "print\"Split ratio = %0.2f %% \"%(S)#\n", + "# The cross talk answer computation is wrong in the book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Excess loss = 1.87 dB \n", + "Insertion loss = 5.229 dB \n", + "Insertion loss = 4.56 dB \n", + "Crosstalk = -43.0 dB \n", + "Split ratio = 46.15 % \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.44 Page no 498" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a)excess loss,b)insertion loss,c)crosstalk and d)split ratio for the device.\n", + "\n", + "#Given data\n", + "P1=116.3*10**-6# # Power launched in port 1\n", + "P2=0.082*10**-6# # Power launched in port 2\n", + "P3=47*10**-6# # Power launched in port 3 \n", + "P4=52*10**-6# # Power launched in port 4\n", + "\n", + "# a)Excess loss\n", + "E=10*log10(P1/(P3+P4))# \n", + "#b)Insertion loss\n", + "I1=10*log10(P1/P3)#\n", + "I2=10*log10(P1/P4)#\n", + "\n", + "#c)Crosstalk\n", + "C=10*log10(P2/P1)#\n", + "\n", + "#d)Split ratio\n", + "S=(P3/(P3+P4))*100#\n", + "\n", + "print\"Excess loss = %0.1f dB \"%(E)#\n", + "print\"Insertion loss = %0.3f dB \"%(I1)#\n", + "print\"Insertion loss = %0.2f dB \"%(I2)#\n", + "print\"Crosstalk = %0.2f \"%(C)#\n", + "print\"Split ratio = %0.2f %% \"%(S)#\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Excess loss = 0.7 dB \n", + "Insertion loss = 3.935 dB \n", + "Insertion loss = 3.50 dB \n", + "Crosstalk = -31.52 \n", + "Split ratio = 47.47 % \n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter8.ipynb b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter8.ipynb new file mode 100644 index 00000000..5f4fa9a0 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter8.ipynb @@ -0,0 +1,385 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:7068b67aec0a119c755333859d80660f2c60ab073f69ac71a3d86fb3e6c35f75" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-8 Telecommunication Application" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.45 Page no 499" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sqrt, pi, log10\n", + "\n", + "# Calculation of incident optical power.\n", + "\n", + "#Given data\n", + "lamda=1.3*10**-6# # Wavelength\n", + "B=6*10**6# # Bandwidth\n", + "S=10**5# # Total system margin\n", + "n=1# # Efficiency\n", + "v=3*10**14#\n", + "h=6.62*10**-34# # Planck constant\n", + "\n", + "\n", + "\n", + "# Incident optical power\n", + "P=(2*S*v*h*B)/n# \n", + "\n", + "P1=10*log10(P/10**-3)#\n", + "\n", + "\n", + "print\"Incident optical power = %0.1f nW \"%(P1)#\n", + "\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Incident optical power = -36.2 nW \n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.46 Page no 500" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of maximum repeater spacing of a)ASK hetrodyne b)PSK homodyne \n", + "\n", + "#Given data\n", + "\n", + "S=0.2# # Split loss\n", + "c=3*10**8# # velocity of light\n", + "lamda=1.55*10**-6# # Wavelength\n", + "B1=50*10**6# # Speed of communication\n", + "h=6.63*10**-34 # Planck constant\n", + "B2=1*10**9# # Speed of communication\n", + "\n", + "\n", + "# a)Maximum repeater spacing for ASK hetrodyne\n", + "P1=(36*h*c*B1)/lamda# \n", + "P1=10*log10(P1/10**-3)#\n", + "s1=4-P1#\n", + "R1=s1/S#\n", + "P2= (36*h*c*B2)/lamda#\n", + "P2=10*log10(P2/10**-3)#\n", + "s2=4-P2#\n", + "R2=s2/S#\n", + "#b)Maximum repeater spacing for PSK homodyne\n", + "K1= (9*h*c*B1)/lamda#\n", + "K1=10*log10(K1/10**-3)#\n", + "K1=4-K1#\n", + "R3=K1/S#\n", + "K2= (9*h*c*B2)/lamda#\n", + "K2=10*log10(K2/10**-3)#\n", + "K2=4-K2#\n", + "R4=K2/S#\n", + "\n", + "\n", + "print\"Maximum repeater spacing = %0.3f km \"%(R1)#\n", + "print\"Maximum repeater spacing = %0.3f km \"%(R2)#\n", + "print\"Maximum repeater spacing = %0.3f km \"%(R3)#\n", + "print\"Maximum repeater spacing = %0.3f km \"%(R4)#\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum repeater spacing = 351.821 km \n", + "Maximum repeater spacing = 286.770 km \n", + "Maximum repeater spacing = 381.924 km \n", + "Maximum repeater spacing = 316.873 km \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.47 Page no 499" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of incident optical power.\n", + "\n", + "#Given data\n", + "\n", + "h=6.62*10**-34# # Planck constant\n", + "c=3*10**8# # velocity of light\n", + "lamda=1.55*10**-6# # Wavelength\n", + "B=400*10**6# # Speed of communication\n", + "\n", + "# Maximum repeater spacing\n", + "P=(36*h*c*B)/lamda# \n", + "P=10*log10(P/10**-3)#\n", + "\n", + "print\"Incident optical power = %0.3f nW \"%(P)#\n", + "\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Incident optical power = -57.340 nW \n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.48 Page no 502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of optical power budget.\n", + "\n", + "#Given data\n", + "M=-10# # Mean optical power\n", + "S=-25# # Split loss\n", + "TS=7# # Total system margin\n", + "SP=1.4# # Split loss\n", + "C=1.6# # Connector loss\n", + "SM=4# # Safety margin\n", + "\n", + "\n", + "# Net margin between LED and receiver\n", + "N=M-S# \n", + "\n", + "# Total system loss\n", + "T=TS+SP+C+SM#\n", + "# Excess power margin\n", + "E=N-T#\n", + "\n", + "print\"Excess power margin = %0.0f dB \"%(E)#\n", + "\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Excess power margin = 1 dB \n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.49 Page no 503" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of viability of digital link.\n", + "\n", + "#Given data\n", + "M=-10# # Mean optical power\n", + "S=-41# # Receiver sensitivity\n", + "TS=18.2# # Total system margin\n", + "SP=3# # Split loss\n", + "C=1.5# # Connector loss\n", + "SM=6# # Safety margin\n", + "\n", + "\n", + "# Net margin between LED and receiver\n", + "N=M-S# \n", + "\n", + "# Total system loss\n", + "T=TS+SP+C+SM#\n", + "# Excess power margin\n", + "E=N-T#\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "print\"Excess power margin = %0.1f dB \"%(E)#\n", + "\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Excess power margin = 2.3 dB \n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.50 Page no 499" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of signal to noise ratio.\n", + "\n", + "#Given data\n", + "\n", + "h=6.62*10**-34# # Planck constant\n", + "c=3*10**8# # velocity of light\n", + "lamda=1.55*10**-6# # Wavelength\n", + "B=400*10**6# # Speed of communication\n", + "s=2#\n", + "# S/N ratio\n", + "\n", + "sn=(s*4.24)/(2**(1/2))#\n", + "i=(sn)**2#\n", + "\n", + "\n", + "print\"Incident optical power = %0.2f nW \"%(i)#\n", + "\n", + "\n", + "# The answer is wrong in the book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Incident optical power = 35.96 nW \n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.52 Page no 504" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of a)Bit rate of communication system b)Bit duration c)Time period\n", + "\n", + "#Given data\n", + "f=8*10**3# # Power launched in port 1\n", + "P2=0.082*10**-6# # Power launched in port 2\n", + "P3=47*10**-6# # Power launched in port 3 \n", + "P4=52*10**-6# # Power launched in port 4\n", + "\n", + "# a)Bit rate of communication system\n", + "c=32*8#\n", + "B=f*c# \n", + "B=B*10**-6#\n", + "# b)Bit duration\n", + "D=1/B#\n", + "D=D*10*10**2#\n", + "P=8*D#\n", + "\n", + "\n", + "# c)Time period\n", + "T=32*P#\n", + "T=T*10**-3#\n", + "\n", + "print\"Bit rate of communication system = %0.3f Mb/s \"%(B)#\n", + "print\"Bit duration = %0.0f ns \"%(D)#\n", + "print\"Time period = %0.0f micro sec \"%(T)#\n", + "\n", + "# The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Bit rate of communication system = 2.048 Mb/s \n", + "Bit duration = 488 ns \n", + "Time period = 125 micro sec \n" + ] + } + ], + "prompt_number": 16 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Potential_Difference.png b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Potential_Difference.png Binary files differnew file mode 100644 index 00000000..854e0e65 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Potential_Difference.png diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Threshold_power.png b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Threshold_power.png Binary files differnew file mode 100644 index 00000000..4c66ef48 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Threshold_power.png diff --git a/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Various_Angles_and_aperture.png b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Various_Angles_and_aperture.png Binary files differnew file mode 100644 index 00000000..7b2ad952 --- /dev/null +++ b/Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Various_Angles_and_aperture.png diff --git a/sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb b/sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb new file mode 100644 index 00000000..d7167f86 --- /dev/null +++ b/sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb @@ -0,0 +1,341 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:012ab8557afdcfdae2cdc3da17271647415fc17ab95dd187f4df0903472edf45" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter - 7 : Cathode Ray Oscilloscopes" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.1 - Page No : 244" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "l=2.5 # in cm\n", + "l=l*10**-2 # in meter\n", + "d=.5 # in cm\n", + "d=d*10**-2 # in meter\n", + "S= 20 # in cm\n", + "S= S*10**-2 # in meter\n", + "Va= 2500 # in volts\n", + "# Formula y = OC*AB/OB = (S*d/2)/(l/2)\n", + "y = (S*d/2)/(l/2) # in meter\n", + "print \"The value of deflection = %0.f cm\" %(y*10**2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of deflection = 4 cm\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.2 - Page No : 244" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "R_E1= 5.6 # in kohm\n", + "C1= 0.2 # in micro F\n", + "V_B1= 6.3 # in volt\n", + "V_BE= 0.7 # in volt\n", + "TL= 2.5 # trigger level for the Schmitt trigger (UTP,LTP) in volt\n", + "del_V1= 2*TL # in volt\n", + "I_C1= (V_B1-V_BE)/R_E1 # in mA\n", + "print \"Charging current = %0.f mA\" %I_C1 \n", + "toh= del_V1*C1/I_C1 # in ms\n", + "print \"Time period = %0.f ms\" %toh" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Charging current = 1 mA\n", + "Time period = 1 ms\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.3 - Page No : 255" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt \n", + "#Given data\n", + "L=10 # trace length in cm\n", + "DS= 5 # deflection sensitivity in V/cm\n", + "V_peakTOpeak= L*DS # in volt\n", + "V_peak= V_peakTOpeak/2 # in volt\n", + "RMS= V_peak/sqrt(2) # RMS value of unknown as voltage in volt\n", + "print \"The value of AC voltage = %0.3f volts\" %RMS " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of AC voltage = 17.678 volts\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.4 - Page No : 255" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division \n", + "#Given data\n", + "Y= 2+1/2 # Positive Y-peaks in pattern\n", + "X= 1/2+1/2 # Positive X-peaks in pattern\n", + "f_h= 3# frequency of horizontal voltage signal in kHz\n", + "f_yBYf_x= Y/X \n", + "# frequency of vertical voltage signal= f_yBYf_x * f_h\n", + "f_v= f_yBYf_x * f_h # frequency of vertical voltage signal in kHz\n", + "print \"frequency of vertical voltage signal = %0.1f kHz\" %f_v " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "frequency of vertical voltage signal = 7.5 kHz\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.5 - Page No : 256" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "f_x= 1000 # in Hz\n", + "Y= 2 # points of tangency to vertical line\n", + "X= 5 # points of tangency to horizontal line\n", + "f_y= f_x*X/Y # in Hz\n", + "print \"Frequency of vertical input = %0.f Hz\" %f_y" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Frequency of vertical input = 2500 Hz\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.6 - Page No : 257" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "f=2000 # in Hz\n", + "T=1/f # in sec\n", + "D=0.2 \n", + "PulseDuration= D*T # in sec\n", + "print \"The value of pulse duration = %0.1f ms\" %(PulseDuration*10**3) " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of pulse duration = 0.1 ms\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.7 - Page No : 258" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "vertical_attenuation= 0.5 # in V/Div\n", + "TPD= 2 # time/Div control in micro sec\n", + "P= 4*vertical_attenuation # peak-to-peak amplitude of the signal in V \n", + "print \"Peak-to-Peak amplitude of the signal = %0.f V\" %P\n", + "T= 4*TPD # in micro sec\n", + "T=T*10**-6 # in sec\n", + "f=1/T # in Hz\n", + "print \"The value of frequency = %0.f kHz\" %(f*10**-3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Peak-to-Peak amplitude of the signal = 2 V\n", + "The value of frequency = 125 kHz\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.8 - Page No : 261" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi \n", + "#Given data\n", + "C_1N= 36 # in pF\n", + "C_2= 150 # in pF\n", + "R_1N= 1 # in M ohm\n", + "R_1= 10 # in M ohm\n", + "R_source= 500 # in ohm\n", + "# R_1/(omega*(C_2+C_1N)) = R_1N/(omega*C_1)\n", + "C_1= R_1N*(C_2+C_1N)/R_1 # in pF\n", + "C_T= 1/(1/C_1+1/(C_2+C_1N)) # in pF\n", + "C_T= C_T*10**-12 # in F\n", + "f= 1/(2*pi*C_T*R_source) \n", + "print \"Signal Frequency = %0.2f MHz\" %(f*10**-6)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Signal Frequency = 18.82 MHz\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.9 - Page No : 263" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "f= 20 # in MHz\n", + "f=f*10**6 # in Hz\n", + "toh= 1/f # in sec\n", + "toh=toh*10**9 # in ns\n", + "# For one cycle occupying 4 horizontal divisions,\n", + "MTD= toh/4 # Minimum time/division in ns/division\n", + "# Using the 10 times magnifier to provide MTD\n", + "MTD_setting= 10*MTD # minimum time/division setting in ns/division\n", + "print \"Minimum time/division setting = %0.f ns/division\" %MTD_setting" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Minimum time/division setting = 125 ns/division\n" + ] + } + ], + "prompt_number": 12 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/sample_notebooks/MohdGufran/chapter_10_1.ipynb b/sample_notebooks/MohdGufran/chapter_10_1.ipynb new file mode 100644 index 00000000..fc8eeccf --- /dev/null +++ b/sample_notebooks/MohdGufran/chapter_10_1.ipynb @@ -0,0 +1,358 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter No - 10 : Mass Transfer\n", + " " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.1 - Page No. : 318" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "P1=4 # in bar\n", + "P2=2 # in bar\n", + "T=25 # in degree C\n", + "Dhp=9*10**-8 # in m**2/s\n", + "S=3*10**-3 # in kg mole/m**3 bar\n", + "del_x=0.5*10**-3 # thickness in m\n", + "#(a) The molar concentration of a gas in terms of solubility\n", + "CH1=S*P1 # in kg mole/m**3\n", + "CH2=S*P2 # in kg mole/m**3\n", + "#(b) Molar diffusion flux of hydrogen through plastic memberence is given by Fick's law of diffision\n", + "#N_H= N_h/A = Dhp*(CH1-CH2)/del_x#\n", + "N_H= Dhp*(CH1-CH2)/del_x # in kg mole/s-m**2\n", + "print \"Molar diffusion flux of hydrogen through the membrane = %0.2e kg mole/s-m**2\" %N_H\n", + "#Mass_d_Flux= N_H*Molecular_Weight \n", + "Molecular_Weight=2#\n", + "Mass_d_Flux= N_H*Molecular_Weight \n", + "print \"Molar diffusion flux = %0.3e kg/s-m**2\" %Mass_d_Flux" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Molar diffusion flux of hydrogen through the membrane = 1.08e-06 kg mole/s-m**2\n", + "Molar diffusion flux = 2.160e-06 kg/s-m**2\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.2 - Page No. : 322" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "T=25 # in degree C\n", + "T=T+273 # in K\n", + "P=1#\n", + "V1=12 #Molecular volume of H2 in cm**3/gm mole\n", + "V2=30 #Molecular volume of Air in cm**3/gm mole\n", + "M1=2 # Molecular weight of H2\n", + "M2=29 # Molecular weight of Air\n", + "#The diffusion coefficient for gases in terms of molecular volumes may be express as\n", + "D_AB= .0043*T**(3/2)/(P*(V1**(1/3)+V2**(1/3)))*(1/M1+1/M2)**(1/2)#\n", + "print \"The diffusion coefficient for gases in terms of molecular volumes = %0.3f cm**2/sec\" %D_AB" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffusion coefficient for gases in terms of molecular volumes = 2.997 cm**2/sec\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.3 - Page No. : 322" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "T=300 # temp of gas mixture in K\n", + "D_HN2=18*10**-6 # in m**2/s at 300 K, 1 bar\n", + "T1=300 # in K\n", + "D_HO2=16*10**-6 # in m**2/s at 273 K, 1 bar\n", + "T2=273 # in K\n", + "O_2=0.2#\n", + "N_2=0.7#\n", + "H_2=0.1#\n", + "#The diffusivity at the mixture temperature and pressure are calculated as \n", + "# D1/D2 = (T1/T2)**(3/2)*(P2/P1)\n", + "D_HO2= (T/T2)**(3/2)*1/4*D_HO2#\n", + "D_HN2= (T/T1)**(3/2)*1/4*D_HN2#\n", + "#The composition of oxygen and nitrogen on a H2 free basis is \n", + "x_O= O_2/(1-H_2)#\n", + "x_N= N_2/(1-H_2)#\n", + "\n", + "# The effective diffusivity for the gas mixture at given temperature and pressure is\n", + "D= 1/(x_O/D_HO2+x_N/D_HN2) # in m**2/s\n", + "print \"Effective diffusivity = %0.3e m**2/s\" %D" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Effective diffusivity = 4.524e-06 m**2/s\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.4 - Page No. : 323" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi\n", + "# Given data\n", + "d=3 # in mm\n", + "d=d*10**-3 # in meter\n", + "T=25 # in \u00b0C\n", + "T=T+273 # in K\n", + "D= 0.4*10**-4 # in m**2/s\n", + "R= 8314#\n", + "P_A1=1 # in atm\n", + "P_A1=P_A1*10**5 # in w/m**2\n", + "P_A2=0#\n", + "C_A2=0#\n", + "x2= 15 # in meter\n", + "x1= 0#\n", + "A= pi/4*d**2#\n", + "M_A= D*A/(R*T)*(P_A1-P_A2)/(x2-x1) # in kg mole/sec\n", + "N_B= M_A#\n", + "M_B= M_A*29 # in kg/sec\n", + "print \"Value of N_B = %0.3e kg mole/sec\" %N_B\n", + "print \"Value of M_B = %0.3e kg /sec\" %M_B" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of N_B = 7.608e-13 kg mole/sec\n", + "Value of M_B = 2.206e-11 kg /sec\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.5 - Page No. : 325" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Given data\n", + "P=3 # in atm\n", + "P=P*10**5 # in N/m**2\n", + "r1=10 # in mm\n", + "r1=r1*10**-3 # in m\n", + "r2=20 # in mm\n", + "r2=r2*10**-3 # in m\n", + "R=4160 # in J/kg-K\n", + "T=303 # in K\n", + "D=3*10**-8 # in m**2/s\n", + "S=3*0.05# # Solubility of hydrogen at a pressure of 3 atm in m**3/m**3 of rubber tubing\n", + "del_x=r2-r1 # in m\n", + "L=1 # in m\n", + "Am=2*pi*L*del_x/log(r2/r1)#\n", + "#Formula P*V= m*R*T\n", + "V=S#\n", + "m=P*V/(R*T) # in kg/m**3 of rubber tubing at the inner surface of the pipe\n", + "C_A1=m#\n", + "C_A2=0#\n", + "#Diffusion flux through the cylinder is given\n", + "M=D*(C_A1-C_A2)*Am/del_x#\n", + "print \"Diffusion flux through the cylinder = %0.2e kg/sm\" %M" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diffusion flux through the cylinder = 9.71e-09 kg/sm\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.6 - Page No. : 329" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi\n", + "# Given data\n", + "R=4160 # in J/kg-K\n", + "M=2#\n", + "D_AB=1.944*10**-8 # in m**2/s\n", + "R_H2=R/M#\n", + "S=2*0.0532# # Solubility of hydrogen at a pressure of 2 atm in cm**3/cm**3 of pipe\n", + "P=2 # in atm\n", + "P=P*1.03*10**5 # N/m**2\n", + "T=25 # in degree C\n", + "T=T+273 # in K\n", + "r1=2.5 # in mm\n", + "r1=r1*10**-3 # in m\n", + "r2=5 # in mm\n", + "r2=r2*10**-3 # in m\n", + "del_x=r2-r1 # in m\n", + "L=1 # in m\n", + "#Formula P*V= m*R*T\n", + "V=S#\n", + "m=P*V/(R*T) # in kg/m**3 of pipe\n", + "# So, Concentration of H2 at inner surface of the pipe\n", + "C_A1=0.0176 # in kg/m**3\n", + "# The resistance of diffusion of H2 away from the outer surface is negligible i.e.\n", + "C_A2=0#\n", + "Am=2*pi*L*del_x/log(r2/r1)#\n", + "# Loss of H2 by diffusion \n", + "M_A= D_AB*(C_A1-C_A2)*Am/del_x#\n", + "print \"Loss of H2 by diffusion = %0.2ef kg/s\" %M_A" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Loss of H2 by diffusion = 3.10e-09f kg/s\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.7 - Page No. : 330" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi\n", + "from math import log\n", + "# Given data\n", + "Px1= 0.14 # in bar\n", + "Px2= 0#\n", + "P=1.013 # in bar\n", + "Py1=P-Px1# # in bar\n", + "Py2=P-Px2# # in bar\n", + "D=8.5*10**-6 # in m**2/s\n", + "d=5 # diameter in meter\n", + "L=1 # in mm\n", + "L=L*10**-3 #in meter\n", + "M=78 # molecular weight\n", + "Am_x= 1/4*pi*d**2*M#\n", + "R=8314#\n", + "del_x=3 # thickness in mm\n", + "del_x=del_x*10**-3 # in m\n", + "T=20 # in degree C\n", + "T=T+273 # in K\n", + "P=P*10**5 # in N/m**2\n", + "m_x= D*Am_x*P*log(Py2/Py1)/(R*T*del_x)#\n", + "# The mass of the benzene to be evaporated\n", + "mass= 1/4*pi*d**2*L#\n", + "density=880 # in kg/m**3\n", + "m_b= mass*density#\n", + "toh=m_b/m_x # in sec\n", + "print \"Time taken for the entire organic compound to evaporate = %0.0f seconds\" %toh\n", + "\n", + "\n", + "# Note: Answer in the book is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time taken for the entire organic compound to evaporate = 644 seconds\n" + ] + } + ], + "prompt_number": 15 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/sample_notebooks/ebbygeorge/Chapter01_1.ipynb b/sample_notebooks/ebbygeorge/Chapter01_1.ipynb new file mode 100644 index 00000000..c17729b1 --- /dev/null +++ b/sample_notebooks/ebbygeorge/Chapter01_1.ipynb @@ -0,0 +1,72 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#Chapter 1:INTRODUCTION" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 1.1, Page number 1.11" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The width = 2.2222 *10**-11 Amp\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "C=20/(9*10^11)#converting cms to farads\n", + "\n", + "#Calculation\n", + "F=154-100#fall in potential\n", + "R=F/60#rate of fall in potential\n", + "I=C*R#ionization current\n", + "\n", + "#Result\n", + "print\"The width = \",round(I*10,4),\"*10**-11 Amp\"" + ] + } + ], + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/sai kiranmalepati/Samplenb.ipynb b/sample_notebooks/sai kiranmalepati/Samplenb.ipynb new file mode 100644 index 00000000..1e3cfad6 --- /dev/null +++ b/sample_notebooks/sai kiranmalepati/Samplenb.ipynb @@ -0,0 +1,158 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#Chapter-1, Section-1.22, pg-24, problem 1\n", + "\n", + "L=20; #True length of the chain is defined as L\n", + "print(' the length of the chain is ',L,'meters'); #Print L\n", + "\n", + "E=0.03; # Error in chain\n", + "print(' the error in the chain is ',E); # Print E\n", + "\n", + "ML=327; # Measured length is defined as ML\n", + "print(' the measured length ',ML,'meters'); #print ML\n", + "\n", + "tlength=((L+E)/L)*ML; #True length of L calculated\n", + "print(' the ture length of the chain is ',tlength,'meters') # Print true length.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Chapter-1, Section-1.23, pg 39, Problem- 4\n", + "\n", + "import math # Library imported.\n", + "\n", + "ab=28.7*math.cos(5*(math.pi/180)); #AB calculated using trigonometry\n", + "b1c=23.4*math.cos(7*(math.pi/180)); #B'C calculated\n", + "c1d=20.9*math.cos(10*(math.pi/180)); # C'D calculated\n", + "d1e=29.6*math.cos(12*(math.pi/180)) ; # D'E calculated\n", + "print(' the value of ab is ',ab,'meters'); #AB printed\n", + "\n", + "print(' the value of b1c is ',b1c,'meters'); #B'C printed\n", + "\n", + "print(' the value of c1d is ',c1d,'meters'); #C'D printed\n", + "\n", + "print(' the value of d1e is ',d1e,'meters'); #D'E printed\n", + "\n", + "\n", + "total=ab+b1c+c1d+d1e; #total calculated.\n", + "print('the total distance is ',total,'meters') #total printed\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Chapter 1, Section 1.22, Problem 6, pg 27.\n", + "\n", + "L=30; # Length of tape\n", + "t0=20; # Temperature of tape\n", + "p0=10; # Pull under which tape is present\n", + "pm=15; # Measured line pull\n", + "tm=32; # Mean temperature.\n", + "a=0.03; # Cross-sectional area\n", + "al=11/(1000000); # Temperature correction co-efficient\n", + "E=2.1*(1000000); # E for steel\n", + "w=0.693; #Total weight\n", + "ml=780; #measured length\n", + "\n", + "n=1; #n defined\n", + "print(' for n=1'); #print n value\n", + "ct=al*L*(tm-t0); # temperature correction calculated\n", + "print('the temperature correction is',ct,'meters'); # print temperature correction\n", + "\n", + "cp=(pm-p0)*L/(a*E); #pull correction calculated\n", + "print('the pull corretion is ',cp,' meters'); #print pull correction\n", + "\n", + "cs=-L*w*w/(24*pm*pm*n*n); #sag correction calculated\n", + "print('the sag correction is ',cs,'meters'); # print sag correction\n", + "\n", + "e=ct+cp+cs; #total correction calculated\n", + "print('the total correction is ',e,'meters'); # total correction printed\n", + "\n", + "l1=L+e; # correction in length =sum of correction and measured length \n", + "\n", + "truelength=(l1/L)*ml; #true length calculated\n", + "print('the true length is ',truelength); #true length printed\n", + "\n", + "n=2; #new n defined\n", + "\n", + "print(' for n=2'); # print n value\n", + "ct=al*L*(tm-t0); # temperature correction calculated\n", + "print('the temperature correction is',ct,'meters'); # print temperature correction\n", + "\n", + "\n", + "cp=(pm-p0)*L/(a*E); #pull correction calculated\n", + "print('the pull corretion is ',cp,' meters'); #print pull correction\n", + "\n", + "cs=-L*w*w/(24*pm*pm*n*n); #sag correction calculated\n", + "print('the sag correction is ',cs,'meters'); #print sag correction\n", + "\n", + "e=ct+cp+cs; #total correction calculated\n", + "print('the total correction is ',e,'meters'); # total correction printed\n", + "\n", + "l1=L+e; #correction in length =sum of correction and measured length \n", + "\n", + "truelength=(l1/L)*ml; #true length calculated\n", + "print('the true length is ',truelength); #true length printed\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# Chapter-2, Section-2.4, Problem 2, Page number 56\n", + "\n", + "import math #Library to be used is imported\n", + "\n", + "cd=(15-15*math.cos(3*(math.pi/180)))/10; #displacement perpendicular to chain line.\n", + "\n", + "print('the required displacement perpendicular to char line is ',cd); #Print cd\n", + "bc=15*(math.sin(3*(math.pi/180)))/10; #displacement parallel to chain line.\n", + "print('the displacemenet parllel to the chain line is ',bc) #print bc" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} |