From b2a89c36eff3882f8a6c4ac8ba7ccfb1e9f0dfb5 Mon Sep 17 00:00:00 2001 From: Trupti Kini Date: Tue, 23 Feb 2016 23:30:06 +0600 Subject: Added(A)/Deleted(D) following books A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER01.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER02.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER03.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER04.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER05.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER07.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER08.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER09.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER10.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER11.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER12.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER14.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER16.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER18.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER19.ipynb A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot02.png A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot04.png A Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot08.png A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_1.ipynb A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_2.ipynb A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_3.ipynb A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_4.ipynb A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_5.ipynb A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_6.ipynb A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_7.ipynb A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_8.ipynb A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t6.png A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t7.png A Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t8.png A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/Chapter9_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter1_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter2_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter3_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter4_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter6_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter7_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter8_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter_5_6.ipynb A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/1.2_1.png A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/3.7_1.png A Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/6.7_1.png A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter11_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter12_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter14_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter1_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter2_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter4_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter5_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter6_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter7_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter9_4.ipynb A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/11.1new_3.png A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.1new_3.png A Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.4new_2.png A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter2.ipynb A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter3.ipynb A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter4.ipynb A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter5.ipynb A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter6.ipynb A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter7.ipynb A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter8.ipynb A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Potential_Difference.png A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Threshold_power.png A Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Various_Angles_and_aperture.png A "sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb" A sample_notebooks/MohdGufran/chapter_10_1.ipynb A sample_notebooks/ebbygeorge/Chapter01_1.ipynb A "sample_notebooks/sai kiranmalepati/Samplenb.ipynb" --- .../CHAPTER01.ipynb | 336 +++ .../CHAPTER02.ipynb | 79 + .../CHAPTER03.ipynb | 663 ++++++ .../CHAPTER04.ipynb | 358 ++++ .../CHAPTER05.ipynb | 217 ++ .../CHAPTER07.ipynb | 167 ++ .../CHAPTER08.ipynb | 662 ++++++ .../CHAPTER09.ipynb | 573 +++++ .../CHAPTER10.ipynb | 329 +++ .../CHAPTER11.ipynb | 89 + .../CHAPTER12.ipynb | 180 ++ .../CHAPTER14.ipynb | 108 + .../CHAPTER16.ipynb | 140 ++ .../CHAPTER18.ipynb | 230 ++ .../CHAPTER19.ipynb | 185 ++ .../screenshots/Screenshot02.png | Bin 0 -> 70404 bytes .../screenshots/Screenshot04.png | Bin 0 -> 75002 bytes .../screenshots/Screenshot08.png | Bin 0 -> 58855 bytes .../chapter_1.ipynb | 721 +++++++ .../chapter_2.ipynb | 1141 ++++++++++ .../chapter_3.ipynb | 900 ++++++++ .../chapter_4.ipynb | 962 +++++++++ .../chapter_5.ipynb | 834 ++++++++ .../chapter_6.ipynb | 209 ++ .../chapter_7.ipynb | 143 ++ .../chapter_8.ipynb | 96 + .../screenshots/t6.png | Bin 0 -> 25382 bytes .../screenshots/t7.png | Bin 0 -> 42535 bytes .../screenshots/t8.png | Bin 0 -> 20412 bytes .../Chapter9_6.ipynb | 419 ++++ .../chapter1_6.ipynb | 625 ++++++ .../chapter2_6.ipynb | 2186 ++++++++++++++++++++ .../chapter3_6.ipynb | 1126 ++++++++++ .../chapter4_6.ipynb | 880 ++++++++ .../chapter6_6.ipynb | 1060 ++++++++++ .../chapter7_6.ipynb | 753 +++++++ .../chapter8_6.ipynb | 1090 ++++++++++ .../chapter_5_6.ipynb | 358 ++++ .../screenshots/1.2_1.png | Bin 0 -> 19120 bytes .../screenshots/3.7_1.png | Bin 0 -> 13804 bytes .../screenshots/6.7_1.png | Bin 0 -> 26943 bytes .../Chapter11_4.ipynb | 76 + .../Chapter12_4.ipynb | 80 + .../Chapter14_4.ipynb | 238 +++ .../Chapter1_4.ipynb | 861 ++++++++ .../Chapter2_4.ipynb | 262 +++ .../Chapter4_4.ipynb | 240 +++ .../Chapter5_4.ipynb | 398 ++++ .../Chapter6_4.ipynb | 321 +++ .../Chapter7_4.ipynb | 76 + .../Chapter9_4.ipynb | 144 ++ .../screenshots/11.1new_3.png | Bin 0 -> 94217 bytes .../screenshots/5.1new_3.png | Bin 0 -> 87046 bytes .../screenshots/5.4new_2.png | Bin 0 -> 89044 bytes .../Chapter2.ipynb | 1027 +++++++++ .../Chapter3.ipynb | 295 +++ .../Chapter4.ipynb | 142 ++ .../Chapter5.ipynb | 344 +++ .../Chapter6.ipynb | 571 +++++ .../Chapter7.ipynb | 196 ++ .../Chapter8.ipynb | 385 ++++ .../screenshots/Potential_Difference.png | Bin 0 -> 49079 bytes .../screenshots/Threshold_power.png | Bin 0 -> 59497 bytes .../screenshots/Various_Angles_and_aperture.png | Bin 0 -> 73406 bytes .../DaudIbrahir Saifi/Chapter_07.ipynb | 341 +++ sample_notebooks/MohdGufran/chapter_10_1.ipynb | 358 ++++ sample_notebooks/ebbygeorge/Chapter01_1.ipynb | 72 + sample_notebooks/sai kiranmalepati/Samplenb.ipynb | 158 ++ 68 files changed, 24404 insertions(+) create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER01.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER02.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER03.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER04.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER05.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER07.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER08.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER09.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER10.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER11.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER12.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER14.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER16.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER18.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./CHAPTER19.ipynb create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot02.png create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot04.png create mode 100644 Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot08.png create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_1.ipynb create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_2.ipynb create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_3.ipynb create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_4.ipynb create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_5.ipynb create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_6.ipynb create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_7.ipynb create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/chapter_8.ipynb create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t6.png create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t7.png create mode 100644 Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t8.png create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/Chapter9_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter1_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter2_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter3_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter4_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter6_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter7_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter8_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter_5_6.ipynb create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/1.2_1.png create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/3.7_1.png create mode 100644 Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/6.7_1.png create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter11_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter12_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter14_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter1_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter2_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter4_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter5_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter6_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter7_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/Chapter9_4.ipynb create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/11.1new_3.png create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.1new_3.png create mode 100644 Modern_Electronic_Instrumentation_And_Measurement_Techniques_by_A._D._Helfrick_And_W._D._Cooper/screenshots/5.4new_2.png create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter2.ipynb create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter3.ipynb create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter4.ipynb create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter5.ipynb create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter6.ipynb create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter7.ipynb create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/Chapter8.ipynb create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Potential_Difference.png create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Threshold_power.png create mode 100644 Textbook_on_Optical_Fiber_Communication_and_Its_Applications_by_S._C._Gupta/screenshots/Various_Angles_and_aperture.png create mode 100644 sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb create mode 100644 sample_notebooks/MohdGufran/chapter_10_1.ipynb create mode 100644 sample_notebooks/ebbygeorge/Chapter01_1.ipynb create mode 100644 sample_notebooks/sai kiranmalepati/Samplenb.ipynb 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 new file mode 100644 index 00000000..e38c28d3 Binary files /dev/null and b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot02.png differ 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 new file mode 100644 index 00000000..7ef80327 Binary files /dev/null and b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot04.png differ 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 new file mode 100644 index 00000000..d1376f9c Binary files /dev/null and b/Fundamentals_Of_Aerodynamics_by_J._D._Anderson_Jr./screenshots/Screenshot08.png differ 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": [ + "" + ] + }, + { + "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": [ + "" + ] + }, + { + "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_BI_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 new file mode 100644 index 00000000..066b9926 Binary files /dev/null and b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t6.png differ 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 new file mode 100644 index 00000000..6f6f7d61 Binary files /dev/null and b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t7.png differ 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 new file mode 100644 index 00000000..c41c48ef Binary files /dev/null and b/Fundamentals_Of_Electronic_Devices_by_P._Raja,_Pragati_Sharma/screenshots/t8.png differ 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 E1d:\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))0:\n", + " b=x1\n", + " else:\n", + " a=x1\n", + " if abs(f(x1))0:\n", + " b=x1\n", + " else:\n", + " a=x1\n", + " if abs(f(x1))0:\n", + " b=x1\n", + " else:\n", + " a=x1\n", + " if abs(f(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)" + ], + "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))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_errerr:\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