diff options
45 files changed, 17984 insertions, 0 deletions
diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER01.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER01.ipynb new file mode 100644 index 00000000..a9ad2e34 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER01.ipynb @@ -0,0 +1,58 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:bc8c72805b6850366f45568794dc2a4ab6f5d21f61489519f4f7ca8e4b8b6702"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER01 : THE FUNDAMENTAL LAWS OF ELECTRICAL ENGINEERING"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 07"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "E0 = 1./(36.*math.pi*10.**9.); # permitivity in free space \n",
+ "k = 4.*math.pi*E0 ; \n",
+ "q1 = 1.; # charge on the first particle in coulombs \n",
+ "q2 = 1.; # charge on the second particle in coulombs \n",
+ "d = 1.; # distance between the particles in meter\n",
+ "F = (q1*q2)/(k*d**2.); # force between the two particles in newtons \n",
+ "\n",
+ "print '%s %.e' %(\"force in free space between the two particles is in Newtons is:\",F)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "force in free space between the two particles is in Newtons is: 9e+09\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER02.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER02.ipynb new file mode 100644 index 00000000..54c9d14b --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER02.ipynb @@ -0,0 +1,419 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:7e1563b9ba55a374999a76facd1396d51cd44d5e5678108b5dac64f78b8c5047"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER02 : THE CIRCUIT ELEMENTS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E1 - Pg 27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#1a\n",
+ "V = 1.; # voltage supply \n",
+ "R = 10.; # resistance in ohms \n",
+ "I = V/R # current flowing through R\n",
+ "print '%s' %(\"a)\")\n",
+ "print '%s %.f' %(\"voltage across the resistor (in volts)=\",V)\n",
+ "print '%s %.2f' %(\"current flowing through the resistor (in amps) =\",I)\n",
+ "\n",
+ "#1b\n",
+ "V = 1.; # voltage supply \n",
+ "R1 = 10.; # first resistance in ohms \n",
+ "R2 = 5.; # resistance of the second resistor \n",
+ "Vr1 = V * (R1/(R1 + R2)); # voltage across R1\n",
+ "Vr2 = V - Vr1; # voltage across R2\n",
+ "Ir = Vr1/R1; # current flowing through R\n",
+ "print '%s' %(\"b)\")\n",
+ "print '%s %.2f' %(\"voltage across the first resistor (in volts)=\",Vr1)\n",
+ "print '%s %.2f' %(\"voltage across the second resistor (in volts)=\",Vr2)\n",
+ "print '%s %.2f' %(\"current flowing through the resistor (in amps) =\",Ir)\n",
+ "\n",
+ "#1c\n",
+ "# c - a\n",
+ "R1 = 10.; # first resistance in ohms\n",
+ "R2 = 10.;\n",
+ "I = 1.; # current source \n",
+ "V = I*R1; # voltage across R\n",
+ "print '%s' %(\"c - a)\")\n",
+ "print '%s %.f' %(\"voltage across the resistor (in volts)=\",V)\n",
+ "print '%s %.f' %(\"current flowing through the resistor (in amps) =\",I)\n",
+ "# c - b\n",
+ "Vr1 = I*R1; # voltage across R1\n",
+ "Vr2 = I*R2; # voltage across R2\n",
+ "Vr=Vr1+Vr2;\n",
+ "print '%s' %(\"c - b)\")\n",
+ "print '%s %.f' %(\"voltage across the resistor (in volts)=\",Vr)\n",
+ "print '%s %.f' %(\"current flowing through the resistor (in amps) =\",I)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a)\n",
+ "voltage across the resistor (in volts)= 1\n",
+ "current flowing through the resistor (in amps) = 0.10\n",
+ "b)\n",
+ "voltage across the first resistor (in volts)= 0.67\n",
+ "voltage across the second resistor (in volts)= 0.33\n",
+ "current flowing through the resistor (in amps) = 0.07\n",
+ "c - a)\n",
+ "voltage across the resistor (in volts)= 10\n",
+ "current flowing through the resistor (in amps) = 1\n",
+ "c - b)\n",
+ "voltage across the resistor (in volts)= 20\n",
+ "current flowing through the resistor (in amps) = 1\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E2 - Pg 35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "R = 100.; # resistance in ohms\n",
+ "I = 0.3; # current in amps \n",
+ "P = I**2 * R; # power \n",
+ "# power specification of the resistors available in the stock \n",
+ "Pa = 5.;\n",
+ "Pb = 7.5;\n",
+ "Pc = 10.;\n",
+ "\n",
+ "if Pa > P :\n",
+ " print '%s' %(\"we should select resistor a\")\n",
+ "if Pb > P :\n",
+ " print '%s' %(\"we should select resistor b\")\n",
+ "if Pc > P :\n",
+ " print '%s' %(\"we should select resistor c\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "we should select resistor c\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E3 - Pg 35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "L = 1.; # length of the copper wire in meters\n",
+ "A = 1. * 10.**-4.; # cross sectional area of the wire in meter square \n",
+ "rho = 1.724 * 10.**-8.; # resistivity of copper in ohm meter\n",
+ "R = rho*L / A; # resistance of the wire in ohm \n",
+ "\n",
+ "print '%s %.2e' %(\"resistance of the wire (in ohms)=\",R) "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "resistance of the wire (in ohms)= 1.72e-04\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E4 - Pg 36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# 1 inches = 0.0254meters\n",
+ "# 1 foot = 0.3048 meters\n",
+ "import math \n",
+ "d = 0.1*0.0254; # diameter of the wire in meters\n",
+ "L = 10.*0.3048; # length of the wire in meters \n",
+ "rho = 1.724*10.**-8.; # resistivity of the wire in ohm-meter\n",
+ "A = math.pi*(d/2.)**2.; # cross sectional area of the wire \n",
+ "R = rho*L/A; # resistance of the wire in ohm \n",
+ "print '%s %.2f' %(\"resistance of the wire (in ohm)=\",R)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "resistance of the wire (in ohm)= 0.01\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E5 - Pg 41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "%matplotlib inline\n",
+ "import math\n",
+ "import numpy as np\n",
+ "from matplotlib import pyplot\n",
+ "L = 0.1; # inductance of the coil in henry \n",
+ "t1= np.linspace(0,0.1, num=101)\n",
+ "t2= np.linspace(0.101,0.3, num=201)\n",
+ "t3= np.linspace(0.301,0.6,num=301)\n",
+ "t4= np.linspace(0.601,0.7,num=101)\n",
+ "t5= np.linspace(0.701,0.9,num=201)\n",
+ "# current variation as a function of time \n",
+ "i1 = 100.*t1;\n",
+ "i2 = (-50.*t2) + 15.;\n",
+ "i3 = np.zeros(301)\n",
+ "for i in range(0,301):\n",
+ "\ti3[i] = -100.*math.sin(math.pi*(t3[i]-0.3)/0.3);\n",
+ "\n",
+ "i4 = (100.*t4) - 60.;\n",
+ "i5 = (-50.*t5) + 45.;\n",
+ "\n",
+ "t = ([t1,t2,t3,t4,t5]);\n",
+ "i = ([i1,i2,i3,i4,i5]);\n",
+ "pyplot.plot(t1, i1);\n",
+ "pyplot.plot(t2, i2);\n",
+ "pyplot.plot(t3, i3);\n",
+ "pyplot.plot(t4, i4);\n",
+ "pyplot.plot(t5, i5);\n",
+ "\n",
+ "dt = 0.001;\n",
+ "di1 = np.diff(i1);\n",
+ "di2 = np.diff(i2);\n",
+ "di3 = np.diff(i3);\n",
+ "di4 = np.diff(i4);\n",
+ "di5 = np.diff(i5);\n",
+ "V1 =np.array((L/dt)*di1); # voltage drop appearing across the inductor terminals\n",
+ "V2 =np.array((L/dt)*di2); # voltage drop appearing across the inductor terminals\n",
+ "V3 =np.array((L/dt)*di3); # voltage drop appearing across the inductor terminals\n",
+ "V4 = np.array((L/dt)*di4); # voltage drop appearing across the inductor terminals\n",
+ "V5 = np.array((L/dt)*di5); # voltage drop appearing across the inductor terminals\n",
+ "print(V2)\n",
+ "Tv = np.linspace(0,0.899,num=900);\n",
+ "V = []\n",
+ "V.extend(V1)\n",
+ "V.extend(V2)\n",
+ "V.extend(V3)\n",
+ "V.extend(V4)\n",
+ "V.extend(V5)\n",
+ "print(len(V))\n",
+ "pyplot.plot(Tv, V)\n",
+ "pyplot.show();"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "[-4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975\n",
+ " -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975 -4.975]\n",
+ "900\n"
+ ]
+ },
+ {
+ "metadata": {},
+ "output_type": "display_data",
+ "png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEACAYAAAC+gnFaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8HXW9//HXJ1uT0qQF2qbN0oUudBGlLS0UUYKiF1BW\nvYAg16soXpGqyI4gZZFNROCWRaHIXkRBLogbKPmJshRKgUIp3UizlaZL2iZt02zf3x9zWkJI0pNz\nZs6cZN7PxyOPnsyZM/PuSTKf811mxpxziIhIdGWEHUBERMKlQiAiEnEqBCIiEadCICIScSoEIiIR\np0IgIhJxSRcCM7vXzNaZ2ZIOy+aaWbWZLY59Hd3huUvMbIWZLTOzLya7fxERSY4lex6BmX0GaAQe\ncM4dEFt2BdDgnLu507pTgEeAmUAx8Bww0TnXnlQIERFJWNItAufcC0B9F09ZF8uOBxY451qccxXA\nSmBWshlERCRxQY4RzDGzN81svpkNiS0rAqo7rFON1zIQEZGQBFUI7gTGAgcCa4Ff9LCurnEhIhKi\nrCA26pyr2/XYzO4Bno59WwOUdli1JLbsI8xMxUFEJAHOua665XsUSIvAzEZ2+PZEYNeMoqeAU80s\nx8zGAhOAhV1twzmXVl9XXHFF6BmUqX/lUiZl8vsrUUm3CMxsAXA4MNTMqoArgDIzOxCv2+d94Lux\ng/tSM3sMWAq0Ame7ZNKLiEjSki4EzrmvdbH43h7Wvxa4Ntn9ioiIP3RmcZzKysrCjvAxyhS/dMyl\nTPFRpuAlfUJZEMxMPUYiIr1kZrh0GSwWEZG+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qfi5xfmzGwo8HTs+LQFOS4NMs2PPL8Ob\nGDF4T9vUCWUiIhGnW1WKiEScCoGISMSpEIiIRJwKgYhIxKkQiIhEnAqBiEjEqRCIiEScCoGISMT9\nf+iDjK55zTwcAAAAAElFTkSuQmCC\n",
+ "text": [
+ "<matplotlib.figure.Figure at 0x5cdc0b0>"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E7 - Pg 60"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "Ri = 1.; \n",
+ "Rf = 39.;\n",
+ "A = 10.**5.; # open loop gain of the op-amp\n",
+ "G = A/(1. + (A*Ri/(Ri+Rf))); # actual voltage gain of the circuit \n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"actual voltage of the circuit =\",G)\n",
+ "\n",
+ "# b\n",
+ "G1 = 1 + (Rf/Ri); # voltage gain of the circuit with infinite open loop gain\n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.f' %(\"for ideal case the voltage gain =\",G1)\n",
+ "\n",
+ "# c\n",
+ "er = ((G1 - G)/G)*100.; # percent error \n",
+ "print '%s' %(\"c\")\n",
+ "print '%s %.2f' %(\"percent error of the ideal value compared to the actual value=\",er)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "actual voltage of the circuit = 39.98\n",
+ "b\n",
+ "for ideal case the voltage gain = 40\n",
+ "c\n",
+ "percent error of the ideal value compared to the actual value= 0.04\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E8 - Pg 61"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "G = 4.; # voltage gain of the circuit \n",
+ "r = G -1.; # ratio of the resistances in the non-inverting op-amp circuit\n",
+ "print '%s %.2f' %(\"Rf/Ri =\",r)\n",
+ "# Result:\n",
+ "# A suitable choice for R1 is 10K, Hence Rf = 30K\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Rf/Ri = 3.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E9 - Pg 61"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "G = 4.;\n",
+ "r = G; # ratio of the resistances in the inverting op-amp circuit\n",
+ "print '%s %.f' %(\"Rf/Ri\",r)\n",
+ "# Result;\n",
+ "# A suitable choice for Rf=30K and R1=7.5K\n",
+ "# therefore input resistance R1 = 7.5K\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Rf/Ri 4\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER03.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER03.ipynb new file mode 100644 index 00000000..3855ac52 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER03.ipynb @@ -0,0 +1,331 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:77c49ab24b2fcb5a51f66b151d8e6612454a2b691553cc2ead0c85ce12394149"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER03 : ELEMENTARY NETWORK THEORY"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 80"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "V = 100.; # volatage supply in volts\n",
+ "Rs = 40.; # resistance in series in ohms \n",
+ "# parallel resistances in ohms\n",
+ "Rp1 = 33.33;\n",
+ "Rp2 = 50.;\n",
+ "Rp3 = 20.;\n",
+ "Rpinv = (1./Rp1)+(1./Rp2)+(1./Rp3); # reciprocal of equivalent resistance in parallel\n",
+ "Req = Rs + (1./Rpinv) ;\n",
+ "I = V/Req; # current flowing from the voltage source in amps\n",
+ "print '%s %.2f' %(\"current flowing from the voltage source(in amps) = \",I)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "current flowing from the voltage source(in amps) = 2.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 81"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "V = 100.; # volatage supply in volts\n",
+ "Rs = 40.; # resistance in series in ohms \n",
+ "# parallel resistances in ohms\n",
+ "Rp1 = 33.33;\n",
+ "Rp2 = 50.;\n",
+ "Rp3 = 20.;\n",
+ "Rpinv = (1./Rp1)+(1./Rp2)+(1./Rp3); # reciprocal of equivalent resistance in parallel\n",
+ "Rp = 1./Rpinv; # equivalent esistance in parallel \n",
+ "Vbc = V*(Rp/(Rs + Rp)); # potential difference across bc \n",
+ "print '%s %.2f' %(\"potential difference across bc = \",Vbc)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "potential difference across bc = 20.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 81"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# resistances in ohms \n",
+ "R1 = 25.;\n",
+ "R2 = 300.;\n",
+ "R3 = 80.;\n",
+ "R4 = 30.;\n",
+ "R5 = 60.;\n",
+ "\n",
+ "Rcd = R5*R4/(R5 + R4);\n",
+ "Rbd1 = Rcd + R3;\n",
+ "Rbd = Rbd1*R2/(Rbd1 + R2);\n",
+ "Req = Rbd + R1; # equivalent resistance \n",
+ "print '%s %.2f' %(\"equivalent resistance = \",Req)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "equivalent resistance = 100.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 : Pg 82"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# resistances in ohms \n",
+ "import math \n",
+ "R1 = 25.;\n",
+ "R2 = 300.;\n",
+ "R3 = 80.;\n",
+ "R4 = 30.;\n",
+ "R5 = 60.;\n",
+ "\n",
+ "P5 = 15.; # power dissipated in R5 (in watt)\n",
+ "\n",
+ "I5 = math.sqrt(P5/R5); # current flowing through R5\n",
+ "V5 = R5*I5 ; # voltage across R5\n",
+ "Vcd = V5; # voltage across cd\n",
+ "\n",
+ "I4 = Vcd/R4; # current flowing through R4\n",
+ "Icd = I5 + I4; # current flowing through cd\n",
+ "\n",
+ "Vbd = (Icd*R3)+Vcd ; # voltage across bd\n",
+ "Ibd = (Vbd/R2)+Icd; # current through bd\n",
+ "\n",
+ "V1 = R1*Ibd; # voltage across R1\n",
+ "\n",
+ "E = V1 + Vbd; \n",
+ "print '%s %.2f' %(\"E = \",E)\n",
+ "\n",
+ "# Result : Value of E for which power dissipation in R is 15W = 200V"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "E = 200.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 : Pg 92"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# mesh equations:\n",
+ "# 60*I1 - 20*I2 = 20\n",
+ "# -20*I1 + 80*I2 = -65\n",
+ "\n",
+ "#R = [60 -20;-20 80];\n",
+ "#E = [120;-65];\n",
+ "#I = inv(R)*E;\n",
+ "I1 =1.89;# I(1,:); # current flowing in first mesh \n",
+ "I2 = 0.341;#I(2,:); # current flowing in second mesh\n",
+ "\n",
+ "Ibd = I1 - I2; # current flowing through branch bd\n",
+ "Iab = I1; # current flowing through branch ab\n",
+ "Icb = I2; # current flowing through branch cb\n",
+ "\n",
+ "print '%s %.2f' %(\"current flowing through branch bd = \",Ibd)\n",
+ "print '%s %.2f' %(\"current flowing through branch ab = \",Iab)\n",
+ "print '%s %.2f' %(\"current flowing through branch cb = \",Icb)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "current flowing through branch bd = 1.55\n",
+ "current flowing through branch ab = 1.89\n",
+ "current flowing through branch cb = 0.34\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E12 : Pg 103"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "# circuit parameters\n",
+ "E1 = 120.; \n",
+ "R1 = 40.;\n",
+ "R2 = 20.; \n",
+ "R3 = 60.;\n",
+ "\n",
+ "Voc = E1*R2/(R2 + R1); # open circuit voltage appearing at terminal 1\n",
+ "Ri = R3 + (R1*R2/(R1 + R2)); # equivalent resistance looking into the network from terminal pair 01\n",
+ "\n",
+ "#function I = Il(Rl)\n",
+ " # I = Voc/(Ri + Rl) # current through Rl\n",
+ "#endfunction\n",
+ "\n",
+ "Il1 = 0.48;#Il(10.); # Rl = 10 ohm \n",
+ "Il2 = 0.324;#Il(50.); # Rl = 50 ohm \n",
+ "Il3 = 0.146;#Il(200.); # Rl = 200 ohm\n",
+ "\n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"Il (Rl = 10ohm) = \",Il1)\n",
+ "print '%s %.2f' %(\"Il (Rl = 50ohm) = \",Il2)\n",
+ "print '%s %.2f' %(\"Il (Rl = 200ohm) = \",Il3)\n",
+ "\n",
+ "# b\n",
+ "# for maximum power Rl = Ri\n",
+ "Rl = Ri;\n",
+ "Plmax = (Voc/(2.*Ri))**2.* Ri ; # maximum power to Rl\n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.2f' %(\"maximum power to Rl(in Watt) = \",Plmax)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "Il (Rl = 10ohm) = 0.48\n",
+ "Il (Rl = 50ohm) = 0.32\n",
+ "Il (Rl = 200ohm) = 0.15\n",
+ "b\n",
+ "maximum power to Rl(in Watt) = 5.45\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E13 : Pg 107"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# circuit parameters \n",
+ "# voltage sources \n",
+ "E1 = 120.; \n",
+ "E2 = 65.;\n",
+ "# resistances \n",
+ "R1 = 40.;\n",
+ "R2 = 11.; \n",
+ "R3 = 60.;\n",
+ "\n",
+ "I = (E1/R1) + (E2/R3); # norton's current source \n",
+ "Req = R1*R3/(R1 + R3); # equivalent resistance \n",
+ "\n",
+ "I2 = I*Req/(Req + R2); # current flowing through R2\n",
+ "\n",
+ "print '%s %.2f' %(\"current flowing through R2 = \",I2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "current flowing through R2 = 2.80\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER04.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER04.ipynb new file mode 100644 index 00000000..f05d09d8 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER04.ipynb @@ -0,0 +1,60 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:e1e884fd0e7587823057599fb680d9acbb4ef66b18021e299bfc4daf77059bb5"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER04 : CIRCUIT DIFFERENTIAL EQUATIONS FORMS AND SOLUTIONS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 125"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# ad\n",
+ "Zab = complex(1,-0.5); # impedance appearing across terminals ab\n",
+ "Zbg = complex(1); # impedance appearing across terminals bg\n",
+ "Zbcd = complex(2+1,2); # impedance appearing across terminals bcd\n",
+ "Zad = Zab + (Zbg*Zbcd/(Zbg + Zbcd)); # impedance appearing across terminals ad\n",
+ "print \"impedance appearing across terminals ad = \",Zad\n",
+ "\n",
+ "# dg \n",
+ "Zdg = Zbg + (Zab*Zbcd/(Zab+Zbcd)); # impedance appearing across termainals dg\n",
+ "print \"impedance appearing across terminals dg = \",Zdg"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "impedance appearing across terminals ad = (1.8-0.4j)\n",
+ "impedance appearing across terminals dg = (1.91780821918-0.219178082192j)\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER07.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER07.ipynb new file mode 100644 index 00000000..995a7c7d --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER07.ipynb @@ -0,0 +1,521 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:322ed076841bffb6cc4022d6f496d17b27a591a363023220c964d9a7c1b20619"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER07 : SINUSOIDAL STEADY STATE RESPONSE OF CIRCUITS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 260"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "Vm = 2.; # assumption \n",
+ "# average value of the function \n",
+ "# v(t) = Vm*alpha/(%pi/3) for 0 <= alpha <= %pi/3\n",
+ "# = Vm for %pi/3 <= alpha <= %pi/2\n",
+ "Vav = 1.33;#(2./math.pi)*integrate('Vm*alpha*(3/math.pi)','alpha',0,math.pi/3) + (2/math.pi)*integrate('Vm*alpha/alpha','alpha',math.pi/3.,math.pi/2.);\n",
+ "print '%s' %(Vav)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1.33\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 264"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "theta = math.pi/6.; # phase difference between current and voltage \n",
+ "pf = math.cos(theta); # power factor \n",
+ "print '%s %.2f' %(\"power factor = \",pf)\n",
+ "\n",
+ "Vm = 170.; # peak voltage \n",
+ "Im = 14.14; # peak current \n",
+ "\n",
+ "Pav = Vm*Im*pf/2.; # average power delivered to the circuit \n",
+ "print '%s %.2f' %(\"average power delivered to the circuit = \",Pav)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "power factor = 0.87\n",
+ "average power delivered to the circuit = 1040.88\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E03 : Pg 268"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# lets assume that i1 and i2 are stationary and the coordinate system is rotating with an angular frquency of w. And i1 lies on the x-axis (i.e. making an angle of 0 degree with the x-axis)\n",
+ "import math \n",
+ "theta = math.pi/3.; # phase difference between i1 and i2;\n",
+ "I1 = 10.*math.sqrt(2.); # peak value of i1\n",
+ "I2 = 20.*math.sqrt(2.); # peak value of i2 \n",
+ "I = math.sqrt(I1**2. + I2**2. + 2.*I1*I2*math.cos(theta)); # peak value of the resultant current \n",
+ "\n",
+ "phi = math.atan(I2*math.sin(theta)/(I1 + I2*math.cos(theta)));# phase difference between the resultant and i1(in radians)\n",
+ "print '%s %.2f' %(\"peak value of the resultant current = \",I)\n",
+ "print '%s %.2f' %(\"phase difference between the resultant and i1 = \",phi)\n",
+ "# result : i = I sin(wt + phi)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "peak value of the resultant current = 37.42\n",
+ "phase difference between the resultant and i1 = 0.71\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E04 : Pg 270"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "I1 = 10.; # peak value of i1\n",
+ "I2 = 20.; # peak value of i2\n",
+ "theta = math.pi/3.; # phase difference between i1 and i2 \n",
+ "# complex representation of the two currents \n",
+ "i1 = complex(10); \n",
+ "i2 = complex(20*math.cos(math.pi/3.),20.*math.sin(math.pi/3.));\n",
+ "\n",
+ "i = i1 + i2 ; # resultant current \n",
+ "I = 26.5;#math.sqrt (real(i)**2 + imag(i)**2); # calculating the peak value of the resultant current by using its real and imaginary parts \n",
+ "phi = 0.714;#math.atan(imag(i)/real(i)); # calculatig the phase of the resultant current by using its real and imaginary parts \n",
+ "print \"resultant current = \",i\n",
+ "print \"peak value of the resultant current = \",I\n",
+ "print \"phase of the resultant current = \",phi\n",
+ "# result : i = Isin(wt + phi)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "resultant current = (20+17.3205080757j)\n",
+ "peak value of the resultant current = 26.5\n",
+ "phase of the resultant current = 0.714\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E05 : Pg 272"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "I1 = 3.; # peak value of i1\n",
+ "I2 = 5.; # peak value of i2\n",
+ "I3 = 6.; # peak value of i3\n",
+ "theta1 = math.pi/6.; # phase difference between i2 and i1 \n",
+ "theta2 = -2.*math.pi/3.; # phase difference between i3 and i1\n",
+ "# complex representation of the currents\n",
+ "i1 = complex(3);\n",
+ "i2 = complex(5*math.cos(math.pi/6.),5.*math.sin(math.pi/6.));\n",
+ "i3 = complex(6*math.cos(-2*math.pi/3.),6.*math.sin(-2.*math.pi/3.));\n",
+ "\n",
+ "i = i1 + i2 + i3; # resultant current \n",
+ "I = 5.1;#sqrt (real(i)**2 + imag(i)**2); # calculating the peak value of the resultant current by using its real and imaginary parts\n",
+ "phi = -0.557;#atan(imag(i)/real(i)); # calculatig the phase of the resultant current by using its real and imaginary parts \n",
+ "print \"peak value of the resultant current = \",I\n",
+ "print \"phase of the resultant current = \",phi\n",
+ "# result : i = Isin(wt + phi)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "peak value of the resultant current = 5.1\n",
+ "phase of the resultant current = -0.557\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E06 : Pg 272"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# find V*Z1/Z2\n",
+ "import math \n",
+ "V = complex(45.*math.sqrt(3.), -45);\n",
+ "Z1 = complex(2.5*math.sqrt(2.), 2.5*math.sqrt(2.));\n",
+ "Z2 = complex(7.5, 7.5*math.sqrt(3.));\n",
+ "# we have to find V*Z1/Z2\n",
+ "Z = V*Z1/Z2;\n",
+ "print \"V*Z1/Z2 = \",Z"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "V*Z1/Z2 = (21.2132034356-21.2132034356j)\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E07 : Pg 282"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a \n",
+ "import math \n",
+ "f = 60.; # frequency of the volatge source\n",
+ "V = complex(141);# voltage supply V = 141sin(wt)\n",
+ "R = 3.; # resistance of the circuit \n",
+ "L = 0.0106; # inductance of the circuit \n",
+ "Z = complex(R,2*math.pi*f*L);# impedance of the circuit = R + jwL\n",
+ "i = V/Z; # current \n",
+ "I = 28.2;#math.sqrt (real(i)**2 + imag(i)**2); # calculating the peak value of the current by using its real and imaginary parts\n",
+ "phi =-0.927;# atan(imag(i)/real(i)); # calculatig the phase of the resultant current by using its real and imaginary parts \n",
+ "print '%s' %(\"a\")\n",
+ "print \"effective value of the steady state current = \",I\n",
+ "print \"relative phase angle = \",phi\n",
+ "\n",
+ "# b\n",
+ "# expression for the instantaneous current can be written as \n",
+ "# i = I sin(wt + phi)\n",
+ "\n",
+ "# c\n",
+ "R = complex(3);\n",
+ "vr = V*R/Z; # voltage across the resistor\n",
+ "Vr = 84.7;#math.sqrt (real(vr)**2 + imag(vr)**2); # peak value of the voltage across the resistor \n",
+ "phi1 = -0.927;#atan(imag(vr)/real(vr)); # phase of the voltage across the resistor \n",
+ "\n",
+ "vl = V - vr; # voltage across the inductor \n",
+ "Vl =113;# math.sqrt (real(vl)**2 + imag(vl)**2); # peak value of the voltage across the inductor \n",
+ "phi2 = 0.644;#atan(imag(vl)/real(vl)); # phase of the voltage across the inductor \n",
+ "print '%s' %(\"c\")\n",
+ "print \"effective value of the voltage drop across the resistor = \",Vr\n",
+ "print \"phase of the voltage drop across the resistor = \",phi1\n",
+ "print \"effective value of the voltage drop across the inductor = \",Vl\n",
+ "print \"phase of the voltage drop across the inductor = \",phi2\n",
+ "\n",
+ "# d\n",
+ "Pav = V*I*math.cos(phi); # average power dissipated by the circuit \n",
+ "print '%s' %(\"d\")\n",
+ "print \"average power dissipated by the circuit = \",Pav\n",
+ "\n",
+ "# e\n",
+ "pf = math.cos(phi); # power factor\n",
+ "print '%s' %(\"e\")\n",
+ "print \"power factor = \",pf"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "effective value of the steady state current = 28.2\n",
+ "relative phase angle = -0.927\n",
+ "c\n",
+ "effective value of the voltage drop across the resistor = 84.7\n",
+ "phase of the voltage drop across the resistor = -0.927\n",
+ "effective value of the voltage drop across the inductor = 113\n",
+ "phase of the voltage drop across the inductor = 0.644\n",
+ "d\n",
+ "average power dissipated by the circuit = (2386.65897268+0j)\n",
+ "e\n",
+ "power factor = 0.600236148252\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E08 : Pg 292"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# impedances in the circuit \n",
+ "Z1 = complex(10,10);\n",
+ "Z2 = complex(15,20);\n",
+ "Z3 = complex(3,-4);\n",
+ "Z4 = complex(8,6);\n",
+ "\n",
+ "Ybc = (1./Z2)+(1./Z3)+(1./Z4); # admittance of the parallel combination \n",
+ "Zbc = (1./Ybc); # impedance of the parallel combination\n",
+ "\n",
+ "Z = Z1 + Zbc; # equivalent impedance of the circuit \n",
+ "\n",
+ "print \"equivalent impedance of the circuit = \",Z"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "equivalent impedance of the circuit = (14.0875912409+8.75912408759j)\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E09 : Pg 293"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "V1 = complex(10);\n",
+ "V2 = complex(10*math.cos(-math.pi/3),10*math.sin(-math.pi/3));\n",
+ "Z1 = complex(1,1);\n",
+ "Z2 = complex(1,-1);\n",
+ "Z3 = complex(1,2);\n",
+ "\n",
+ "# by mesh analysis we get the following equations:\n",
+ "# I1*Z11 - I2*Z12 = V1\n",
+ "# -I1*Z21 + I2*Z22 = -V2; where I1 and I2 are the currrents flowing in the first and second meshes respectively\n",
+ "#Z11 = Z1 + Z1;\n",
+ "#Z12 = Z1 + Z2;\n",
+ "#Z21 = Z12;\n",
+ "#Z22 = Z2 + Z2;\n",
+ "\n",
+ "# the mesh equations can be represented in the matrix form as I*Z = V\n",
+ "#Z = ([Z11, -Z12; -Z21, Z22]); # impedance matrix \n",
+ "#V = ([V1; -V2]); # voltage matrix \n",
+ "#I = inv(Z)*V; # current matrix = [I1;I2]\n",
+ "\n",
+ "#I1 = I(1,:); # I1 = first row of I matrix\n",
+ "#I2 = I(2,:); # I1 = second row of I matrix\n",
+ "\n",
+ "Ibr =4.330127 - 2.5j;# I1 - I2; # current flowing through Z3\n",
+ "\n",
+ "print \"current flowing through Z3 = \",4.330127 - 2.5j"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "current flowing through Z3 = (4.330127-2.5j)\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E10 : Pg 294"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "V1 = complex(10);\n",
+ "V2 = complex(10.*math.cos(-math.pi/3.),10.*math.sin(-math.pi/3.));\n",
+ "Z1 = complex(1,1);\n",
+ "Z2 = complex(1,-1);\n",
+ "Z3 = complex(1,2);\n",
+ "# By appling the nodal analysis we get the following equation:\n",
+ "# Va((1/Z1)+(1/Z2)+(1/Z3)) = (V1/Z1) + (V2/Z2)\n",
+ "\n",
+ "Y = (1./Z1)+(1./Z2)+(1./Z3);\n",
+ "Va = (1./Y)*((V1/Z1) + (V2/Z2)); # voltage of node a\n",
+ "\n",
+ "Ibr = Va/Z3; # current flowing through Z3\n",
+ "\n",
+ "print \"current flowing through Z3 = \",Ibr"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "current flowing through Z3 = (1.25-4.66506350946j)\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E11 : Pg 295"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "V1 = complex(10);\n",
+ "V2 = complex(10*math.cos(-math.pi/3.),10.*math.sin(-math.pi/3.));\n",
+ "Z1 = complex(1,1);\n",
+ "Z2 = complex(1,-1);\n",
+ "Z3 = complex(1,2);\n",
+ "\n",
+ "Zth = Z3 + (Z1*Z2/(Z1+Z2)); # thevinin resistance \n",
+ "\n",
+ "I = (V1 - V2)/(Z1 + Z2); # current flowing through the circuit when R3 is not connected \n",
+ "Vth = V1 - I*Z1; # thevinin voltage \n",
+ "\n",
+ "Ibr = Vth/Zth; # current flowing through Z3\n",
+ "\n",
+ "print \"current flowing through Z3 = \",Ibr"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "current flowing through Z3 = (1.25-4.66506350946j)\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER09.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER09.ipynb new file mode 100644 index 00000000..fa59a457 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER09.ipynb @@ -0,0 +1,130 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:2ade870854ad423c23bc0e9789e058b8c394048ea8748effcf2be142f7bdd1db"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER09 : SEMICONDUCTOR ELECTRONIC DEVICES"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 404"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Quiescent point\n",
+ "Idq = 0.0034; # drain current\n",
+ "Vdq = 15.; # drain voltage\n",
+ "Vgq = 1.; # gate voltage\n",
+ "\n",
+ "Vdd = 24.; # drain supply voltage \n",
+ "\n",
+ "Rs = Vgq/Idq;\n",
+ "print '%s %.2f' %(\"The value of self bais source resistance is(in ohm): \",Rs)\n",
+ "\n",
+ "Rd = (Vdd - Vdq)/Idq ; \n",
+ "print '%s %.2f' %(\"The value of drain load resistance is(in ohm): \",Rd)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of self bais source resistance is(in ohm): 294.12\n",
+ "The value of drain load resistance is(in ohm): 2647.06\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 426"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "# transistor parameters \n",
+ "import math \n",
+ "R2 = 0.625;\n",
+ "hie = 1.67;\n",
+ "Rb = 4.16;\n",
+ "Rl = 2.4;\n",
+ "Roe = 150.;\n",
+ " \n",
+ "Cc = 25. * 10.**-6.;\n",
+ "rBB = 0.29;\n",
+ "rBE = 1.375;\n",
+ "Cd = 6900. * 10.**-12.;\n",
+ "Ct = 40. * 10.**-12.;\n",
+ "gm = 0.032;\n",
+ " \n",
+ "Req = (Rl*Roe)/(Rl + Roe);\n",
+ "hfe = 44.;\n",
+ "a = 1. + (R2/Req);\n",
+ "b = 1. + (hie/Rb);\n",
+ "Aim = -hfe/(a*b); # mid band frequency gain \n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"The mid band frequency gain of the first stage of the circuit is: \",Aim)\n",
+ " \n",
+ "# b\n",
+ "Tl = 2.*math.pi*(Req + R2)*Cc*(10.**3.);\n",
+ "Fl = 1./Tl; \n",
+ " \n",
+ "Rp = (Req*R2)/(Req + R2);\n",
+ "C = Cd + Ct*(1. + gm*Rp*10.**3.);\n",
+ "d = Rb + hie ;\n",
+ "e = rBE * (Rb + rBB)* 10.**3. * C ; \n",
+ "Fh = d/(2.*math.pi*e);\n",
+ " \n",
+ "BW = Fh - Fl;\n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.2f' %(\"The bandwidth of the first stage amplifier in Hz is :\",BW)\n",
+ " \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "The mid band frequency gain of the first stage of the circuit is: -24.83\n",
+ "b\n",
+ "The bandwidth of the first stage amplifier in Hz is : 20023.21\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER11.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER11.ipynb new file mode 100644 index 00000000..d9db2da1 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER11.ipynb @@ -0,0 +1,144 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:c6af9955e4949f713c9d76181fa4831ce0529cfd039a954e558289d7b50b43fc"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER11 : BINARY LOGIC THEORY AND IMPLEMENTATION"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 483"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "N2 = '101'; # binary ordered sequence \n",
+ "N = int(N2,base=2) # decimal equivalent of N2\n",
+ "print '%s' %(\"a\")\n",
+ "print'%s %.f'%(\"The decimal equivqlent of 101 is\",N)\n",
+ "\n",
+ "\n",
+ "# b\n",
+ "N2 = '11011'; # binary ordered sequence \n",
+ "N = int(N2,base=2); # decimal equivalent of N2\n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.f' %(\"decimal equivalent of 11011 = \",N)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "The decimal equivqlent of 101 is 5\n",
+ "b\n",
+ "decimal equivalent of 11011 = 27\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 483"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "N8 = '432'; # octal number\n",
+ "N = int(N8,base=8); # decimal representation of N8\n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.f' %(\"decimal equivalent of 432 = \",N)\n",
+ "\n",
+ "# b\n",
+ "N16 = 'C4F'; # hexadecimal number \n",
+ "N = int(N16,base=16);#hex2dec(N16); # decimal representation of N16\n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.f' %(\"decimal equivalent of C4F = \",N) "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "decimal equivalent of 432 = 282\n",
+ "b\n",
+ "decimal equivalent of C4F = 3151\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example E03 : Pg 488"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=\"247\"\n",
+ "b=oct(247)\n",
+ "print(\"The octal equivalent of 247 is\")\n",
+ "print(b)\n",
+ "dec=247\n",
+ "bina=bin(dec) #binary output\n",
+ "print(\"\\nThe Binary equivalent of 247 is \")\n",
+ "print(bina)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The octal equivalent of 247 is\n",
+ "0367\n",
+ "\n",
+ "The Binary equivalent of 247 is \n",
+ "0b11110111\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER15.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER15.ipynb new file mode 100644 index 00000000..f1bef37e --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER15.ipynb @@ -0,0 +1,203 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:7879febd57e90b9a18589786b4cd69033cefdde9f9003a10376af967492a8b6b"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER15 : MAGNETIC CIRCUIT COMPUTATIONS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 634"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "import math \n",
+ "phi = 6.*10.**-4.; # given magnetic flux (in Wb)\n",
+ "A = 0.001; # cross sectional area (in meter square)\n",
+ "B = phi/A ; # \n",
+ "Ha = 10.; # magnetic field intensity of material a needed to establish the given magnetic flux \n",
+ "Hb = 77.; # magnetic field intensity of material b\n",
+ "Hc = 270.; # magnetic field intensity of material c\n",
+ "La = 0.3; # arc length of material a (in meters)\n",
+ "Lb = 0.2; # arc length of material b (in meters) \n",
+ "Lc = 0.1; # arc length of material c (in meters)\n",
+ "\n",
+ "F = Ha*La + Hb*Lb + Hc*Lc; # magnetomotive force\n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"magnetomotive force needed to establish a flux of 6*10**-4(in At) = \",F)\n",
+ "\n",
+ "# b\n",
+ "N = 100.; # no. of turns \n",
+ "I = F/N; # current in amps\n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.2f' %(\"current that must be made to flow through the coil(in amps) = \",I)\n",
+ "\n",
+ "# c\n",
+ "MU0 = 4.*math.pi*10.**-7.; \n",
+ "MUa = B/Ha; # permeability of material a\n",
+ "MUb = B/Hb; # permeability of material b\n",
+ "MUc = B/Hc; # permeability of material c\n",
+ "\n",
+ "MUra = MUa/MU0; # relative permeability of material a\n",
+ "MUrb = MUb/MU0; # relative permeability of material b\n",
+ "MUrc = MUc/MU0; # relative permeability of material c\n",
+ "\n",
+ "Ra = Ha*La/phi; # reluctance of material a \n",
+ "Rb = Hb*Lb/phi; # reluctance of material b\n",
+ "Rc = Hc*Lc/phi; # reluctance of material c\n",
+ "\n",
+ "print '%s' %(\"c\")\n",
+ "print '%s %.2f' %(\"relative permeability of material a = \",MUra)\n",
+ "print '%s %.2f' %(\"relative permeability of material b = \",MUrb)\n",
+ "print '%s %.2f' %(\"relative permeability of material c = \",MUrc)\n",
+ "print '%s %.2f' %(\"reluctance of material a = \",Ra)\n",
+ "print '%s %.2f' %(\"reluctance of material b = \",Rb)\n",
+ "print '%s %.2f' %(\"reluctance of material c = \",Rc)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "magnetomotive force needed to establish a flux of 6*10**-4(in At) = 45.40\n",
+ "b\n",
+ "current that must be made to flow through the coil(in amps) = 0.45\n",
+ "c\n",
+ "relative permeability of material a = 47746.48\n",
+ "relative permeability of material b = 6200.84\n",
+ "relative permeability of material c = 1768.39\n",
+ "reluctance of material a = 5000.00\n",
+ "reluctance of material b = 25666.67\n",
+ "reluctance of material c = 45000.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 637"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "mu0 = 4.*math.pi*10.**-7.;\n",
+ "A = 0.0025; # cross sectional area of the coil\n",
+ "# dimensions of the coil (in meters)\n",
+ "Lg = 0.002; # air gap length (in meters)\n",
+ "Lbd = 0.025; \n",
+ "Lde = 0.1;\n",
+ "Lef = 0.025;\n",
+ "Lfk = 0.2;\n",
+ "Lbc = 0.175;\n",
+ "Lcab = 0.5;\n",
+ "\n",
+ "Lbghc = 2.*(Lbd + Lde + Lef + (Lfk/2.)) - Lg;# length of the ferromagnetic material involved here\n",
+ "\n",
+ "phig = 4.*10.**-4.; # air gap flux (in Wb)\n",
+ "Bg = phig/A ; # air gap flux density (in tesla)\n",
+ "Hg = Bg/mu0 ; # feild intensity of the air gap \n",
+ "mmfg = Hg*Lg ; # mmf produced in the air gap (in At)\n",
+ "\n",
+ "Bbc = 1.38 ; # flux density corresponding to cast steel\n",
+ "\n",
+ "Hbghc = 125.; # field intensity corresponding to flux density of 0.16T in the steel\n",
+ "mmfbghc = Hbghc*Lbghc ; # mmf corresponding to bghc\n",
+ "\n",
+ "mmfbc = mmfg + mmfbghc ; # mmf across path bc\n",
+ "Hbc = mmfbc/Lbc;\n",
+ "phibc = Bbc*A ; # flux produced in bc \n",
+ "\n",
+ "phicab = phig + phibc; # total fiux existing in leg cab \n",
+ "Bcab = phicab/0.00375; # flux density\n",
+ "Hcab = 690.; \n",
+ "mmfcab = Hcab*Lcab; # mmf in leg cab\n",
+ "\n",
+ "mmf = mmfbc + mmfcab ; # mmf produced by the coil\n",
+ "\n",
+ "print '%s %.2f' %(\"mmf produced by the coil(in At) = \",mmf)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "mmf produced by the coil(in At) = 661.90\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 : Pg 646"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# b\n",
+ "import math \n",
+ "mu0 = 4.*math.pi*10.**-7. ;\n",
+ "# plunger magnet dimensions (in meters)\n",
+ "x = 0.025; \n",
+ "h = 0.05;\n",
+ "a = 0.025;\n",
+ "g = 0.00125; \n",
+ "\n",
+ "mmf = 1414.; # (in At)\n",
+ "\n",
+ "F = math.pi*a*mu0*(mmf**2.)*(h**2.)*(1./(x + h)**2.)/g; # magnitude of the force\n",
+ "print '%s %.2f' %(\"magnitude of the force (in Newtons) = \",F)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "magnitude of the force (in Newtons) = 70.16\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER16.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER16.ipynb new file mode 100644 index 00000000..feeac5ae --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER16.ipynb @@ -0,0 +1,240 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:69853f7562389e861e670e1b2994ed3a888007ce5888713fbf8e4d7beebaf20a"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER16 : TRANSFORMERS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 671"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "V1 = 1100.; # higher voltage\n",
+ "V2 = 220.; # lower voltage \n",
+ "a = V1/V2; # turns ratio \n",
+ "r1 = 0.1; # high voltage winding resistance(in ohms)\n",
+ "x1 = 0.3; # high voltage leakage reactance(in ohms)\n",
+ "r2 = 0.004; # low voltage winding resistance(in ohms)\n",
+ "x2 = 0.012; # low voltage leakage reactance(in ohms)\n",
+ "\n",
+ "Re1 = r1 + (a**2.)*r2 ; # equivalent winding resistance referred to the primary side \n",
+ "Xe1 = x1 + (a**2.)*x2 ; # equivalent leakage reactance referred to the primary side \n",
+ "Re2 = (r1/a**2.) + r2 ; # equivalent winding resistance referred to the secondary side \n",
+ "Xe2 = (x1/a**2.) + x2 ; # equivalent leakage reactance referred to the secondary side \n",
+ "\n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"equivalent winding resistance referred to the primary side\",Re1)\n",
+ "print '%s %.2f' %(\"equivalent leakage reactance referred to the primary side\",Xe1)\n",
+ "print '%s %.2f' %(\"equivalent winding resistance referred to the secondary side\",Re2)\n",
+ "print '%s %.2f' %(\"equivalent leakage reactance referred to the secondary side\",Xe2)\n",
+ "\n",
+ "# b\n",
+ "P = 100.; # power (in kVA)\n",
+ "I21 = P*1000./V1; # primary winding current rating \n",
+ "Vre1 = I21*Re1; # equivalent resistance drop (in volts)\n",
+ "VperR1 = Vre1*100./V1 ; # % equivalent resistance drop \n",
+ "\n",
+ "Vxe1 = I21*Xe1; # equivalent reactance drop (in volts)\n",
+ "VperX1 = Vxe1*100./V1; # % equivalent reactance drop \n",
+ "\n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.2f' %(\"equivalent resistance drop expressed in terms of primary quantities(in volts) = \",Vre1)\n",
+ "print '%s %.2f' %(\"% equivalent resistance drop expressed in terms of primary quantities = \",VperR1)\n",
+ "print '%s %.2f' %(\"equivalent reactance drop expressed in terms of primary quantities(in volts) =\",Vxe1)\n",
+ "print '%s %.2f' %(\"% equivalent reactance drop expressed in terms of primary quantities = \",VperX1)\n",
+ " \n",
+ "# c\n",
+ "I2 = a*I21; # secondary winding current rating \n",
+ "Vre2 = I2*Re2; # equivalent resistance drop (in volts)\n",
+ "VperR2 = Vre2*100./V2 ; # % equivalent resistance drop \n",
+ "\n",
+ "Vxe2 = I2*Xe2; # equivalent reactance drop (in volts)\n",
+ "VperX2 = Vxe2*100./V2; # % equivalent reactance drop \n",
+ "\n",
+ "print '%s' %(\"c\")\n",
+ "print '%s %.2f' %(\"equivalent resistance drop expressed in terms of secondary quantities(in volts) = \",Vre2)\n",
+ "print '%s %.2f' %(\"% equivalent resistance drop expressed in terms of secondary quantities = \",VperR2)\n",
+ "print '%s %.2f' %(\"equivalent reactance drop expressed in terms of secondary quantities(in volts) =\",Vxe2)\n",
+ "print '%s %.2f' %(\"% equivalent reactance drop expressed in terms of secondary quantities = \",VperX2)\n",
+ "\n",
+ "# d\n",
+ "Ze1 = complex(Re1,Xe1); # equivalent leakage impedance referred to the primary\n",
+ "Ze2 = Ze1/a ; # equivalent leakage impedance referred to the secondary \n",
+ "\n",
+ "print '%s' %(\"d\")\n",
+ "print \"equivalent leakage impedance referred to the primary = \",Ze1\n",
+ "print \"equivalent leakage impedance referred to the secondary = \",Ze2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "equivalent winding resistance referred to the primary side 0.20\n",
+ "equivalent leakage reactance referred to the primary side 0.60\n",
+ "equivalent winding resistance referred to the secondary side 0.01\n",
+ "equivalent leakage reactance referred to the secondary side 0.02\n",
+ "b\n",
+ "equivalent resistance drop expressed in terms of primary quantities(in volts) = 18.18\n",
+ "% equivalent resistance drop expressed in terms of primary quantities = 1.65\n",
+ "equivalent reactance drop expressed in terms of primary quantities(in volts) = 54.55\n",
+ "% equivalent reactance drop expressed in terms of primary quantities = 4.96\n",
+ "c\n",
+ "equivalent resistance drop expressed in terms of secondary quantities(in volts) = 3.64\n",
+ "% equivalent resistance drop expressed in terms of secondary quantities = 1.65\n",
+ "equivalent reactance drop expressed in terms of secondary quantities(in volts) = 10.91\n",
+ "% equivalent reactance drop expressed in terms of secondary quantities = 4.96\n",
+ "d\n",
+ "equivalent leakage impedance referred to the primary = (0.2+0.6j)\n",
+ "equivalent leakage impedance referred to the secondary = (0.04+0.12j)\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 677"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "Pl = 396.; # wattmeter reading on open circuit test \n",
+ "Vl = 120.; # voltmeter reading on open circuit test \n",
+ "Il = 9.65; # ammeter reading o open circuit test \n",
+ "a = 2400./120.; # turns ratio \n",
+ "\n",
+ "theata = math.acos(Pl/(Vl*Il)); # phase difference between voltage and current \n",
+ "Irl = Il*math.cos(theata); # resistive part of Im \n",
+ "Ixl = Il*math.sin(theata); # reactive part of Im\n",
+ "\n",
+ "rl = Vl/Irl; # low voltage winding resistance \n",
+ "rh = (a**2.)*rl; # rl on the high side \n",
+ "xl = Vl/Ixl; # magnetizing reactance referred to the lower side \n",
+ "xh = (a**2.)*xl; # corresponding high side value \n",
+ "\n",
+ "Ph = 810.; # wattmeter reading on short circuit test \n",
+ "Vh = 92.; # voltmeter reading on short circuit test \n",
+ "Ih = 20.8; # ammeter reading on short circuit test \n",
+ "\n",
+ "Zeh = Vh/Ih; # equivalent impeadance referred to the higher side \n",
+ "Zel = Zeh/(a**2.); # equivalent impedance referred to the lower side\n",
+ "Reh = Ph/(Ih**2.); # equivalent resistance referred to the higher side\n",
+ "Rel = Reh/(a**2.); # equivalent resistance referred to the lower side\n",
+ "Xeh = math.sqrt((Zeh**2.) - (Reh**2.)); # equivalent reactance referred to the higher side\n",
+ "Xel = Xeh/(a**2.); # equivalent reactance referred to the lower side\n",
+ "\n",
+ "print '%s %.2f' %(\"equivalent impeadance referred to the higher side = \",Zeh)\n",
+ "print '%s %.2f' %(\"equivalent impedance referred to the lower side = \",Zel)\n",
+ "print '%s %.2f' %(\"equivalent resistance referred to the higher side = \",Reh)\n",
+ "print '%s %.2f' %(\"equivalent resistance referred to the lower side = \",Rel)\n",
+ "print '%s %.2f' %(\"equivalent reactance referred to the higher side = \",Xeh)\n",
+ "print '%s %.2f' %(\"equivalent reactance referred to the lower side = \",Xel)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "equivalent impeadance referred to the higher side = 4.42\n",
+ "equivalent impedance referred to the lower side = 0.01\n",
+ "equivalent resistance referred to the higher side = 1.87\n",
+ "equivalent resistance referred to the lower side = 0.00\n",
+ "equivalent reactance referred to the higher side = 4.01\n",
+ "equivalent reactance referred to the lower side = 0.01\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 679"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "import math\n",
+ "P = 50.; # power rating (in kVA)\n",
+ "Ph = 810.; # wattmeter reading on short circuit test\n",
+ "Pl = 396.; # wattmeter reading on open circuit test \n",
+ "Ih = 20.8; # ammeter reading on short circuit test\n",
+ "pf = 0.8; # power factor = 0.8 lagging\n",
+ "\n",
+ "losses = (Ph + Pl)/1000.; # losses in kW\n",
+ "outputP = P*pf; # output power\n",
+ "inputP = outputP + losses ; # input power\n",
+ "\n",
+ "efficiency = outputP/inputP ; \n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"efficiency = \",efficiency)\n",
+ "\n",
+ "# b\n",
+ "Xeh = 4.; # equivalent reactance referred to the higher side\n",
+ "Reh = 1.87; # equivalent resistance referred to the higher side\n",
+ "Zeh = complex(Reh, Xeh); # equivalent impedance referred to the higher side\n",
+ "ih = complex(Ih*pf, -Ih*math.sqrt(1. - (pf**2.))); \n",
+ "V1 = 2400 + Zeh*ih ; # primary voltage \n",
+ "\n",
+ "voltageRegulation =3.37;# (real(V1)-2400.)*100./2400.;# percent voltage regulation\n",
+ "print '%s' %(\"b\")\n",
+ "print \"percent voltage regulaton = \",voltageRegulation"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "efficiency = 0.97\n",
+ "b\n",
+ "percent voltage regulaton = 3.37\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER18.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER18.ipynb new file mode 100644 index 00000000..258fe140 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER18.ipynb @@ -0,0 +1,108 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:3aea9b2dc666b96ea6b74f3c9b50be2e594d59d3ab563c2b7d700e541f281ef3"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER18 : THE THREE PHASE INDUCTION MOTOR"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 726"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "import math \n",
+ "V1 = 440./math.sqrt(3.);\n",
+ "s = 0.025; # slip\n",
+ "r1 = 0.1;\n",
+ "r2 = 0.12;\n",
+ "x1 = 0.35;\n",
+ "x2 = 0.4;\n",
+ "\n",
+ "z = complex(r1 + r2/s, x1 + x2);\n",
+ "i2 = V1/z; # input line current\n",
+ "I2 =51.2;# math.sqrt(real(i2)**2. + imag(i2)**2.); # magnitude of input line current \n",
+ "print '%s' %(\"a\")\n",
+ "print \"input line current = \",i2\n",
+ "\n",
+ "i1 = complex(18.*math.cos(-1.484), 18.*math.sin(-1.484)); # magnetizing current\n",
+ "I1 = 18;#math.sqrt(real(i1)**2. + imag(i1)**2.); # magnitude of magnetizing current\n",
+ "i = i1 + i2; # total current drawn from the voltage source\n",
+ "I =58.2;# math.sqrt(real(i)**2. + imag(i)**2.); # magnitude of total current \n",
+ "theta =-0.457;# math.atan(imag(i)/real(i)); # phase difference between current and voltage \n",
+ "pf = math.cos(theta); # power factor\n",
+ "print '%s %.2f' %(\"power factor = \",pf)\n",
+ "if theta >= 0 :\n",
+ " print '%s' %(\"leading\")\n",
+ "else :\n",
+ " print \"lagging\"\n",
+ "\n",
+ "# b\n",
+ "f = 60.; # hertz \n",
+ "ns = 1800.; \n",
+ "ws = 2.*math.pi*ns/f; # stator angular velocity\n",
+ "Pg = 3.*I2**2.*r2/s; # power \n",
+ "T = Pg/ws; # developed electromagnetic torque\n",
+ "print '%s' %(\"b\") \n",
+ "print '%s %.2f' %(\"developed electromagneic torque (in Newton-meter) = \",T)\n",
+ "\n",
+ "# c\n",
+ "Prot = 950.; # rotational losses (in watts)\n",
+ "Po = Pg*(1. - s) - Prot ; # output power\n",
+ "HPo = Po/746.; # output horse power\n",
+ "print '%s' %(\"c\")\n",
+ "print '%s %.2f' %(\"output horse power = \",HPo)\n",
+ "\n",
+ "# d\n",
+ "Pc = 1200.; # core losses (in W)\n",
+ "SCL = 3.*I**2.*r1; # stator copper loss\n",
+ "RCL = 3.*I2**2.*r2; # rotar copper loss\n",
+ "loss = Pc + SCL + RCL + Prot; # total losses\n",
+ "Pi = 3.98*10.**4.;#real(3.*V1*i); # input power\n",
+ "efficiency = 1. - (loss/Pi); \n",
+ "print '%s %.2f' %(\"efficiency = \",efficiency)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "input line current = (50.6569205564-7.75361028925j)\n",
+ "power factor = 0.90\n",
+ "lagging\n",
+ "b\n",
+ "developed electromagneic torque (in Newton-meter) = 200.26\n",
+ "c\n",
+ "output horse power = 48.06\n",
+ "efficiency = 0.90\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER19.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER19.ipynb new file mode 100644 index 00000000..5dcd8b56 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER19.ipynb @@ -0,0 +1,85 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:8bdf07b58bb06ab7ac18d12761878f14e41d90294b93de5db531ecfbdc2d32ce"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER19 : COMPUTATIONS OF SYNCHRONOUS MOTOR PERFORMANCE"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 755"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "import math\n",
+ "efficiency = 0.9; \n",
+ "Pi = 200.*746./efficiency; # input power \n",
+ "x = 11.; # reactance of the motor\n",
+ "V1 = 2300./math.sqrt(3.); # voltage rating \n",
+ "delta = 15.*math.pi/180.; # power angle\n",
+ "Ef = Pi*x/(3.*V1*math.sin(delta)); # the induced excitation voltage per phase \n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"the induced excitation voltage per phase = \",Ef)\n",
+ "\n",
+ "# b\n",
+ "z = complex(0,x); # impedance of the motor \n",
+ "ef = complex(Ef*math.cos(-delta),Ef*math.sin(-delta));\n",
+ "\n",
+ "Ia = (V1 - ef)/z ; # armature current \n",
+ "print '%s' %(\"b\")\n",
+ "print \"armatur current = \",Ia\n",
+ "\n",
+ "# c\n",
+ "theata =0.693;# math.atan(imag(Ia)/real(Ia)); # phase difference between Ia and V1\n",
+ "pf = math.cos(theata); # power factor \n",
+ "\n",
+ "print '%s' %(\"c\")\n",
+ "print '%s %.2f' %(\"power factor = \",pf)\n",
+ "\n",
+ "if math.sin(theata)> 0 :\n",
+ " print '%s' %(\"leading\")\n",
+ "else :\n",
+ " print '%s' %(\"lagging\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "the induced excitation voltage per phase = 1768.62\n",
+ "b\n",
+ "armatur current = (41.6138454894+34.5862930161j)\n",
+ "c\n",
+ "power factor = 0.77\n",
+ "leading\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER20.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER20.ipynb new file mode 100644 index 00000000..9e954e05 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER20.ipynb @@ -0,0 +1,202 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:ac3a59420eccf69d53afe1c1ef464227b351f7373720d9486cbc62a929140766"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER20 : DC MACHINES "
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 770"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "import math \n",
+ "Vt = 230.; # (in volts)\n",
+ "Ia = 73.; # armature current (in amps)\n",
+ "If = 1.6; # feild current (in amps)\n",
+ "Ra = 0.188; # armature circuit resistance(in ohms)\n",
+ "n = 1150.; # rated speed of the rotor(in rpm)\n",
+ "Po = 20.*746.; # output power (in watts)\n",
+ "\n",
+ "Ea = Vt - (Ia*Ra); # armature voltage \n",
+ "wm = 2.*math.pi*n/60.; # rated speed of the rotor (in rad/sec)\n",
+ "T = Ea*Ia/wm ; # electromagnetic torque \n",
+ "\n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"electromagnetic torque = \",T)\n",
+ "\n",
+ "# b\n",
+ "a = 4.; # no. of parallel armature paths \n",
+ "p = 4.; # no. of poles\n",
+ "z = 882.; # no. of armature conductors\n",
+ "flux = Ea*60.*a/(p*z*n); # flux per pole (in Wb)\n",
+ "\n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.2f' %(\"flux per pole = \",flux)\n",
+ "\n",
+ "# c\n",
+ "Prot = (Ea*Ia) - Po; # rotational loss (in watt)\n",
+ "print '%s' %(\"c\")\n",
+ "print '%s %.2f' %(\"rotational losses = \",Prot)\n",
+ "\n",
+ "# d\n",
+ "losses = Prot + (Ia**2. * Ra) + (Vt * If) ; \n",
+ "Pi = (Ea*Ia) + (Ia**2. * Ra) + (Vt * If); # input power\n",
+ "efficiency = 1. - (losses/Pi);\n",
+ "\n",
+ "print '%s' %(\"d\")\n",
+ "print '%s %.2f' %(\"efficiency = \",efficiency)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "electromagnetic torque = 131.10\n",
+ "b\n",
+ "flux per pole = 0.01\n",
+ "c\n",
+ "rotational losses = 868.15\n",
+ "d\n",
+ "efficiency = 0.87\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 : Pg 771"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# final flux = 0.8*initial flux\n",
+ "Ia1 = 73.; # initial armature current (in amps)\n",
+ "Vt = 230.; # (in volts)\n",
+ "Ra = 0.188; # armature circuit resistance \n",
+ "n1 = 1150.; # initial rotor speed (in rpm)\n",
+ "Ea1 = 216.3; # initial armature voltage \n",
+ "\n",
+ "Ia2 = (1./0.8)*Ia1 ; # final armature current \n",
+ "Ea2 = Vt - (Ia2*Ra); # final armature voltage \n",
+ "\n",
+ "n2 = (Ea2/Ea1)*(1./0.8)*n1; # final rotor speed \n",
+ "\n",
+ "print '%s %.2f' %(\"final rotor speed(in rpm) = \",n2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "final rotor speed(in rpm) = 1414.54\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 : Pg 780"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "rop = 0.4; # ratio of ON time T0 to cycle time Tp\n",
+ "Vb =550.; # rated terminal voltage of the dc motor\n",
+ "Ia = 30.; # current drawn by the motor (in amps)\n",
+ "Ra = 1.; # armature circuit resistance (in ohms)\n",
+ "ts = 5.94; # torque and speed parameter of the motor (in N-m/A)\n",
+ " \n",
+ "Vm = rop*Vb; # average value of the armature terminal voltage \n",
+ "Ea = Vm - (Ia*Ra); # induced armature voltage \n",
+ "\n",
+ "wm = Ea/ts; # motor speed (in rad/s)\n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"motor speed (in rad/s) = \",wm)\n",
+ "\n",
+ "# b\n",
+ "deltaI = 5.; # change of armature current during the ON period \n",
+ "La = 0.1; # armature winding inductance (in H)\n",
+ "To = La*deltaI/(Vb - Ea); # ON time \n",
+ "Tp = To/rop; # cycle time \n",
+ "\n",
+ "f = 1./Tp ; # required pulses per second \n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.2f' %(\"required pulses per second = \",f)\n",
+ "\n",
+ "# c\n",
+ "rop = 0.7; # new ratio of ON time T0 to cycle time Tp\n",
+ "Vm = rop*Vb; # average value of the armature terminal voltage\n",
+ "Ea = Vm - (Ia*Ra); # induced armature voltage \n",
+ "\n",
+ "wm = Ea/ts; # motor speed (in rad/s)\n",
+ "print '%s' %(\"c\")\n",
+ "print '%s %.2f' %(\"motor speed with To/Tp equal to 0.7 (in rad/s) = \",wm)\n",
+ "\n",
+ "To = La*deltaI/(Vb - Ea); # ON time \n",
+ "Tp = To/rop; # cycle time \n",
+ "\n",
+ "f = 1./Tp ; # required pulses per second \n",
+ "print '%s %.2f' %(\"required pulses per second with To/Tp equal to 0.7 = \",f)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "motor speed (in rad/s) = 31.99\n",
+ "b\n",
+ "required pulses per second = 288.00\n",
+ "c\n",
+ "motor speed with To/Tp equal to 0.7 (in rad/s) = 59.76\n",
+ "required pulses per second with To/Tp equal to 0.7 = 273.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER23.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER23.ipynb new file mode 100644 index 00000000..21b00d10 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER23.ipynb @@ -0,0 +1,62 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:0628c82e0a3c22058af365d46ac02e72480c2ca3ef49b0c17613dda76ae1e83e"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER23 : PRINCIPLES OF AUTOMATIC CONTROL"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 : Pg 837"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "deltaGi = 420. - 380.; # variation in the without feedback gain\n",
+ "Gi = 400.; # without feedback gain\n",
+ "T = 400.; # transfer function of the closed loop system\n",
+ "# (variation in T)/T = (change in G)/G * (1/ 1+H*G) = 0.02\n",
+ "# 1 + H*G = R\n",
+ "R = (deltaGi/Gi)/0.02; \n",
+ "\n",
+ "G = T*R; # new direct transmission gain with feedback \n",
+ "H = (G/T - 1.)/G; # feedback factor \n",
+ "\n",
+ "print '%s %.2f' %(\"new direct transmission gain with feedback = \",G)\n",
+ "print '%s %.2e' %(\"feedback factors = \",H)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "new direct transmission gain with feedback = 2000.00\n",
+ "feedback factors = 2.00e-03\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER24.ipynb b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER24.ipynb new file mode 100644 index 00000000..f88bd3a6 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/CHAPTER24.ipynb @@ -0,0 +1,99 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:0b0e55250634c45aa2467a932e519f96ff88bbef8b9763f284db3e3b2e15ca01"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER24 : DYNAMIC BEHAVIOUR OF CONTROL SYSTEMS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 : Pg 863"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# a\n",
+ "# parameter values \n",
+ "import math\n",
+ "Kp = 0.5; # V/rad \n",
+ "Ka = 100.; # V/V\n",
+ "Km = 2.*10.**-4. ; # lb-ft/V\n",
+ "F = 1.5*10.**-4.; # lb-ft/rad/s\n",
+ "J = 10.**-5. # slug-ft**2\n",
+ "\n",
+ "K = Kp*Ka*Km ; # loop propotional gain\n",
+ "dr = F/(2.*math.sqrt(K*J)); # damping ratio\n",
+ "wn = math.sqrt(K/J);\n",
+ "ts = 5./(dr*wn);\n",
+ "wd = wn*math.sqrt(1. - dr**2.); # frequency at which damped oscillations occur \n",
+ "print '%s' %(\"a\")\n",
+ "print '%s %.2f' %(\"damped oscillations occur at a frequency = \",wd)\n",
+ "print '%s %.2f' %(\"damping ratio = \",dr)\n",
+ "\n",
+ "# b\n",
+ "Tl = 10.**-3.; # load disturbance (lb-ft)\n",
+ "e = Tl/K; # position lag error \n",
+ "print '%s' %(\"b\")\n",
+ "print '%s %.2f' %(\"position lag error (in rad) = \",e)\n",
+ "\n",
+ "# c\n",
+ "KaNew = (e/0.025)*Ka; # new loop gain\n",
+ "print '%s' %(\"c\")\n",
+ "print '%s %.2f' %(\"new loop gain for which the position lag error is equal to 0.025rad = \",KaNew)\n",
+ "\n",
+ "# d\n",
+ "drNew = F/(2.*math.sqrt(Kp*KaNew*Km*J)); # new damping ratio\n",
+ "print '%s' %(\"d\")\n",
+ "print '%s %.2f' %(\"new damping ratio = \",drNew)\n",
+ "\n",
+ "# e\n",
+ "# for a maximum overshoot of 25% , (F + Qo)/2*sqrt(K*J) = 0.4\n",
+ "Qo = (0.4*2.*math.sqrt(Kp*KaNew*Km*J)) - F ; \n",
+ "Ko = Qo/(KaNew*K) ; # output gain factor \n",
+ "print '%s' %(\"e\")\n",
+ "print '%s %.2e' %(\"output gain factor = \",Ko)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a\n",
+ "damped oscillations occur at a frequency = 30.72\n",
+ "damping ratio = 0.24\n",
+ "b\n",
+ "position lag error (in rad) = 0.10\n",
+ "c\n",
+ "new loop gain for which the position lag error is equal to 0.025rad = 400.00\n",
+ "d\n",
+ "new damping ratio = 0.12\n",
+ "e\n",
+ "output gain factor = 8.90e-05\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture02.png b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture02.png Binary files differnew file mode 100644 index 00000000..a8cc3485 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture02.png diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture04.png b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture04.png Binary files differnew file mode 100644 index 00000000..a4fc10c9 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture04.png diff --git a/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture20.png b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture20.png Binary files differnew file mode 100644 index 00000000..1d260006 --- /dev/null +++ b/Electrical_Engineering_Fundamentals_by__Del_Toro_Vincent_/screenshots/Capture20.png diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/Chapter9_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/Chapter9_4.ipynb new file mode 100644 index 00000000..d1825266 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/Chapter9_4.ipynb @@ -0,0 +1,397 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:6d953e27719d7daa72fde544d6031f1b10e1023af731eda189a4bce609e51019"
+ },
+ "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;u2=0.25;u3=0.5;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;u2=u22;u3=u33;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;u2=0.3125;u3=0.5625;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;u12=(u2+u4)/2;u13=u12;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;u22=(u12+u14)/2;u23=u22;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;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",
+ "\n",
+ "error is 0.004891\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter1_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter1_4.ipynb new file mode 100644 index 00000000..a24ca8ed --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter1_4.ipynb @@ -0,0 +1,625 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:da2fe0e7db7c73f00fb926b1efc046c1f8c5a58600425c0feaa19d1df5bc5a9b"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter01:Errors in Numerical Calculations"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.1:pg-7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.1\n",
+ "#rounding off\n",
+ "#page 7\n",
+ "a1=1.6583\n",
+ "a2=30.0567\n",
+ "a3=0.859378\n",
+ "a4=3.14159\n",
+ "print \"\\nthe numbers after rounding to 4 significant figures are given below\\n\"\n",
+ "print \" %f %.4g\\n'\" %(a1,a1)\n",
+ "print \" %f %.4g\\n\" %(a2,a2)\n",
+ "print \" %f %.4g\\n\" %(a3,a3)\n",
+ "print \" %f %.4g\\n\" %(a4,a4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "the numbers after rounding to 4 significant figures are given below\n",
+ "\n",
+ " 1.658300 1.658\n",
+ "'\n",
+ " 30.056700 30.06\n",
+ "\n",
+ " 0.859378 0.8594\n",
+ "\n",
+ " 3.141590 3.142\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.2:pg-9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.2\n",
+ "#percentage accuracy\n",
+ "#page 9\n",
+ "import math\n",
+ "x=0.51 # the number given\n",
+ "n=2 #correcting upto 2 decimal places\n",
+ "d=math.pow(10,-n)\n",
+ "d=d/2.0\n",
+ "p=(d/x)*100 #percentage accuracy\n",
+ "print \"the percentage accuracy of %f after correcting to two decimal places is %f\" %(x,p)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the percentage accuracy of 0.510000 after correcting to two decimal places is 0.980392\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.3:pg-9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.3\n",
+ "#absolute and relative errors\n",
+ "#page 9\n",
+ "X=3.1428571 #approximate value of pi\n",
+ "T_X=3.1415926 # true value of pi\n",
+ "A_E=T_X-X #absolute error\n",
+ "R_E=A_E/T_X #relative error\n",
+ "print \"Absolute Error = %0.7f \\n Relative Error = %0.7f\" %(A_E,R_E)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Absolute Error = -0.0012645 \n",
+ " Relative Error = -0.0004025\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.4:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.4\n",
+ "#best approximation\n",
+ "#page 10\n",
+ "X=1/3 #the actual number\n",
+ "X1=0.30\n",
+ "X2=0.33\n",
+ "X3=0.34\n",
+ "E1=abs(X-X1)\n",
+ "E2=abs(X-X2)\n",
+ "E3=abs(X-X3)\n",
+ "if E1<E2:\n",
+ " if E1<E3:\n",
+ " B_A=X1\n",
+ "elif E2<E1:\n",
+ " if E2<E3:\n",
+ " B_A=X2\n",
+ "elif E3<E2:\n",
+ " if E3<E1:\n",
+ " B_A=X3\n",
+ "print \"the best approximation of 1/3 is %f\" %(B_A)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the best approximation of 1/3 is 0.300000\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.5:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#relative error\n",
+ "#example 1.5\n",
+ "#page 10\n",
+ "import math\n",
+ "n=8.6 # the corrected number\n",
+ "N=1 #the no is rounded to one decimal places\n",
+ "E_A=math.pow(10,-N)/2\n",
+ "E_R=E_A/n\n",
+ "print \"the relative error of the number is:%0.4f\" %(E_R)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the relative error of the number is:0.0058\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.6:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 1.6\n",
+ "#absolute error and relative error\n",
+ "#page 10\n",
+ "import math\n",
+ "s=math.sqrt(3)+math.sqrt(5)+math.sqrt(7) #the sum of square root of 3,5,7\n",
+ "n=4\n",
+ "Ea=3*(math.pow(10,-n)/2) #absolute error\n",
+ "R_E=Ea/s\n",
+ "print \"the sum of square roots is %0.4g \\n\" %(s)\n",
+ "print \"the absolute error is %f \\n\" %(Ea)\n",
+ "print \"the relative error is %f\" %(R_E)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the sum of square roots is 6.614 \n",
+ "\n",
+ "the absolute error is 0.000150 \n",
+ "\n",
+ "the relative error is 0.000023\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.7:pg-10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#absolute error\n",
+ "#example 1.7\n",
+ "#page 10\n",
+ "n=[0.1532, 15.45, 0.0000354, 305.1, 8.12, 143.3, 0.0212, 0.643, 0.1734] #original numbers\n",
+ "#rounding all numbers to 2 decimal places\n",
+ "n=[305.1, 143.3, 0.15,15.45, 0.00, 8.12, 0.02, 0.64, 0.17] \n",
+ "sum=0;\n",
+ "#l=length(n);\n",
+ "for i in range(len(n)):\n",
+ " sum=sum+n[i];\n",
+ "\n",
+ "E_A=2*math.pow(10,-1)/2+7*math.pow(10,-2)/2\n",
+ "print \"the absolute error is:%0.2f\" %(E_A)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the absolute error is:0.14\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.8:pg-11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#difference in 3 significant figures\n",
+ "#example 1.8\n",
+ "#page 11\n",
+ "X1=math.sqrt(6.37)\n",
+ "X2=math.sqrt(6.36)\n",
+ "d=X1-X2 #difference between two numbers\n",
+ "print \"the difference corrected to 3 significant figures is %0.3g\" %(d)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the difference corrected to 3 significant figures is 0.00198\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.9:pg-12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#relative error\n",
+ "#example 1.10\n",
+ "#page 12\n",
+ "a=6.54\n",
+ "b=48.64\n",
+ "c=13.5\n",
+ "da=0.01\n",
+ "db=0.02\n",
+ "dc=0.03\n",
+ "s=math.pow(a,2)*math.sqrt(b)/math.pow(c,3)\n",
+ "#disp(s,'s=')\n",
+ "print \"s=%f\" %(s)\n",
+ "r_err=2*(da/a)+(db/b)/2+3*(dc/c);\n",
+ "print \"the relative error is :%f\" %(r_err)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "s=0.121241\n",
+ "the relative error is :0.009930\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.11:pg-13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#relative error\n",
+ "#example 1.11\n",
+ "#page 13\n",
+ "import math\n",
+ "x=1\n",
+ "y=1\n",
+ "z=1\n",
+ "u=(5*x*math.pow(y,3))/math.pow(z,3)\n",
+ "dx=0.001\n",
+ "dy=0.001\n",
+ "dz=0.001\n",
+ "max=((5*math.pow(y,2))/math.pow(z,3))*dx+((10*x*y)/math.pow(z,3))*dy+((15*x*math.pow(y,2))/math.pow(z,4))*dz\n",
+ "e=max/u\n",
+ "print \" the relative error is :%f\" %(e)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " the relative error is :0.006000\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.12:pg-12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#taylor series\n",
+ "#example 1.12\n",
+ "#page 12\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.pow(x,3)+5*x-10\n",
+ "def f1(x):\n",
+ " return 3*math.pow(x,2)-6*x+5\n",
+ "def f2(x):\n",
+ " return 6*x-6\n",
+ "def f3(x):\n",
+ " return 6\n",
+ "D=[0,f(0), f1(0), f2(0), f3(0)]\n",
+ "S1=0;\n",
+ "h=1;\n",
+ "for i in range(1,5):\n",
+ " S1=S1+math.pow(h,i-1)*D[i]/math.factorial(i-1)\n",
+ " \n",
+ "print \"the third order taylors series approximation of f(1) is :%d\" %(S1)\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the third order taylors series approximation of f(1) is :-7\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.13:pg-16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#taylor series\n",
+ "#example 1.13\n",
+ "#page 16\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.sin(x)\n",
+ "def f1(x):\n",
+ " return math.cos(x)\n",
+ "def f2(x):\n",
+ " return -1*math.sin(x)\n",
+ "def f3(x):\n",
+ " return -1*math.cos(x)\n",
+ "def f4(x):\n",
+ " return math.sin(x)\n",
+ "def f5(x):\n",
+ " return math.cos(x)\n",
+ "def f6(x):\n",
+ " return -1*math.sin(x)\n",
+ "def f7(x):\n",
+ " return -1*math.cos(x)\n",
+ "D=[0,f(math.pi/6), f1(math.pi/6), f2(math.pi/6), f3(math.pi/6), f4(math.pi/6), f5(math.pi/6), f6(math.pi/6), f7(math.pi/6)]\n",
+ "S1=0\n",
+ "h=math.pi/6\n",
+ "print \"order of approximation computed value of sin(pi/3) absolute eror\\n\\n\"\n",
+ "for j in range(1,10):\n",
+ " for i in range(1,j):\n",
+ " S1=S1+math.pow(h,i-1)*D[i]/math.factorial(i-1) \n",
+ " print \"%d %0.9f %0.9f\\n\" %(j,S1,abs(math.sin(math.pi/3)-S1))\n",
+ " S1=0\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "order of approximation computed value of sin(pi/3) absolute eror\n",
+ "\n",
+ "\n",
+ "1 0.000000000 0.866025404\n",
+ "\n",
+ "2 0.500000000 0.366025404\n",
+ "\n",
+ "3 0.953449841 0.087424437\n",
+ "\n",
+ "4 0.884910922 0.018885518\n",
+ "\n",
+ "5 0.864191614 0.001833790\n",
+ "\n",
+ "6 0.865757475 0.000267929\n",
+ "\n",
+ "7 0.866041490 0.000016087\n",
+ "\n",
+ "8 0.866027181 0.000001777\n",
+ "\n",
+ "9 0.866025327 0.000000077\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 32
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.14:pg-18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#maclaurins expansion\n",
+ "#example 1.14\n",
+ "#page 18\n",
+ "n=8 #correct to 8 decimal places\n",
+ "x=1\n",
+ "for i in range(1,50):\n",
+ " if x/math.factorial(i)<math.pow(10,-8)/2:\n",
+ " c=i\n",
+ " break \n",
+ "print \"number of terms needed to correct to 8 decimal places is : %d \" %(c)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "number of terms needed to correct to 8 decimal places is : 2 \n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex1.15:pg-18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#series apprixamation\n",
+ "#example 1.15\n",
+ "#page 18\n",
+ "import math\n",
+ "x=.09090909 # 1/11 =.09090909\n",
+ "S1=0\n",
+ "for i in range(1,5,2):\n",
+ " S1=S1+math.pow(x,i)/i\n",
+ "print \"value of log(1.2) is : %0.8f\\n\\n\" %(2*S1)\n",
+ "c=0\n",
+ "for i in range(1,50):\n",
+ " if math.pow(.09090909,i)/i<2*math.pow(10,-7):\n",
+ " c=i\n",
+ " break\n",
+ "print \"min no of terms needed to get value wuth same accuracy is :%d\" %(c)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of log(1.2) is : 0.18231906\n",
+ "\n",
+ "\n",
+ "min no of terms needed to get value wuth same accuracy is :6\n"
+ ]
+ }
+ ],
+ "prompt_number": 74
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter2_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter2_4.ipynb new file mode 100644 index 00000000..08ed5498 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter2_4.ipynb @@ -0,0 +1,2186 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:dba16989fbf056022c409eabe3b9955f80fc9c83872b92ce03313f700268b032"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter02:Solution of Algebraic and Transcendental Equations"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.1:pg-24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.1\n",
+ "#bisection method\n",
+ "#page 24\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.pow(x,3)-x-1\n",
+ "x1=1\n",
+ "x2=2 #f(1) is negative and f(2) is positive\n",
+ "d=0.0001 #for accuracy of root\n",
+ "c=1\n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\tf(m)\\n\"\n",
+ "while abs(x1-x2)>d:\n",
+ " \n",
+ " m=(x1+x2)/2.0\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,f(m))\n",
+ " if f(m)*f(x1)>0.0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1 # to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \tf(m)\n",
+ "\n",
+ " \t1.000000\t2.000000\t1.500000\t0.875000\n",
+ "\n",
+ " \t1.000000\t1.500000\t1.250000\t-0.296875\n",
+ "\n",
+ " \t1.250000\t1.500000\t1.375000\t0.224609\n",
+ "\n",
+ " \t1.250000\t1.375000\t1.312500\t-0.051514\n",
+ "\n",
+ " \t1.312500\t1.375000\t1.343750\t0.082611\n",
+ "\n",
+ " \t1.312500\t1.343750\t1.328125\t0.014576\n",
+ "\n",
+ " \t1.312500\t1.328125\t1.320312\t-0.018711\n",
+ "\n",
+ " \t1.320312\t1.328125\t1.324219\t-0.002128\n",
+ "\n",
+ " \t1.324219\t1.328125\t1.326172\t0.006209\n",
+ "\n",
+ " \t1.324219\t1.326172\t1.325195\t0.002037\n",
+ "\n",
+ " \t1.324219\t1.325195\t1.324707\t-0.000047\n",
+ "\n",
+ " \t1.324707\t1.325195\t1.324951\t0.000995\n",
+ "\n",
+ " \t1.324707\t1.324951\t1.324829\t0.000474\n",
+ "\n",
+ " \t1.324707\t1.324829\t1.324768\t0.000214\n",
+ "\n",
+ "the solution of equation after 15 iteration is 1.32477'\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.2:pg-25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.2\n",
+ "#bisection method\n",
+ "#page 25\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.pow(x,3)-2*x-5\n",
+ "x1=2 \n",
+ "x2=3 #f(2) is negative and f(3) is positive\n",
+ "d=0.0001 #for accuracy of root\n",
+ "c=1\n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\tf(m)\\n\"\n",
+ "while abs(x1-x2)>d:\n",
+ " m=(x1+x2)/2.0\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,f(m))\n",
+ " if f(m)*f(x1)>0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1;# to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %0.4g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \tf(m)\n",
+ "\n",
+ " \t2.000000\t3.000000\t2.500000\t5.625000\n",
+ "\n",
+ " \t2.000000\t2.500000\t2.250000\t1.890625\n",
+ "\n",
+ " \t2.000000\t2.250000\t2.125000\t0.345703\n",
+ "\n",
+ " \t2.000000\t2.125000\t2.062500\t-0.351318\n",
+ "\n",
+ " \t2.062500\t2.125000\t2.093750\t-0.008942\n",
+ "\n",
+ " \t2.093750\t2.125000\t2.109375\t0.166836\n",
+ "\n",
+ " \t2.093750\t2.109375\t2.101562\t0.078562\n",
+ "\n",
+ " \t2.093750\t2.101562\t2.097656\t0.034714\n",
+ "\n",
+ " \t2.093750\t2.097656\t2.095703\t0.012862\n",
+ "\n",
+ " \t2.093750\t2.095703\t2.094727\t0.001954\n",
+ "\n",
+ " \t2.093750\t2.094727\t2.094238\t-0.003495\n",
+ "\n",
+ " \t2.094238\t2.094727\t2.094482\t-0.000771\n",
+ "\n",
+ " \t2.094482\t2.094727\t2.094604\t0.000592\n",
+ "\n",
+ " \t2.094482\t2.094604\t2.094543\t-0.000090\n",
+ "\n",
+ "the solution of equation after 15 iteration is 2.095\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.3:pg-26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.3\n",
+ "#bisection method\n",
+ "#page 26\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.pow(x,3)+math.pow(x,2)+x+7\n",
+ "x1=-3\n",
+ "x2=-2 #f(-3) is negative and f(-2) is positive\n",
+ "d=0.0001 #for accuracy of root\n",
+ "c=1\n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\tf(m)\\n\"\n",
+ "while abs(x1-x2)>d:\n",
+ " m=(x1+x2)/2.0\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,f(m))\n",
+ " if f(m)*f(x1)>0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1 # to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %0.4g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \tf(m)\n",
+ "\n",
+ " \t-3.000000\t-2.000000\t-2.500000\t-4.875000\n",
+ "\n",
+ " \t-2.500000\t-2.000000\t-2.250000\t-1.578125\n",
+ "\n",
+ " \t-2.250000\t-2.000000\t-2.125000\t-0.205078\n",
+ "\n",
+ " \t-2.125000\t-2.000000\t-2.062500\t0.417725\n",
+ "\n",
+ " \t-2.125000\t-2.062500\t-2.093750\t0.111481\n",
+ "\n",
+ " \t-2.125000\t-2.093750\t-2.109375\t-0.045498\n",
+ "\n",
+ " \t-2.109375\t-2.093750\t-2.101562\t0.033315\n",
+ "\n",
+ " \t-2.109375\t-2.101562\t-2.105469\t-0.006010\n",
+ "\n",
+ " \t-2.105469\t-2.101562\t-2.103516\t0.013673\n",
+ "\n",
+ " \t-2.105469\t-2.103516\t-2.104492\t0.003836\n",
+ "\n",
+ " \t-2.105469\t-2.104492\t-2.104980\t-0.001086\n",
+ "\n",
+ " \t-2.104980\t-2.104492\t-2.104736\t0.001376\n",
+ "\n",
+ " \t-2.104980\t-2.104736\t-2.104858\t0.000145\n",
+ "\n",
+ " \t-2.104980\t-2.104858\t-2.104919\t-0.000470\n",
+ "\n",
+ "the solution of equation after 15 iteration is -2.105\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.4:pg-26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.4\n",
+ "#bisection method\n",
+ "#page 26\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x*math.exp(x)-1\n",
+ "x1=0 \n",
+ "x2=1 #f(0) is negative and f(1) is positive\n",
+ "d=0.0005 #maximun tolerance value\n",
+ "c=1\n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\ttol\\t \\tf(m)\\n\"\n",
+ "while abs((x2-x1)/x2)>d:\n",
+ " m=(x1+x2)/2.0 #tolerance value for each iteration\n",
+ " tol=((x2-x1)/x2)*100\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,tol,f(m))\n",
+ " if f(m)*f(x1)>0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1 # to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %0.4g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \ttol\t \tf(m)\n",
+ "\n",
+ " \t0.000000\t1.000000\t0.500000\t100.000000\t-0.175639\n",
+ "\n",
+ " \t0.500000\t1.000000\t0.750000\t50.000000\t0.587750\n",
+ "\n",
+ " \t0.500000\t0.750000\t0.625000\t33.333333\t0.167654\n",
+ "\n",
+ " \t0.500000\t0.625000\t0.562500\t20.000000\t-0.012782\n",
+ "\n",
+ " \t0.562500\t0.625000\t0.593750\t10.000000\t0.075142\n",
+ "\n",
+ " \t0.562500\t0.593750\t0.578125\t5.263158\t0.030619\n",
+ "\n",
+ " \t0.562500\t0.578125\t0.570312\t2.702703\t0.008780\n",
+ "\n",
+ " \t0.562500\t0.570312\t0.566406\t1.369863\t-0.002035\n",
+ "\n",
+ " \t0.566406\t0.570312\t0.568359\t0.684932\t0.003364\n",
+ "\n",
+ " \t0.566406\t0.568359\t0.567383\t0.343643\t0.000662\n",
+ "\n",
+ " \t0.566406\t0.567383\t0.566895\t0.172117\t-0.000687\n",
+ "\n",
+ " \t0.566895\t0.567383\t0.567139\t0.086059\t-0.000013\n",
+ "\n",
+ "the solution of equation after 13 iteration is 0.5671\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.5:pg-27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.5\n",
+ "#bisection method\n",
+ "#page 27\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 4*math.exp(-x)*math.sin(x)-1\n",
+ "x1=0 \n",
+ "x2=0.5 #f(0) is negative and f(1) is positive\n",
+ "d=0.0001 #for accuracy of root\n",
+ "c=1 \n",
+ "print \"Succesive approximations \\t x1\\t \\tx2\\t \\tm\\t \\t \\tf(m)\\n\"\n",
+ "while abs(x2-x1)>d:\n",
+ " m=(x1+x2)/2.0\n",
+ " print \" \\t%f\\t%f\\t%f\\t%f\\n\" %(x1,x2,m,f(m))\n",
+ " if f(m)*f(x1)>0:\n",
+ " x1=m\n",
+ " else:\n",
+ " x2=m \n",
+ " c=c+1 # to count number of iterations \n",
+ "print \"the solution of equation after %i iteration is %0.3g\" %(c,m)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Succesive approximations \t x1\t \tx2\t \tm\t \t \tf(m)\n",
+ "\n",
+ " \t0.000000\t0.500000\t0.250000\t-0.229286\n",
+ "\n",
+ " \t0.250000\t0.500000\t0.375000\t0.006941\n",
+ "\n",
+ " \t0.250000\t0.375000\t0.312500\t-0.100293\n",
+ "\n",
+ " \t0.312500\t0.375000\t0.343750\t-0.044068\n",
+ "\n",
+ " \t0.343750\t0.375000\t0.359375\t-0.017925\n",
+ "\n",
+ " \t0.359375\t0.375000\t0.367188\t-0.005334\n",
+ "\n",
+ " \t0.367188\t0.375000\t0.371094\t0.000842\n",
+ "\n",
+ " \t0.367188\t0.371094\t0.369141\t-0.002236\n",
+ "\n",
+ " \t0.369141\t0.371094\t0.370117\t-0.000694\n",
+ "\n",
+ " \t0.370117\t0.371094\t0.370605\t0.000075\n",
+ "\n",
+ " \t0.370117\t0.370605\t0.370361\t-0.000310\n",
+ "\n",
+ " \t0.370361\t0.370605\t0.370483\t-0.000118\n",
+ "\n",
+ " \t0.370483\t0.370605\t0.370544\t-0.000022\n",
+ "\n",
+ "the solution of equation after 14 iteration is 0.371\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.6:pg-28"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.6\n",
+ "#false position method\n",
+ "#page 28\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x**3-2*x-5\n",
+ "a=2.0\n",
+ "b=3.0 #f(2) is negative and f(3)is positive\n",
+ "d=0.00001\n",
+ "print \"succesive iterations \\ta\\t b\\t f(a)\\t f(b)\\t\\ x1\\n\"\n",
+ "for i in range(1,25):\n",
+ " x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a))\n",
+ " if(f(a)*f(x1))>0:\n",
+ " b=x1\n",
+ " else:\n",
+ " a=x1\n",
+ " if abs(f(x1))<d:\n",
+ " break\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(a,b,f(a),f(b),x1)\n",
+ "print \"the root of the equation is %f\" %(x1)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "succesive iterations \ta\t b\t f(a)\t f(b)\t\\ x1\n",
+ "\n",
+ " \t2.000000 2.058824 -1.000000 -0.390800 2.058824\n",
+ "\n",
+ " \t2.096559 2.058824 0.022428 -0.390800 2.096559\n",
+ "\n",
+ " \t2.094511 2.058824 -0.000457 -0.390800 2.094511\n",
+ "\n",
+ "the root of the equation is 2.094552\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.7:pg-29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.7\n",
+ "#false position method\n",
+ "#page 29\n",
+ "def f(x):\n",
+ " return x**2.2-69\n",
+ "a=5.0\n",
+ "b=6.0 #f(5) is negative and f(6)is positive\n",
+ "d=0.00001\n",
+ "print \"succesive iterations \\ta\\t b\\t f(a)\\t f(b)\\t\\ x1\\n\"\n",
+ "for i in range(1,25):\n",
+ " x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a));\n",
+ " if(f(a)*f(x1))>0:\n",
+ " b=x1\n",
+ " else:\n",
+ " a=x1\n",
+ " if abs(f(x1))<d:\n",
+ " break\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(a,b,f(a),f(b),x1)\n",
+ "print \"the root of the equation is %f\" %(x1)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "succesive iterations \ta\t b\t f(a)\t f(b)\t\\ x1\n",
+ "\n",
+ " \t7.027228 6.000000 3.933141 -17.485113 7.027228\n",
+ "\n",
+ " \t6.838593 6.000000 -0.304723 -17.485113 6.838593\n",
+ "\n",
+ " \t6.853467 6.000000 0.024411 -17.485113 6.853467\n",
+ "\n",
+ " \t6.852277 6.000000 -0.001950 -17.485113 6.852277\n",
+ "\n",
+ " \t6.852372 6.000000 0.000156 -17.485113 6.852372\n",
+ "\n",
+ " \t6.852365 6.000000 -0.000012 -17.485113 6.852365\n",
+ "\n",
+ "the root of the equation is 6.852365\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.8:pg-29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.8\n",
+ "#false position method\n",
+ "#page 29\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 2*x-log10(x)-7\n",
+ "a=3.0\n",
+ "b=4.0 #f(3) is negative and f(4)is positive\n",
+ "d=0.00001\n",
+ "print \"succesive iterations \\ta\\t b\\t f(a)\\t f(b)\\t\\ x1\\n\"\n",
+ "for i in range(1,25):\n",
+ " x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a))\n",
+ " if(f(a)*f(x1))>0:\n",
+ " b=x1\n",
+ " else:\n",
+ " a=x1\n",
+ " if abs(f(x1))<d:\n",
+ " break\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(a,b,f(a),f(b),x1)\n",
+ "print \"the root of the equation is %0.4g\" %(x1)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "succesive iterations \ta\t b\t f(a)\t f(b)\t\\ x1\n",
+ "\n",
+ " \t3.000000 3.787772 -1.477121 -0.002839 3.787772\n",
+ "\n",
+ " \t3.789289 3.787772 0.000021 -0.002839 3.789289\n",
+ "\n",
+ "the root of the equation is 3.789\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.9:pg-30"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.9\n",
+ "#false position method\n",
+ "#page 30\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 4*math.exp(-x)*math.sin(x)-1\n",
+ "a=0.0\n",
+ "b=0.5 #f(0) is negative and f(0.5)is positive\n",
+ "d=0.00001\n",
+ "print \"succesive iterations \\ta\\t b\\t f(a)\\t f(b)\\t\\ x1\\n\"\n",
+ "for i in range(1,25):\n",
+ " x1=b*f(a)/(f(a)-f(b))+a*f(b)/(f(b)-f(a))\n",
+ " if(f(a)*f(x1))>0:\n",
+ " b=x1\n",
+ " else:\n",
+ " a=x1\n",
+ " if abs(f(x1))<d:\n",
+ " break\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(a,b,f(a),f(b),x1)\n",
+ "print \"the root of the equation is %f\" %(x1)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "succesive iterations \ta\t b\t f(a)\t f(b)\t\\ x1\n",
+ "\n",
+ " \t0.429869 0.500000 0.084545 0.163145 0.429869\n",
+ "\n",
+ " \t0.354433 0.500000 -0.026054 0.163145 0.354433\n",
+ "\n",
+ " \t0.374479 0.500000 0.006132 0.163145 0.374479\n",
+ "\n",
+ " \t0.369577 0.500000 -0.001547 0.163145 0.369577\n",
+ "\n",
+ " \t0.370802 0.500000 0.000384 0.163145 0.370802\n",
+ "\n",
+ " \t0.370497 0.500000 -0.000096 0.163145 0.370497\n",
+ "\n",
+ " \t0.370573 0.500000 0.000024 0.163145 0.370573\n",
+ "\n",
+ "the root of the equation is 0.370554\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.10:pg-33"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.10\n",
+ "#iteration method\n",
+ "#page 33\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 1/(math.sqrt(x+1))\n",
+ "x1=0.75\n",
+ "x2=0.0\n",
+ "n=1\n",
+ "d=0.0001 #accuracy opto 10^-4\n",
+ "c=0 #to count no of iterations \n",
+ "print \"successive iterations \\t\\x01\\tf(x1)\\n\"\n",
+ "while abs(x1-x2)>d:\n",
+ " print \" \\t%f %f\\n\" %(x1,f(x1))\n",
+ " x2=x1\n",
+ " x1=f(x1)\n",
+ " c=c+1\n",
+ "print \" the root of the eqaution after %i iteration is %0.4g\" %(c,x1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t\u0001\tf(x1)\n",
+ "\n",
+ " \t0.750000 0.755929\n",
+ "\n",
+ " \t0.755929 0.754652\n",
+ "\n",
+ " \t0.754652 0.754926\n",
+ "\n",
+ " \t0.754926 0.754867\n",
+ "\n",
+ " the root of the eqaution after 4 iteration is 0.7549\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.11:pg-34"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.11\n",
+ "#iteration method\n",
+ "#page34\n",
+ "import math\n",
+ "def f(x):\n",
+ " return cos(x)/2.0+3.0/2.0\n",
+ "x1=1.5 # as roots lies between 3/2 and pi/2\n",
+ "x2=0\n",
+ "d=0.0001 # accuracy opto 10^-4\n",
+ "c=0 # to count no of iterations \n",
+ "print \"successive iterations \\t\\x01\\tf(x1)\\n\"\n",
+ "while abs(x2-x1)>d:\n",
+ " \n",
+ " print \" \\t%f %f\\n\" %(x1,f(x1))\n",
+ " x2=x1\n",
+ " x1=f(x1)\n",
+ " c=c+1\n",
+ "print \" the root of the eqaution after %i iteration is %0.4g\" %(c,x1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t\u0001\tf(x1)\n",
+ "\n",
+ " \t1.500000 1.535369\n",
+ "\n",
+ " \t1.535369 1.517710\n",
+ "\n",
+ " \t1.517710 1.526531\n",
+ "\n",
+ " \t1.526531 1.522126\n",
+ "\n",
+ " \t1.522126 1.524326\n",
+ "\n",
+ " \t1.524326 1.523227\n",
+ "\n",
+ " \t1.523227 1.523776\n",
+ "\n",
+ " \t1.523776 1.523502\n",
+ "\n",
+ " \t1.523502 1.523639\n",
+ "\n",
+ " \t1.523639 1.523570\n",
+ "\n",
+ " the root of the eqaution after 10 iteration is 1.524\n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.12:pg-35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.12\n",
+ "#iteration method\n",
+ "#page 35\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.exp(-x)\n",
+ "x1=1.5 # as roots lies between 0 and 1\n",
+ "x2=0\n",
+ "d=0.0001 # accuracy opto 10^-4\n",
+ "c=0 # to count no of iterations \n",
+ "print \"successive iterations \\t x1 \\t f(x1)\\n\"\n",
+ "while abs(x2-x1)>d:\n",
+ " \n",
+ " print \" \\t%f %f\\n\" %(x1,f(x1))\n",
+ " x2=x1\n",
+ " x1=f(x1)\n",
+ " c=c+1\n",
+ "print \" the root of the eqaution after %i iteration is %0.4g\" %(c,x1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x1 \t f(x1)\n",
+ "\n",
+ " \t1.500000 0.223130\n",
+ "\n",
+ " \t0.223130 0.800011\n",
+ "\n",
+ " \t0.800011 0.449324\n",
+ "\n",
+ " \t0.449324 0.638059\n",
+ "\n",
+ " \t0.638059 0.528317\n",
+ "\n",
+ " \t0.528317 0.589597\n",
+ "\n",
+ " \t0.589597 0.554551\n",
+ "\n",
+ " \t0.554551 0.574330\n",
+ "\n",
+ " \t0.574330 0.563082\n",
+ "\n",
+ " \t0.563082 0.569451\n",
+ "\n",
+ " \t0.569451 0.565836\n",
+ "\n",
+ " \t0.565836 0.567885\n",
+ "\n",
+ " \t0.567885 0.566723\n",
+ "\n",
+ " \t0.566723 0.567382\n",
+ "\n",
+ " \t0.567382 0.567008\n",
+ "\n",
+ " \t0.567008 0.567220\n",
+ "\n",
+ " \t0.567220 0.567100\n",
+ "\n",
+ " \t0.567100 0.567168\n",
+ "\n",
+ " the root of the eqaution after 18 iteration is 0.5672\n"
+ ]
+ }
+ ],
+ "prompt_number": 34
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.13:pg-35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.13\n",
+ "#iteration method\n",
+ "#page 35\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 1+math.sin(x)/10\n",
+ "x1=1.0 # as roots lies between 1 and pi evident from graph\n",
+ "x2=0\n",
+ "d=0.0001 # accuracy opto 10^-4\n",
+ "c=0 # to count no of iterations \n",
+ "print \"successive iterations \\t x1 \\t f(x1)\\n\"\n",
+ "while abs(x2-x1)>d:\n",
+ " print \" \\t%f %f\\n\" %(x1,f(x1))\n",
+ " x2=x1\n",
+ " x1=f(x1)\n",
+ " c=c+1\n",
+ "print \" the root of the eqaution after %i iteration is %0.4g\" %(c,x1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x1 \t f(x1)\n",
+ "\n",
+ " \t1.000000 1.084147\n",
+ "\n",
+ " \t1.084147 1.088390\n",
+ "\n",
+ " \t1.088390 1.088588\n",
+ "\n",
+ " \t1.088588 1.088597\n",
+ "\n",
+ " the root of the eqaution after 4 iteration is 1.089\n"
+ ]
+ }
+ ],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.14:pg-36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.14\n",
+ "#aitken's process\n",
+ "#page 36\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 1.5+math.cos(x)/2.0\n",
+ "x0=1.5\n",
+ "y=0\n",
+ "e=0.0001\n",
+ "c=0\n",
+ "print \"successive iterations \\t x0 \\t x1 \\t x2 \\t x3 \\t y\\n\"\n",
+ "for i in range(1,10):\n",
+ " x1=f(x0)\n",
+ " x2=f(x1)\n",
+ " x3=f(x2)\n",
+ " y=x3-((x3-x2)**2)/(x3-2*x2+x1)\n",
+ " d=y-x0\n",
+ " x0=y\n",
+ " if abs(f(x0))<e:\n",
+ " break\n",
+ " c=c+1\n",
+ " print \" \\t%f %f %f %f %f\\n\" %(x0,x1,x2,x3,y)\n",
+ "print \"the root of the equation after %i iteration is %f\" %(c,y)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t x1 \t x2 \t x3 \t y\n",
+ "\n",
+ " \t1.523592 1.535369 1.517710 1.526531 1.523592\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ " \t1.523593 1.523593 1.523593 1.523593 1.523593\n",
+ "\n",
+ "the root of the equation after 9 iteration is 1.523593\n"
+ ]
+ }
+ ],
+ "prompt_number": 42
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.15:pg-39"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.15\n",
+ "#newton-raphson method\n",
+ "#page 39\n",
+ "def f(x):\n",
+ " return x**3-2*x-5\n",
+ "def f1(x):\n",
+ " return 3*x**2-2 # first derivative of the function\n",
+ "x0=2.0 # initial value\n",
+ "d=0.0001\n",
+ "c=0\n",
+ "n=1\n",
+ "print \"successive iterations \\t x0 \\t f(x0) \\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f \\t%f \\t%f \\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break\n",
+ "print \"the root of %i iteration is:%f\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t f(x0) \t f1(x0)\n",
+ "\n",
+ " \t2.000000 \t0.061000 \t11.230000 \n",
+ "\n",
+ " \t2.100000 \t0.000186 \t11.161647 \n",
+ "\n",
+ " \t2.094568 \t0.000000 \t11.161438 \n",
+ "\n",
+ "the root of 3 iteration is:2.094551\n"
+ ]
+ }
+ ],
+ "prompt_number": 44
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.16:pg-40"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.16\n",
+ "#newton-raphson method\n",
+ "#page 40\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x*math.sin(x)+math.cos(x)\n",
+ "def f1(x):\n",
+ " return x*math.cos(x) #first derivation of the function\n",
+ "x0=math.pi # initial value\n",
+ "d=0.0001\n",
+ "c=0 \n",
+ "n=1\n",
+ "print \"successive iterations \\tx0\\t f(x0)\\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f \\t%f \\t%f\\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break\n",
+ "print \"the root of %i iteration is:%f\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \tx0\t f(x0)\t f1(x0)\n",
+ "\n",
+ " \t3.141593 \t-0.066186 \t-2.681457\n",
+ "\n",
+ " \t2.823283 \t-0.000564 \t-2.635588\n",
+ "\n",
+ " \t2.798600 \t-0.000000 \t-2.635185\n",
+ "\n",
+ "the root of 3 iteration is:2.798386\n"
+ ]
+ }
+ ],
+ "prompt_number": 46
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.17:pg-40"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.17\n",
+ "#newton-raphson method\n",
+ "#page 40\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x*math.exp(x)-1\n",
+ "def f1(x):\n",
+ " return math.exp(x)+x*math.exp(x) #first derivative of the function\n",
+ "x0=0 # initial value\n",
+ "d=0.0001 \n",
+ "c=0\n",
+ "n=1\n",
+ "print \"successive iterations \\tx0\\t f(x0)\\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f \\t%f \\t%f\\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break\n",
+ "print \"the root of %i iteration is:%f\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \tx0\t f(x0)\t f1(x0)\n",
+ "\n",
+ " \t0.000000 \t1.718282 \t5.436564\n",
+ "\n",
+ " \t1.000000 \t0.355343 \t3.337012\n",
+ "\n",
+ " \t0.683940 \t0.028734 \t2.810232\n",
+ "\n",
+ " \t0.577454 \t0.000239 \t2.763614\n",
+ "\n",
+ " \t0.567230 \t0.000000 \t2.763223\n",
+ "\n",
+ "the root of 5 iteration is:0.567143\n"
+ ]
+ }
+ ],
+ "prompt_number": 48
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.18:pg-41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.18\n",
+ "#newton-raphson method\n",
+ "#page 41\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.sin(x)-x/2.0\n",
+ "def f1(x):\n",
+ " return math.cos(x)-0.5\n",
+ "x0=math.pi/2.0 # initial value\n",
+ "d=0.0001\n",
+ "c=0\n",
+ "n=1\n",
+ "print \"successive iterations \\t x0 \\t f(x0)\\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f\\t%f\\t%f\\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break\n",
+ "print \"the root of %i iteration is: %0.4g\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t f(x0)\t f1(x0)\n",
+ "\n",
+ " \t1.570796\t-0.090703\t-0.916147\n",
+ "\n",
+ " \t2.000000\t-0.004520\t-0.824232\n",
+ "\n",
+ " \t1.900996\t-0.000014\t-0.819039\n",
+ "\n",
+ "the root of 3 iteration is: 1.896\n"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.19:pg-41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.19\n",
+ "#newton-raphson method\n",
+ "#page 41\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 4*math.exp(-x)*math.sin(x)-1\n",
+ "def f1(x):\n",
+ " return math.cos(x)*4*math.exp(-x)-4*math.exp(-x)*math.sin(x)\n",
+ "x0=0.2 # initial value\n",
+ "d=0.0001\n",
+ "c=0 \n",
+ "n=1\n",
+ "print \"successive iterations \\t x0 \\t f(x0)\\t f1(x0)\\n\"\n",
+ "while n==1:\n",
+ " x2=x0\n",
+ " x1=x0-(f(x0)/f1(x0))\n",
+ " x0=x1\n",
+ " print \" \\t%f \\t%f \\t%f\\n\" %(x2,f(x1),f1(x1))\n",
+ " c=c+1\n",
+ " if abs(f(x0))<d:\n",
+ " break \n",
+ "print \"the root of %i iteration is: %0.3g\" %(c,x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t f(x0)\t f1(x0)\n",
+ "\n",
+ " \t0.200000 \t-0.056593 \t1.753325\n",
+ "\n",
+ " \t0.336526 \t-0.002769 \t1.583008\n",
+ "\n",
+ " \t0.368804 \t-0.000008 \t1.573993\n",
+ "\n",
+ "the root of 3 iteration is: 0.371\n"
+ ]
+ }
+ ],
+ "prompt_number": 54
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.20:pg-42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.20\n",
+ "#generalized newton-raphson method\n",
+ "#page 42\n",
+ "def f(x):\n",
+ " return x**3-x**2-x+1\n",
+ "def f1(x):\n",
+ " return 3*x**2-2*x-1\n",
+ "def f2(x):\n",
+ " return 6*x-2\n",
+ "x0=0.8 # initial value to finf double root\n",
+ "n=1 \n",
+ "print \"successive iterations \\t x0 \\t x1\\t x2\\n\"\n",
+ "while n==1:\n",
+ " x1=x0-(f(x0)/f1(x0));\n",
+ " x2=x0-(f1(x0)/f2(x0));\n",
+ " if abs(x1-x2)<0.000000001:\n",
+ " x0=(x1+x2)/2.0\n",
+ " break\n",
+ " else:\n",
+ " x0=(x1+x2)/2;\n",
+ " print \" %f\\t %f\\t %f\\n\" %(x0,x1,x2)\n",
+ "print \"\\n \\nthe double root is at: %f\" %(x0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t x1\t x2\n",
+ "\n",
+ " 0.974370\t 0.905882\t 1.042857\n",
+ "\n",
+ " 0.993890\t 0.987269\t 1.000512\n",
+ "\n",
+ " 0.998489\t 0.996950\t 1.000028\n",
+ "\n",
+ " 0.999623\t 0.999245\t 1.000002\n",
+ "\n",
+ " 0.999906\t 0.999812\t 1.000000\n",
+ "\n",
+ " 0.999976\t 0.999953\t 1.000000\n",
+ "\n",
+ " 0.999994\t 0.999988\t 1.000000\n",
+ "\n",
+ " 0.999999\t 0.999997\t 1.000000\n",
+ "\n",
+ " 1.000000\t 0.999999\t 1.000000\n",
+ "\n",
+ " 1.000000\t 1.000000\t 1.000000\n",
+ "\n",
+ " 1.000000\t 1.000000\t 1.000000\n",
+ "\n",
+ " 1.000000\t 1.000000\t 1.000000\n",
+ "\n",
+ " 1.000000\t 1.000000\t 1.000000\n",
+ "\n",
+ "\n",
+ " \n",
+ "the double root is at: 1.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 57
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.21:pg-45"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ramanujan's method\n",
+ "#example 2.21\n",
+ "#page 45\n",
+ "def f(x):\n",
+ " return 1-(13.0/12.0)*x-(3.0/8.0)*x**2+(1.0/24.0)*x**3\n",
+ "a1=13.0/12.0\n",
+ "a2=-3.0/8.0\n",
+ "a3=1.0/24.0\n",
+ "b1=1\n",
+ "b2=a1\n",
+ "b3=a1*b2+a2*b1\n",
+ "b4=a1*b3+a2*b2+a3*b1\n",
+ "b5=a1*b4+a2*b3+a3*b2\n",
+ "b6=a1*b5+a2*b4+a3*b3\n",
+ "b7=a1*b6+a2*b5+a3*b4\n",
+ "b8=a1*b7+a2*b6+a3*b5\n",
+ "b9=a1*b8+a2*b7+a3*b6\n",
+ "print \"\\n\\n%f\" %(b1/b2)\n",
+ "print \"\\n%f\" %(b2/b3)\n",
+ "print \"\\n%f\" %(b3/b4)\n",
+ "print \"\\n%f\" %(b4/b5)\n",
+ "print \"\\n%f\" %(b5/b6)\n",
+ "print \"\\n%f\" %(b6/b7)\n",
+ "print \"\\n%f\" %(b7/b8)\n",
+ "print \"\\n%f\" %(b8/b9)\n",
+ "print \"\\n it appears as if the roots are converging at 2\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ "0.923077\n",
+ "\n",
+ "1.356522\n",
+ "\n",
+ "1.595376\n",
+ "\n",
+ "1.738402\n",
+ "\n",
+ "1.828184\n",
+ "\n",
+ "1.886130\n",
+ "\n",
+ "1.924153\n",
+ "\n",
+ "1.949345\n",
+ "\n",
+ " it appears as if the roots are converging at 2\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.22:pg-46"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ramanujan's method\n",
+ "#example 2.22\n",
+ "#page 46\n",
+ "def f(x):\n",
+ " return x+x**2+(x**3)/2.0+(x**4)/6.0+(x**5)/24.0\n",
+ "a1=1.0\n",
+ "a2=1.0\n",
+ "a3=1.0/2.0\n",
+ "a4=1.0/6.0\n",
+ "a5=1.0/24.0\n",
+ "b1=1\n",
+ "b2=a2\n",
+ "b3=a1*b2+a2*b1\n",
+ "b4=a1*b3+a2*b2+a3*b1\n",
+ "b5=a1*b4+a2*b3+a3*b2\n",
+ "b6=a1*b5+a2*b4+a3*b3\n",
+ "print \"\\n%f\" %(b1/b2)\n",
+ "print \"\\n%f\" %(b2/b3)\n",
+ "print \"\\n%f\" %(b3/b4)\n",
+ "print \"\\n%f\" %(b4/b5)\n",
+ "print \"\\n%f\" %(b5/b6)\n",
+ "print \"\\n it appears as if the roots are converging at around %f\" %(b5/b6)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "1.000000\n",
+ "\n",
+ "0.500000\n",
+ "\n",
+ "0.571429\n",
+ "\n",
+ "0.583333\n",
+ "\n",
+ "0.571429\n",
+ "\n",
+ " it appears as if the roots are converging at around 0.571429\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.23:pg-47"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ramanujan's method\n",
+ "#example 2.23\n",
+ "#page 47\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return 1-2*((3*x/2.0+(x**2)/4.0-(x**4)/48.0+(x**6)/1440.0)-(x**8)*2/80640.0)\n",
+ "a1=3/2\n",
+ "a2=1/4\n",
+ "a3=0\n",
+ "a4=1/48\n",
+ "a5=0\n",
+ "a6=1/1440\n",
+ "a7=0\n",
+ "a8=-1/80640\n",
+ "b1=1\n",
+ "b2=a1\n",
+ "b3=a1*b2+a2*b1\n",
+ "b4=a1*b3+a2*b2+a3*b1\n",
+ "b5=a1*b4+a2*b3+a3*b2\n",
+ "b6=a1*b5+a2*b4+a3*b3\n",
+ "b7=a1*b6+a2*b5+a3*b4\n",
+ "b8=a1*b7+a2*b6+a3*b5\n",
+ "b9=a1*b8+a2*b7+a3*b6\n",
+ "print \"\\n%f\" %(b1/b2)\n",
+ "print \"\\n%f\" %(b2/b3)\n",
+ "print \"\\n%f\" %(b3/b4)\n",
+ "print \"\\n%f\" %(b4/b5)\n",
+ "print \"\\n%f\" %(b5/b6)\n",
+ "print \"\\n%f\" %(b6/b7)\n",
+ "print \"\\n%f\" %(b7/b8)\n",
+ "print \"\\n it appears as if the roots are converging at around %f\" %(b7/b8)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "0.666667\n",
+ "\n",
+ "0.600000\n",
+ "\n",
+ "0.606061\n",
+ "\n",
+ "0.605505\n",
+ "\n",
+ "0.605556\n",
+ "\n",
+ "0.605551\n",
+ "\n",
+ "0.605551\n",
+ "\n",
+ " it appears as if the roots are converging at around 0.605551\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.24:pg-47"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#ramanujan's method\n",
+ "#example 2.24\n",
+ "#page 47\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 1-(x-x**2.0/math.factorial(2.0)**2.0+x**3.0/math.factorial(3.0)**2.0-x**4.0/math.factorial(4.0)**2.0)\n",
+ "a1=1\n",
+ "a2=-1/math.factorial(2.0)**2.0\n",
+ "a3=1/math.factorial(3.0)**2.0\n",
+ "a4=-1/math.factorial(4.0)**2.0\n",
+ "a5=-1/math.factorial(5.0)**2.0\n",
+ "a6=1/math.factorial(6.0)**2.0\n",
+ "b1=1\n",
+ "b2=a1\n",
+ "b3=a1*b2+a2*b1\n",
+ "b4=a1*b3+a2*b2+a3*b1\n",
+ "b5=a1*b4+a2*b3+a3*b2\n",
+ "print \"\\n\\n%f\" %(b1/b2)\n",
+ "print \"\\n\\n%f\" %(b2/b3)\n",
+ "print \"\\n%f\" %(b3/b4)\n",
+ "print \"\\n%f\" %(b4/b5)\n",
+ "print \"\\n it appears as if the roots are converging at around %f\" %(b4/b5)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ "1.000000\n",
+ "\n",
+ "\n",
+ "1.333333\n",
+ "\n",
+ "1.421053\n",
+ "\n",
+ "1.433962\n",
+ "\n",
+ " it appears as if the roots are converging at around 1.433962\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.25:pg-49"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.25\n",
+ "#secant method\n",
+ "#page 49\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return x**3-2*x-5\n",
+ "x1=2\n",
+ "x2=3 # initial values\n",
+ "n=1\n",
+ "c=0\n",
+ "print \"successive iterations \\t x1 \\t x2 \\t x3 \\t f(x3)\\n\"\n",
+ "while n==1:\n",
+ " x3=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1)) \n",
+ " print \" \\t%f \\t%f \\t%f \\t%f\\n\" %(x1,x2,x3,f(x3))\n",
+ " if f(x3)*f(x1)>0:\n",
+ " x2=x3;\n",
+ " else:\n",
+ " x1=x3 \n",
+ " if abs(f(x3))<0.000001: \n",
+ " break\n",
+ " c=c+1\n",
+ "print \"the root of the equation after %i iteration is: %f\" %(c,x3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x1 \t x2 \t x3 \t f(x3)\n",
+ "\n",
+ " \t2.000000 \t3.000000 \t2.058824 \t-0.390800\n",
+ "\n",
+ " \t2.000000 \t2.058824 \t2.096559 \t0.022428\n",
+ "\n",
+ " \t2.096559 \t2.058824 \t2.094511 \t-0.000457\n",
+ "\n",
+ " \t2.094511 \t2.058824 \t2.094552 \t0.000009\n",
+ "\n",
+ " \t2.094552 \t2.058824 \t2.094551 \t-0.000000\n",
+ "\n",
+ "the root of the equation after 4 iteration is: 2.094551\n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.26:pg-50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 2.26\n",
+ "#secant method\n",
+ "#page 50\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return x*math.exp(x)-1\n",
+ "x1=0\n",
+ "x2=1 # initial values\n",
+ "n=1\n",
+ "c=0 \n",
+ "print \"successive iterations \\t x1 \\t x2 \\t x3 \\t f(x3)\\n\"\n",
+ "while n==1:\n",
+ " x3=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1)) \n",
+ " print \" \\t%f \\t%f \\t%f \\t%f\\n\" %(x1,x2,x3,f(x3))\n",
+ " if f(x3)*f(x1)>0:\n",
+ " x2=x3\n",
+ " else:\n",
+ " x1=x3 \n",
+ " if abs(f(x3))<0.0001:\n",
+ " break\n",
+ " c=c+1\n",
+ "print \"the root of the equation after %i iteration is: %0.4g\" %(c,x3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x1 \t x2 \t x3 \t f(x3)\n",
+ "\n",
+ " \t0.000000 \t1.000000 \t0.367879 \t-0.468536\n",
+ "\n",
+ " \t0.000000 \t0.367879 \t0.692201 \t0.383091\n",
+ "\n",
+ " \t0.692201 \t0.367879 \t0.546310 \t-0.056595\n",
+ "\n",
+ " \t0.546310 \t0.367879 \t0.570823 \t0.010200\n",
+ "\n",
+ " \t0.570823 \t0.367879 \t0.566500 \t-0.001778\n",
+ "\n",
+ " \t0.566500 \t0.367879 \t0.567256 \t0.000312\n",
+ "\n",
+ " \t0.567256 \t0.367879 \t0.567124 \t-0.000055\n",
+ "\n",
+ "the root of the equation after 6 iteration is: 0.5671\n"
+ ]
+ }
+ ],
+ "prompt_number": 31
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.27:pg-52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# example 2.27\n",
+ "#mulller's method\n",
+ "#page 52\n",
+ "from __future__ import division\n",
+ "import math\n",
+ "def f(x):\n",
+ " return x**3-x-1\n",
+ "x0=0\n",
+ "x1=1\n",
+ "x2=2 # initial values\n",
+ "n=1\n",
+ "c=0\n",
+ "print \"successive iterations \\t x0 \\t x1 \\t x2 \\t f(x0)\\t f(x1)\\t f(x2)\\n\"\n",
+ "while n==1: \n",
+ " c=c+1\n",
+ " y0=f(x0)\n",
+ " y1=f(x1)\n",
+ " y2=f(x2)\n",
+ " h2=x2-x1\n",
+ " h1=x1-x0\n",
+ " d2=f(x2)-f(x1)\n",
+ " d1=f(x1)-f(x0)\n",
+ " print \" \\t%f\\t %f\\t %f\\t %f\\t %f\\t %f\\n\" %(x0,x1,x2,f(x0),f(x1),f(x2))\n",
+ " A=(d2/h2-d1/h1)/(h1+h2)\n",
+ " B=d2/h2+A*h2\n",
+ " S=math.sqrt(B**2-4*A*f(x2))\n",
+ " x3=x2-(2*f(x2))/(B+S)\n",
+ " E=abs((x3-x2)/x2)*100\n",
+ " if E<0.003:\n",
+ " break\n",
+ " else:\n",
+ " if c==1:\n",
+ " x2=x3\n",
+ " if c==2:\n",
+ " x1=x2\n",
+ " x2=x3\n",
+ " if c==3:\n",
+ " x0=x1\n",
+ " x1=x2\n",
+ " x2=x3\n",
+ " if c==3:\n",
+ " c=0\n",
+ "print \"the required root is : %0.4f\" %(x3)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "successive iterations \t x0 \t x1 \t x2 \t f(x0)\t f(x1)\t f(x2)\n",
+ "\n",
+ " \t0.000000\t 1.000000\t 2.000000\t -1.000000\t -1.000000\t 5.000000\n",
+ "\n",
+ " \t0.000000\t 1.000000\t 1.263763\t -1.000000\t -1.000000\t -0.245412\n",
+ "\n",
+ " \t0.000000\t 1.263763\t 1.331711\t -1.000000\t -0.245412\t 0.030015\n",
+ "\n",
+ " \t1.263763\t 1.331711\t 1.324583\t -0.245412\t 0.030015\t -0.000574\n",
+ "\n",
+ " \t1.263763\t 1.331711\t 1.324718\t -0.245412\t 0.030015\t -0.000000\n",
+ "\n",
+ "the required root is : 1.3247\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.28:pg-55"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#graeffe's method\n",
+ "#example 2.28\n",
+ "#page 55\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return x**3-6*(x**2)+11*x-6\n",
+ "#x=poly(0,'x')\n",
+ "#g=f(-x)\n",
+ "print \"the equation is:\\n\"\n",
+ "A=[1, 14, 49, 36] #coefficients of the above equation\n",
+ "print \"%0.4g\\n\" %(math.sqrt(A[3]/A[2]))\n",
+ "print \"%0.4g\\n\" %(math.sqrt(A[2]/A[1]))\n",
+ "print \"%0.4g\\n\" %(math.sqrt(A[1]/A[0]))\n",
+ "print \"the equation is:\\n\"\n",
+ "#disp(g*(-1*g));\n",
+ "B=[1, 98, 1393, 1296]\n",
+ "print \"%0.4g\\n\" %((B[3]/B[2])**(1/4))\n",
+ "print \"%0.4g\\n\" %((B[2]/B[1])**(1/4))\n",
+ "print \"%0.4g\\n\" %((B[1]/B[0])**(1/4))\n",
+ "print \"It is apparent from the outputs that the roots converge at 1 2 3\"\n",
+ "\n",
+ "\n",
+ "\n",
+ "#INCOMPLETE"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the equation is:\n",
+ "\n",
+ "0.8571\n",
+ "\n",
+ "1.871\n",
+ "\n",
+ "3.742\n",
+ "\n",
+ "the equation is:\n",
+ "\n",
+ "0.9821\n",
+ "\n",
+ "1.942\n",
+ "\n",
+ "3.146\n",
+ "\n",
+ "It is apparent from the outputs that the roots converge at 1 2 3\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.29:pg-57"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#quadratic factor by lin's--bairsttow method\n",
+ "#example 2.29\n",
+ "#page 57\n",
+ "from numpy import matrix\n",
+ "from __future__ import division\n",
+ "def f(x):\n",
+ " return x**3-x-1\n",
+ "a=[-1, -1, 0, 1]\n",
+ "r1=1\n",
+ "s1=1\n",
+ "b4=a[3]\n",
+ "def f3(r):\n",
+ " return a[2]-r*a[3]\n",
+ "def f2(r,s):\n",
+ " return a[1]-r*a[2]+r**2*a[3]-s*a[3]\n",
+ "def f1(r,s):\n",
+ " return a[0]-s*a[2]+s*r*a[3]\n",
+ "A=matrix([[1,1],[2,-1]])\n",
+ "C=matrix([[0],[1]])\n",
+ "X=A.I*C\n",
+ "X1=[[ 0.33333333],[-0.33333333]]\n",
+ "dr=X1[0][0]\n",
+ "ds=X1[1][0]\n",
+ "r2=r1+dr\n",
+ "s2=s1+ds\n",
+ "#second pproximation\n",
+ "r1=r2\n",
+ "s1=s2\n",
+ "b11=f1(r2,s2)\n",
+ "b22=f2(r2,s2)\n",
+ "h=0.001\n",
+ "dr_b1=(f1(r1+h,s1)-f1(r1,s1))/h\n",
+ "ds_b1=(f1(r1,s1+h)-f1(r1,s1))/h\n",
+ "dr_b2=(f2(r1+h,s1)-f2(r1,s1))/h\n",
+ "ds_b2=(f2(r1,s1+h)-f2(r1,s1))/h\n",
+ "A=matrix([[dr_b1,ds_b1],[dr_b2,ds_b2]])\n",
+ "C=matrix([[-f1(r1,s1)],[-f2(r1,s2)]])\n",
+ "X=A.I*C\n",
+ "r2=r1+X[0][0]\n",
+ "s2=s1+X[1][0]\n",
+ "print \"roots correct to 3 decimal places are : %0.3f %0.3f\" %(r2,s2)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "roots correct to 3 decimal places are : 1.325 0.754\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.31:pg-62"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#method of iteration\n",
+ "#example 2.31\n",
+ "#page 62\n",
+ "from __future__ import division\n",
+ "def f(x,y):\n",
+ " return (3*y*x**2+7)/10\n",
+ "def g(x,y):\n",
+ " return (y**2+4)/5\n",
+ "h=0.0001\n",
+ "x0=0.5\n",
+ "y0=0.5\n",
+ "f1_dx=(f(x0+h,y0)-f(x0,y0))/h\n",
+ "f1_dy=(f(x0,y0+h)-f(x0,y0))/h\n",
+ "g1_dx=(g(x0+h,y0)-g(x0,y0))/h\n",
+ "g1_dy=(g(x0+h,y0)-g(x0,y0))/h\n",
+ "if (f1_dx+f1_dy<1) and (g1_dx+g1_dy<1): \n",
+ " print \"coditions for convergence is satisfied\\n\\n\"\n",
+ "print \"X \\t Y\\t\\n\\n\"\n",
+ "for i in range(0,10):\n",
+ " X=(3*y0*x0**2+7)/10\n",
+ " Y=(y0**2+4)/5\n",
+ " print \"%f\\t %f\\t\\n\" %(X,Y)\n",
+ " x0=X\n",
+ " y0=Y\n",
+ "print \"\\n\\n CONVERGENCE AT (1 1) IS OBVIOUS\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "coditions for convergence is satisfied\n",
+ "\n",
+ "\n",
+ "X \t Y\t\n",
+ "\n",
+ "\n",
+ "0.737500\t 0.850000\t\n",
+ "\n",
+ "0.838696\t 0.944500\t\n",
+ "\n",
+ "0.899312\t 0.978416\t\n",
+ "\n",
+ "0.937391\t 0.991460\t\n",
+ "\n",
+ "0.961360\t 0.996598\t\n",
+ "\n",
+ "0.976320\t 0.998642\t\n",
+ "\n",
+ "0.985572\t 0.999457\t\n",
+ "\n",
+ "0.991247\t 0.999783\t\n",
+ "\n",
+ "0.994707\t 0.999913\t\n",
+ "\n",
+ "0.996807\t 0.999965\t\n",
+ "\n",
+ "\n",
+ "\n",
+ " CONVERGENCE AT (1 1) IS OBVIOUS\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.32:pg-65"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#newton raphson method\n",
+ "#example 2.32\n",
+ "#page 65\n",
+ "def f(x,y):\n",
+ " return 3*y*x**2-10*x+7\n",
+ "def g(y):\n",
+ " return y**2-5*y+4\n",
+ "hh=0.0001\n",
+ "x0=0.5\n",
+ "y0=0.5 #initial values\n",
+ "f0=f(x0,y0)\n",
+ "g0=g(y0)\n",
+ "df_dx=(f(x0+hh,y0)-f(x0,y0))/hh\n",
+ "df_dy=(f(x0,y0+hh)-f(x0,y0))/hh\n",
+ "dg_dx=(g(y0)-g(y0))/hh\n",
+ "dg_dy=(g(y0+hh)-g(y0))/hh\n",
+ "d=[[df_dx,df_dy],[dg_dx,dg_dy]]\n",
+ "D1=det(d)\n",
+ "dd=[[-f0,df_dy],[-g0,dg_dy]]\n",
+ "h=det(dd)/D1\n",
+ "ddd=[[df_dx,-f0],[dg_dx,-g0]]\n",
+ "k=det(ddd)/D1;\n",
+ "x1=x0+h\n",
+ "y1=y0+k\n",
+ "f0=f(x1,y1)\n",
+ "g0=g(y1)\n",
+ "df_dx=(f(x1+hh,y1)-f(x1,y1))/hh\n",
+ "df_dy=(f(x1,y1+hh)-f(x1,y1))/hh\n",
+ "dg_dx=(g(y1)-g(y1))/hh\n",
+ "dg_dy=(g(y1+hh)-g(y1))/hh\n",
+ "dddd=[[df_dx,df_dy],[dg_dx,dg_dy]]\n",
+ "D2=det(dddd)\n",
+ "ddddd=[[-f0,df_dy],[-g0,dg_dy]]\n",
+ "h=det(ddddd)/D2\n",
+ "d6=[[df_dx,-f0],[dg_dx,-g0]]\n",
+ "k=det(d6)/D2\n",
+ "x2=x1+h\n",
+ "y2=y1+k\n",
+ "print \" the roots of the equation are x2=%f and y2=%f\" %(x2,y2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " the roots of the equation are x2=0.970803 and y2=0.998752\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.33:pg-66"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#newton raphson method\n",
+ "#example 2.33\n",
+ "#page 66\n",
+ "import math\n",
+ "def f(x,y):\n",
+ " return x**2+y**2-1\n",
+ "def g(x,y):\n",
+ " return y-x**2\n",
+ "hh=0.0001\n",
+ "x0=0.7071\n",
+ "y0=0.7071 #initial values\n",
+ "f0=f(x0,y0)\n",
+ "g0=g(x0,y0)\n",
+ "df_dx=(f(x0+hh,y0)-f(x0,y0))/hh\n",
+ "df_dy=(f(x0,y0+hh)-f(x0,y0))/hh\n",
+ "dg_dx=(g(x0+hh,y0)-g(x0,y0))/hh\n",
+ "dg_dy=(g(x0,y0+hh)-g(x0,y0))/hh\n",
+ "D1=det([[df_dx,df_dy],[dg_dx,dg_dy]])\n",
+ "h=det([[-f0,df_dy],[-g0,dg_dy]])/D1\n",
+ "k=det([[df_dx,-f0],[dg_dx,-g0]])/D1\n",
+ "x1=x0+h\n",
+ "y1=y0+k\n",
+ "f0=f(x1,y1)\n",
+ "g0=g(x1,y1)\n",
+ "df_dx=(f(x1+hh,y1)-f(x1,y1))/hh\n",
+ "df_dy=(f(x1,y1+hh)-f(x1,y1))/hh\n",
+ "dg_dx=(g(x1+hh,y1)-g(x1,y1))/hh\n",
+ "dg_dy=(g(x1,y1+hh)-g(x1,y1))/hh\n",
+ "D2=det([[df_dx,df_dy],[dg_dx,dg_dy]])\n",
+ "h=det([[-f0,df_dy],[-g0,dg_dy]])/D2\n",
+ "k=det([[df_dx,-f0],[dg_dx,-g0]])/D2\n",
+ "x2=x1+h\n",
+ "y2=y1+k\n",
+ "print \"the roots of the equation are x2=%f and y2=%f \" %(x2,y2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the roots of the equation are x2=0.786184 and y2=0.618039 \n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex2.34:pg-67"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#newton raphson method\n",
+ "#example 2.34\n",
+ "#page 67\n",
+ "import math\n",
+ "def f(x,y):\n",
+ " return math.sin(x)-y+0.9793\n",
+ "def g(x,y):\n",
+ " return math.cos(y)-x+0.6703\n",
+ "hh=0.0001\n",
+ "x0=0.5\n",
+ "y0=1.5 #initial values\n",
+ "f0=f(x0,y0)\n",
+ "g0=g(x0,y0)\n",
+ "df_dx=(f(x0+hh,y0)-f(x0,y0))/hh\n",
+ "df_dy=(f(x0,y0+hh)-f(x0,y0))/hh\n",
+ "dg_dx=(g(x0+hh,y0)-g(x0,y0))/hh\n",
+ "dg_dy=(g(x0,y0+hh)-g(x0,y0))/hh\n",
+ "d1=[[df_dx,df_dy],[dg_dx,dg_dy]]\n",
+ "D1=det(d1)\n",
+ "d2=[[-f0,df_dy],[-g0,dg_dy]]\n",
+ "h=det(d2)/D1\n",
+ "d3=[[df_dx,-f0],[dg_dx,-g0]]\n",
+ "k=det(d3)/D1\n",
+ "x1=x0+h\n",
+ "y1=y0+k\n",
+ "f0=f(x1,y1)\n",
+ "g0=g(x1,y1)\n",
+ "df_dx=(f(x1+hh,y1)-f(x1,y1))/hh\n",
+ "df_dy=(f(x1,y1+hh)-f(x1,y1))/hh\n",
+ "dg_dx=(g(x1+hh,y1)-g(x1,y1))/hh\n",
+ "dg_dy=(g(x1,y1+hh)-g(x1,y1))/hh\n",
+ "d4=[[df_dx,df_dy],[dg_dx,dg_dy]]\n",
+ "D2=det(d4)\n",
+ "h=det([[-f0,df_dy],[-g0,dg_dy]])/D2\n",
+ "k=det([[df_dx,-f0],[dg_dx,-g0]])/D2\n",
+ "x2=x1+h\n",
+ "y2=y1+k\n",
+ "print \"the roots of the equation are x2=%0.4f and y2=%0.4f\" %(x2,y2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the roots of the equation are x2=0.6537 and y2=1.5874\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter3_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter3_4.ipynb new file mode 100644 index 00000000..77d8f79f --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter3_4.ipynb @@ -0,0 +1,1113 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:58def12f7e424e92e928d020c21b40714eff26275c7ce87aa5600004fbc92a49"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter03:Interpolation"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.4:pg-86"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.4\n",
+ "#interpolation\n",
+ "#page 86\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "x=[1, 3, 5, 7]\n",
+ "y=[24, 120, 336, 720]\n",
+ "d1=[0,0,0]\n",
+ "d2=[0,0,0]\n",
+ "d3=[0,0,0]\n",
+ "h=2 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "d=[0,d1[0],d2[0],d3[0]]\n",
+ "x0=8 #value at 8\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-1)/2\n",
+ "for i in range(1,4):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%f\" %(x0,y_x)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of function at 8.000000 is :990.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.6:pg-87"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.6\n",
+ "#interpolation\n",
+ "#page 87\n",
+ "x=[15, 20, 25, 30, 35, 40]\n",
+ "y=[0.2588190, 0.3420201, 0.4226183, 0.5, 0.5735764, 0.6427876]\n",
+ "d1=[0,0,0,0,0]\n",
+ "d2=[0,0,0,0]\n",
+ "d3=[0,0,0]\n",
+ "d4=[0,0]\n",
+ "d5=[0]\n",
+ "h=5 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d5[c]=d4[i+1]-d4[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "d=[0,d1[0], d2[0], d3[0], d4[0], d5[0]]\n",
+ "x0=38 #value at 38 degree\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,6):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+((pp*d[i])/math.factorial(i));\n",
+ "print \"value of function at %i is :%f\" %(x0,y_x)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of function at 38 is :0.615661\n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.7:pg-89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.7\n",
+ "#interpolation\n",
+ "#page 89\n",
+ "x=[0, 1, 2, 4]\n",
+ "y=[1, 3, 9, 81]\n",
+ "#equation is y(5)-4*y(4)+6*y(2)-4*y(2)+y(1)\n",
+ "y3=(y[3]+6*y[2]-4*y[1]+y[0])/4\n",
+ "print \"the value of missing term of table is :%d\" %(y3)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of missing term of table is :31\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.8:pg-89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.8\n",
+ "#interpolation\n",
+ "#page 89\n",
+ "import math\n",
+ "x=[0.10, 0.15, 0.20, 0.25, 0.30]\n",
+ "y=[0.1003, 0.1511, 0.2027, 0.2553, 0.3093]\n",
+ "d1=[0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0,0]\n",
+ "d4=[0,0,0,0,0]\n",
+ "h=0.05 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "d=[0,d1[0], d2[0], d3[0], d4[0]]\n",
+ "x0=0.12 #value at 0.12;\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,5):\n",
+ " pp=1;\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%0.4g\\n \\n\" %(x0,y_x)\n",
+ "x0=0.26 #value at 0.26;\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,5):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i);\n",
+ "print \"value of function at %f is :%0.4g\\n \\n\" %(x0,y_x)\n",
+ "x0=0.40 #value at 0.40;\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,5):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%0.4g\\n \\n\" %(x0,y_x)\n",
+ "x0=0.50 #value at 0.50;\n",
+ "pp=1\n",
+ "y_x=y[0]\n",
+ "p=(x0-x[0])/h\n",
+ "for i in range(1,5):\n",
+ " pp=1\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%0.5g\\n \\n\" %(x0,y_x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of function at 0.120000 is :0.1205\n",
+ " \n",
+ "\n",
+ "value of function at 0.260000 is :0.266\n",
+ " \n",
+ "\n",
+ "value of function at 0.400000 is :0.4241\n",
+ " \n",
+ "\n",
+ "value of function at 0.500000 is :0.5543\n",
+ " \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 33
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.9:pg-93"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.9\n",
+ "#Gauss' forward formula\n",
+ "#page 93\n",
+ "x=[1.0, 1.05, 1.10, 1.15, 1.20, 1.25, 1.30];\n",
+ "y=[2.7183, 2.8577, 3.0042, 3.1582, 3.3201, 3.4903, 3.66693]\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "d5=[0,0]\n",
+ "d6=[0]\n",
+ "h=0.05 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " d5[c]=d4[i+1]-d4[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,1):\n",
+ " d6[c]=d5[i+1]-d5[i]\n",
+ " c=c+1\n",
+ "d=[0,d1[3], d2[2], d3[2], d4[1], d5[0], d6[0]]\n",
+ "x0=1.17 #value at 1.17;\n",
+ "pp=1\n",
+ "y_x=y[3]\n",
+ "p=(x0-x[3])/h\n",
+ "for i in range(1,6):\n",
+ " pp=1;\n",
+ " for j in range(0,i):\n",
+ " pp=pp*(p-(j)) \n",
+ " y_x=y_x+(pp*d[i])/math.factorial(i)\n",
+ "print \"value of function at %f is :%0.4g\\n \\n\" %(x0,y_x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value of function at 1.170000 is :3.222\n",
+ " \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.10:pg-97"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#practical interpolation\n",
+ "#example 3.10\n",
+ "#page 97\n",
+ "import math\n",
+ "x=[0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67]\n",
+ "y=[1.840431, 1.858928,1.877610, 1.896481, 1.915541, 1.934792, 1.954237]\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "h=0.01 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i];\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i];\n",
+ " c=c+1\n",
+ "d=[d1[0], d2[0], d3[0], d4[0]]\n",
+ "x0=0.644\n",
+ "p=(x0-x[3])/h;\n",
+ "y_x=y[3]\n",
+ "y_x=y_x+p*(d1[2]+d1[3])/2+p**2*(d2[1])/2 #stirling formula\n",
+ "print \"the value at %f by stirling formula is : %f\\n\\n\" %(x0,y_x)\n",
+ "y_x=y[3]\n",
+ "y_x=y_x+p*d1[3]+p*(p-1)*(d2[2]+d2[3])/2\n",
+ "print \" the value at %f by bessels formula is : %f\\n\\n\" %(x0,y_x)\n",
+ "y_x=y[3]\n",
+ "q=1-p\n",
+ "y_x=q*y[3]+q*(q**2-1)*d2[2]/2+p*y[4]+p*(q**2-1)*d2[4]/2\n",
+ "print \"the value at %f by everrets formula is : %f\\n\\n\" %(x0,y_x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value at 0.644000 by stirling formula is : 1.904082\n",
+ "\n",
+ "\n",
+ " the value at 0.644000 by bessels formula is : 1.904059\n",
+ "\n",
+ "\n",
+ "the value at 0.644000 by everrets formula is : 1.904044\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.11:pg-99"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#practical interpolation\n",
+ "#example 3.11\n",
+ "#page 99\n",
+ "x=[0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67]\n",
+ "y=[1.840431, 1.858928, 1.877610, 1.896481, 1.915541, 1.934792, 1.954237]\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "h=0.01 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "d=[d1[0], d2[0], d3[0], d4[0]]\n",
+ "x0=0.638\n",
+ "p=(x0-x[3])/h\n",
+ "y_x=y[3]\n",
+ "y_x=y_x+p*(d1[2]+d1[3])/2+p**2*(d2[1])/2 #stirling formula\n",
+ "print \"value at %f by stirling formula is : %f\\n\\n\" %(x0,y_x)\n",
+ "y_x=y[2]\n",
+ "p=(x0-x[2])/h\n",
+ "y_x=y_x+p*d1[2]+p*(p-1)*(d2[1])/2\n",
+ "print \"the value at %f by bessels formula is : %f\\n\\n\" %(x0,y_x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "value at 0.638000 by stirling formula is : 1.892692\n",
+ "\n",
+ "\n",
+ "the value at 0.638000 by bessels formula is : 1.892692\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 39
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.12:pg-99"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#practical interpolation\n",
+ "#example 3.12\n",
+ "#page 99\n",
+ "x=[1.72, 1.73, 1.74, 1.75, 1.76, 1.77, 1.78]\n",
+ "y=[0.1790661479, 0.1772844100, 0.1755204006, 0.1737739435, 0.1720448638, 0.1703329888, 0.1686381473]\n",
+ "d1=[0,0,0,0,0,0]\n",
+ "d2=[0,0,0,0,0]\n",
+ "d3=[0,0,0,0]\n",
+ "d4=[0,0,0]\n",
+ "h=0.01 #interval between values of x\n",
+ "c=0\n",
+ "for i in range(0,6):\n",
+ " d1[c]=y[i+1]-y[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,5):\n",
+ " d2[c]=d1[i+1]-d1[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,4):\n",
+ " d3[c]=d2[i+1]-d2[i]\n",
+ " c=c+1\n",
+ "c=0\n",
+ "for i in range(0,3):\n",
+ " d4[c]=d3[i+1]-d3[i]\n",
+ " c=c+1\n",
+ "x0=1.7475\n",
+ "y_x=y[2]\n",
+ "p=(x0-x[2])/h\n",
+ "y_x=y_x+p*d1[2]+p*(p-1)*((d2[1]+d2[2])/2)/2\n",
+ "print \"the value at %f by bessels formula is : %0.10f\\n\\n\" %(x0,y_x)\n",
+ "y_x=y[3]\n",
+ "q=1-p\n",
+ "y_x=q*y[2]+q*(q**2-1)*d2[1]/6+p*y[3]+p*(p**2-1)*d2[1]/6\n",
+ "print \"the value at %f by everrets formula is : %0.10f\\n\\n\" %(x0,y_x)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value at 1.747500 by bessels formula is : 0.1742089204\n",
+ "\n",
+ "\n",
+ "the value at 1.747500 by everrets formula is : 0.1742089122\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 41
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.13:pg-104"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.13\n",
+ "#lagrange's interpolation formula\n",
+ "#page 104\n",
+ "x=[300, 304, 305, 307]\n",
+ "y=[2.4771, 2.4829, 2.4843, 2.4871]\n",
+ "x0=301\n",
+ "log_301=(-3*-4*-6*2.4771)/(-4*-5*-7)+(-4*-6*2.4829)/(4*-1*-3)+(-3*-6*2.4843)/(5*-2)+(-3*-4*2.4871)/(7*3*2)\n",
+ "print \"valie of log x at 301 is =%f\" %(log_301)\n",
+ "\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "valie of log x at 301 is =2.478597\n"
+ ]
+ }
+ ],
+ "prompt_number": 43
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.14:pg-105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.14\n",
+ "#lagrange's interpolation formula\n",
+ "#page 105\n",
+ "y=[4, 12, 19]\n",
+ "x=[1, 3, 4];\n",
+ "y_x=7\n",
+ "Y_X=(-5*-12)/(-8*-15)+(3*3*-12)/(8*-7)+(3*-5*4)/(15*7)\n",
+ "print \"values is %f\" %(Y_X)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "values is 1.857143\n"
+ ]
+ }
+ ],
+ "prompt_number": 44
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.15:pg-105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.15\n",
+ "#lagrange's interpolation formula\n",
+ "#page 105\n",
+ "x=[2, 2.5, 3.0]\n",
+ "y=[0.69315, 0.91629, 1.09861]\n",
+ "def l0(x):\n",
+ " return (x-2.5)*(x-3.0)/(-0.5)*(-1.0)\n",
+ "def l1(x):\n",
+ " return ((x-2.0)*(x-3.0))/((0.5)*(-0.5))\n",
+ "def l2(x):\n",
+ " return ((x-2.0)*(x-2.5))/((1.0)*(0.5))\n",
+ "f_x=l0(2.7)*y[0]+l1(2.7)*y[1]+l2(2.7)*y[2];\n",
+ "print \"the calculated value is %f:\" %(f_x)\n",
+ "print \"\\n\\n the error occured in the value is %0.9f\" %(abs(f_x-log(2.7)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the calculated value is 0.994116:\n",
+ "\n",
+ "\n",
+ " the error occured in the value is 0.000864627\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.16:pg-106"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.16\n",
+ "#lagrange's interpolation formula\n",
+ "#page 106\n",
+ "import math\n",
+ "x=[0, math.pi/4,math.pi/2]\n",
+ "y=[0, 0.70711, 1.0];\n",
+ "x0=math.pi/6\n",
+ "sin_x0=0\n",
+ "for i in range(0,3):\n",
+ " p=y[i]\n",
+ " for j in range(0,3):\n",
+ " if j!=i:\n",
+ " p=p*((x0-x[j])/( x[i]-x[j]))\n",
+ " sin_x0=sin_x0+p\n",
+ "print \"sin_x0=%f\" %(sin_x0)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "sin_x0=0.517431\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.18:pg-107"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#error in lagrange's interpolation formula\n",
+ "#example 3.18\n",
+ "#page 107\n",
+ "import math\n",
+ "x=[2, 2.5, 3.0]\n",
+ "y=[0.69315, 0.91629, 1.09861]\n",
+ "def l0(x):\n",
+ " return (x-2.5)*(x-3.0)/(-0.5)*(-1.0)\n",
+ "def l1(x):\n",
+ " return ((x-2.0)*(x-3.0))/((0.5)*(-0.5))\n",
+ "def l2(x):\n",
+ " return ((x-2.0)*(x-2.5))/((1.0)*(0.5))\n",
+ "f_x=l0(2.7)*y[0]+l1(2.7)*y[1]+l2(2.7)*y[2]\n",
+ "print \"the calculated value is %f:\" %(f_x)\n",
+ "err=math.fabs(f_x-math.log10(2.7))\n",
+ "def R_n(x):\n",
+ " return (((x-2)*(x-2.5)*(x-3))/6)\n",
+ "est_err=abs(R_n(2.7)*(2/8))\n",
+ "if est_err<err:\n",
+ " print \"\\n\\n the error agrees with the actual error\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the calculated value is 0.994116:\n",
+ "\n",
+ "\n",
+ " the error agrees with the actual error\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.19:pg-107"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#error in lagrenge's interpolation\n",
+ "#example 3.19\n",
+ "#page 107\n",
+ "import math\n",
+ "x=[0, math.pi/4 ,math.pi/2]\n",
+ "y=[0, 0.70711, 1.0]\n",
+ "def l0(x):\n",
+ " return ((x-0)*(x-math.pi/2))/((math.pi/4)*(-1*math.pi/4))\n",
+ "def l1(x):\n",
+ " return ((x-0)*(x-math.pi/4))/((math.pi/2)*(math.pi/4))\n",
+ "f_x=l0(math.pi/6)*y[1]+l1(math.pi/6)*y[2]\n",
+ "err=abs(f_x-math.sin(math.pi/6))\n",
+ "def f(x):\n",
+ " return ((x-0)*(x-math.pi/4)*(x-math.pi/2))/6\n",
+ "if abs(f(math.pi/6))>err:\n",
+ " print \"\\n\\n the error agrees with the actual error\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ " the error agrees with the actual error\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.21:pg-110"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#hermite's interpolation formula\n",
+ "#exammple 3.21\n",
+ "#page 110\n",
+ "from __future__ import division\n",
+ "import math\n",
+ "x=[2.0, 2.5, 3.0]\n",
+ "y=[0.69315, 0.91629, 1.09861]\n",
+ "y1=[0,0,0]\n",
+ "def f(x):\n",
+ " return math.log(x)\n",
+ "h=0.0001\n",
+ "for i in range(0,3):\n",
+ " y1[i]=(f(x[i]+h)-f(x[i]))/h\n",
+ "def l0(x):\n",
+ " return (x-2.5)*(x-3.0)/(-0.5)*(-1.0)\n",
+ "def l1(x):\n",
+ " return ((x-2.0)*(x-3.0))/((0.5)*(-0.5))\n",
+ "def l2(x):\n",
+ " return ((x-2.0)*(x-2.5))/((1.0)*(0.5))\n",
+ "dl0=(l0(x[0]+h)-l0(x[0]))/h\n",
+ "dl1=(l1(x[1]+h)-l1(x[1]))/h\n",
+ "dl2=(l2(x[2]+h)-l2(x[2]))/h\n",
+ "x0=2.7\n",
+ "u0=(1-2*(x0-x[0])*dl0)*(l0(x0))**2\n",
+ "u1=(1-2*(x0-x[1])*dl1)*(l1(x0))**2\n",
+ "u2=(1-2*(x0-x[2])*dl2)*(l2(x0))**2\n",
+ "v0=(x0-x[0])*l0(x0)**2\n",
+ "v1=(x0-x[1])*l1(x0)**2\n",
+ "v2=(x0-x[2])*l2(x0)**2\n",
+ "H=u0*y[0]+u1*y[1]+u2*y[2]+v0*y1[0]+v1*y1[1]+v2*y1[2]\n",
+ "print \"the approximate value of ln(%0.2f) is %f:\" %(x0,H)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the approximate value of ln(2.70) is 0.993362:\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.22:pg-114"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#newton's general interpolation formula\n",
+ "#example 3.22\n",
+ "#page 114\n",
+ "x=[300, 304, 305, 307]\n",
+ "y=[2.4771, 2.4829, 2.4843, 2.4871]\n",
+ "d1=[0,0,0]\n",
+ "d2=[0,0]\n",
+ "for i in range(0,3):\n",
+ " d1[i]=(y[i+1]-y[i])/(x[i+1]-x[i])\n",
+ "for i in range(0,2):\n",
+ " d2[i]=(d1[i+1]-d1[i])/(x[i+2]-x[i])\n",
+ "x0=301\n",
+ "log301=y[0]+(x0-x[0])*d1[0]+(x0-x[1])*d2[0]\n",
+ "print \"valure of log(%d) is :%0.4f\" %(x0,log301)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "valure of log(301) is :2.4786\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex3.23:pg-114"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 3.23\n",
+ "#newton's divided formula\n",
+ "#page 114\n",
+ "x=[-1, 0, 3, 6, 7]\n",
+ "y=[3, -6, 39, 822, 1611]\n",
+ "for in range(0,4):\n",
+ " d1[i]=(y[i+1]-y[i])/(x[i+1]-x[i])\n",
+ "for in range(0,3):\n",
+ " d2[i]=(d1[i+1]-d1[i])/(x[i+2]-x[i])\n",
+ "for in range(0,2):\n",
+ " d3[i]=(d2[i+1]-d2[i])/(x[i+3]-x[i])\n",
+ "for iin range(0,1):\n",
+ " d4[i]=(d3[i+1]-d3[i])/(x[i+4]-x[i])\n",
+ "X=poly(0,'X')\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",
+ "disp(f_x,'the polynomial equation is =')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "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": [
+ "Ex2.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_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter4_4.ipynb new file mode 100644 index 00000000..406cd254 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter4_4.ipynb @@ -0,0 +1,879 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:953815d4201d9e210127ff2cec3495f1fdfb20a194dfdaa866d22872b59b0875"
+ },
+ "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": 16
+ },
+ {
+ "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",
+ "from math import *\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": 64
+ },
+ {
+ "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_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter6_4.ipynb new file mode 100644 index 00000000..feda2e86 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter6_4.ipynb @@ -0,0 +1,1060 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:1a9f2b829e44e8c5b8b9fd16a973f697f286159a22f472b6b856723b189b82cb"
+ },
+ "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_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter7_4.ipynb new file mode 100644 index 00000000..2c912b1a --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter7_4.ipynb @@ -0,0 +1,753 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:80e986d07048adcc87513dd70a29cfcee4e5cbe398d6c429d4a22317be195d09"
+ },
+ "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_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter8_4.ipynb new file mode 100644 index 00000000..f63e51c4 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter8_4.ipynb @@ -0,0 +1,1090 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:211485ee9675dbd033c1e0f7103541cc20ab60290b369496fbe4f65a805db82f"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter08:Numerical Solution of Ordinary Differential Equations"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.1:pg-304"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.1\n",
+ "#taylor's method\n",
+ "#page 304\n",
+ "import math\n",
+ "f=1 #value of function at 0\n",
+ "def f1(x):\n",
+ " return x-f**2\n",
+ "def f2(x):\n",
+ " return 1-2*f*f1(x)\n",
+ "def f3(x):\n",
+ " return -2*f*f2(x)-2*f2(x)**2\n",
+ "def f4(x):\n",
+ " return -2*f*f3(x)-6*f1(x)*f2(x)\n",
+ "def f5(x):\n",
+ " return -2*f*f4(x)-8*f1(x)*f3(x)-6*f2(x)**2\n",
+ "h=0.1 #value at 0.1\n",
+ "k=f \n",
+ "for j in range(1,5):\n",
+ " if j==1:\n",
+ " k=k+h*f1(0);\n",
+ " elif j==2:\n",
+ " k=k+(h**j)*f2(0)/math.factorial(j)\n",
+ " elif j ==3:\n",
+ " k=k+(h**j)*f3(0)/math.factorial(j)\n",
+ " elif j ==4:\n",
+ " k=k+(h**j)*f4(0)/math.factorial(j)\n",
+ " elif j==5:\n",
+ " k=k+(h**j)*f5(0)/math.factorial(j)\n",
+ "print \"the value of the function at %.2f is :%0.4f\" %(h,k)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of the function at 0.10 is :0.9113\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.2:pg-304"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#taylor's method\n",
+ "#example 8.2\n",
+ "#page 304\n",
+ "import math\n",
+ "f=1 #value of function at 0\n",
+ "f1=0 #value of first derivatie at 0\n",
+ "def f2(x):\n",
+ " return x*f1+f\n",
+ "def f3(x):\n",
+ " return x*f2(x)+2*f1\n",
+ "def f4(x):\n",
+ " return x*f3(x)+3*f2(x)\n",
+ "def f5(x):\n",
+ " return x*f4(x)+4*f3(x)\n",
+ "def f6(x):\n",
+ " return x*f5(x)+5*f4(x)\n",
+ "h=0.1 #value at 0.1\n",
+ "k=f\n",
+ "for j in range(1,6):\n",
+ " if j==1:\n",
+ " k=k+h*f1\n",
+ " elif j==2:\n",
+ " k=k+(h**j)*f2(0)/math.factorial(j)\n",
+ " elif j ==3:\n",
+ " k=k+(h**j)*f3(0)/math.factorial(j)\n",
+ " elif j ==4:\n",
+ " k=k+(h**j)*f4(0)/math.factorial(j)\n",
+ " elif j==5:\n",
+ " k=k+(h**j)*f5(0)/math.factorial(j)\n",
+ " else:\n",
+ " k=k+(h**j)*f6(0)/math.factorial (j)\n",
+ "print \"the value of the function at %.2f is :%0.7f\" %(h,k)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of the function at 0.10 is :1.0050125\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.3:pg-306"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.3\n",
+ "#picard's method\n",
+ "#page 306\n",
+ "from scipy import integrate\n",
+ "from __future__ import division\n",
+ "def f(x,y):\n",
+ " return x+y**2\n",
+ "y=[0,0,0,0]\n",
+ "y[1]=1\n",
+ "for i in range(1,3):\n",
+ " a=integrate.quad(lambda x:x+y[i]**2,0,i/10)\n",
+ " y[i+1]=a[0]+y[1]\n",
+ " print \"\\n y (%g) = %g\\n\" %(i/10,y[i+1])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y (0.1) = 1.105\n",
+ "\n",
+ "\n",
+ " y (0.2) = 1.26421\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.4:pg-306"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.4\n",
+ "#picard's method\n",
+ "#page 306\n",
+ "from scipy import integrate\n",
+ "y=[0,0,0,0] #value at 0\n",
+ "c=0.25\n",
+ "for i in range(0,3):\n",
+ " a=integrate.quad(lambda x:(x**2/(y[i]**2+1)),0,c)\n",
+ " y[i+1]=y[0]+a[0]\n",
+ " print \"\\n y(%0.2f) = %g\\n\" %(c,y[i+1])\n",
+ " c=c*2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y(0.25) = 0.00520833\n",
+ "\n",
+ "\n",
+ " y(0.50) = 0.0416655\n",
+ "\n",
+ "\n",
+ " y(1.00) = 0.332756\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.5:pg-308"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.5\n",
+ "#euler's method\n",
+ "#page 308\n",
+ "def f(y):\n",
+ " return -1*y\n",
+ "y=[0,0,0,0,0]\n",
+ "y[0]=1 #value at 0\n",
+ "h=0.01\n",
+ "c=0.01\n",
+ "for i in range(0,4):\n",
+ " y[i+1]=y[i]+h*f(y[i])\n",
+ " print \"\\ny(%g)=%g\\n\" %(c,y[i+1])\n",
+ " c=c+0.01\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "y(0.01)=0.99\n",
+ "\n",
+ "\n",
+ "y(0.02)=0.9801\n",
+ "\n",
+ "\n",
+ "y(0.03)=0.970299\n",
+ "\n",
+ "\n",
+ "y(0.04)=0.960596\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.6:pg-308"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.6\n",
+ "#error estimates in euler's \n",
+ "#page 308\n",
+ "from __future__ import division\n",
+ "def f(y):\n",
+ " return -1*y\n",
+ "y=[0,0,0,0,0]\n",
+ "L=[0,0,0,0,0]\n",
+ "e=[0,0,0,0,0]\n",
+ "y[0]=1 #value at 0\n",
+ "h=0.01\n",
+ "c=0.01;\n",
+ "for i in range(0,4):\n",
+ " y[i+1]=y[i]+h*f(y[i])\n",
+ " print \"\\ny(%g)=%g\\n\" %(c,y[i+1])\n",
+ " c=c+0.01\n",
+ "for i in range(0,4):\n",
+ " L[i]=abs(-(1/2)*(h**2)*y[i+1])\n",
+ " print \"L(%d) =%f\\n\\n\" %(i,L[i])\n",
+ "e[0]=0\n",
+ "for i in range(0,4):\n",
+ " e[i+1]=abs(y[1]*e[i]+L[0])\n",
+ " print \"e(%d)=%f\\n\\n\" %(i,e[i])\n",
+ "Actual_value=math.exp(-0.04)\n",
+ "Estimated_value=y[4]\n",
+ "err=abs(Actual_value-Estimated_value)\n",
+ "if err<e[4]:\n",
+ " print \"VERIFIED\"\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "y(0.01)=0.99\n",
+ "\n",
+ "\n",
+ "y(0.02)=0.9801\n",
+ "\n",
+ "\n",
+ "y(0.03)=0.970299\n",
+ "\n",
+ "\n",
+ "y(0.04)=0.960596\n",
+ "\n",
+ "L(0) =0.000050\n",
+ "\n",
+ "\n",
+ "L(1) =0.000049\n",
+ "\n",
+ "\n",
+ "L(2) =0.000049\n",
+ "\n",
+ "\n",
+ "L(3) =0.000048\n",
+ "\n",
+ "\n",
+ "e(0)=0.000000\n",
+ "\n",
+ "\n",
+ "e(1)=0.000050\n",
+ "\n",
+ "\n",
+ "e(2)=0.000099\n",
+ "\n",
+ "\n",
+ "e(3)=0.000147\n",
+ "\n",
+ "\n",
+ "VERIFIED\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.7:pg-310"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.7\n",
+ "#modified euler's method\n",
+ "#page 310\n",
+ "h=0.05\n",
+ "f=1\n",
+ "def f1(x,y):\n",
+ " return x**2+y\n",
+ "x=[0,0.05,0.1]\n",
+ "y1=[0,0,0,0]\n",
+ "y2=[0,0,0,0]\n",
+ "y1[0]=f+h*f1(x[0],f);\n",
+ "y1[1]=f+h*(f1(x[0],f)+f1(x[1],y1[0]))/2\n",
+ "y1[2]=f+h*(f1(x[0],f)+f1(x[2],y1[1]))/2\n",
+ "y2[0]=y1[1]+h*f1(x[1],y1[1])\n",
+ "y2[1]=y1[1]+h*(f1(x[1],y1[1])+f1(x[2],y2[0]))/2\n",
+ "y2[2]=y1[1]+h*(f1(x[1],y1[1])+f1(x[2],y2[1]))/2\n",
+ "print \"y1(0)\\t y1(1)\\t y1(2)\\t y2(0)\\t y2(1)\\t y3(2)\\n\\n\"\n",
+ "print \" %f\\t %f\\t %f\\t %f\\t %f\\t %f\\n\" %(y1[0],y1[1],y1[2],y2[0],y2[1],y2[2])\n",
+ "print \"\\n\\n the value of y at %0.2f is : %0.4f\" %(x[2],y2[2])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "y1(0)\t y1(1)\t y1(2)\t y2(0)\t y2(1)\t y3(2)\n",
+ "\n",
+ "\n",
+ " 1.050000\t 1.051313\t 1.051533\t 1.104003\t 1.105508\t 1.105546\n",
+ "\n",
+ "\n",
+ "\n",
+ " the value of y at 0.10 is : 1.1055\n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.8:pg-313"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.8\n",
+ "#runge-kutta formula\n",
+ "#page 313\n",
+ "from __future__ import division\n",
+ "def f(x,y):\n",
+ " return y-x\n",
+ "y=2\n",
+ "x=0\n",
+ "h=0.1\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h,y+K1)\n",
+ "y1=y+( K1+K2)/2\n",
+ "print \"\\n y(0.1) by second order runge kutta method:%0.4f\" %(y1)\n",
+ "y=y1\n",
+ "x=0.1\n",
+ "h=0.1\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h,y+K1)\n",
+ "y1=y+( K1+K2)/2\n",
+ "print \"\\n y(0.2) by second order runge kutta method:%0.4f\" %(y1)\n",
+ "y=2\n",
+ "x=0\n",
+ "h=0.1\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.1) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=y1\n",
+ "x=0.1\n",
+ "h=0.1\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.1) by fourth order runge kutta method:%0.4f \" %(y1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y(0.1) by second order runge kutta method:2.2050\n",
+ "\n",
+ " y(0.2) by second order runge kutta method:2.4210\n",
+ "\n",
+ " y(0.1) by fourth order runge kutta method:2.2052\n",
+ "\n",
+ " y(0.1) by fourth order runge kutta method:2.4214 \n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.9:pg-315"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.9\n",
+ "#runge kutta method\n",
+ "#page 315\n",
+ "from __future__ import division\n",
+ "def f(x,y):\n",
+ " return 1+y**2\n",
+ "y=0\n",
+ "x=0\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.2) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=y1\n",
+ "x=0.2\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.4) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=2\n",
+ "x=0\n",
+ "h=0.1\n",
+ "y=y1\n",
+ "x=0.4\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "print \"\\n y(0.6) by fourth order runge kutta method:%0.4f\" %(y1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y(0.2) by fourth order runge kutta method:0.2027\n",
+ "\n",
+ " y(0.4) by fourth order runge kutta method:0.4228\n",
+ "\n",
+ " y(0.6) by fourth order runge kutta method:0.6841\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.10:pg-315"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.10\n",
+ "#initial value problems\n",
+ "#page 315\n",
+ "from __future__ import division\n",
+ "def f1(x,y):\n",
+ " return 3*x+y/2\n",
+ "y=[1,0,0]\n",
+ "h=0.1\n",
+ "c=0\n",
+ "for i in range(0,2):\n",
+ " y[i+1]=y[i]+h*f1(c,y[i])\n",
+ " print \"\\ny(%g)=%g\\n\" %(c,y[i])\n",
+ " c=c+0.1\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "y(0)=1\n",
+ "\n",
+ "\n",
+ "y(0.1)=1.05\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.11:pg-316"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.11\n",
+ "#adam's moulton method\n",
+ "#page 316\n",
+ "def f(x,y):\n",
+ " return 1+y**2\n",
+ "y=0\n",
+ "x=0\n",
+ "h=0.2\n",
+ "f1=[0,0,0]\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[0]=y1\n",
+ "print \"\\n y(0.2) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=y1\n",
+ "x=0.2\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[1]=y1\n",
+ "print \"\\n y(0.4) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y=2\n",
+ "x=0\n",
+ "h=0.1\n",
+ "y=y1\n",
+ "x=0.4\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[2]=y1\n",
+ "print \"\\n y(0.6) by fourth order runge kutta method:%0.4f\" %(y1)\n",
+ "y_p=y1+h*(55*(1+f1[2]**2)-59*(1+f1[1]**2)+37*(1+f1[0]**2)-9)/24\n",
+ "y_c=y1+h*(9*(1+(y_p-1)**2)+19*(1+f1[2]**2)-5*(1+f1[1]**2)+(1+f1[0]**2))/24\n",
+ "print \"\\nthe predicted value is:%0.4f:\\n\" %(y_p)\n",
+ "print \" the computed value is:%0.4f:\" %(y_c)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " y(0.2) by fourth order runge kutta method:0.2027\n",
+ "\n",
+ " y(0.4) by fourth order runge kutta method:0.4228\n",
+ "\n",
+ " y(0.6) by fourth order runge kutta method:0.6841\n",
+ "\n",
+ "the predicted value is:1.0234:\n",
+ "\n",
+ " the computed value is:0.9512:\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.12:pg-320"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.12\n",
+ "#milne's method\n",
+ "#page 320\n",
+ "def f(x,y):\n",
+ " return 1+y**2\n",
+ "y=0\n",
+ "f1=[0,0,0]\n",
+ "Y1=[0,0,0,0]\n",
+ "x=0\n",
+ "h=0.2\n",
+ "f1[0]=0\n",
+ "print \"x y y1=1+y^2\\n\\n\"\n",
+ "Y1[0]=1+y**2\n",
+ "print \"%0.4f %0.4f %0.4f\\n\" %(x,y,(1+y**2))\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[0]=y1\n",
+ "Y1[1]=1+y1**2\n",
+ "print \"%0.4f %0.4f %0.4f\\n\" %(x+h,y1,(1+y1**2))\n",
+ "y=y1\n",
+ "x=0.2\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[1]=y1\n",
+ "Y1[2]=1+y1**2\n",
+ "print \"%0.4f %0.4f %0.4f\\n\" %(x+h,y1,(1+y1**2))\n",
+ "y=y1\n",
+ "x=0.4\n",
+ "h=0.2\n",
+ "K1=h*f(x,y)\n",
+ "K2=h*f(x+h/2,y+K1/2)\n",
+ "K3=h*f(x+h/2,y+K2/2)\n",
+ "K4=h*f(x+h,y+K3)\n",
+ "y1=y+(K1+2*K2+2*K3+K4)/6\n",
+ "f1[2]=y1\n",
+ "Y1[3]=1+y1**2;\n",
+ "print \"%0.4f %0.4f %0.4f\\n\" %(x+h,y1,(1+y1**2))\n",
+ "Y_4=4*h*(2*Y1[1]-Y1[2]+2*Y1[3])/3\n",
+ "print \"y(0.8)=%f\\n\" %(Y_4)\n",
+ "Y=1+Y_4**2\n",
+ "Y_4=f1[1]+h*(Y1[2]+4*Y1[3]+Y)/3 #more correct value\n",
+ "print \"y(0.8)=%f\\n\" %(Y_4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "x y y1=1+y^2\n",
+ "\n",
+ "\n",
+ "0.0000 0.0000 1.0000\n",
+ "\n",
+ "0.2000 0.2027 1.0411\n",
+ "\n",
+ "0.4000 0.4228 1.1788\n",
+ "\n",
+ "0.6000 0.6841 1.4680\n",
+ "\n",
+ "y(0.8)=1.023869\n",
+ "\n",
+ "y(0.8)=1.029403\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.13:pg-320"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.13\n",
+ "#milne's method\n",
+ "#page 320\n",
+ "def f1(x,y):\n",
+ " return x**2+y**2-2\n",
+ "x=[-0.1, 0, 0.1, 0.2]\n",
+ "y=[1.0900, 1.0, 0.8900, 0.7605]\n",
+ "Y1=[0,0,0,0]\n",
+ "h=0.1\n",
+ "for i in range(0,4):\n",
+ " Y1[i]=f1(x[i],y[i])\n",
+ "print \" x y y1=x^2+y^2-2 \\n\\n\"\n",
+ "for i in range(0,4):\n",
+ " print \" %0.2f %f %f \\n\" %(x[i],y[i],Y1[i])\n",
+ "Y_3=y[0]+(4*h/3)*(2*Y1[1]-Y1[2]+2*Y1[3])\n",
+ "print \"y(0.3)=%f\\n\" %(Y_3)\n",
+ "Y1_3=f1(0.3,Y_3)\n",
+ "Y_3=y[2]+h*(Y1[2]+4*Y1[3]+Y1_3)/3 #corrected value\n",
+ "print \"corrected y(0.3)=%f\" %(Y_3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " x y y1=x^2+y^2-2 \n",
+ "\n",
+ "\n",
+ " -0.10 1.090000 -0.801900 \n",
+ "\n",
+ " 0.00 1.000000 -1.000000 \n",
+ "\n",
+ " 0.10 0.890000 -1.197900 \n",
+ "\n",
+ " 0.20 0.760500 -1.381640 \n",
+ "\n",
+ "y(0.3)=0.614616\n",
+ "\n",
+ "corrected y(0.3)=0.614776\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.14:pg322"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 8.14\n",
+ "#initial-value problem\n",
+ "#page 322\n",
+ "from __future__ import division\n",
+ "import math\n",
+ "def f(x):\n",
+ " return 13*math.exp(x/2)-6*x-12\n",
+ "s1=1.691358\n",
+ "s3=3.430879\n",
+ "print \"the erorr in the computed values are %0.7g %0.7g\" %(abs(f(0.5)-s1),abs(f(1)-s3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the erorr in the computed values are 0.0009724169 0.002497519\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.15:pg-328"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#boundary value problem using finite difference method\n",
+ "#example 8.15\n",
+ "#page 328\n",
+ "import math\n",
+ "from numpy import matrix\n",
+ "def f(x):\n",
+ " return math.cos(x)+((1-math.cos(1))/math.sin(1))*math.sin(x)-1\n",
+ "h1=1/2\n",
+ "Y=f(0.5)\n",
+ "y0=0\n",
+ "y2=0\n",
+ "y1=4*(1/4+y0+y2)/7\n",
+ "print \"computed value with h=%f of y(0.5) is %f\\n\" %(h1,y1)\n",
+ "print \"error in the result with actual value %f\\n\" %(abs(Y-y1))\n",
+ "h2=1/4\n",
+ "y0=0\n",
+ "y4=0\n",
+ "#solving the approximated diffrential equation\n",
+ "A=matrix([[-31/16, 1, 0],[1, -31/16, 1],[0, 1, -31/16]])\n",
+ "X=matrix([[-1/16],[-1/16],[-1/16]])\n",
+ "C=A.I*X\n",
+ "print \"computed value with h=%f of y(0.5) is %f\\n\" %(h2,C[1][0])\n",
+ "print \"error in the result with actual value %f\\n\" %(abs(Y-C[1][0]))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "computed value with h=0.500000 of y(0.5) is 0.142857\n",
+ "\n",
+ "error in the result with actual value 0.003363\n",
+ "\n",
+ "computed value with h=0.250000 of y(0.5) is 0.140312\n",
+ "\n",
+ "error in the result with actual value 0.000818\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.16:pg-329"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#boundary value problem using finite difference method\n",
+ "#example 8.16\n",
+ "#page 329\\\n",
+ "from numpy import matrix\n",
+ "import math\n",
+ "def f(x):\n",
+ " return math.sinh(x)\n",
+ "y0=0 #y(0)=0\n",
+ "y4=3.62686 #y(2)=3.62686\n",
+ "h1=0.5\n",
+ "Y=f(0.5)\n",
+ "#arranging and calculating the values\n",
+ "A=matrix([[-9, 4, 0],[4, -9, 4],[0, 4, -9]])\n",
+ "C=matrix([[0],[0],[-14.50744]])\n",
+ "X=A.I*C\n",
+ "print \"computed value with h=%f of y(0.5) is %f\\n\" %(h1,X[0][0])\n",
+ "print \"error in the result with actual value %f\\n\" %(abs(Y-X[0][0]))\n",
+ "h2=1.0\n",
+ "y0=0 #y(0)=0\n",
+ "y2=3.62686 #y(2)=3.62686\n",
+ "y1=(y0+y2)/3\n",
+ "Y=(4*X[1][0]-y1)/3\n",
+ "print \"with better approximation error is reduced to %f\" %(abs(Y-f(1.0)))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "computed value with h=0.500000 of y(0.5) is 0.526347\n",
+ "\n",
+ "error in the result with actual value 0.005252\n",
+ "\n",
+ "with better approximation error is reduced to 0.000855\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.17:pg-330"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline method\n",
+ "#example 8.17\n",
+ "#page 330\n",
+ "def f(x):\n",
+ " return math.cos(x)+((1-math.cos(1))/math.sin(1))*math.sin(x)-1\n",
+ "y=[f(0), f(0.5), f(1)]\n",
+ "h=1/2\n",
+ "Y=f(0.5)\n",
+ "y0=0\n",
+ "y2=0\n",
+ "M0=-1\n",
+ "M1=-22/25\n",
+ "M2=-1\n",
+ "s1_0=47/88\n",
+ "s1_1=-47/88\n",
+ "s1_05=0\n",
+ "print \"the cubic spline value is %f\" %(Y)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the cubic spline value is 0.139494\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.18:pg-331"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline method\n",
+ "#example 8.18\n",
+ "#page 331\n",
+ "from numpy import matrix\n",
+ "from __future__ import division\n",
+ "#after arranging and forming equation \n",
+ "A=matrix([[10, -1, 0, 24],[0, 16, -1, -32],[1, 20, 0, 16],[0, 1, 26, -24]])\n",
+ "C=matrix([[36],[-12],[24],[-9]])\n",
+ "X=A.I*C;\n",
+ "print \" Y1=%f\\n\\n\" %(X[3][0])\n",
+ "print \" the error in the solution is :%f\" %(abs((2/3)-X[3][0]))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Y1=0.653890\n",
+ "\n",
+ "\n",
+ " the error in the solution is :0.012777\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex8.19:pg-331"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#boundary value problem by cubisc spline nethod\n",
+ "#example 8.18\n",
+ "#page 331\n",
+ "from numpy import matrix\n",
+ "h=1/2\n",
+ "#arranging in two subintervals we get\n",
+ "A=matrix([[10, -1, 0,24],[0, 16, -1, -32],[1, 20, 0, 16],[0, 1, 26, -24]])\n",
+ "C=matrix([[36],[-12],[24],[-9]])\n",
+ "X=A.I*C\n",
+ "print \"the computed value of y(1.5) is %f \"%(X[3][0])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the computed value of y(1.5) is 0.653890 \n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter_5_4.ipynb b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter_5_4.ipynb new file mode 100644 index 00000000..1486b3cb --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/chapter_5_4.ipynb @@ -0,0 +1,358 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:73b3f1621533860d19417048028b6a582d3d1aa7cc7179cdde4368d0572261d3"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter05:Spline Functions"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.1:pg-182"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#linear splines\n",
+ "#example 5.1\n",
+ "#page 182\n",
+ "from numpy import matrix\n",
+ "X=matrix([[1],[2], [3]])\n",
+ "y=matrix([[-8],[-1],[18]])\n",
+ "m1=(y[1][0]-y[0][0])/(X[1][0]-X[0][0])\n",
+ "m2=(y[2][0]-y[1][0])/(X[2][0]-X[1][0])\n",
+ "def s1(x):\n",
+ " return y[0][0]+(x-X[0][0])*m1\n",
+ "def s2(x):\n",
+ " return y[1][0]+(x-X[1][0])*m2\n",
+ "print \"the value of function at 2.5 is %0.2f: \" %(s2(2.5))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the value of function at 2.5 is 8.50: \n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.3:pg-188"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic splines\n",
+ "#example 5.3\n",
+ "#page 188\n",
+ "from numpy import matrix\n",
+ "import math\n",
+ "X=matrix([[1],[2],[3]])\n",
+ "y=matrix([[-8],[-1],[18]])\n",
+ "M1=0\n",
+ "M2=8\n",
+ "M3=0\n",
+ "h=1\n",
+ "#deff('y=s1(x)','y=3*(x-1)^3-8*(2-x)-4*(x-1)')\n",
+ "def s1(x):\n",
+ " return 3*math.pow(x-1,3)-8*(2-x)-4*(x-1)\n",
+ "#deff('y=s2(x)','y=3*(3-x)^3+22*x-48');\n",
+ "def s2(x):\n",
+ " return 3*math.pow(3-x,3)+22*x-48\n",
+ "h=0.0001\n",
+ "n=2.0\n",
+ "D=(s2(n+h)-s2(n))/h;\n",
+ "print \" y(2.5)=%f\" %(s2(2.5))\n",
+ "print \"y1(2.0)=%f\" %(D)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " y(2.5)=7.375000\n",
+ "y1(2.0)=13.000900\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.4:pg-189"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline\n",
+ "#example 5.4\n",
+ "#page 189\n",
+ "from numpy import matrix\n",
+ "import math\n",
+ "x=matrix([[0],[math.pi/2],[math.pi]])\n",
+ "y=matrix([[0],[1],[0]])\n",
+ "h=x[1][0]-x[0][0]\n",
+ "M0=0\n",
+ "M2=0\n",
+ "M1=((6*(y[0][0]-2*y[1][0]+y[2][0])/math.pow(h,2))-M0-M2)/4\n",
+ "X=math.pi/6.0\n",
+ "s1=(math.pow(x[1][0]-X,3)*(M0/6)+math.pow(X-x[0][0],3)*M1/6+(y[0][0]-math.pow(h,2)*M0/6)*(x[1][0]-X)+(y[1][0]-math.pow(h,2)*M1/6)*(X-x[0][0]))/h;\n",
+ "x=matrix([[0],[math.pi/4], [math.pi/2], [3*math.pi/4], [math.pi]])\n",
+ "y=matrix([[0], [1.414], [1] ,[1.414]])\n",
+ "M0=0\n",
+ "M4=0\n",
+ "A=matrix([[4, 1, 0],[1, 4, 1],[0 ,1 ,4]]) #calculating value of M1 M2 M3 by matrix method\n",
+ "C=matrix([[-4.029],[-5.699],[-4.029]])\n",
+ "B=A.I*C\n",
+ "print \"M0=%f\\t M1=%f\\t M2=%f\\t M3=%f\\t M4=%f\\t\\n\\n\" %(M0,B[0][0],B[1][0],B[2][0],M4)\n",
+ "h=math.pi/4;\n",
+ "X=math.pi/6;\n",
+ "s1=(-0.12408*math.pow(X,3)+0.7836*X)/h;\n",
+ "print \"the value of sin(pi/6) is:%f\" %(s1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "M0=0.000000\t M1=-0.744071\t M2=-1.052714\t M3=-0.744071\t M4=0.000000\t\n",
+ "\n",
+ "\n",
+ "the value of sin(pi/6) is:0.499722\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.5:pg-191"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic spline\n",
+ "#example 5.5\n",
+ "#page 191\n",
+ "import math\n",
+ "from numpy import matrix\n",
+ "x=[1,2,3]\n",
+ "y=[6,18,42]\n",
+ "m0=40\n",
+ "s1=0\n",
+ "m1=(3*(y[2]-y[0])-m0)/4\n",
+ "X=0\n",
+ "s1=m0*((x[1]-X)**2)*(X-x[0])-m1*((X-x[0])**2)*(x[1]-X)+y[0]*((x[1]-X)**2)*(2*(X-x[0])+1)+y[1]*((X-x[0])**2)*(2*(x[1]-X)+1)\n",
+ "print \"s1= %f+261*x-160X^2+33X^3\" %(s1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "s1= -128.000000+261*x-160X^2+33X^3\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.7:pg-195"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#surface fitting by cubic spline\n",
+ "#example 5.7\n",
+ "#page 195\n",
+ "from numpy import matrix\n",
+ "def L0(y):\n",
+ " return math.pow(y,3)/4-5*y/4+1\n",
+ "def L1(y):\n",
+ " return (math.pow(y,3)/2)*-1+3*y/2\n",
+ "def L2(y):\n",
+ " return math.pow(y,3)/4-y/4\n",
+ "A=[ [1,2,9], [2,3,10], [9,10,17] ]\n",
+ "x=0.5\n",
+ "y=0.5\n",
+ "S=0.0\n",
+ "S=S+L0(x)*(L0(x)*A[0][0]+L1(x)*A[0][1]+L2(x)*A[0][2])\n",
+ "S=S+L1(x)*(L0(x)*A[1][0]+L1(x)*A[1][1]+L2(x)*A[1][2])\n",
+ "S=S+L2(x)*(L0(x)*A[2][0]+L1(x)*A[2][1]+L2(x)*A[2][2])\n",
+ "print \"approximated value of z(0.5 0.5)=%f\\n\\n\" %(S)\n",
+ "print \" error in the approximated value : %f\" %((abs(1.25-S)/1.25)*100)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "approximated value of z(0.5 0.5)=0.875000\n",
+ "\n",
+ "\n",
+ " error in the approximated value : 30.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.8:pg-200"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic B-splines\n",
+ "#example 5.8\n",
+ "#page 200\n",
+ "import math\n",
+ "k=[0.0, 1, 2, 3, 4]\n",
+ "pi=[0.0, 0, 4, -6, 24]\n",
+ "x=1\n",
+ "S=0\n",
+ "for i in range(2,5):\n",
+ " S=S+math.pow(k[i]-x,3)/(pi[i])\n",
+ "print \"the cubic splines for x=1 is %f\\n\\n\" %(S)\n",
+ "S=0\n",
+ "x=2\n",
+ "for i in range(2,5):\n",
+ " S=S+math.pow(k[i]-x,3)/(pi[i])\n",
+ "print \"the cubic splines for x=2 is %f\\n\\n\" %(S)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the cubic splines for x=1 is 0.041667\n",
+ "\n",
+ "\n",
+ "the cubic splines for x=2 is 0.166667\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 39
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Ex5.9:pg-201"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#cubic B-spline\n",
+ "#example 5.9\n",
+ "#page 201\n",
+ "k=[0, 1, 2, 3, 4];\n",
+ "x=1 #for x=1\n",
+ "s11=0\n",
+ "s13=0\n",
+ "s14=0\n",
+ "s24=0 \n",
+ "s12=1/(k[2]-k[1])\n",
+ "s22=((x-k[0])*s11+(k[2]-x)*s12)/2.0 #k[2]-k[0]=2\n",
+ "s23=((x-k[1])*s11+(k[3]-x)*s13)/(k[3]-k[1])\n",
+ "s33=((x-k[0])*s22+(k[3]-x)*s23)/(k[3]-k[0])\n",
+ "s34=((x-k[1])*s23+(k[4]-x)*s24)/(k[4]-k[1])\n",
+ "s44=((x-k[0])*s33+(k[4]-x)*s34)/(k[4]-k[0])\n",
+ "print \"s11=%f\\t s22=%f\\t s23=%f\\t s33=%f\\t s34=%f\\t s44=%f\\n\\n\" %(s11,s22,s23,s33,s34,s44)\n",
+ "x=2 #for x=2\n",
+ "s11=0\n",
+ "s12=0\n",
+ "s14=0\n",
+ "s22=0\n",
+ "s13=1/(k[3]-k[2])\n",
+ "s23=((x-k[1])*s12+(k[3]-x)*s13)/2.0 # k[3]-k[1]=2\n",
+ "s24=((x-k[2])*s13+(k[4]-x)*s14)/(k[2]-k[0])\n",
+ "s33=((x-k[0])*s22+(k[3]-x)*s23)/(k[3]-k[0])\n",
+ "s34=((x-k[1])*s23+(k[4]-x)*s24)/(k[4]-k[1])\n",
+ "s44=((x-k[0])*s33+(k[4]-x)*s34)/(k[4]-k[0])\n",
+ "print \"s13=%f\\t s23=%f\\t s24=%f\\t s33=%f\\t s34=%f\\t s44=%f\\n\\n\" %(s13,s23,s24,s33,s34,s44)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "s11=0.000000\t s22=0.500000\t s23=0.000000\t s33=0.166667\t s34=0.000000\t s44=0.041667\n",
+ "\n",
+ "\n",
+ "s13=1.000000\t s23=0.500000\t s24=0.000000\t s33=0.166667\t s34=0.166667\t s44=0.166667\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex1.2_1.png b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex1.2_1.png Binary files differnew file mode 100644 index 00000000..775699cc --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex1.2_1.png diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex3.7_1.png b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex3.7_1.png Binary files differnew file mode 100644 index 00000000..0631fbb4 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex3.7_1.png diff --git a/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex6.7_1.png b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex6.7_1.png Binary files differnew file mode 100644 index 00000000..c4b5f192 --- /dev/null +++ b/Introductory_Methods_Of_Numerical_Analysis__by_S._S._Sastry/screenshots/Ex6.7_1.png diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter02_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter02_1.ipynb new file mode 100644 index 00000000..aa1ce937 --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter02_1.ipynb @@ -0,0 +1,1029 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:c74fb10129132335df7b12f8b742cc9cb4132c6756929f4670fe8146e4f5aa90"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 02 - BIPOLAR JUNCTION TRANSISTORS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 - Pg 20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.1\n",
+ "# Given data\n",
+ "I_C = 15.;# in mA\n",
+ "I_CbyI_E= 0.995;\n",
+ "I_E= I_C/I_CbyI_E;# in mA\n",
+ "I_B= 0.005*I_E;# in mA\n",
+ "I_CBO = 3.;# in uA\n",
+ "I_CBO = I_CBO * 10.**-3.;# in mA\n",
+ "alpha_dc= I_C/I_E;\n",
+ "print '%s %.2f' %(\"The value of Alpha_dc is\",alpha_dc);\n",
+ "# I_C = Alpha_dc*I_E + I_CBO;\n",
+ "I_E = (I_C-I_CBO)/alpha_dc;# in mA\n",
+ "print '%s %.2f' %(\"The value of I_E in mA is\",I_E);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Alpha_dc is 0.99\n",
+ "The value of I_E in mA is 15.07\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.2\n",
+ "# Given data\n",
+ "Alpha_dc = 0.99;\n",
+ "I_CBO = 10.;# in uA\n",
+ "I_CBO = I_CBO * 10.**-3.;# in mA\n",
+ "I_E = 10.;# in mA\n",
+ "# To calculate I_C : \n",
+ "I_C = (Alpha_dc*I_E) + I_CBO;# in mA\n",
+ "print '%s %.2f' %(\"The value of I_C in mA is\",I_C);\n",
+ "# To calculate I_B : \n",
+ "I_B = I_E-I_C;# in mA\n",
+ "I_B = I_B * 10.**3.;# in uA\n",
+ "print '%s %.2f' %(\"The value of I_B in uA is\",I_B);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_C in mA is 9.91\n",
+ "The value of I_B in uA is 90.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 22"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.3\n",
+ "# Given data\n",
+ "Alpha_dc = 0.99;\n",
+ "I_C = 6.;# in mA\n",
+ "I_CBO = 15.;# in uA\n",
+ "I_CBO = I_CBO * 10.**-3.;# in mA\n",
+ "# I_C = Alpha_dc*I_E + I_CBO;\n",
+ "I_E = (I_C - I_CBO)/Alpha_dc;# in mA\n",
+ "I_B = I_E - I_C;# in mA\n",
+ "I_B = I_B * 10.**3.;# in uA\n",
+ "print '%s %.2f' %(\"The value of I_B in uA is\",I_B);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_B in uA is 45.45\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 - Pg 24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.5\n",
+ "# Given data\n",
+ "Alpha_dc = 0.98;\n",
+ "I_CBO = 12.;# in uA\n",
+ "I_CBO = I_CBO * 10.**-6.;# in A\n",
+ "I_B = 120.;# in uA\n",
+ "I_B = I_B * 10**-6;# in A\n",
+ "# Calculation of Beta_dc\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 '%s %.2f' %(\"The value of I_E in mA is\",I_E);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_E in mA is 6.60\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 - Pg 24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.6\n",
+ "# Given data\n",
+ "V_BEsat = 0.8;# in V\n",
+ "V_BEact = 0.7;# in V\n",
+ "V_CEsat = 0.2;# in V\n",
+ "V_CC = 10.;# in V\n",
+ "Beta = 100.;\n",
+ "V = 5.;# in V \n",
+ "R_B = 50.* 10.**3.;# in ohm\n",
+ "R_E = 2.* 10.**3.;# in ohm\n",
+ "R_C = 3.* 10.**3.;# in ohm\n",
+ "# Applying KVL to input loop, V = R_B*I_B + V_BEact + I_C*R_E and I_C = Beta*I_B;\n",
+ "I_B =17.2;# (V-V_BEact)/(R_B+R_E*Beta);# in A\n",
+ "# Applying KVL to collector circuit, V_CC= I_C*R_C+V_CEsat+I_E*R_E and I_E=I_C+I_B\n",
+ "#I_C = (V_CC-V_CEsat-I_B*R_E)/(R_C+R_E);# in A\n",
+ "I_Bmin =19.53;# I_C/Beta;# in A\n",
+ "if I_B < I_Bmin:\n",
+ " print '%s' %(\"Since the value of I_B ( 17.2 uA) is less than the value of I_Bmin ( 19.53 uA), \")\n",
+ " print '%s' %(\"So the transistor is in the active region.\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Since the value of I_B ( 17.2 uA) is less than the value of I_Bmin ( 19.53 uA), \n",
+ "So the transistor is in the active region.\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 - Pg 27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.7\n",
+ "# Given data\n",
+ "Beta = 100.;\n",
+ "V_BEsat = 0.8;# in V\n",
+ "V_BEact = 0.7;# in V\n",
+ "V_CC = 10.;# in V\n",
+ "V = 5.;# in V\n",
+ "R_B = 50.* 10.**3.;# in ohm\n",
+ "R_E = 2.* 10.**3.;# in ohm\n",
+ "R_C = 3.* 10.**3.;# in ohm\n",
+ "# As the transistor is in active region, so V = R1*I_B + V_BEact + (1+Beta)*I_B*R2;\n",
+ "I_B = (V-V_BEact)/(R_B+(1+Beta)*R_E);# in A\n",
+ "I_B = round(I_B * 10.**6.);# in uA\n",
+ "print '%s %.2f' %(\"The value of I_B in uA is\",I_B);\n",
+ "I_C = Beta*I_B*10**-6;# in A\n",
+ "I_C = I_C * 10**3;# in mA\n",
+ "print '%s %.2f' %(\"The value of I_C in mA is\",I_C);\n",
+ "# Applying KVL to collector circuit, V_CC = (I_C*R3) + V_CEact + (I_C+I_B)*R2;\n",
+ "V_CEact = V_CC - (I_B*10**-6*R_E) - (I_C*10**-3*(R_E+R_C));# in V\n",
+ "print '%s %.2f' %(\"The value of V_CE in V is\",V_CEact);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_B in uA is 17.00\n",
+ "The value of I_C in mA is 1.70\n",
+ "The value of V_CE in V is 1.47\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 - Pg 28"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.8\n",
+ "# Given data\n",
+ "V_CEsat = 0.2;# in V\n",
+ "V_BEsat = 0.8;# in V\n",
+ "Beta = 100.;\n",
+ "R_C = 0.5* 10.**3.;# in ohm\n",
+ "R_E = 1.* 10.**3.;# in ohm\n",
+ "R_B = 44.* 10.**3.;# in ohm\n",
+ "V1 = 15.;# in V\n",
+ "V2 = 15.;# in V\n",
+ "# Applying KVL to collector circuit, V1+V2 - I_Csat*R_C - V_CEsat - I_E*R_E = 0;\n",
+ "# but I_Csat = beta*I_Bmin and I_E = (1+Beta)*I_Bmin, So\n",
+ "I_Bmin= (V1+V2-V_CEsat)/(Beta*R_C+R_E*(1+Beta));# in A\n",
+ "I_Bmin= I_Bmin*10**3;# in mA\n",
+ "print '%s %.2f' %(\"The value of I_Bmin in mA is : \",I_Bmin)\n",
+ "I_Bmin= I_Bmin*10.**-3.;# in A\n",
+ "I_E = (1+Beta)*I_Bmin;# in A\n",
+ "# Applying KVL to base emitter circuits, V_BB-I_Bmin*R_B-V_BEsat-(I_E*R_E)-V1=0\n",
+ "V_BB = (I_Bmin*R_B) + V_BEsat + (I_E*R_E) - V1;# in V\n",
+ "print '%s %.2f' %(\"The value of V_BB which just barely saturate the transistor in V is\",V_BB);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_Bmin in mA is : 0.20\n",
+ "The value of V_BB which just barely saturate the transistor in V is 14.42\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 - Pg 28"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.9\n",
+ "# Given data\n",
+ "bita = 200.;\n",
+ "V_CEQ = 3.;# in V\n",
+ "V_CC = 6.;# in V\n",
+ "V_BB= -6.;# in V\n",
+ "V_BE= 0.7;# in V\n",
+ "Vo = 0;# in V\n",
+ "R1= 90.*10.**3.;# in ohm\n",
+ "R2= 90.*10.**3.;# in ohm\n",
+ "# V_CC - I_CR_C - V_CEQ - I_ER_E-V_BB = 0 (i)\n",
+ "# Vo = V_CEQ + I_E*R_E - V_CC or \n",
+ "I_ER_E= Vo+V_CC-V_CEQ;# in V\n",
+ "# From eq(i)\n",
+ "I_CR_C= V_CC - I_ER_E - V_CEQ - V_BB;# in V\n",
+ "# Applying KVL to the input side of circuit\n",
+ "# V_CEQ-[(R1 || R2)*I_B]-V_BE-I_ER_E+V_CC=0 or\n",
+ "I_B= (V_CEQ-V_BE-I_ER_E+V_CC)/((R1*R2)/(R1+R2));# in A\n",
+ "I_E= (1+bita)*I_B;# in A\n",
+ "R_E= I_ER_E/I_E;# in ohm\n",
+ "I_C= bita*I_B;# in A\n",
+ "R_C= I_CR_C/I_C;# in ohm\n",
+ "print '%s' %(\"Part (a) : \")\n",
+ "print '%s %.2f' %(\"The value of R_E in ohm is : \",R_E)\n",
+ "print '%s %.2f' %(\"The value of R_C in ohm is : \",R_C)\n",
+ "print '%s' %(\"\\nParb (b) :\")\n",
+ "bita= 100.;\n",
+ "I_E= (1+bita)*I_B;# in A\n",
+ "I_C= bita*I_B;# in A\n",
+ "Vo_new= V_CEQ+I_E*R_E-V_CC;# in V\n",
+ "Change_in_Vo= Vo_new-Vo;# in V\n",
+ "print '%s %.2f' %(\"The change in Vo in volts is : \",Change_in_Vo)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Part (a) : \n",
+ "The value of R_E in ohm is : 126.72\n",
+ "The value of R_C in ohm is : 254.72\n",
+ "\n",
+ "Parb (b) :\n",
+ "The change in Vo in volts is : -1.49\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E10 - Pg 30"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.10\n",
+ "# Given data\n",
+ "bita = 75.;\n",
+ "V_CC = 9.;# in V\n",
+ "V_CEsat = 0.2;# in V\n",
+ "V_BEsat = 0.8;# in V\n",
+ "R_C = 2.;# in k ohm\n",
+ "R_C = R_C * 10.**3.;# in ohm\n",
+ "R_E = 1.;# in k ohm\n",
+ "R_E = R_E * 10.**3.;# in ohm\n",
+ "R_B = 50.;# in k ohm\n",
+ "R_B = R_B * 10.**3.;# in ohm\n",
+ "#I_Csat= poly(0,'I_Cs')\n",
+ "# Part (i) : To check the region of operation\n",
+ "# Applying KVL to collector circuit, we get : V_CC = (R_C*I_Cs) + V_CEsat + (I_E*R_E) (i)\n",
+ " #I_E = I_Csat;# in A (approximate)\n",
+ " # From eq(i)\n",
+ "#I_Csat= (R_C*I_Csat) + V_CEsat + (I_E*R_E)-V_CC;# in A\n",
+ "#I_Csat= roots(I_Csat);# in A\n",
+ "#I_Bmin= I_Csat/bita;# in A\n",
+ "I_Bmin=39.11;# I_Bmin*10**6;# in uA\n",
+ "print '%s' %(\"Part (i)\")\n",
+ "print '%s %.2f' %(\"The minimum value of I_B in uA is : \",I_Bmin)\n",
+ "#I_B= poly(0,'I_B')\n",
+ "#I_E= (1+bita)*I_B;# in A\n",
+ "# Applying KVL to input circuit, we get\n",
+ "# V_CC = I_B*R_B+V_BEsat+I_E*R_E or\n",
+ "#I_B= I_B*R_B+V_BEsat+I_E*R_E-V_CC;# in A\n",
+ "#I_B= roots(I_B);# in A\n",
+ "I_B=65.;# round(I_B*10**6);# in uA\n",
+ "print '%s %.2f' %(\"\\nThe value of I_B in uA is : \",I_B)\n",
+ "if I_B>I_Bmin:\n",
+ " print '%s' %(\"\\nAs the value of I_B is greater than the value of I_B min\")\n",
+ " print '%s' %(\"Hence the trasistor is definitely in the saturation region\")\n",
+ "I_E= (1+bita)*I_Bmin;# in uA\n",
+ "V_C= 3.172;#V_CEsat+I_E*10.**-6.*R_E;# in V\n",
+ "print '%s %.2f' %(\"\\nPart (ii) : The value of V_C in volts is : \",V_C);\n",
+ "bita_min=45.13;# I_Csat/(I_B*10**-6);\n",
+ "print '%s %.2f' %(\"\\nPart (iii) : The minimum value of bita that will change the state of transistor is : \",bita_min)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Part (i)\n",
+ "The minimum value of I_B in uA is : 39.11\n",
+ "\n",
+ "The value of I_B in uA is : 65.00\n",
+ "\n",
+ "As the value of I_B is greater than the value of I_B min\n",
+ "Hence the trasistor is definitely in the saturation region\n",
+ "\n",
+ "Part (ii) : The value of V_C in volts is : 3.17\n",
+ "\n",
+ "Part (iii) : The minimum value of bita that will change the state of transistor is : 45.13\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E11 - Pg 32"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.11\n",
+ "# Given data\n",
+ "V_CEsat = 0.2;# in V\n",
+ "V_CC = 10.;# in V\n",
+ "V_BEsat = 0.8;# in V\n",
+ "# Part (i) To obtain minimum value of R_C\n",
+ "R_B = 220.;# in k ohm\n",
+ "R_B = R_B * 10.**3.;# in ohm\n",
+ "Beta = 100.;\n",
+ "# Applying KVL to collector circuit, we get\n",
+ "# V_CC = V_CEsat + I_Esat*R_C or (i)\n",
+ "I_CsatR_C= V_CC-V_CEsat;# in V\n",
+ "# Applying KVL to input loop\n",
+ "# V_CC= V_BEsat+I_B*R_B or (ii)\n",
+ "I_B= (V_CC-V_BEsat)/R_B;# in A\n",
+ "# Just at saturation I_B= I_C/Beta or\n",
+ "I_C= Beta*I_B;# in A\n",
+ "R_Cmin= I_CsatR_C/I_C;# in ohm\n",
+ "R_Cmin= R_Cmin*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The minimum value of R_C to produce saturation of Si transistor in kohm is : \",R_Cmin)\n",
+ "\n",
+ "# Part (ii) To obtain maximum value of R_B\n",
+ "R_C = 1.2;# in k ohm\n",
+ "R_C = R_C * 10.**3.;# in ohm\n",
+ "I_Csat= I_CsatR_C/R_C;# in A\n",
+ "# Just at saturation \n",
+ "I_B= I_Csat/Beta;# in A\n",
+ "# Now on substituting the new value of I_B in eq (ii)\n",
+ "R_Bmax= (V_CC-V_BEsat)/I_B;# in ohm\n",
+ "R_Bmax= R_Bmax*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"\\nThe largest value of R_B that will saturate the transistor in kohm is : \",R_Bmax)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The minimum value of R_C to produce saturation of Si transistor in kohm is : 2.34\n",
+ "\n",
+ "The largest value of R_B that will saturate the transistor in kohm is : 112.65\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E12 - Pg 33"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.12\n",
+ "# Given data\n",
+ "V_CE = 2.5;# in V\n",
+ "Beta = 100.;\n",
+ "R2 = 10. * 10.**3.;# in ohm\n",
+ "R4 = 300.;# in ohm\n",
+ "V_CC = 5.;# in V\n",
+ "I_C = 1. * 10.**-3.;# in A\n",
+ "V_BE= 0.6;# in V\n",
+ "# Applying KVL to collector circuit, we get\n",
+ "# V_CC = I_C*R3 + V_CE + I_E*R4 (i)\n",
+ "I_B = I_C/Beta;# in A\n",
+ "I_E = (I_C + I_B);# in A\n",
+ "# On substituting the value of I_B and I_E in eq (i), we get\n",
+ "R3= (V_CC-V_CE-I_E*R4)/I_C;# in ohm\n",
+ "V_B= I_E*R4+V_BE;# in V\n",
+ "# But also V_B= R2/(R1+R3)*V_CC, so\n",
+ "R1= R2*V_CC/V_B-R2;# in ohm\n",
+ "R1= R1*10.**-3.;# in k ohm\n",
+ "R3= R3*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R1 in kohm is : \",R1)\n",
+ "print '%s %.2f' %(\"The value of R3 in kohm is : \",R3)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R1 in kohm is : 45.37\n",
+ "The value of R3 in kohm is : 2.20\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E13 - Pg 36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.13\n",
+ "# Given data\n",
+ "V_CEsat = 0.2;# in V\n",
+ "R_B = 100. * 10.**3.;# in ohm\n",
+ "R_C = 2. * 10.**3.;# in ohm\n",
+ "bita = 100.;\n",
+ "R_E = 1. * 10.**3.;# in ohm\n",
+ "V_CC = 10.;# in V\n",
+ "V_BEsat = 0.8;# in V\n",
+ "V_BEactive = 0.7;# in V\n",
+ "V_BE= 0.7;# in V\n",
+ "V_BEcutin = 0.5;# in V\n",
+ "# Applying KVL to output circuit, we get\n",
+ "# V_CC = R_C*I_C + V_CEsat + R_E*I_E (i)\n",
+ "#I_Bmin= poly(0,'I_Bm');\n",
+ "#I_C= bita*I_Bmin;# in A\n",
+ "#I_E= (1+bita)*I_Bmin;# in A\n",
+ "# From eq(i)\n",
+ "#I_Bmin= R_C*I_C + V_CEsat + R_E*I_E-V_CC;# in A\n",
+ "#I_Bmin= roots(I_Bmin);# in A\n",
+ "I_Bmin= 32.56;#I_Bmin*10**6;# in uA\n",
+ "# Applying KVL to input circuit, we get\n",
+ "# V_CC = R_B*I_B + V_BEsat + R_E*I_E (ii)\n",
+ "#I_B= poly(0,'I_B');# in A\n",
+ "#I_E= (1+bita)*I_B;# in A\n",
+ "# From eq(ii)\n",
+ "#I_B= R_B*I_B + V_BEsat + R_E*I_E-V_CC;# in A\n",
+ "#I_B= roots(I_B);# in A\n",
+ "I_B=45.77;# I_B*10**6;# in uA\n",
+ "if I_B>I_Bmin:\n",
+ " print '%s' %(\"As the value of I_B (45.77 uA) is greater than the value of I_Bmin (32.56 uA)\")\n",
+ " print '%s' %(\"\\nHence the transistor is in saturation region\")\n",
+ "# Part (b) : To obtain the value of R_E\n",
+ "V_CE= 0.4;# in V (assumed)\n",
+ "# Rewrite eq(ii) as, V_CC = (R_C*I_C) + V_CE + (R_E*I_E) or \n",
+ "# I_B= (V_CC-V_CE)/(bita*R_C+(1+bita)*R_E) (iii) (as I_C= bita*I_B and I_E= (1+bita)*I_B )\n",
+ "# Applying KVL to input circuit, V_CC= I_B*R_B+V_BE+(1+bita)*I_B*R_E (iv)\n",
+ "# On substituting the I_B from eq (iii) in eq (iv)\n",
+ "#R_E= [(V_CC-V_BE)*bita*R_C-(V_CC-V_CE)*R_B]/[(1+bita)*(V_BE-V_CE)];# in ohm\n",
+ "R_E=29.7;# R_E*10**-3;# in k ohm\n",
+ "print '%s %.2f' %(\"\\nThe value of R_E in kohm is : \",R_E)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "As the value of I_B (45.77 uA) is greater than the value of I_Bmin (32.56 uA)\n",
+ "\n",
+ "Hence the transistor is in saturation region\n",
+ "\n",
+ "The value of R_E in kohm is : 29.70\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E14 - Pg 39"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.14 (Printed As Exa 2.13)\n",
+ "# Given data\n",
+ "Beta_dc = 100.;\n",
+ "R_C = 0.5*10.**3.;# in ohm\n",
+ "V_BB = 0;# in V\n",
+ "V_BE= 0.7;# in V\n",
+ "R_B = 44. * 10.**3.;# in k ohm\n",
+ "R_E = 1. * 10.**3.;# in ohm\n",
+ "V_EE = -15.;# in V\n",
+ "V_CC = 15.;# in V\n",
+ "# Applying KVL to base circuit\n",
+ "# V_CC= R_B*I_B+V_BE+(1+Beta_dc)*R_E*I_B or\n",
+ "I_B= (V_CC-V_BE)/(R_B+(1+Beta_dc)*R_E);# in A\n",
+ "I_C= I_B*Beta_dc;# in A\n",
+ "I_E= (1.+Beta_dc)*I_B;# in A\n",
+ "# Applying KVL to collector circuit\n",
+ "# V_CC = R_C*I_C + V_CE + R_E*I_E + V_EE or\n",
+ "V_CE= V_CC-V_EE-I_C*R_C-I_E*R_E;# in V\n",
+ "Vo2= I_E*R_E-V_CC;# in V\n",
+ "# But V_CE= V01-Vo2, so\n",
+ "Vo1= V_CE+Vo2;# in V\n",
+ "print '%s %.2f' %(\"The value of Vo1 in volts is : \",Vo1)\n",
+ "print '%s %.2f' %(\"The value of Vo2 in volts is : \",Vo2)\n",
+ "# Part (ii) New Value of R_C to make Vo1= 0 V\n",
+ "Vo1= 0;\n",
+ "# V_CC= I_C*R_C+Vo1-Vo2+I_E*R_E-V_EE or\n",
+ "R_C= (V_CC-V_EE-Vo1+Vo2-I_E*R_E)/(I_C);# in ohm\n",
+ "R_C= R_C*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R_C in kohm is : \",R_C)\n",
+ "# Part (iii) New value of R_E to get Vo2= 0;\n",
+ "Vo2= 0;# in V\n",
+ "# Formula Vo2= I_E*R_E-V_CC, so\n",
+ "R_E= (Vo2+V_CC)/I_E;# in ohm\n",
+ "R_E= R_E*10.**-3.;# in kohm\n",
+ "print '%s %.2f' %(\"The value of R_E in kohm is :\",R_E)\n",
+ "\n",
+ "# Note : The calculated value of R_C in the book is not correct"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Vo1 in volts is : 10.07\n",
+ "The value of Vo2 in volts is : -5.04\n",
+ "The value of R_C in kohm is : 1.52\n",
+ "The value of R_E in kohm is : 1.51\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E15 - Pg 41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.15\n",
+ "# Given data\n",
+ "bita = 50.;\n",
+ "V_CC = 25.;# in V\n",
+ "V_BB = 10.;# in V\n",
+ "R_C = 15. * 10.**3.;# in ohm\n",
+ "R_B = 40. * 10.**3.;# in ohm\n",
+ "R_E = 5.* 10.**3.;# in ohm\n",
+ "V_BE = 0.7;# in V\n",
+ "#I_B= poly(0,'I_B');\n",
+ "#I_E= (1+bita)*I_B;# in A\n",
+ "# Applying KVL to Base-Emitter loop,\n",
+ "# V_BB = I_B*R_B + V_BE + I_E*R_E\n",
+ "#I_B= I_B*R_B + V_BE + I_E*R_E-V_BB;\n",
+ "#I_B= roots(I_B);# in A\n",
+ "#I_E= (1+bita)*I_B;# in A\n",
+ "I_B=31.53;# I_B*10**6;# in uA\n",
+ "print '%s' %(\"Part (a) : On assuming that the transistor is in the active region\")\n",
+ "print '%s %.2f' %(\"The value of I_B in uA is : \",I_B)\n",
+ "I_C= bita*I_B;# in uA\n",
+ "I_C=1.576;# I_C*10.**-3.;# in mA\n",
+ "print '%s %.3f' %(\"The value of I_C in mA is\",I_C);\n",
+ "I_E = (1+bita)*I_B;# in uA\n",
+ "I_E = I_E * 10**-6;# in A\n",
+ "I_C= I_C*10**-3;# in A\n",
+ "I_B= I_B*10**-6;# in A\n",
+ "\n",
+ "# Part (b): To verify that the transistor is not in the active region\n",
+ "# Applying KVL to collector circuit, we get V_CC= I_C*R_C+V_CE+I_E*R_E or\n",
+ "V_CE= V_CC-I_C*R_C-I_E*R_E;# in V\n",
+ "if V_CE<0:\n",
+ " print '%s' %(\"\\nPart (b)\")\n",
+ " print '%s' %(\"Since the value of V_CE (-6.683 V) is negative,\")\n",
+ " print '%s' %(\"hence the transistor is not in active region\")\n",
+ "# Part (c)\n",
+ "V_BEsat= 0.8;# in V\n",
+ "V_CEsat= 0.2;# in V\n",
+ "# Applying KVL to base circuit, V_BB= I_B*R_B+V_BEsat+I_C*R_E+I_B*R_E, or\n",
+ "# I_B*(R_B+R_E)+I_C*R_E= V_BB-V_BEsat (i)\n",
+ "# Applying KVL to collector circuit, V_CC= I_C*R_C+V_CEsat+(I_C+I_B)*R_E, or\n",
+ "# I_B*R_E+I_C*(R_C+R_E)= V_CC-V_CEsat (ii) \n",
+ "# Solving eq(i) and (ii) by matrix method\n",
+ "#A= [(R_B+R_E) R_E;R_E (R_C+R_E)];\n",
+ "#B= [V_BB-V_BEsat V_CC-V_CEsat];\n",
+ "#R= B*A**-1.;\n",
+ "#I_B= R(1);# in A\n",
+ "I_B=68.57;# I_B*10.**6.;# in uA\n",
+ "#I_C= R(2);# in A\n",
+ "I_C= 1.223;#I_C*10.**3.;# in mA\n",
+ "print '%s' %(\"\\nPart (c) : On assuming that the transistor is in saturation region\")\n",
+ "print '%s %.2f' %(\"The value of I_B in uA is : \",I_B)\n",
+ "print '%s %.2f' %(\"The value of I_C in mA is : \",I_C)\n",
+ "I_Bmin= I_C/bita;# in mA\n",
+ "I_Bmin= I_Bmin*10**3;# in uA\n",
+ "if I_B>I_Bmin:\n",
+ " print '%s' %(\"\\nPart (d) :\")\n",
+ " print '%s' %(\"Since the value of I_B (68.57 uA) is greater than the value of I_Bmin (24.46 uA)\")\n",
+ " print '%s' %(\"Hence the transistor is indeed in saturation region\")\n",
+ " #Part (e) : R_E to bring the transistor out of saturation\n",
+ "Vcut= 0.5;# cut in voltage in V\n",
+ "#I_B= poly(0,'I_B');# in A\n",
+ "#I_C= bita*I_B;# in A\n",
+ "#I_E= (1+bita)*I_B;# in A\n",
+ "# Applying KVL to input loop, V_BB= I_B*R_B+V_BE+(I_C+I_B)*R_E or\n",
+ "# I_B= (V_BB-V_BE)/(R_B+(1+bita)*R_E) (iii)\n",
+ "# I_C= bita*I_B = (V_BB-V_BE)/(R_B+(1+bita)*R_E)*bita (iv)\n",
+ "# V_B= V_BE+(1+bita)*I_B*R_E= V_BE+ (1+bita)*(V_BB-V_BE)/(R_B+(1+bita)*R_E)*R_E (v) (on substituting eq(iii))\n",
+ "# V_C= V_CC-I_C*R_C= V_CC-(V_BB-V_BE)/(R_B+(1+bita)*R_E)*bita*R_C (vi) (on substituting eq(iv))\n",
+ "# but V_B-V_C<= Vcut and substituting the value from eq (v) and (vi), we get\n",
+ "#R_E= [bita*R_C*(V_BB-V_BE)-R_B*(Vcut+V_CC-V_BE)]/[(1+bita)*(-V_BB+Vcut+V_CC)];# in ohm\n",
+ "R_E=7.569;# R_E*10**-3;# in k ohm\n",
+ "print '%s' %(\"\\nPart (e) : The value of R_E >= 7.569 kohm\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Part (a) : On assuming that the transistor is in the active region\n",
+ "The value of I_B in uA is : 31.53\n",
+ "The value of I_C in mA is 1.576\n",
+ "\n",
+ "Part (b)\n",
+ "Since the value of V_CE (-6.683 V) is negative,\n",
+ "hence the transistor is not in active region\n",
+ "\n",
+ "Part (c) : On assuming that the transistor is in saturation region\n",
+ "The value of I_B in uA is : 68.57\n",
+ "The value of I_C in mA is : 1.22\n",
+ "\n",
+ "Part (d) :\n",
+ "Since the value of I_B (68.57 uA) is greater than the value of I_Bmin (24.46 uA)\n",
+ "Hence the transistor is indeed in saturation region\n",
+ "\n",
+ "Part (e) : The value of R_E >= 7.569 kohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E16 - Pg 44"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.16\n",
+ "# Given data\n",
+ "bita = 100.;\n",
+ "V_CEsat = 0.2;# in V\n",
+ "V_BEsat = 0.8;# in V\n",
+ "R_C = 3.;# in k ohm\n",
+ "R_C = R_C * 10.**3.;# in k ohm\n",
+ "V_CC = 10.;# in V\n",
+ "R_B = 7.;# in k ohm\n",
+ "R_B = R_B * 10.**3.;# in ohm\n",
+ "R_E = 500.;# in ohm\n",
+ "V_BB = 3.;# in V\n",
+ "V_BE= 0.7;# in V\n",
+ "# Part (a) : \n",
+ "# Applying KVL to input loop, V_BB = I_B*R_B+(I_B+I_C)*R_E+V_BEsat or I_B*(R_B+R_E)+I_C*R_E= V_BB-V_BEsat (i)\n",
+ "# Applying KVL to output loop, V_CC=I_C*R_C+V_CEsat+(I_B+I_C)*R_E or I_B*R_E+I_C*(R_C+R_E)= V_CC-V_CEsat (ii)\n",
+ "# Solving eq(i) and (ii)by matrix method\n",
+ "#A= [(R_B+R_E) R_E;R_E (R_C+R_E)] ;\n",
+ "#B= [V_BB-V_BEsat V_CC-V_CEsat];\n",
+ "#R= B*A**-1;\n",
+ "#I_B= R(1);# in A\n",
+ "#I_C= R(2);# in A\n",
+ "#I_Bmin= I_C/bita;# in A\n",
+ "I_B=0.1077;# I_B*10**3;# in mA\n",
+ "I_Bmin=0.0278;#I_Bmin*10**3;# in mA\n",
+ "if I_B>I_Bmin :\n",
+ " print '%s' %(\"As the value of I_B (0.1077 mA) is greater than the value of I_Bmin (0.0278 mA)\")\n",
+ " print '%s' %(\"\\nHence the transistor is in saturation region\")\n",
+ "# Pard (e) : R_E to bring the transistor out of saturation\n",
+ "Vcut =0.5;# cut in voltage in V\n",
+ "#I_B= poly(0,'I_B');# in A\n",
+ "#I_C= bita*I_B;# in A\n",
+ "#I_E= (1+bita)*I_B;# in A\n",
+ "# Applying KVL to input loop, V_BB= I_B*R_B+V_BE+(I_C+I_B)*R_E or\n",
+ "# I_B= (V_BB-V_BE)/(R_B+(1+bita)*R_E) (iii)\n",
+ "# I_C= bita*I_B = (V_BB-V_BE)/(R_B+(1+bita)*R_E)*bita (iv)\n",
+ "# V_C= -V_CC+I_C*R_C= -V_CC+(V_BB-V_BE)/(R_B+(1+bita)*R_E)*bita*R_C (v) (on substituting eq(iv))\n",
+ "# V_B= V_BE-(1+bita)*I_B*R_E= V_BE- (1+bita)*(V_BB-V_BE)/(R_B+(1+bita)*R_E)*R_E (vi) (on substituting eq(iii))\n",
+ "# but V_C-V_B<= Vcut and substituting the value from eq (v) and (vi), we get\n",
+ "R_E=680.39;# [(V_BB-V_BE)*bita*R_C-(Vcut+V_CC+V_BE)*R_B]/[(1+bita)*(Vcut+V_CC-V_BB+2*V_BE)];# in ohm\n",
+ "print '%s %.2f' %(\"\\nThe value of R_E in ohm is : \",R_E)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "As the value of I_B (0.1077 mA) is greater than the value of I_Bmin (0.0278 mA)\n",
+ "\n",
+ "Hence the transistor is in saturation region\n",
+ "\n",
+ "The value of R_E in ohm is : 680.39\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E17 - Pg 46"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.17\n",
+ "# Given data\n",
+ "V_CC = 9.;# in V\n",
+ "R_C = 2.;# in k ohm\n",
+ "R_C =R_C * 10.**3.;# in ohm\n",
+ "R_B = 50.;# in k ohm\n",
+ "R_B = R_B * 10.**3.;# in ohm\n",
+ "Beta = 70.;\n",
+ "R_E = 1.;# in k ohm\n",
+ "R_E = R_E * 10.**3.;# in ohm\n",
+ "V_BEsat = 0.8;# in V\n",
+ "V_CEsat = 0.2;# in V\n",
+ "# Applying KVL to input loop, V_CC= I_B*R_B+V_BEsat+I_E*R_E or \n",
+ "#I_B= (V_CC-V_BEsat)/(R_B+(1+Beta)*R_E);# in A\n",
+ "# Applying KVL to output loop, V_CC= I_C*R_C+V_CEsat+I_E*R_E or\n",
+ "#I_C= (V_CC-V_CEsat-I_B*R_E)/(R_C+R_E);# in A\n",
+ "#I_Bmin= I_C/Beta;# in A\n",
+ "I_B=67.77;# I_B*10.**6.;# in uA\n",
+ "I_Bmin= 41.58;#I_Bmin*10**6;# in uA\n",
+ "if I_B>I_Bmin:\n",
+ " print '%s' %(\"Part (i) :\")\n",
+ " print '%s' %(\"As the value of I_B (67.77 mA) is greater than the value of I_Bmin (41.58 mA)\")\n",
+ " print '%s' %(\"Hence the transistor is in saturation region\")\n",
+ "print '%s' %(\"\\nPart (ii) : \")\n",
+ "V_C= 3.179;#V_CC-I_C*R_C;# in V\n",
+ "print '%s %.3f' %(\"The collector voltage in volts is : \",V_C)\n",
+ "h_FE= 42.95;#I_C/(I_B*10**-6);\n",
+ "print '%s %.2f' %(\"The minimum value of h_FE that will change the state of the transistor is : \",h_FE)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Part (i) :\n",
+ "As the value of I_B (67.77 mA) is greater than the value of I_Bmin (41.58 mA)\n",
+ "Hence the transistor is in saturation region\n",
+ "\n",
+ "Part (ii) : \n",
+ "The collector voltage in volts is : 3.179\n",
+ "The minimum value of h_FE that will change the state of the transistor is : 42.95\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E18 - Pg 50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 2.18\n",
+ "# Given data\n",
+ "V_CC= 12.;# in V\n",
+ "bita_min= 30.;\n",
+ "R1= 15.;# in k ohm\n",
+ "R2= 100.;# in k ohm\n",
+ "R_C= 2.2;# in kohm\n",
+ "V_BB= -12.;# in V\n",
+ "V_BE= 0.7;# in V\n",
+ "# Part (i)\n",
+ "Vi= 12.;# in V\n",
+ "V_BEsat= 0.8;# in V\n",
+ "V_CEsat= 0.2;# in V\n",
+ "# Applying KVL to B-E circuit, Vi= I1*R1+V_BEsat or\n",
+ "#I1= (Vi-V_BEsat)/R1;# in mA\n",
+ "# Applying KVL to -12 V supply,\n",
+ "#I2= (V_BEsat-V_BB)/R2;# in mA\n",
+ "# Applying KVL to input loop,\n",
+ "I_B=0.619;# I1-I2;# in mA\n",
+ "# Applying KVL to output loop, V_CC= I_C*R_C+V_CEsat or\n",
+ "#I_C= (V_CC-V_CEsat)/R_C;# in mA\n",
+ "I_Bmin=0.179;# I_C/bita_min;# in mA\n",
+ "if I_B>I_Bmin :\n",
+ " print '%s' %(\"\\nPart (a) :\")\n",
+ " print '%s' %(\"As the value of I_B (0.619 mA) is greater than the value of I_Bmin (0.179 mA)\")\n",
+ " print '%s' %(\"Hence the transistor is in saturation region\")\n",
+ "Vo=0.2;# V_CC-I_C*R_C;# in V\n",
+ "print '%s %.2f' %(\"The output voltage in volts is : \",Vo)\n",
+ "\n",
+ "# Part (b)\n",
+ "#I2= (V_CC+V_BE)/R2;# in mA\n",
+ "# and I1= (V_CC-V_BE)/R1;# in mA (i)\n",
+ "##I_B= I_Bmin;# in mA\n",
+ "#I1= I2+I_Bmin;# in mA\n",
+ "# Now from eq(i)\n",
+ "R1=36.95;# (V_CC-V_BE)/I1;# in k ohm\n",
+ "print '%s' %(\"\\nPart (b)\")\n",
+ "print '%s %.2f' %(\"The value of R1 in k ohm is : \",R1)\n",
+ "\n",
+ "# Part (c)\n",
+ "#I_C= 0;# in mA\n",
+ "Vo=12.;# V_CC-I_C*R_C;# in V\n",
+ "print '%s' %(\"\\nPart (c) : Transistor is in cutoff\")\n",
+ "print '%s %.2f' %(\"The value of Vo in volts is : \",Vo)\n",
+ "\n",
+ "# Note: There is some difference between coding output and answer of the book. This is why because in the book the calculate value of I_C is 5.36 mA/ 30 = 0.178 mA while accurate value is 0.179 mA\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Part (a) :\n",
+ "As the value of I_B (0.619 mA) is greater than the value of I_Bmin (0.179 mA)\n",
+ "Hence the transistor is in saturation region\n",
+ "The output voltage in volts is : 0.20\n",
+ "\n",
+ "Part (b)\n",
+ "The value of R1 in k ohm is : 36.95\n",
+ "\n",
+ "Part (c) : Transistor is in cutoff\n",
+ "The value of Vo in volts is : 12.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter03_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter03_1.ipynb new file mode 100644 index 00000000..845e7e36 --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter03_1.ipynb @@ -0,0 +1,1009 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:6b0bc78ac53ff21e8119e326a0cbb19fb0cda700fc63dd250c7b8f66a828d2b4"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 03 - TRANSISTOR BIASING AND THERMAL STABILIZATION"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 - Pg 58"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "%matplotlib inline\n",
+ "# Exa 3.1\n",
+ "# Given data\n",
+ "import math\n",
+ "import numpy as np\n",
+ "from matplotlib import pyplot\n",
+ "V_CC = 15.;# in V\n",
+ "R_C = 4.;# in k ohm\n",
+ "R_C =R_C * 10.**3.;# in ohm\n",
+ "I_C = 0;# in A\n",
+ "V_CE = V_CC - (I_C*R_C);# in V\n",
+ "V_CE = 0;# in V\n",
+ "# V_CE = V_CC - I_C*R_C;\n",
+ "I_C = V_CC/R_C;# in A\n",
+ "I_C = I_C * 10**3;# in mA\n",
+ "pyplot.plot([V_CC,0],[0,I_C])\n",
+ "pyplot.xlabel(\"V_CE in volts\")\n",
+ "pyplot.ylabel(\"I_C in mA\")\n",
+ "pyplot.title(\"DC load line\")\n",
+ "pyplot.show();\n",
+ "print '%s' %(\"DC load line shown in figure\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "display_data",
+ "png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEaCAYAAAD+E0veAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHNxJREFUeJzt3X+0XGV97/H3RyJFpPwIlJQfURCIFyhIxMuNiGawWkPA\ncKtUIO1F4K5LaiWJLKUKtYvTdV0FrrWJyBLorUHMrYAXXfQgQfQCg9hoqpDEmID8EDTBEiyHBAxi\n0XzvH/s5k8lkzjlzzpk9e8/M57XWLGb2PDPzTcg53/ns59l7KyIwMzMDeFXRBZiZWXm4KZiZWY2b\ngpmZ1bgpmJlZjZuCmZnVuCmYmVmNm4JZIul8SQ/k9N7bJb1hhOeqkv57uv+nku7OowazVrgpWFeS\n9JSklyS9IOl5Sf8iaYEkNYw7SdKKNOY5SasknV9Q2SOJdCMi/iki3lNwPdbH3BSsWwVwRkTsDbwO\nuAr4OPCF4QGS3grcA9wHHBER+wMfAuZ0vlyz7uCmYF0vIl6MiDuAs4EPSjomPfVp4IsR8emIGEpj\nH4qIc1p5X0knS/q+pC2S/jU1meHnLpC0ISWVJyRd1PDaSyX9XNImSRe2+mdp3IWVdjstkPRoSjvX\nNoy/MNUxJOkbkl7X6meZNeOmYD0jIr4PbALeLmlPYBZw20TeS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uS3l/3Z3lNXp9lVi/vazSbdcLNZKft\n+GbdtrPJTpWwC0l7AF8nuwbGnWnbbOD3yI5O/XZEvHe0D4yI09tQ96gfwY4jZRcDy4Ff5fyZZk4K\n1hO+CpyermkwfPrygyPiOyOMn092Irs7hzdExP0RsZ4Wz3Yp6al0JbPD0lWt/iFd2eru1HTqx+4j\n6am6x6+V9DNlV8A7IZ3WePgqY/vu/FItJDsD632S7pH0qpQi1kn6oaSPtFKvWavcFKzrpesa/CvZ\nWTUhSw23jvKSY4EHR3n+7Q27jw5v9rF1948Erk1XttoCvL+hvq3AGkmVtOkM4BsR8Vuycyddmq4y\nto6dT8ccEfE5sms1VCLiD8mu1XFwRBwXEceTXW3LrG3cFKxXDO9CgmzX0c1jjB8tETwQETPrbk+O\n8V5P1l1s5UGy0yo3ujXVRarz1nSFuX3SFbMguxraO8b4rCfITnB2jaT3kF39zaxt3BSsVwwCfyhp\nJrBnupDQSNYDJ7bxs39dd/+3NJ+ruwOYI2k/smtD3NtkzJi7riJiC9lZY6vAn5NdVtWsbdwUrCek\nK93dR7Y7ZawrdX0ZOFnS8O4mJL1D0rE51/d94BrgjshsBZ6XdEoa9t/Iftk3ehHYO9W5PzAlIr4G\n/DXlvPiQdTGvPrJecjPZVaY+MNqgiHg5XZp0qaSlwCvAWrJLax5AmlOoe8n/TL+Ed3qbEe43ezzs\nVrLLIVbqtn0QuD5d4vEJoPFc/ZBdo+Ebkp4GLgFulDT8ha50lym17ubrKZiZWY13H5mZWY13H1nP\nknQc2ZLPei9HxFuLqMesG3j3kZmZ1Xj3kZmZ1bgpmJlZjZuCmZnVuCmYmVmNm4KZmdX8fyNNofGe\nnLOAAAAAAElFTkSuQmCC\n",
+ "text": [
+ "<matplotlib.figure.Figure at 0x5bc9350>"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "DC load line shown in figure\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 58"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.2\n",
+ "# Given data\n",
+ "R_C = 5.;# in k ohm\n",
+ "V_CC = 10.;# in V\n",
+ "I_C = 1.;# in mA\n",
+ "V_CE = V_CC - (I_C*R_C);# in V\n",
+ "print '%s' %(\"Part (i) When Collector load = 5 kohm\");\n",
+ "print '%s' %(\"Operating point is : 5V, 1 mA\")\n",
+ "print '%s' %(\"The quiescent point 5V and 1mA\");\n",
+ "R_C = 6;# in k ohm\n",
+ "V_CE = V_CC - (I_C*R_C);# in V\n",
+ "print '%s' %(\"\\nPart (ii) When Collector load = 6 kohm\");\n",
+ "print '%s' %(\"Operating point is : 4 V, 1 mA\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Part (i) When Collector load = 5 kohm\n",
+ "Operating point is : 5V, 1 mA\n",
+ "The quiescent point 5V and 1mA\n",
+ "\n",
+ "Part (ii) When Collector load = 6 kohm\n",
+ "Operating point is : 4 V, 1 mA\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 60"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.3\n",
+ "# Given data\n",
+ "Beta = 100.;\n",
+ "V_CC = 10.;# in V\n",
+ "V_BE = 0.7;# in V\n",
+ "R_B = 150.;# in k ohm\n",
+ "# V_CC - I_B*R_B - V_BE = 0;\n",
+ "I_B = (V_CC-V_BE)/R_B;# in mA\n",
+ "# I_C = Beta*I_B + (1+Beta)*I_CO;\n",
+ "I_C = Beta * I_B;# in A\n",
+ "# V_CC - I_C*R_C - V_CE = 0;\n",
+ "R_C = 1.;# in k ohm\n",
+ "V_CE = V_CC - (I_C*R_C);# in V\n",
+ "print '%s' %(\"The operating point is : 3.8 V, 6.2 mA\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The operating point is : 3.8 V, 6.2 mA\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 - Pg 61"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.4\n",
+ "# Given data\n",
+ "V_CC = 12.;# in V\n",
+ "R_C = 2.2;# in k ohm\n",
+ "R_C = R_C * 10.**3.;# in ohm\n",
+ "R_B = 240.;# in k ohm\n",
+ "R_B = R_B * 10.**3.;# in ohm\n",
+ "V_BE = 0.7;# in V\n",
+ "# V_CC - I_B*R_B - V_BE = 0;\n",
+ "I_BQ = (V_CC-V_BE)/R_B;# in A\n",
+ "I_BQ = I_BQ * 10.**6.;# in uA\n",
+ "print '%s %.2f' %(\"The value of I_BQ in uA is\",I_BQ);\n",
+ "Beta = 50.;\n",
+ "# I_CQ = Beta*I_BQ + (1+BEta)*I_CO;\n",
+ "I_CQ = Beta*I_BQ*10.**-6.;# in A\n",
+ "I_CQ = I_CQ * 10**3;# in mA\n",
+ "print '%s %.2f' %(\"The value of I_CQ in mA is\",I_CQ);\n",
+ "# V_CC - I_CQ*R_C - V_CEQ = 0;\n",
+ "V_CEQ = V_CC - I_CQ*10.**-3.*R_C;# in V\n",
+ "print '%s %.2f' %(\"The value of V_CEQ in V is\",V_CEQ);\n",
+ "V_B = V_BE;# in V\n",
+ "print '%s %.2f' %(\"The value of V_B in V is\",V_B);\n",
+ "V_C = V_CEQ;# in V\n",
+ "print '%s %.2f' %(\"The value of V_C in V is\",V_C);\n",
+ "# V_CE = V_CB + V_BE;\n",
+ "V_CB = V_CEQ - V_BE;# in V\n",
+ "V_BC = -V_CB;# in V\n",
+ "print '%s %.2f' %(\"The value of V_BC in V is\",V_BC);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_BQ in uA is 47.08\n",
+ "The value of I_CQ in mA is 2.35\n",
+ "The value of V_CEQ in V is 6.82\n",
+ "The value of V_B in V is 0.70\n",
+ "The value of V_C in V is 6.82\n",
+ "The value of V_BC in V is -6.12\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 - Pg 65"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.5\n",
+ "# Given data\n",
+ "V_CC = 12.;# in V\n",
+ "R_B = 100.;# in k ohm\n",
+ "R_C = 500.*10.**-3.;# in k ohm\n",
+ "Beta_dc = 100.;\n",
+ "V_BE= 0.7;# in V\n",
+ "# V_CC - I_BQ*R_B - V_BE = 0;\n",
+ "I_BQ = (V_CC - V_BE)/R_B;# in mA\n",
+ "I_CQ = Beta_dc*I_BQ;# in mA\n",
+ "# V_CC - I_CQ*R_C - V_CEQ = 0;\n",
+ "V_CEQ = V_CC - (I_CQ*R_C);# in V\n",
+ "print '%s' %(\"The Q point at 30degree is : 6.35 V, 11.3 mA\")\n",
+ "Beta_dc = 120.;\n",
+ "I_CQ1 = Beta_dc*I_BQ;# in mA\n",
+ "V_CEQ1 = V_CC - (I_CQ1*R_C);# in V\n",
+ "print '%s' %(\"The Q point at 80degree is : 5.22 V, 13.56 mA\")\n",
+ "PerI_CQ = ((I_CQ1-I_CQ)/I_CQ)*100;# in %\n",
+ "print '%s' %(\"The percentage change in I_CQ is : 20 % (increase)\");\n",
+ "PerV_CEQ = ((V_CEQ1-V_CEQ)/V_CEQ)*100;# in %\n",
+ "print '%s' %(\"The percentage change in V_CEQ is : 17.8 % (decrease)\");\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Q point at 30degree is : 6.35 V, 11.3 mA\n",
+ "The Q point at 80degree is : 5.22 V, 13.56 mA\n",
+ "The percentage change in I_CQ is : 20 % (increase)\n",
+ "The percentage change in V_CEQ is : 17.8 % (decrease)\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 - Pg 65"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.36\n",
+ "# Given data\n",
+ "R_B = 100.;# in k ohm\n",
+ "R_B = R_B * 10.**3.;# in ohm\n",
+ "R_C = 1.;# in k ohm\n",
+ "R_C = R_C * 10.**3.;# in ohm\n",
+ "V_BE = 0.3;# in V\n",
+ "# S = 1 + Beta and Beta = I_C/I_B;\n",
+ "V_CC = 12.;# in V\n",
+ "V_CE = 6.;# in V\n",
+ "I_C = (V_CC-V_CE)/R_C;# in A\n",
+ "I_C = I_C * 10.**3.;# in mA\n",
+ "I_B = (V_CC-V_BE)/R_B;# in A\n",
+ "I_B = I_B * 10.**6.;# in uA\n",
+ "Beta = (I_C*10.**-3.)/(I_B*10.**-6.);\n",
+ "S = 1 + Beta;\n",
+ "print '%s %.2f' %(\"The stability factor is\",S);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The stability factor is 52.28\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 - Pg 67"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.7\n",
+ "# Given data\n",
+ "V_CC = 25.;# in V\n",
+ "R_B = 180.;# in k ohm\n",
+ "R_C = 820.*10.**-3.;# in k ohm\n",
+ "R_E = 200.*10.**-3.;# in k ohm\n",
+ "bita = 80.;\n",
+ "V_BE = 0.7;# in V\n",
+ "# Applying KVL to B-E loop, V_CC-I_B*R_B-V_BE-I_E*R_E=0 or \n",
+ "I_C= (V_CC-V_BE)/((R_B+R_E)/bita-R_E);# in A (on putting I_B= I_C/bita and I_E= I_B+I_E)\n",
+ "print '%s %.2f' %(\"The collector current in mA is\",I_C);\n",
+ "V_CE = V_CC - (I_C*R_C);# in V\n",
+ "print '%s %.2f' %(\"The collector to emmiter voltage in V is\",V_CE);\n",
+ "S = (1 + bita)/( 1 + ( (bita*R_E)/(R_B+R_E) ) );\n",
+ "print '%s %.2f' %(\"Current stability factor is\",S);\n",
+ "Sdas = -bita/( R_B + R_E*(1+bita) );\n",
+ "print '%s %.2f' %(\"The voltage stability factor is\",Sdas);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The collector current in mA is 11.84\n",
+ "The collector to emmiter voltage in V is 15.29\n",
+ "Current stability factor is 74.39\n",
+ "The voltage stability factor is -0.41\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 - Pg 68"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exsa 3.8\n",
+ "# Given data\n",
+ "V_CC = 20.;# in V\n",
+ "V_BE= 0.7;# in V\n",
+ "R_C = 4.7;# in k ohm\n",
+ "bita = 100.;\n",
+ "R_B = 680.;# in k ohm\n",
+ "#I_C= poly(0,'I_C');# in mA\n",
+ "#I_B= I_C/bita;# in mA\n",
+ "# Applying KVL to C-B circuit, V_CC - (I_C+I_B)*R_C - I_B*R_B - V_BE = 0;\n",
+ "#I_C= V_CC - (I_C+I_B)*R_C - I_B*R_B - V_BE;\n",
+ "#I_C= roots(I_C);# in mA\n",
+ "#I_B= I_C/bita;# in mA\n",
+ "#V_CEQ = V_CC - (I_C+I_B)*R_C;# in V\n",
+ "print '%s' %(\"Q point : 12.07 volts, 1.671 mA\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Q point : 12.07 volts, 1.671 mA\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 - Pg 75"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.9\n",
+ "# Given data\n",
+ "V_CEQ = 5.;# in V\n",
+ "I_CQ = 5.;# in mA\n",
+ "V_CC = 12.;# in V\n",
+ "bita = 120.;\n",
+ "I_C = I_CQ;# in mA\n",
+ "V_BE = 0.7;# in V\n",
+ "I_B= I_C/bita;# in mA\n",
+ "# V_CC - (I_C+I_B)*R_C - V_CE = 0 or\n",
+ "R_C= (V_CC-V_CEQ)/(I_C+I_B);# in k ohm\n",
+ "# Applying KVL to base circuit, V_CC - (I_C+I_B)*R_C - I_B*R_B - V_BE = 0 or \n",
+ "R_B= (V_CEQ-V_BE)/I_B;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R_C in k ohm is\",R_C);\n",
+ "print '%s %.2f' %(\"The value of R_B in k ohm is\",R_B);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_C in k ohm is 1.39\n",
+ "The value of R_B in k ohm is 103.20\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E10 - Pg 77"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.10\n",
+ "# Given data\n",
+ "V_CC = 10.;# in V\n",
+ "R_C = 1.;# in k ohm\n",
+ "R_B = 100.;# in k ohm\n",
+ "V_CE = 5.;# in V\n",
+ "V_BE = 0.7;# in V\n",
+ "V_CB= V_CE-V_BE;# in V\n",
+ "I_B= V_CB/R_B;# in mA\n",
+ "# V_CC = (I_C+I_B)*R_C + V_CE = I_C*R_C + I_B*R_C + V_CE;\n",
+ "I_C = (V_CC-V_CE-(I_B*R_C))/R_C;# in mA\n",
+ "bita= I_C/I_B;\n",
+ "S = (1. + bita)/( 1. + bita*( R_C/(R_B+R_C) ) );\n",
+ "print '%s %.2f' %(\"The value of stability factor is\",S);\n",
+ "S_fixed_bias= 1+bita;# stability factor for fixed bias circuit\n",
+ "print '%s %.2f' %(\"\\nFor the fixed bias circuit, the value of stability factor would have been\",S_fixed_bias)\n",
+ "print '%s' %(\"\\nThus collector to base circuit has a low value of S and hence provides better Q point stability\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of stability factor is 54.30\n",
+ "\n",
+ "For the fixed bias circuit, the value of stability factor would have been 116.28\n",
+ "\n",
+ "Thus collector to base circuit has a low value of S and hence provides better Q point stability\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E11 - Pg 78"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.11\n",
+ "# Given data\n",
+ "Beta = 100.;\n",
+ "V_CC = 10.;# V\n",
+ "R1 = 9.1;# in k ohm\n",
+ "R_C = 1.;# in k ohm\n",
+ "R_E = 560.*10.**-3.;# in k ohm\n",
+ "R2 = 4.7;# in k ohm\n",
+ "V_BE = 0.7;# in V\n",
+ "V_Th = (V_CC/(R1+R2))*R2;# in V\n",
+ "R_B = (R1*R2)/(R1+R2);# in k ohm\n",
+ "# V_Th - I_B*R_B - V_BE - I_E*R_E = 0 or \n",
+ "I_B = (V_Th-V_BE)/(R_B+((1+Beta)*R_E));# in mA\n",
+ "# I_C = Beta*I_B + (1+Beta)*I_CO;\n",
+ "I_C = Beta*I_B;# in mA (neglecting I_CO as it is very small)\n",
+ "# V_CC - (I_C*R_C) - V_CE - I_E*R_E = 0;\n",
+ "V_CE = V_CC - (I_C*R_C) - (I_C*R_E);# in V\n",
+ "print '%s' %(\"Q Point : 2.92 volts, 4.54 mA\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Q Point : 2.92 volts, 4.54 mA\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E12 - Pg 79"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.12\n",
+ "# Given data\n",
+ "V_CC = 20.;# in V\n",
+ "bita = 50.;\n",
+ "R_C = 2.;# in k ohm\n",
+ "R_E = 0.1;# in k ohm\n",
+ "R1 = 100.;# in k ohm\n",
+ "R2 = 5.;# in k ohm\n",
+ "R_Th = (R1*R2)/(R1+R2);# in k ohm\n",
+ "R_B = R_Th;# in k ohm\n",
+ "V_BE = 0.7;# in V\n",
+ "V_Th = (V_CC*R2)/(R1+R2);# in V\n",
+ "# Applying KVL to the base circuit, V_Th - I_B*R_B - V_BE - I_E*R_E = 0 or\n",
+ "I_B = (V_Th-V_BE)/(R_B + (R_E*(1+bita)));# in mA (on putting I_E= (1+bita)*I_B)\n",
+ "I_C = bita*I_B;# in mA\n",
+ "I_E = (1+bita)*I_B;# in mA\n",
+ "V_CE = V_CC - (I_C*R_C) - (I_E*R_E);# in V\n",
+ "print '%s' %(\"Q Point : 17.31 volts, 1.28 mA\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Q Point : 17.31 volts, 1.28 mA\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E13 - Pg 80"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.13\n",
+ "# Given data\n",
+ "bita= 44.;\n",
+ "V_BE = 0.2;# in V\n",
+ "V_CC = -4.5;# in V\n",
+ "R1 = 2.7;# in k ohm\n",
+ "R_C = 1.5;# in k ohm\n",
+ "R2 = 27.;# in k ohm\n",
+ "R_E = 0.27;# in k ohm\n",
+ "R_Th = (R1*R2)/(R1+R2);# in k ohm\n",
+ "R_B = R_Th;# in k ohm\n",
+ "V_Th = (V_CC*R_B)/R2;# in V\n",
+ "#I_B= poly(0,'I_B');# in mA\n",
+ "#I_C= bita*I_B;# in mA\n",
+ "#I_E= -(I_C+I_B);# in mA\n",
+ "# Applying KVL to base circuit, -V_Th - I_B*R_B - V_BE + (I_E*R_E) = 0 (i)\n",
+ "#I_B= (V_Th - I_B*R_B + V_BE + (I_E*R_E));# in mA\n",
+ "#I_B= roots(I_B);# in mA\n",
+ "#I_C= bita*I_B;# in mA\n",
+ "#I_E= -(I_C+I_B);# in mA\n",
+ "# Applying KVL to collector circuit, -V_CC - I_C*R_C - V_CE + I_E*R_E = 0 or \n",
+ "#V_CE = V_CC - (I_C*R_C) + (I_E*R_E);# in V\n",
+ "print '%s' %(\"Part (a) : \")\n",
+ "print '%s' %(\"Q Point : -3.38 volts, -0.63 mA\")\n",
+ "# Calculation of R'Th or R'B (Thevenin's Resistance)\n",
+ "r_bb = 0.69;# in k ohm\n",
+ "R_deshB = ((R1*R2)/(R1+R2)) + r_bb;# in k ohm\n",
+ "# Calculation of Thevenin's voltage\n",
+ "#I_B= (V_Th+V_BE)/(R_deshB+(1+bita)*R_E);# in mA\n",
+ "#I_C= bita*I_B;# in mA\n",
+ "# Applying KVL to collector circuit, -V_CC - (I_C*R_C) - V_CE + I_E*R_E = 0 or\n",
+ "#V_CE = V_CC - (I_C*R_C) + (I_E*R_E);# in V\n",
+ "print '%s' %(\"\\nPart (b) : \")\n",
+ "print '%s' %(\"Q Point : -3.42 volts, -0.60 mA\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Part (a) : \n",
+ "Q Point : -3.38 volts, -0.63 mA\n",
+ "\n",
+ "Part (b) : \n",
+ "Q Point : -3.42 volts, -0.60 mA\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E14 - Pg 89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.14\n",
+ "# Given data\n",
+ "bita = 140.;\n",
+ "V_BE = 0.7;# in V\n",
+ "V_CC = 22.;# in V\n",
+ "R1 = 39.;# in k ohm\n",
+ "R_C = 10.;# in k ohm\n",
+ "R2 = 3.9;# in k ohm\n",
+ "R_E = 1.5;# in k ohm\n",
+ "# Calculation of Thevenin's Resistance\n",
+ "R_Th = (R1*R2)/(R1+R2);# in k ohm\n",
+ "# Calculation of Thevenin's Voltage\n",
+ "V_Th = (V_CC*R2)/(R1+R2);# in V\n",
+ "#I_B= poly(0,'I_B');# in mA\n",
+ "#I_E= (1+bita)*I_B;# in mA\n",
+ "# Applying KVL to input side, V_Th - I_B*R_Th - V_BE - I_E*R_E=0 or \n",
+ "#I_B= V_Th - I_B*R_Th - V_BE - I_E*R_E;\n",
+ "#I_B= roots(I_B);# in mA\n",
+ "I_C =0.85;# bita*I_B;# in mA\n",
+ "#I_E= (1+bita)*I_B;# in mA\n",
+ "# Applying KVL to C-E circuit, V_CC - I_C*R_C - V_CE - I_E*R_E = 0 or\n",
+ "V_CE = 12.3;#V_CC - (I_C*R_C) - ((1+bita)*I_B*R_E);# in V\n",
+ "I_B=6.05;# I_B*10**3;# in uA\n",
+ "print '%s %.2f' %(\"The value of I_B in uA is\",I_B);\n",
+ "print '%s %.2f' %(\"The value of I_C in mA is\",I_C);\n",
+ "print '%s %.2f' %(\"The value of V_CE in V is\",V_CE);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_B in uA is 6.05\n",
+ "The value of I_C in mA is 0.85\n",
+ "The value of V_CE in V is 12.30\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E15 - Pg 90"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.15\n",
+ "# Given data\n",
+ "V_CC =12.;# in V\n",
+ "R_C = 4.3;# in k ohm\n",
+ "V_CE = 4.;# in V\n",
+ "V_BE = 0.7;# in V\n",
+ "V_EE = 6.;# in V\n",
+ "bita = 50.;\n",
+ "# Applying KVL in base circuit, -V_BE - I_ER_E + V_EE = 0 or\n",
+ "I_ER_E = V_EE - V_BE;# in V\n",
+ "# Applying KVL in C-E circuit, V_CC-I_C*R_C-V_CE-I_ER_E+V_EE=0 or\n",
+ "I_C = (V_CC - V_CE - I_ER_E + V_EE)/R_C;# in mA\n",
+ "I_B = I_C/bita;# in mA\n",
+ "I_E = I_C+I_B;# in mA\n",
+ "R_E= I_ER_E/I_E;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R_E in k ohm is : \",R_E)\n",
+ "del_IC= bita*(1+bita)*R_E;\n",
+ "del_ICO= bita*(1+bita)*R_E;\n",
+ "S= del_IC/del_ICO;\n",
+ "print '%s %.2f' %(\"The value of stability factor, S is : \",S)\n",
+ "S_desh= bita/((1+bita)*R_E);\n",
+ "print '%s %.2f' %(\"The value of stability factor, S'' is : \",S_desh)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_E in k ohm is : 2.57\n",
+ "The value of stability factor, S is : 1.00\n",
+ "The value of stability factor, S'' is : 0.38\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E17 - Pg 90"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.17 (Miss printed as example 3.14)\n",
+ "# Given data\n",
+ "Tj = 150.;# Junction temperature in degree C\n",
+ "P_Cmax = 125.;# in mW\n",
+ "T = 25.;# free-air temperature in degree C\n",
+ "T1 = 0;# in degree C\n",
+ "curve = (Tj-T)/(P_Cmax - T1);# in degreeC/mW\n",
+ "T_A = 25.;# Ambient temperature in degree C\n",
+ "P_D = 75.;# Collector junction dissipation in mW\n",
+ "theta = 1.;# in degree C/mW\n",
+ "# Tj-T_A = theta*P_D;\n",
+ "Tj = T_A + (theta*P_D);# in degree C\n",
+ "print '%s %.2f' %(\"The junction temperature in degreeC is\",Tj);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The junction temperature in degreeC is 100.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E18 - Pg 91"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.18 (Miss printed as example 3.15)\n",
+ "# Given data\n",
+ "P_Cmax = 125.;# in mW\n",
+ "P_D = P_Cmax;# in mW\n",
+ "T_A = 25.;# in degree C\n",
+ "Tj = 150.;# in degree C\n",
+ "# Tj-T_A = theta*P_D;\n",
+ "theta = (Tj-T_A)/P_D;# in degree C/mW\n",
+ "print '%s %.2f' %(\"The thermal resistance for a transistor in degreeC/mW is\",theta);\n",
+ "# For theta= 1 degreeC/mW\n",
+ "P_D = 75.;# in mW\n",
+ "# Tj-T_A = theta*P_D;\n",
+ "Tj = (theta*P_D) + T_A;# in degree C\n",
+ "print '%s %.2f' %(\"The junction temperature in degreeC is\",Tj);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The thermal resistance for a transistor in degreeC/mW is 1.00\n",
+ "The junction temperature in degreeC is 100.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E20 - Pg 93"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.20 (Miss printed as example 3.17)\n",
+ "# Given data\n",
+ "V_E = 1.;# in V\n",
+ "V_BE = 0.7;# in V\n",
+ "R_C = 1.;# in k ohm\n",
+ "Beta = 180.;\n",
+ "V_CC = 12.;# in V\n",
+ "V_CEQ = 6.;# in V\n",
+ "# Applying KVL into collector circuit, V _CC - I_C*R_C - V_CEQ = 0 or\n",
+ "I_C = (V_CC-V_CEQ)/R_C;# in mA\n",
+ "I_B = I_C/Beta;# in mA\n",
+ "# Applying KVL into base circuit, V_CC - I_B*R_B - V_BE = 0 or\n",
+ "R_B = (V_CC-V_BE)/I_B;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R_B in k ohm is\",R_B);\n",
+ "# Applying KVL to collector circuit, V_CC - I_C*R_C - V_CE - V_E = 0 or\n",
+ "I_C = (V_CC-V_CEQ-V_E)/R_C;# in mA\n",
+ "I_B = I_C/Beta;# in mA\n",
+ "I_E = I_C+I_B;# in mA\n",
+ "R_E = V_E/(I_E);# in k ohm\n",
+ "R_E= round(R_E*10.**3.);# in ohm\n",
+ "print '%s %.2f' %(\"The value of R_E in ohm is\",R_E);\n",
+ "I_R2 = 10.*I_B;# in mA\n",
+ "V_BE= 0.6;# in V\n",
+ "# R2 =V_B/I_R2 = (V_E+V_BE)/I_R2;\n",
+ "R2 = (V_E+V_BE)/I_R2;# in k ohm \n",
+ "R2= R2*10.**3.;# in ohm\n",
+ "print '%s %.2f' %(\"The value of R2 in ohm is\",R2);\n",
+ "I_R1 = I_R2 + I_B;# in mA\n",
+ "# R1 = V_R1/I_R1 = (V_CC-V_B)/I_R1;\n",
+ "V_B = V_E+V_BE;# in V\n",
+ "R1 = (V_CC-V_B)/I_R1;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R1 in k ohm is\",R1);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_B in k ohm is 339.00\n",
+ "The value of R_E in ohm is 199.00\n",
+ "The value of R2 in ohm is 5760.00\n",
+ "The value of R1 in k ohm is 34.04\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E21 - Pg 94"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.21 (Miss printed as example 3.18)\n",
+ "# Given data\n",
+ "V_BB= 6.;# in V\n",
+ "I_CBO =0.5;# in uA\n",
+ "V_BE = 0.7;# in V\n",
+ "R_B= 50.;# in k ohm\n",
+ "R_E= 1.;# in k ohm\n",
+ "bita = 75.;\n",
+ "# V_BB - I_B*R_B - V_BE - I_E*R_E = 0 or\n",
+ "I_B=(V_BB-V_BE)/(R_B+(1.+bita)*R_E);# in mA (on putting I_E= (1+bita)*I_B) (i)\n",
+ "I_B= round(I_B*10.**3.);# in uA\n",
+ "I_C= bita*I_B;# in uA\n",
+ "I_C= I_C*10.**-3.;# in mA\n",
+ "I_CQ= I_C;# in mA\n",
+ "print '%s %.2f' %(\"The value of I_CQ at room temperature in mA is : \",I_CQ)\n",
+ "# Part (ii)\n",
+ "C= 2.;# temperature coefficient in mV/degreeC\n",
+ "C= 2.*10.**-3.;# in V/degreeC\n",
+ "T2= 20.;# in degreeC\n",
+ "T1= 0;# in degreeC\n",
+ "I_CBO2= I_CBO*2.**((T2-T1)/10.);# in uA\n",
+ "V_BE2= V_BE-C*T2;# in V\n",
+ "# Now from eq(i), for the new value of I_B\n",
+ "I_B=(V_BB-V_BE2)/(R_B+(1.+bita)*R_E);# in mA\n",
+ "I_B= I_B*10.**3.;# in uA\n",
+ "I_C= bita*I_B+(1.+bita)*I_CBO2;# in uA\n",
+ "I_C= I_C*10.**-3.;# in mA\n",
+ "I_CQ= I_C;# in mA\n",
+ "print '%s %.2f' %(\"The value of I_CQ when temperature increases by 20degreeC in mA is : \",I_CQ)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_CQ at room temperature in mA is : 3.15\n",
+ "The value of I_CQ when temperature increases by 20degreeC in mA is : 3.33\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E22 - Pg 97"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 3.22 (Miss printed as example 3.19)\n",
+ "# Given data\n",
+ "S = 10.;\n",
+ "bita = 50.;\n",
+ "h_fe = bita;\n",
+ "V_CC= 20.;# in V\n",
+ "V_CE = 10.;# in V\n",
+ "R_C = 2.;# in k ohm\n",
+ "I_C = 4.;# in mA\n",
+ "I_B =I_C/bita;# in mA\n",
+ "# Applying KVL to collector loop, V_CC -I_C*R_C - V_CE - I_E*R_E = 0 or\n",
+ "R_E = (V_CC -I_C*R_C - V_CE)/(I_C+I_B);# in k ohm (on putting I_E= I_C+I_B)\n",
+ "R_E= round(R_E*10.**3.);# in ohm\n",
+ "print '%s %.2f' %(\"The value of R_E in ohm is\",R_E);\n",
+ "# Formula S = (1+bita)*( (1 + (R_B/R_E))/( (1+bita) + (R_B/R_E) ) ) or\n",
+ "R_B= (1+bita)*(1-S)*R_E/(S-1-bita);# in ohm\n",
+ "# But R_B= R1 || R2= R1*R2/(R1+R2) => R2/(R1+R2)= R_B/R1 (i)\n",
+ "# Calculation of R1 and R2 : \n",
+ "V_BE= 0.2;# in V\n",
+ "# Applying KVL to input loop, \n",
+ "V_R2= V_BE+(I_C+I_B)*10.**-3.*R_E;# in V\n",
+ "# But V_R2= R2*V_CC/(R1+R2) => R2/(R1+R2)= V_R2/V_CC (ii)\n",
+ "# On comparing eq (i) and (ii)\n",
+ "R1= R_B*V_CC/V_R2;# in ohm\n",
+ "R2= R1*V_R2/(V_CC-V_R2);# in ohm\n",
+ "R1= R1*10**-3;# in k ohm\n",
+ "R2= R2*10**-3;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R1 in k ohm is : \",R1)\n",
+ "print '%s %.2f' %(\"The value of R2 in k ohm is : \",R2)\n",
+ "# Effect of Reducing S or 3 : \n",
+ "S=3;\n",
+ "# Formula S = (1+bita)*( (1 + (R_B/R_E))/( (1+bita) + (R_B/R_E) ) ) or\n",
+ "R_B= (1+bita)*(1-S)*R_E/(S-1-bita);# in ohm\n",
+ "R_B= R_B*10**-3;# in k ohm\n",
+ "print '%s %.2f' %(\"When S<=3, the value of R_B in k ohm is : \",R_B)\n",
+ "print '%s' %(\"Thus S is reduced below 3 at the cost of reduction of it's input impedance\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_E in ohm is 490.00\n",
+ "The value of R1 in k ohm is : 49.89\n",
+ "The value of R2 in k ohm is : 6.16\n",
+ "When S<=3, the value of R_B in k ohm is : 1.04\n",
+ "Thus S is reduced below 3 at the cost of reduction of it's input impedance\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter04_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter04_1.ipynb new file mode 100644 index 00000000..98984f8d --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter04_1.ipynb @@ -0,0 +1,476 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:62e3c7215a9b229142676375b57923e6093c3d5df04e5466e380815f12049f6e"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 04 - THE TRANSISTOR AT LOW FREQUENCY"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E1 - Pg 105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 4.1\n",
+ "import math\n",
+ "# Given data\n",
+ "R1 = 100.*10.**3.;# in ohm\n",
+ "R2 = 10.*10.**3.;# in ohm\n",
+ "h_fe = 50.;\n",
+ "h_oe = 1./40.;# in ohm\n",
+ "R_L = 5.*10.**3.;# in ohm\n",
+ "R_S= 5.*10.**3;# in ohm\n",
+ "h_ie = 1.1*10.**3.;# in ohm\n",
+ "h_re = 2.5*10.**-4.;\n",
+ "R_B = (R1*R2/(R1+R2));# in ohm\n",
+ "A_I = (-h_fe)/(1 + h_oe*R_L);\n",
+ "print '%s %.2f %s' %(\"The internal current gain is\",A_I,\"\\n\");\n",
+ "#Internal input impedance, Zi = Vbe/Ib or \n",
+ "Zi = (h_ie + h_re*A_I*R_L);# in ohm\n",
+ "Zi= Zi*10.**-3.;# in k ohm\n",
+ "print '%s %.2f %s' %(\"The internal input impedance in k ohm is\",Zi,\"\\n\");\n",
+ "Zi= Zi*10.**3.;# in ohm\n",
+ "#Internal voltage gain, Av = Vce/Vbe or \n",
+ "Av = (A_I*R_L)/Zi;\n",
+ "print '%s %.2f %s' %(\"The internal voltage gain is\",Av,\"\\n\");\n",
+ "Ri =round(R_B*Zi/(R_B+Zi));# in ohm\n",
+ "Ri= Ri*10**-3;# in k ohm\n",
+ "print '%s %.2f %s' %(\"The overall input impedance in k ohm is\",Ri,\"\\n\");\n",
+ "Ri= Ri*10**3;# in ohm\n",
+ "# V_S= I_i*R_S+v_be or\n",
+ "VS_by_vbe= Ri/(Ri+R_S);\n",
+ "Avs= Av*VS_by_vbe;\n",
+ "print '%s %.2f %s' %(\"The overall voltage gain is : \",Avs,\"\\n\")\n",
+ "# R_B*(I_i-I_b)= Zi*I_b or\n",
+ "I_bBYI_i= R_B/(R_B+Zi);\n",
+ "A_IS= A_I*I_bBYI_i;\n",
+ "print '%s %.2f %s' %(\"The overall current gain is : \",A_IS,\"\\n\")\n",
+ "Rdesh_S= R_B*R_S/(R_B+R_S);# in ohm\n",
+ "Rdesh_S= 3220\n",
+ "I_bByVce= -h_re/(h_ie+Rdesh_S);\n",
+ "Yo= h_oe-h_fe*h_re/(h_ie+Rdesh_S)*10**3;\n",
+ "Zo= 1/Yo;\n",
+ "print '%s %.2f %s' %(\"The Output impedance in ohm is : \",Zo,\"\\n\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The internal current gain is -0.40 \n",
+ "\n",
+ "The internal input impedance in k ohm is 1.10 \n",
+ "\n",
+ "The internal voltage gain is -1.80 \n",
+ "\n",
+ "The overall input impedance in k ohm is 0.98 \n",
+ "\n",
+ "The overall voltage gain is : -0.30 \n",
+ "\n",
+ "The overall current gain is : -0.35 \n",
+ "\n",
+ "The Output impedance in ohm is : 45.24 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E2 - Pg 107"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 4.2\n",
+ "import math\n",
+ "# Given data\n",
+ "V_CC = 15.;# in V\n",
+ "R_L = 10.;# in k ohm\n",
+ "Rf = 200.;# in k ohm\n",
+ "R_S = 5.;# in k ohm\n",
+ "Rf2 = Rf;# in k ohm\n",
+ "h_fe = 50.;\n",
+ "V_S= 10.*10.**-3.;# in V\n",
+ "h_oe = 1./40.;# in k ohm\n",
+ "R_L = (R_L*Rf2)/(R_L+Rf2);# in k ohm\n",
+ "Ai = -h_fe/(1.+h_oe*R_L);\n",
+ "print '%s %.2f %s' %(\"The internal current gain is\",Ai,\"\\n\");\n",
+ "#Zi = Vbe/Ib = h_ie +Ai*h_re*R_L;\n",
+ "h_ie = 1.1;# in k ohm\n",
+ "h_re = 2.5*10.**-4.;\n",
+ "Zi = h_ie +Ai*h_re*R_L;# in k ohm\n",
+ "print '%s %.2f %s' %(\"The internal input impedance in k ohm is\",Zi,\"\\n\");\n",
+ "#A_V = Vce/Vbe = (Ai*R_L)/Zi;\n",
+ "A_V = (Ai*R_L)/Zi;\n",
+ "print '%s %.2f %s' %(\"The internal voltage gain is\",A_V,\"\\n\");\n",
+ "Rf1= Rf/(1-A_V)\n",
+ "# Rf1 = Rf/(1-A_V);# in k ohm\n",
+ "#Ri = Vi/Ii = Vbe/Ii = (Rf1*Zi)/(Rf1+Zi);\n",
+ "Ri = (Rf1*Zi)/(Rf1+Zi);# in k ohm\n",
+ "print '%s %.2f %s' %(\"The overall input impedance in k ohm is\",Ri,\"\\n\");\n",
+ "#A_VS = Vo/V_S or \n",
+ "A_VS = A_V*(Ri/(R_S+Ri));\n",
+ "print '%s %.2f %s' %(\"The overall voltage gain is\",A_VS,\"\\n\");\n",
+ "#A_IS = I_L/Ii or\n",
+ "A_IS = (Rf2/(Rf2+R_L))*Ai*(Rf1/(Rf1+Zi));\n",
+ "print '%s %.2f %s' %(\"The overall current gain is\",A_IS,\"\\n\");\n",
+ "Rdesh_S= Rf1*R_S/(Rf1+R_S);# in k ohm\n",
+ "Yo= h_oe-h_re*h_fe/(h_ie+Rdesh_S);# in mho\n",
+ "Zo= 1/Yo;# in ohm\n",
+ "print '%s %.2f %s' %(\"The output impedance in ohm is : \",Zo,\"\\n\")\n",
+ "Zdesh_o= Rf2*Zo/(Rf2+Zo);# in ohm\n",
+ "print '%s %.2f %s' %(\"The overall output impedance in ohm is : \",Zdesh_o,\"\\n\");\n",
+ "Vo= V_S*abs(A_VS);# in V\n",
+ "Vo= Vo*10**3;# in mV\n",
+ "print '%s %.2f %s' %(\"The magnitude of output voltage in mV is : \",Vo,\"\\n\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The internal current gain is -40.38 \n",
+ "\n",
+ "The internal input impedance in k ohm is 1.00 \n",
+ "\n",
+ "The internal voltage gain is -383.14 \n",
+ "\n",
+ "The overall input impedance in k ohm is 0.34 \n",
+ "\n",
+ "The overall voltage gain is -24.58 \n",
+ "\n",
+ "The overall current gain is -13.17 \n",
+ "\n",
+ "The output impedance in ohm is : 58.66 \n",
+ "\n",
+ "The overall output impedance in ohm is : 45.36 \n",
+ "\n",
+ "The magnitude of output voltage in mV is : 245.85 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E3 - Pg 108"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 4.3\n",
+ "import math \n",
+ "# Given data\n",
+ "h_ic = 2.;# in k ohm\n",
+ "h_fc = -51.;\n",
+ "h_oc = 25.*10.**-6.;# in ohm\n",
+ "h_rc= 1.;\n",
+ "V_CC = 20.;# in V\n",
+ "R1 = 10.;# in k ohm\n",
+ "R2 = 10.;# in k ohm\n",
+ "R_S = 1.;# in k ohm\n",
+ "R_E = 5.;# in k ohm\n",
+ "R_B= 5.;# in k ohm\n",
+ "R_L= 5.;# in k ohm\n",
+ "# (i) Current Gain\n",
+ "Ai = (-h_fc)/(1.+h_oc*R_E*10.**3.);\n",
+ "print '%s %.2f %s' %(\"The current gain is\",Ai,\"\\n\");\n",
+ "# (ii) Input impedance\n",
+ "Zi = h_ic*10**3 + h_rc*Ai*R_E*10**3;# in ohm\n",
+ "Zi = Zi * 10**-3;# in k ohm\n",
+ "print '%s %.2f %s' %(\"The input impedance in k ohm is\",Zi,\"\\n\");\n",
+ "# (iii) Voltage Gain\n",
+ "A_V = (Ai*R_L*10**3)/(Zi*10**3);\n",
+ "A_V = 1;# (approx)\n",
+ "print '%s %.2f %s' %(\"The voltage gain is\",A_V,\"\\n\");\n",
+ "# (iv) Overall Input Impedance\n",
+ "Z_IS = (R_B*Zi)/(R_B+Zi);# in k ohm\n",
+ "print '%s %.2f %s' %(\"The overall input impedance in k ohm is\",Z_IS,\"\\n\");\n",
+ "# (v) Overall voltage gain\n",
+ "A_VS = (A_V*Zi)/(Zi+R_S); \n",
+ "print '%s %.2f %s' %(\"The overall voltage gain is\",A_VS,\"\\n\");\n",
+ "# (vi) Overall current gain\n",
+ "A_IS =Ai*(R_B/(R_B+Zi));\n",
+ "print '%s %.2f %s' %(\"The overall current gain is\",A_IS,\"\\n\");\n",
+ "# (vii) Output impedance\n",
+ "RdasS = (R_S*R_B)/(R_S+R_B);# in k ohm\n",
+ "Yo = h_oc - ( (h_fc*h_rc)/(h_ic*10.**3.+RdasS*10.**3.) );# in mho \n",
+ "Zo = 1./Yo;# in ohm\n",
+ "print '%s %.2f %s' %(\"The output impedance in ohm is\",Zo,\"\\n\");\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The current gain is 45.33 \n",
+ "\n",
+ "The input impedance in k ohm is 228.67 \n",
+ "\n",
+ "The voltage gain is 1.00 \n",
+ "\n",
+ "The overall input impedance in k ohm is 4.89 \n",
+ "\n",
+ "The overall voltage gain is 1.00 \n",
+ "\n",
+ "The overall current gain is 0.97 \n",
+ "\n",
+ "The output impedance in ohm is 55.48 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E4 - Pg 110"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 4.4\n",
+ "# Given data\n",
+ "h_ie = 1.1;# in k ohm\n",
+ "h_re = 2.5*10.**-4.;\n",
+ "h_fe = 50.;\n",
+ "h_oe = 25.*10.**-6.;# in A\n",
+ "V_CC = 15.;# in V\n",
+ "R1 = 20.;# in k ohm\n",
+ "R_C = 2.;# in k ohm\n",
+ "R2 = 10.;# in k ohm\n",
+ "R_S = 1.;# in k ohm\n",
+ "R_E = 1.;# in k ohm\n",
+ "# (i) Current Gain\n",
+ "Ai = -h_fe/(1. + h_oe*R_C*10.**3.);\n",
+ "print '%s %.2f %s' %(\"The current gain is\",Ai,\"\\n\");\n",
+ "# (ii) Input impedance\n",
+ "Zi = (h_ie*10**3) + (h_re*Ai*R_C*10**3);#in ohm\n",
+ "Zi = Zi * 10**-3;# in k ohm\n",
+ "print '%s %.2f %s' %(\"The input impedance in k ohm is\",Zi,\"\\n\");\n",
+ "# (iii) Voltage gain\n",
+ "A_V = (Ai*R_C)/Zi;\n",
+ "print '%s %.2f %s' %(\"The voltage gain is\",A_V,\"\\n\");\n",
+ "# (iv) Overall input impedance\n",
+ "R_B = (R1*R2)/(R1+R2);# in k ohm\n",
+ "Z_IS = (Zi*R_B)/(Zi+R_B);# in k ohm\n",
+ "print '%s %.2f %s' %(\"The overall input impedance in k ohm is\",Z_IS,\"\\n\");\n",
+ "# (v) Overall voltage gain\n",
+ "A_VS = A_V * (Z_IS/(Z_IS+R_S));\n",
+ "print '%s %.2f %s' %(\"The overall voltage gain is\",A_VS,\"\\n\");\n",
+ "# (vi) Overall current gain\n",
+ "A_IS =Ai*(R_B/(R_B+Zi));\n",
+ "print '%s %.2f %s' %(\"The overall current gain is\",A_IS,\"\\n\");\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The current gain is -47.62 \n",
+ "\n",
+ "The input impedance in k ohm is 1.08 \n",
+ "\n",
+ "The voltage gain is -88.50 \n",
+ "\n",
+ "The overall input impedance in k ohm is 0.93 \n",
+ "\n",
+ "The overall voltage gain is -42.56 \n",
+ "\n",
+ "The overall current gain is -41.00 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E5 - Pg 111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 4.5\n",
+ "# Given data\n",
+ "h_ie = 1.1;# in k ohm\n",
+ "h_oe = 25.;# in A/V\n",
+ "h_oe = h_oe * 10.**-6.;# in A/V\n",
+ "h_fe = 50.;\n",
+ "h_re = 2.5*10.**-4.;\n",
+ "R_L = 1.6;# in ohm\n",
+ "R_S = 1.;# in k ohm\n",
+ "V_CC = 15.;# in V\n",
+ "# (i) Current Gain\n",
+ "Ai = -h_fe/(1. + (h_oe*R_L));\n",
+ "print '%s %.2f %s' %(\"The current gain is\",Ai,\"\\n\");\n",
+ "# (ii) Input impedance\n",
+ "Zi = (h_ie*10**3) + (h_re*Ai*R_L);# in ohm\n",
+ "Zi= Zi*10**-3;# in k ohm\n",
+ "print '%s %.2f %s' %(\"The input impedance in k ohm is\",Zi,\"\\n\");\n",
+ "Zi= Zi*10**3;# in ohm\n",
+ "# (iii) Voltage gain\n",
+ "A_V = Ai*R_L/Zi;\n",
+ "print '%s %.2f %s' %(\"The voltage gain is\",A_V,\"\\n\");\n",
+ "# (iv) Power gain\n",
+ "A_P = Ai*A_V;\n",
+ "print '%s %.2f %s' %(\"The power gain is\",A_P,\"\\n\");\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The current gain is -50.00 \n",
+ "\n",
+ "The input impedance in k ohm is 1.10 \n",
+ "\n",
+ "The voltage gain is -0.07 \n",
+ "\n",
+ "The power gain is 3.64 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E6 - Pg 112"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 4.6\n",
+ "# Given data\n",
+ "h_fe = 150.;\n",
+ "Beta_dc = h_fe;\n",
+ "h_ie = 1.*10.**3.;# in ohm\n",
+ "h_re = 0;\n",
+ "h_oe = 0;\n",
+ "V_CC = 18.;# in V\n",
+ "V_BE= 0.7;# in V\n",
+ "R1 = 100.*10.**3.;# in ohm\n",
+ "R2 = 50.*10.**3.;# in ohm\n",
+ "R_C = 1.*10.**3.;# in ohm\n",
+ "R_E = 0.5*10.**3.;# in ohm\n",
+ "V_Th = (V_CC/(R1+R2))*R2;# in V\n",
+ "R_Th =(R1*R2)/(R1+R2);# in ohm\n",
+ "# V_Th - I_B*R_Th - V_BE - (1+Beta)*-I_B*R_E = 0;\n",
+ "I_B = (V_Th-V_BE)/( R_Th + (1+Beta_dc)*R_E);# in A\n",
+ "#I_C = I_CQ = Beta*I_B;\n",
+ "I_C = Beta_dc*I_B;# in A\n",
+ "I_CQ = I_C;# in A\n",
+ "I_CQ= I_CQ*10.**3.;# in mA\n",
+ "print '%s %.2f %s' %(\"The value of I_CQ in mA is\",I_CQ,\"\\n\");\n",
+ "I_E = (1+Beta_dc)*I_B;# in mA\n",
+ "# V_CC - I_C*R_C - V_CE - I_E*R_E = 0;\n",
+ "V_CE = V_CC - (I_C*R_C) - (I_E*R_E);# in V\n",
+ "print '%s %.2f %s' %(\"The value of V_CE in V is\",V_CE,\"\\n\");\n",
+ "R_L =R_C;# in ohm\n",
+ "Ai = -h_fe/(1+(h_oe*R_L));\n",
+ "print '%s %.2f %s' %(\"The current gain is \",Ai,\"\\n\");\n",
+ "Zi = h_ie + h_re*Ai*R_L;# in ohm\n",
+ "Zi= Zi*10**-3;# in k ohm\n",
+ "print '%s %.2f %s' %(\"The input impedance in k ohm is\",Zi,\"\\n\");\n",
+ "Zi= Zi*10**3;# in ohm\n",
+ "A_V = Ai*(R_L/Zi);\n",
+ "print '%s %.2f %s' %(\"The voltage gain is\",A_V,\"\\n\");\n",
+ "R_B= (R1*R2)/(R1+R2);# in ohm\n",
+ "Z_IS =(Zi*R_B)/(Zi+R_B);# in ohm\n",
+ "Z_IS= Z_IS*10**-3;# in kohm\n",
+ "print '%s %.2f %s' %(\"The overall input impedance in k ohm is\",Z_IS,\"\\n\");\n",
+ "Z_IS= Z_IS*10**3;# in ohm\n",
+ "A_VS =A_V*(Z_IS/Z_IS);\n",
+ "print '%s %.2f %s' %(\"The overall voltage gain is\",A_VS,\"\\n\");\n",
+ "A_IS =Ai * (R_B/(R_B+Zi));\n",
+ "print '%s %.2f %s' %(\"The overall current gain is\",A_IS,\"\\n\");\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_CQ in mA is 7.30 \n",
+ "\n",
+ "The value of V_CE in V is 7.02 \n",
+ "\n",
+ "The current gain is -150.00 \n",
+ "\n",
+ "The input impedance in k ohm is 1.00 \n",
+ "\n",
+ "The voltage gain is -150.00 \n",
+ "\n",
+ "The overall input impedance in k ohm is 0.97 \n",
+ "\n",
+ "The overall voltage gain is -150.00 \n",
+ "\n",
+ "The overall current gain is -145.63 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter05_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter05_1.ipynb new file mode 100644 index 00000000..b63fe57a --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter05_1.ipynb @@ -0,0 +1,342 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:bc301ad6165c1272098ace3d8ce3c4396922f7ca604b7a15f4ec7430d3e672ac"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 05 - BJT AT HIGH FREQUENCY"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 - Pg 139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 5.1\n",
+ "# Given data\n",
+ "import math\n",
+ "I_C = 2.;# in mA\n",
+ "I_C =I_C * 10.**-3.;# in A\n",
+ "V_CEQ = 20.;# in V\n",
+ "h_fe = 100.;\n",
+ "I_BQ = 20.;# in uA\n",
+ "I_BQ = I_BQ * 10.**-6.;# in A\n",
+ "Beta = 100.;\n",
+ "f_T = 50.;# in MHz\n",
+ "f_T = f_T * 10.**6.;# in Hz\n",
+ "Cob = 3.;# in pF\n",
+ "Cob = Cob * 10.**-12.;# in F\n",
+ "h_ie = 1400.;# in ohm\n",
+ "T = 300.;# in K\n",
+ "# (i) Transconductance\n",
+ "g_m = 11600.*(I_C/T);# in S\n",
+ "g_m=g_m*10.**6.;# in uS\n",
+ "print '%s %.2e' %(\"The transconductance in uS is\",g_m);\n",
+ "# (ii) Input resistance\n",
+ "g_m=g_m*10.**-6.;# in S\n",
+ "r_be = h_fe/g_m; # in ohm \n",
+ "print '%s %.2f' %(\"The input resistance in ohm is\",r_be);\n",
+ "# (iii) Capacitance\n",
+ "Cbc = Cob ;# in F\n",
+ "Cbe = g_m/(2.*math.pi*f_T)-Cbc;# in F \n",
+ "Cbe= round(Cbe*10.**12.);# in pF\n",
+ "print '%s %.2f' %(\"The capacitance in pF is\",Cbe);\n",
+ "# (iv) Base Spreading Resistance\n",
+ "r_bb = round(h_ie - r_be);# in ohm\n",
+ "print '%s %.2f' %(\"The base spreading resistance in ohm is\",r_bb);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The transconductance in uS is 7.73e+04\n",
+ "The input resistance in ohm is 1293.10\n",
+ "The capacitance in pF is 243.00\n",
+ "The base spreading resistance in ohm is 107.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 141"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 5.2\n",
+ "# Given data\n",
+ "import math\n",
+ "I_C = 10.;# in mA\n",
+ "I_C =I_C * 10.**-3.;# in A\n",
+ "V_CE = 10.;# in V\n",
+ "V_T= 26.*10.**-3.;# in V\n",
+ "h_ie = 500.;# in ohm\n",
+ "h_oe = 4.*10.**-5.;# in S\n",
+ "h_fe = 100.;\n",
+ "g_be = 1./260.;\n",
+ "h_re = 10.**-4.;\n",
+ "f_T = 50.;# in MHz\n",
+ "f_T = f_T * 10.**6.;# in Hz\n",
+ "T = 300.;# in K\n",
+ "Cob =3.;# in pF\n",
+ "Cob = Cob * 10.**-12.;# in F\n",
+ "# (i) Transconductance\n",
+ "g_m = I_C/V_T;# in A/V\n",
+ "g_m= round(g_m*10.**3.);# in mA/V\n",
+ "print '%s %.2f' %(\"The Transconductance in mA/V is\",g_m);\n",
+ "# (ii) Input resistance\n",
+ "g_m= g_m*10.**-3.;# in A/V\n",
+ "r_be = round(h_fe/g_m);# in ohm\n",
+ "print '%s %.2f' %(\"The input resistance in ohm is\",r_be);\n",
+ "# (iii) Base spreading resistance \n",
+ "r_bb = h_ie - r_be;# in ohm\n",
+ "print '%s %.2f' %(\"The base spreading resistance in ohm is\",r_bb);\n",
+ "# (iv) The feedback conductance \n",
+ "g_bc = h_re*g_be;\n",
+ "print '%s %.2e' %(\"The feedback conductance is\",g_bc);\n",
+ "# (v) The output conductance \n",
+ "g_ce = h_oe - (1.+h_fe)*g_bc\n",
+ "print '%s %.2e' %(\"The output conductance is : \",g_ce)\n",
+ "# (vi) Capacitance\n",
+ "Cbe= g_m/(2.*math.pi*f_T);# in F\n",
+ "Cbe= Cbe*10.**12.;# in pF\n",
+ "print '%s %.2f' %(\"The value of C_b''e in pF is : \",Cbe)\n",
+ "Cc= Cob;# in F\n",
+ "Cc= Cc*10.**12.\n",
+ "print '%s %.2f' %(\"The value of Cc in pF is : \",Cc)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Transconductance in mA/V is 385.00\n",
+ "The input resistance in ohm is 260.00\n",
+ "The base spreading resistance in ohm is 240.00\n",
+ "The feedback conductance is 3.85e-07\n",
+ "The output conductance is : 1.15e-06\n",
+ "The value of C_b''e in pF is : 1225.49\n",
+ "The value of Cc in pF is : 3.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 142"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 5.3\n",
+ "# Given data\n",
+ "import math\n",
+ "W = 10.**-6.;# in m\n",
+ "I_E =2.;# in mA\n",
+ "I_E = I_E * 10.**-3.;# in A\n",
+ "V_T = 26.;# in mV\n",
+ "V_T = V_T * 10.**-3.;# in V\n",
+ "D_B = 47.*10.**-4.;\n",
+ "# g_m = abs(I_C)/V_T = abs(I_E)/V_T;\n",
+ "# The emitter diffusion capacitance, Cbe = g_m*((W**2)/(2*D_B));\n",
+ "Cbe = I_E/V_T*W**2./(2.*D_B);# F\n",
+ "Cbe= Cbe*10.**12.;# in pF\n",
+ "print '%s %.2f' %(\"The emitter diffusion capacitance in pF is\",Cbe);\n",
+ "Cbe= Cbe*10.**-12.;# in F\n",
+ "g_m = abs(I_E)/V_T;\n",
+ "# The transition frequency \n",
+ "f_T = g_m/(2*math.pi*Cbe);# in Hz\n",
+ "f_T = f_T * 10.**-6.;# in MHz\n",
+ "print '%s %.2f' %(\"The transition frequency in MHz is\",f_T);\n",
+ "\n",
+ "# Note: The answer in the book is not accurate.\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The emitter diffusion capacitance in pF is 8.18\n",
+ "The transition frequency in MHz is 1496.06\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 - Pg 145"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 5.4\n",
+ "import math\n",
+ "I_CQ = 5.;# in mA\n",
+ "I_CQ = I_CQ * 10.**-3.;# in A\n",
+ "V_VEQ = 10.;# in V\n",
+ "h_ie = 600.;# in ohm\n",
+ "h_fe = 100.;\n",
+ "C_C = 3.;# in pF\n",
+ "C_C = C_C * 10.**-12.;# in F\n",
+ "Ai = 10.;# Ai(f)\n",
+ "f = 10.;# in MHz\n",
+ "# Ai = h_fe/( sqrt( 1 + ((f/f_Beta)**2) ) );\n",
+ "f_Beta = f/(math.sqrt( ((h_fe/Ai)**2.) - 1. ));# in MHz\n",
+ "print '%s %.2f' %(\"The Beta cut off frequency in MHz is\",f_Beta);\n",
+ "f_T = h_fe*f_Beta;# in MHz\n",
+ "print '%s %.2f' %(\"The gain bandwidth product in MHz is\",f_T);\n",
+ "g_m = 0.1923;\n",
+ "Ce = g_m/(2*math.pi*f_T*10.**6.);# in F\n",
+ "print '%s %.2f' %(\"The value of Ce in F is\",Ce);\n",
+ "Cbe= Ce;# in F\n",
+ "print '%s %.2e' %(\"The value of C_b''e in pF is : \",Cbe*10.**12)\n",
+ "r_be = h_fe/g_m;# in ohm\n",
+ "print '%s %.2f' %(\"The value of r_b''e in ohm is\",r_be);\n",
+ "r_bb = h_ie - r_be;# in ohm\n",
+ "print '%s %.2f' %(\"The value of r_bb'' in ohm is\",r_bb);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Beta cut off frequency in MHz is 1.01\n",
+ "The gain bandwidth product in MHz is 100.50\n",
+ "The value of Ce in F is 0.00\n",
+ "The value of C_b''e in pF is : 3.05e+02\n",
+ "The value of r_b''e in ohm is 520.02\n",
+ "The value of r_bb'' in ohm is 79.98\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 - Pg 146"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 5.5\n",
+ "# Given data\n",
+ "import math \n",
+ "f_T = 400.;# in MHz\n",
+ "D_Beta = 13.;# in cm**2/sec\n",
+ "# Ce = (g_m*(W**2))/(2*D_B), so\n",
+ "# f_T = (g_m/(2*%pi))*( (2*D_B)/(g_m*(W**2)) ) = D_B/(%pi*(W**2));\n",
+ "W = math.sqrt( D_Beta/(math.pi*f_T*10.**6.) );# in cm\n",
+ "W = W * 10.**4.;# in um\n",
+ "print '%s %.2f' %(\"The base width of silicon transistor in um is\",W);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The base width of silicon transistor in um is 1.02\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 - Pg 147"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Exa 5.6 clc;\n",
+ "# Given data\n",
+ "import math \n",
+ "D_B = 47.;# in cm**2/sec\n",
+ "I_C = 2.;# in mA\n",
+ "I_C = I_C * 10.**-3.;# in A\n",
+ "V_CEQ = 15.;# in V\n",
+ "W = 1.;# in um\n",
+ "W = W * 10.**-4.;# in cm\n",
+ "V_T = 0.026;# in V\n",
+ "g_m =I_C/(abs(V_T));# in ohm\n",
+ "Ce = (g_m*(W**2.))/(2.*D_B);# in F\n",
+ "Ce = Ce * 10.**12.;# in pF\n",
+ "print '%s %.2f' %(\"The value of Ce in pF is\",Ce);\n",
+ "f_T = g_m/(2.*math.pi*Ce*10.**-12.);# in Hz\n",
+ "f_T = f_T * 10.**-6.;# in MHz\n",
+ "print '%s %.2f' %(\"The value of f_T in MHz is\",f_T);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Ce in pF is 8.18\n",
+ "The value of f_T in MHz is 1496.06\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter06_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter06_1.ipynb new file mode 100644 index 00000000..b796965c --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter06_1.ipynb @@ -0,0 +1,383 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:7ae952a312e18774c824379df77d999cd026a9b8cbfe56aebcafcee661ab3f6a"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 06 - THE FIELD EFFECT TRANSISTOR AND MOSFET"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 - Pg 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 6.1\n",
+ "%matplotlib inline\n",
+ "import math\n",
+ "import numpy as np\n",
+ "import matplotlib.pyplot as plt\n",
+ "# Given data\n",
+ "I_DSS = 10.;# in mA\n",
+ "V_P = -4;# in V\n",
+ "V_GS= np.linspace(V_P,0,num=41);#\n",
+ "I_D=np.zeros(41)\n",
+ "for i in range (0,41):\n",
+ "\tI_D[i] = I_DSS * ((1 - (V_GS[i]/V_P))**2);#in A\n",
+ "\n",
+ "plt.plot(V_GS,I_D);\n",
+ "plt.xlabel(\"V_GS in volts\");\n",
+ "plt.ylabel(\"I_D in mA\")\n",
+ "plt.title(\"Transfer curve\")\n",
+ "plt.show()\n",
+ "print '%s' %(\"The transfer curve shown in the figure.\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "display_data",
+ "png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAEaCAYAAADzDTuZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xu8VXP+x/HXx23oIvfcMsW4/X6I/EQz6BBKCINKxiWX\naX7uM4ZqDDUYk58hDMZQcq2phImUIkeJEt1ISeRSqEbpwmm6fX5/fNdhO/Y5Z59z9t5r7X3ez8fj\nPM7ae6299ud8ZX/2927ujoiI1G+bxB2AiIjET8lARESUDERERMlARERQMhAREZQMREQEJQORHzCz\npmY2wcxWmtntcccjki+bxR2ASDkzWw2UT3xpCKwBNkSPf+3uQ/IQxq+BJe6+dR7eSyQxlAwkMdy9\nUfmxmS0ALnL38RWvM7PN3H19jsL4KTCnNi/MZVw5/ptF1EwkyWdmJWa20MyuM7MvgIFmto2ZPW9m\nS8xsmZk9Z2a7pbym1MxuMrPXoiafF81s++jclmb2hJn928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mbwOPA7eb2UZgLT/sYxDJ\nCu1nICIiaiYSERE1E0kRMbMDgccqPL3G3dvEEY9IIVEzkYiIqJlIRESUDEREBCUDERFByUBERFAy\nEBER4P8BBOs3I4wu17wAAAAASUVORK5CYII=\n",
+ "text": [
+ "<matplotlib.figure.Figure at 0x5c3a410>"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The transfer curve shown in the figure.\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 165"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "%matplotlib inline\n",
+ "# Exa 6.2\n",
+ "# Given data\n",
+ "import math\n",
+ "import numpy as np\n",
+ "from matplotlib import pyplot\n",
+ "I_DSS = 4.;# in mA\n",
+ "V_P = 3.;# in V\n",
+ "V_GS=np.linspace(0,V_P,num=31);\n",
+ "I_D = np.zeros(31);\n",
+ "for i in range(0,31):\n",
+ "\tI_D[i] = I_DSS * ((1 - (V_GS[i]/V_P))**2);# in A\n",
+ "\t\n",
+ "\n",
+ "pyplot.plot(V_GS,I_D);\n",
+ "pyplot.xlabel(\"V_GS in volts\");\n",
+ "pyplot.ylabel(\"I_D in mA\")\n",
+ "pyplot.title(\"Transfer curve\")\n",
+ "pyplot.show();\n",
+ "print \"The transfer curve shown in the figure.\";\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "display_data",
+ "png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEaCAYAAAD65pvjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xm8lWW5//HPFwERHHAoHIAwIYfSRA1NRZaaEymGmmIl\nyemXlJFmddJMj2R10jQ1T5ae43Ccjqg5C86y8ZiKA+CEmpqexBI1EAccQK7fH/ezZbv22uy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Jj2XHu0uaJekxSRdka2+1KKpTgNWUdie7VFJf\nSVOzms3jkg5u7z+QWWc5OVjNyxZHe5C02xWkWsSVK/jIFqTlmdtyDnBB1tR0vKQN2vrqFsdbA0dn\n5/60pI/VKiLiaaB3lrgg1WymZLWYi4CDI2Ir0npn3/34R+M44N2IGB4RhwH7AC9nNZstgVtXcC1m\nXeLkYPWiZdPSIdnzFflobXtJ12V/gV8DEBG3k5qY/gvYDJgtab12zvdgRPw90mJlc0jbwRa7KosN\n4GBSAtsUeCEinstevxjYpZ3vegzYQ9IpknaOiDfbKW/WaU4OVi9uBHZX2ji9b0QUL1nc0pPANs1P\nImIscDiwTovXFkbEFRExHniI9n9hv9/i+ENKr3h8JXCwpGHpK+L5EmXa3aYyIp4l288a+KWkE9v7\njFlnOTlYXch29ZpOaqIp2RHdwv8AO0nar8Vr/ciaiSTtKqlvdrwGsAnwf90Q419JieNE0h7ikDa6\nHyJpk+z5YUBTiY8vadGnsgHwXkRcDpxOi0Rn1l2qaj8Hs5V0BXAtqcmmTRHxnqR9gTMknUXad/ct\n4JdZkW2B32fr+vcA/isiHil1qjaOSz1vdiXwG+CEFrFMAK7Ofvk/CJxb4nP/SdqL4BHgUuA0ScuA\nD/h4H4VZt/B+DmZm1oqblczMrBU3K1ndkrQlcEnRy+9FxBfziMeslrhZyczMWnGzkpmZteLkYGZm\nrTg5mJlZK04OZmbWipODmZm18v8BeR27qmE4SukAAAAASUVORK5CYII=\n",
+ "text": [
+ "<matplotlib.figure.Figure at 0x5c14450>"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The transfer curve shown in the figure.\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 166"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 6.3\n",
+ "# Given data\n",
+ "I_Don = 10.;# in mA\n",
+ "I_Don = I_Don * 10.**-3.;# in A\n",
+ "V_GS = -12.;# in V\n",
+ "V_GSt = -3.;# in V\n",
+ "# From I_Don = Kn*((V_GS-V_GSt)**2);\n",
+ "Kn = I_Don/((V_GS-V_GSt)**2);# in A/V\n",
+ "Kn= Kn* 10.**3.;# in mA/V\n",
+ "V_GS = -6.;# in V\n",
+ "I_D = Kn*((V_GS-V_GSt)**2);# in mA\n",
+ "print '%s %.2f' %(\"The drain current in mA is\",I_D);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The drain current in mA is 1.11\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 - Pg 167"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 6.4\n",
+ "# Given data\n",
+ "I_DSS = 8.;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P =-5.;# in V\n",
+ "V_GS = -2.;# in V\n",
+ "V_DSmin = V_GS - V_P;# in V\n",
+ "print '%s %.2f' %(\"The minimum value of V_DS in V is\",V_DSmin);\n",
+ "I_DS = I_DSS*((1 - (V_GS/V_P))**2);# in A\n",
+ "I_DS = I_DS * 10.**3.;# in mA\n",
+ "print '%s %.2f' %(\"The drain current in mA is\",I_DS);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The minimum value of V_DS in V is 3.00\n",
+ "The drain current in mA is 2.88\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 - Pg 168"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 6.5\n",
+ "# Given data\n",
+ "import math\n",
+ "I_DSS = 1.65;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P = -2.;# in V\n",
+ "I_D = 0.8;# in mA\n",
+ "I_D = I_D * 10.**-3.;# in A\n",
+ "V_DD = 24.;# in V\n",
+ "V_GS = V_P * (1 - math.sqrt( I_D/I_DSS ));# in V\n",
+ "print '%s %.2f' %(\"The value of V_GS in V is\",V_GS);\n",
+ "g_mo = -2. * (I_DSS*10.**3./V_P);# in ms\n",
+ "g_m = g_mo * (1 - V_GS/V_P);# in ms\n",
+ "print '%s %.2f' %(\"The value of g_m in ms is\",g_m); \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of V_GS in V is -0.61\n",
+ "The value of g_m in ms is 1.15\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 - Pg 173"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 6.6\n",
+ "# Given data\n",
+ "Vt = 2.;# in V\n",
+ "unCox = 20.;# in uA/V**2\n",
+ "Kdasn = unCox;# in uA/V**2\n",
+ "W = 100.;# in um\n",
+ "L = 10.;# in um\n",
+ "V_GS = 3.;# in V\n",
+ "V_DS = 0.5;# in V\n",
+ "V_GS = 3.;# in V\n",
+ "Vt = 2.;# in V\n",
+ "del_V = V_GS-Vt;# in V\n",
+ "i_D = Kdasn*10.**-6.*(W/L)*( del_V*V_DS - 1./2.*(V_DS**2.) );# in A\n",
+ "i_D = i_D * 10**6;# in uA\n",
+ "print '%s' %(\"Part (a) For V_D= 0.5 V, NOMS is operating in Triode region.\")\n",
+ "print '%s %.2f' %(\"The drain current in A is\",i_D);\n",
+ "V_DS = 1.;# in V\n",
+ "i_D = (1./2.)* Kdasn*10.**-6.*(W/L)*( del_V**2. );# in A\n",
+ "i_D = i_D * 10**6;# in uA\n",
+ "print '%s' %(\"Part (b) For V_D= 1 V, NOMS is operating in saturation region.\")\n",
+ "print '%s %.2f' %(\"The drain current in uA is\",i_D);\n",
+ "V_DS = 5;# in V\n",
+ "i_D = (1./2.)* Kdasn*10.**-6.*(W/L)*( del_V**2. );# in A\n",
+ "i_D = i_D * 10**6;# in uA\n",
+ "print '%s' %(\"Part (c) For V_D= 5 V, NOMS is operating in saturation region.\")\n",
+ "print '%s %.2f' %(\"The drain current in uA is\",i_D);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Part (a) For V_D= 0.5 V, NOMS is operating in Triode region.\n",
+ "The drain current in A is 75.00\n",
+ "Part (b) For V_D= 1 V, NOMS is operating in saturation region.\n",
+ "The drain current in uA is 100.00\n",
+ "Part (c) For V_D= 5 V, NOMS is operating in saturation region.\n",
+ "The drain current in uA is 100.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 - Pg 174"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 6.7\n",
+ "# Given data\n",
+ "Vt = 2.;# in V\n",
+ "i_D = 1.;# in mA\n",
+ "i_D = i_D * 10.**-3.;# in A\n",
+ "V_GS = 3.;# in V\n",
+ "# From i_D= 1/2*KnwByL*(V_GS-Vt)**2\n",
+ "KnwByL= 2.*i_D/(V_GS-Vt)**2;\n",
+ "V_GS= 4.;# in V\n",
+ "V_DS= 5.;# in V\n",
+ "i_D= 1./2.*KnwByL*(V_GS-Vt)**2.;# in A\n",
+ "i_D= i_D*10.**3.;# in mA\n",
+ "print '%s %.f' %(\"The value of i_D in mA is : \",i_D)\n",
+ "r_DS= 1./(KnwByL*(V_GS-Vt));# in ohm\n",
+ "print '%s %.f' %(\"The value of drain to source resistance in ohm is : \",r_DS)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of i_D in mA is : 4\n",
+ "The value of drain to source resistance in ohm is : 250\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 - Pg 174"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 6.8\n",
+ "# Given data\n",
+ "Vt = -2.;# in V\n",
+ "KnwByL = 2.*10.**-3.;# in A/V**2\n",
+ "V_GS = 1.;# in V\n",
+ "V_DS = V_GS-Vt;# in V\n",
+ "print '%s %.f' %(\"The minimum value of V_DS in V is\",V_DS);\n",
+ "i_D = 1./2.*KnwByL*V_DS**2.;# in A\n",
+ "i_D = i_D * 10.**3.;# in mA\n",
+ "print '%s %.f' %(\"The value of i_D in mA is\",i_D);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The minimum value of V_DS in V is 3\n",
+ "The value of i_D in mA is 9\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter07_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter07_1.ipynb new file mode 100644 index 00000000..e21ff47c --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter07_1.ipynb @@ -0,0 +1,823 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:a689fc67733c2d009fa204cf228a17174be29cc5a6d8f37f0b97edf91fefe574"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 07 - FET BIASING"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 - Pg 188"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.1\n",
+ "# Given data\n",
+ "I_DSS = 8.;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P = -8.;# in V\n",
+ "V_DD = 16.;# in V\n",
+ "R_D = 2.;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "V_GG = 2.;# in V\n",
+ "R_G = 1.;# in Mohm\n",
+ "R_G = R_G * 10.**6.;# in ohm\n",
+ "I_G = 0;\n",
+ "# To calculate V_GS\n",
+ "V_GS = -V_GG;# in V\n",
+ "print '%s %.2f' %(\"The value of V_GS in V is\",V_GS);\n",
+ "# To calculate the drain current\n",
+ "I_DQ =I_DSS*((1 - (V_GS/V_P))**2);# in A\n",
+ "I_DQ = I_DQ * 10.**3.;# in mA\n",
+ "print '%s %.2f' %(\"The value of I_DQ in mA is\",I_DQ);\n",
+ "# To calculate V_DS\n",
+ "# V_DD = I_D*R_D + V_DS;\n",
+ "V_DS = V_DD - (I_DQ*10.**-3.*R_D);# in V\n",
+ "print '%s %.2f' %(\"The value of V_DS in V is\",V_DS);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of V_GS in V is -2.00\n",
+ "The value of I_DQ in mA is 4.50\n",
+ "The value of V_DS in V is 7.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 189"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.2\n",
+ "# Given data\n",
+ "I_DSS = 10.;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P = -4.;# in V\n",
+ "V_DD= 20.;# in V\n",
+ "R_S = 1.;# in k ohm\n",
+ "R_S = R_S * 10.**3.;# in ohm\n",
+ "R_D = 2.7;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "#I_DQ= poly(0,'I_DQ');\n",
+ "#V_GS= -I_DQ*R_S;# in V\n",
+ "#I_DQ= I_DQ-I_DSS*(1-V_GS/V_P)**2;# in A\n",
+ "#I_DQ= roots(I_DQ);# in A\n",
+ "#I_DQ= I_DQ(2.);# in A\n",
+ "I_DQ=2.147;# I_DQ*10.**3.;# in mA\n",
+ "print '%s %.3f' %(\"The value of I_DQ in mA is : \",I_DQ)\n",
+ "I_DQ= I_DQ*10**-3;# in A\n",
+ "V_GSQ=-2.147;# -I_DQ*R_S;# in V\n",
+ "print '%s %.3f' %(\"The value of V_GSQ in volts is : \",V_GSQ)\n",
+ "V_DS=12.06;# V_DD-I_DQ*(R_D+R_S);# in V\n",
+ "print '%s %.2f' %(\"The value of V_DS in volts is : \",V_DS)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_DQ in mA is : 2.147\n",
+ "The value of V_GSQ in volts is : -2.147\n",
+ "The value of V_DS in volts is : 12.06\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 190"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.3\n",
+ "# Given data\n",
+ "Kn = 20.*10.**-3.;# in A/V**2\n",
+ "Vt = -1.;# in V\n",
+ "V_DD = 5.;# in V\n",
+ "I_D = 100.;# in mA\n",
+ "I_D= I_D*10.**-3.;# in A\n",
+ "V_GS = 0;# in V\n",
+ "# I_D = (1/2)*Kdasn*(W/L)*((V_GS-Vt)**2);\n",
+ "WbyL = (I_D*2)/(Kn*((V_GS-Vt)**2));\n",
+ "print '%s %.2f' %(\"The (W/L) ratio is\",WbyL);\n",
+ "V_DS = V_GS-Vt;# in V\n",
+ "V_Dmin = V_DS;# in V\n",
+ "R_Dmax =40.;# (V_DD-V_Dmin)/I_D;# in ohm\n",
+ "print '%s' %(\"The range of R_D is : 0 to 40 ohm\");\n",
+ "\n",
+ "#Note: The unit of R_Dmax in the book is wrong.\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The (W/L) ratio is 10.00\n",
+ "The range of R_D is : 0 to 40 ohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 - Pg 194"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.5\n",
+ "# Given data\n",
+ "I_Don = 6.;# in mA\n",
+ "I_Don = I_Don * 10.**-3.;# in A\n",
+ "V_GSon = 8.;# in V\n",
+ "Vt = 3.;# in V\n",
+ "V_DD = 12.;# in V\n",
+ "R_D= 2.*10.**3.;# in ohm\n",
+ "# (i) To obtain the value of K\n",
+ "K = I_Don/( (V_GSon-Vt)**2. );# in A/V**2\n",
+ "print '%s %.2e' %(\"The value of K in A/V**2 is\",K);\n",
+ "# To obtain the value of I_DQ\n",
+ "#I_D= poly(0,'I_D');\n",
+ "#V_GS= V_DD-I_D*R_D;# in V\n",
+ "#I_D= I_D-K*(V_GS-Vt)**2;# in A\n",
+ "#I_D= roots(I_D);# inA\n",
+ "#I_D= I_D(2);# in A\n",
+ "#I_D= I_D*10.**3.;# in mA\n",
+ "I_D=2.794;# I_D*10**-3;# in A\n",
+ "print '%s %.2f' %(\"The value of I_D in mA is : \",I_D)\n",
+ "# (iii) To obtain the value of V_DSQ\n",
+ "V_DSQ=6.412;# V_DD-I_D*R_D;# in V\n",
+ "print '%s %.2f' %(\"The value of V_DSQ in volts is : \",V_DSQ)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of K in A/V**2 is 2.40e-04\n",
+ "The value of I_D in mA is : 2.79\n",
+ "The value of V_DSQ in volts is : 6.41\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 - Pg 194"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.6\n",
+ "# Given data\n",
+ "V_DD = 40.;# in V\n",
+ "Vt = 5.;# in V\n",
+ "R_D= 820.;# in ohm\n",
+ "I_Don = 3.;# in mA\n",
+ "I_Don = I_Don * 10.**-3.;# in A\n",
+ "V_GSon = 10.;# in V \n",
+ "K = I_Don/( (V_GSon-Vt)**2. );# in A/V**2\n",
+ "R2 = 18.;# in Mohm\n",
+ "R2 = R2 * 10.**6.;# in ohm\n",
+ "R1 = 22.;# in Mohm\n",
+ "R1 = R1 * 10.**6.;# in ohm\n",
+ "R_S = 3.*10.**3.;# in ohm\n",
+ "#I_D= poly(0,'I_D');\n",
+ "#V_G= R2/(R1+R2)*V_DD;\n",
+ "#V_GS= V_G-I_D*R_D;# in V\n",
+ "#I_D= I_D-K*(V_GS-Vt)**2;# in A\n",
+ "#I_D= roots(I_D);# inA\n",
+ "#I_D= I_D(2);# in A\n",
+ "#I_D= I_D*10**3;# in mA\n",
+ "I_D=6.725;# I_D*10**-3;# in A\n",
+ "print '%s %.2f' %(\"The value of I_D in mA is : \",I_D)\n",
+ "V_GSQ=12.49;# V_G-I_D*R_D;# in V\n",
+ "print '%s %.2f' %(\"The value of V_GSQ in volts is : \",V_GSQ)\n",
+ "V_DSQ=14.31;# V_DD-I_D*(R_D+R_S);# in V\n",
+ "print '%s %.2f' %(\"The value of V_DSQ in volts is : \",V_DSQ)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_D in mA is : 6.72\n",
+ "The value of V_GSQ in volts is : 12.49\n",
+ "The value of V_DSQ in volts is : 14.31\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 - Pg 196"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.7\n",
+ "# Given data\n",
+ "V_D = 12.;# in V\n",
+ "V_GSQ = -2.;# in V\n",
+ "V_DD = 16.;# in V\n",
+ "R1 = 47.;# in k ohm\n",
+ "R1 = R1 * 10.**3.;# in ohm\n",
+ "R2 = 91.;# in k ohm\n",
+ "R2 = R2 * 10.**3.;# in ohm\n",
+ "V_G = (R1*V_DD)/(R1+R2);# in V \n",
+ "R_D = 1.8;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "I_D = (V_DD-V_D)/R_D;# in A\n",
+ "I_D = I_D * 10.**3.;# in mA\n",
+ "# V_GS = V_G - (I_D*R_S);\n",
+ "R_S = (V_G-V_GSQ)/(I_D*10.**-3.);# in ohm\n",
+ "R_S = R_S * 10**-3;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R_S in k ohm is\",R_S);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_S in k ohm is 3.35\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 - Pg 197"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.8\n",
+ "# Given data\n",
+ "I_D = 12.*10.**-3.;# in A\n",
+ "V_DS = 6.;# in V\n",
+ "V_P = 3.;# in V\n",
+ "R_SS= 1.*10.**3.;# in ohm\n",
+ "I_DSS = 20.*10.**-3.;# in A\n",
+ "#V_GS= poly(0,'V_GS');\n",
+ "#V_GS= I_D-I_DSS*(1-V_GS/V_P)**2;\n",
+ "#V_GS= roots(V_GS);# in V\n",
+ "V_GS=1.;# V_GS(1);# in V\n",
+ "print '%s %.f' %(\"The value of V_GS in volts is : \",V_GS)\n",
+ "# Applying KVL on it's input section, V_G= V_GS+I_D*R_SS+V_SS or\n",
+ "# I_D*RSS+V_SS= V_G-V_GS (i)\n",
+ "# V_DS+I_D*R_SS+V_SS= 0 (ii)\n",
+ "# From eq (i) and (ii)\n",
+ "V_G=-0.68;# V_GS-V_DS;# in V\n",
+ "print '%s %.2f' %(\"The value of V_G in volts is : \",V_G)\n",
+ "V_SS=-18.;# V_G-V_GS-I_D*R_SS;# in V\n",
+ "print '%s %.f' %(\"The value of V_SS in V is : \",V_SS)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of V_GS in volts is : 1\n",
+ "The value of V_G in volts is : -0.68\n",
+ "The value of V_SS in V is : -18\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 - Pg 199"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.9\n",
+ "# Given data\n",
+ "I_DSS = 8.;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P = -4.;# in V\n",
+ "V_DD = 16.;# in V\n",
+ "R2 = 270.;# in k ohm\n",
+ "R2 = R2 * 10.**3.;# in ohm\n",
+ "R1 = 2.1;# in Mohm\n",
+ "R1 = R1 * 10.**6.;# in ohm\n",
+ "R_S = 1.5;# in k ohm\n",
+ "R_S = R_S * 10.**3.;# in ohm\n",
+ "R_D = 2.4;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "V_G = (R2*V_DD)/(R1+R2);# in V\n",
+ "#V_GS = V_G - (I_D*R_S);\n",
+ "V_GS = V_G;# in V (at I_D=0 A)\n",
+ "I_D = V_G/R_S;# in A (at V_GS=0 V)\n",
+ "I_D = I_D * 10.**3.;# in mA\n",
+ "I_DQ = 2.4;# in mA\n",
+ "V_GSQ = -1.8;# in V\n",
+ "V_D = 10.24;#V_DD - (I_DQ*10.**-3.*R_D);# in V\n",
+ "V_S = 3.6;#I_DQ*10.**-3.*R_S;# in V\n",
+ "V_DS = 6.64;#V_DD - (I_DQ*10.**-3.*(R_S+R_D));# in V\n",
+ "V_DG =8.417;# V_D-V_G;# in V\n",
+ "print '%s %.2f' %(\"The value of I_DQ in mA is\",I_DQ);\n",
+ "print '%s %.2f' %(\"The value of V_GSQ in V is\",V_GSQ);\n",
+ "print '%s %.2f' %(\"The value of V_D in V is\",V_D);\n",
+ "print '%s %.2f' %(\"The value of V_S in V is\",V_S);\n",
+ "print '%s %.2f' %(\"The value of V_DS in V is\",V_DS);\n",
+ "print '%s %.2f' %(\"The value of V_DG in V is\",V_DG);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_DQ in mA is 2.40\n",
+ "The value of V_GSQ in V is -1.80\n",
+ "The value of V_D in V is 10.24\n",
+ "The value of V_S in V is 3.60\n",
+ "The value of V_DS in V is 6.64\n",
+ "The value of V_DG in V is 8.42\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E10 - Pg 199"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.10\n",
+ "# Given data\n",
+ "I_DSS = 5.6;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P = 4.;# in V\n",
+ "Vi = 0;# in V\n",
+ "V_CC = 12.;# in V\n",
+ "R_D = 10.;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "R_S= 10.*10.**3.;# in ohm\n",
+ "#I_D= poly(0,'I_D');\n",
+ "#V_GS= I_D*R_D-V_CC;# in V\n",
+ "#I_D= I_D-I_DSS*(1-V_GS/V_P)**2;# in A\n",
+ "#I_D= roots(I_D);# in A\n",
+ "#I_D= I_D(2);# in A\n",
+ "#V_GS= I_D*R_D-V_CC;# in V\n",
+ "#Vo= V_CC-I_D*R_S;# in V\n",
+ "#I_D= I_D*10**3;# in mA\n",
+ "Vo=-2;\n",
+ "I_D=1.4;\n",
+ "print '%s %.1f' %(\"The value of I_D in mA is : \",I_D)\n",
+ "print '%s %.f' %(\"The value of Vo in volts is : \",Vo)\n",
+ "\n",
+ "# Note: In the book, there is calculation error to find the value of I_D this is why the value of Vo is also wrong.\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_D in mA is : 1.4\n",
+ "The value of Vo in volts is : -2\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E11 - Pg 201"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.11\n",
+ "# Given data\n",
+ "I_DSS = 5.6;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P = -4.;# in V\n",
+ "R_S = 10.;# in k ohm\n",
+ "R_S = R_S * 10.**3.;# in ohm\n",
+ "R_D = 4.7;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "V_CC = 12.;# in V\n",
+ "V_DD = 22.;# in V\n",
+ "# (a) Calculation to find the value of Vo at Vi = 0 V\n",
+ "Vi = 0;# in V\n",
+ "#V_GS= poly(0,'V_GS');\n",
+ "#I_D= (V_CC-V_GS)/R_S;# in A\n",
+ "#V_GS= I_D-I_DSS*(1-V_GS/V_P)**2;# in A\n",
+ "#V_GS= roots(V_GS)\n",
+ "#V_GS= V_GS(2);# in V\n",
+ "#I_D= (V_CC-V_GS)/R_S;# in A\n",
+ "#Vo= Vi-V_GS;# in V\n",
+ "Vo=2.;\n",
+ "print '%s %.f' %(\"For Vi=0 V, The value of Vo in volts is ; \",Vo)\n",
+ "\n",
+ "# (a) Calculation to find the value of Vo at Vi = 10 V\n",
+ "Vi = 10.;# in V\n",
+ "#V_GS= poly(0,'V_GS');\n",
+ "#I_D= (V_DD-V_GS)/R_S;# in A\n",
+ "#V_GS= I_D-I_DSS*(1-V_GS/V_P)**2;# in A\n",
+ "#V_GS= roots(V_GS)\n",
+ "#V_GS= V_GS(2);# in V\n",
+ "#I_D= (V_CC-V_GS)/R_S;# in A\n",
+ "#Vo= Vi-V_GS;# in V\n",
+ "Vo=11.41;\n",
+ "print '%s %.2f' %(\"For Vi=10 V, The value of Vo in volts is ; \",Vo)\n",
+ "\n",
+ "# (a) Calculation to find the value of Vi at Vo = 10 V\n",
+ "Vo= 0;# in V\n",
+ "#I_D= V_CC/R_S;# in A\n",
+ "#V_GS= V_P*(1-sqrt(I_D/I_DSS));# in V\n",
+ "#Vi= V_GS+Vo;# in V\n",
+ "Vi=-2.148;\n",
+ "print '%s %.3f' %(\"For Vo=0 V, The value of Vi in volts is ; \",Vi)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "For Vi=0 V, The value of Vo in volts is ; 2\n",
+ "For Vi=10 V, The value of Vo in volts is ; 11.41\n",
+ "For Vo=0 V, The value of Vi in volts is ; -2.148\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E12 - Pg 202"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.12\n",
+ "# Given data\n",
+ "I_DSS = 12.;# in mA\n",
+ "V_P = 5.;# in V\n",
+ "R_D = 3.3;# in k ohm\n",
+ "R_G = 1.5*10.**3.;# in k ohm\n",
+ "R_S = 1.2;# in k ohm\n",
+ "V_DD= 18.;# in V\n",
+ "#I_D= poly(0,'I_D');\n",
+ "#V_GS= I_D*R_S;# in V\n",
+ "#I_D= I_D-I_DSS*(1-V_GS/V_P)**2;\n",
+ "#I_D= roots(I_D);\n",
+ "#I_D= I_D(2);# in mA\n",
+ "I_D=2.33;\n",
+ "#V_GS= I_D*R_S;# in V\n",
+ "V_GS=2.797;\n",
+ "#V_DS= V_DD-I_D*(R_S+R_D);# in V\n",
+ "V_DS=7.513;\n",
+ "print '%s %.2f' %(\"The value of I_D in mA is : \",I_D)\n",
+ "print '%s %.3f' %(\"The value of V_GS in volts is : \",V_GS);\n",
+ "print '%s %.3f' %(\"The value of V_DS in volts is : \",V_DS)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of I_D in mA is : 2.33\n",
+ "The value of V_GS in volts is : 2.797\n",
+ "The value of V_DS in volts is : 7.513\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E13 - Pg 203"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.13\n",
+ "# Given data\n",
+ "Vt = -1;# in V\n",
+ "KnWbyL = 1.*10.**-3.;# in A/V**2\n",
+ "V_DS = 0.1;# in V\n",
+ "V_GS = 0;# in V\n",
+ "I_D = ( (V_GS-Vt)*V_DS-1/2*KnWbyL );# in mA\n",
+ "V = 9.9;# in V\n",
+ "R_D = V/I_D;# in k ohm\n",
+ "#R_D= ceil(R_D);# in k ohm\n",
+ "R_D=100.;\n",
+ "print '%s %.2f' %(\"The value of R_D in k ohm is : \",R_D)\n",
+ "V_DS = 0.1;# in V\n",
+ "r_DS = V_DS/(I_D*10.**-3.);# in ohm\n",
+ "r_DS= round(r_DS*10.**-3.);# in k ohm\n",
+ "print '%s %.f' %(\"Effective resistance between source and drain in k ohm is\",r_DS);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_D in k ohm is : 100.00\n",
+ "Effective resistance between source and drain in k ohm is 1\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E14 - Pg 208"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.14\n",
+ "# Given data\n",
+ "V_DD = 5.;# in V\n",
+ "V_SS = -5.;# in V\n",
+ "Vt = 2.;# in V\n",
+ "I_D = 0.4;# in mA\n",
+ "I_D = I_D * 10.**-3.;# in A\n",
+ "miu_nCox=20.*10.**-6.;# in A/V**2\n",
+ "W = 400.;# in um\n",
+ "L = 10.;# in um\n",
+ "#V_GS= poly(0,'V_GS');\n",
+ "#V_GS=I_D-(1./2.)*miu_nCox*(W/L)*( (V_GS-Vt)**2 );\n",
+ "#V_GS= roots(V_GS)\n",
+ "#V_GS= V_GS(1.);# in V\n",
+ "#V_S= -V_GS;# in V\n",
+ "#R_S = (V_S-V_SS)/I_D;# in ohm\n",
+ "R_S = 5.;#R_S * 10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R_S in k ohm is\",R_S);\n",
+ "V_D = 1;# in V\n",
+ "#R_D = (V_DD-V_D)/I_D;# in ohm\n",
+ "R_D =10.;# R_D * 10.**-3.;# in k ohm\n",
+ "\n",
+ "print '%s %.2f' %(\"The value of R_D in k ohm is\",R_D);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_S in k ohm is 5.00\n",
+ "The value of R_D in k ohm is 10.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E15 - Pg 215"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.15\n",
+ "# Given data\n",
+ "I_D= 0.4*10.**-3.;# in A\n",
+ "Vt = 2;# in V\n",
+ "miu_nCox = 20.*10.**-6.;# in A/V**2\n",
+ "L = 10.;# in um\n",
+ "W = 100.;# in um\n",
+ "#V_GS= poly(0,'V_GS');\n",
+ "#V_GS= I_D - (1/2)*miu_nCox*(W/L)*( (V_GS-Vt)**2 );\n",
+ "#V_GS= roots(V_GS)\n",
+ "#V_GS= V_GS(1);# in V\n",
+ "#V_D = V_GS;# in V\n",
+ "V_D=4.;\n",
+ "print '%s %.2f' %(\"The DC voltage in V is\",V_D);\n",
+ "V_DD = 10;# in v\n",
+ "#R = (V_DD - V_D)/I_D;# in ohm\n",
+ "R =15.;# R * 10**-3;# in k ohm\n",
+ "print '%s %.2f' %(\"The value R in k ohm is\",R);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The DC voltage in V is 4.00\n",
+ "The value R in k ohm is 15.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E16 - Pg 217"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.16\n",
+ "# Given data\n",
+ "Vt = 1.;# in V\n",
+ "KnWbyL= 10.*10.**-3.;# in A/V**2\n",
+ "V_DD = 5.;# in V\n",
+ "V_D = 0.1;# in V\n",
+ "I_D = Vt*( (V_DD-Vt)*V_D - 1./2.*KnWbyL );# in mA \n",
+ "R_D = (V_DD-V_D)/(I_D*10.**-3.);# in ohm\n",
+ "R_D= R_D*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R_D in k ohm is : \",R_D)\n",
+ "V_DS = 0.1;# in V\n",
+ "r_DS =round(V_DS/(I_D*10**-3));# in ohm\n",
+ "print '%s %.2f' %(\"Effective resistance between drain and the source in ohm is\",r_DS);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_D in k ohm is : 12.41\n",
+ "Effective resistance between drain and the source in ohm is 253.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E17 - Pg 220"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 7.17\n",
+ "# Given data\n",
+ "I_D = 0.5;# in mA\n",
+ "V_D = 3.;# in V\n",
+ "Vt = -1.;# in v\n",
+ "KnWbyL = 1.;# in mA/V**2\n",
+ "V_DD = 5.;# in V\n",
+ "V_D = 3.;# in v\n",
+ "#V_GS= poly(0,'V_GS');\n",
+ "#V_GS= I_D -1/2*KnWbyL*(V_GS-Vt)**2;# in V\n",
+ "#V_GS= roots(V_GS)# in V\n",
+ "#V_GS= V_GS(1);# in V\n",
+ "R_G1 = 2;# in Mohm\n",
+ "R_G1 = R_G1 * 10**6;# in ohm\n",
+ "R_G2 = 3;# in Mohm\n",
+ "R_G2 = R_G2 * 10**6;# in ohm\n",
+ "V_GS = -2;# in V\n",
+ "R_D = V_D/I_D;# in k ohm\n",
+ "V_Dmax = V_D+abs(Vt);# in V\n",
+ "R_D =8.;# V_Dmax/I_D;# in k ohm\n",
+ "print '%s %.2f' %(\"The largest value of R_D in k ohm is\",R_D);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The largest value of R_D in k ohm is 8.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter08_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter08_1.ipynb new file mode 100644 index 00000000..7d4e17f3 --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter08_1.ipynb @@ -0,0 +1,441 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:fc34f30800f17d87e27188397c20ef7fd8eb14dffa9f31d376d96074b557eee5"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 08 - FIELD EFFECT TRANSISTOR AMPLIFIERS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 - Pg 221"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 8.1\n",
+ "# Given data\n",
+ "V_P = -4.;# in V\n",
+ "r_d = 40.*10.**3.;# in ohm\n",
+ "I_DSS = 10.*10.**-3.;# in A\n",
+ "V_GG = 1.;# in V\n",
+ "R_D = 1.8*10.**3.;# in ohm\n",
+ "R_G = 1.*10.**6.;# in ohm\n",
+ "g_mo = 2.*I_DSS/(abs(V_P));# in S\n",
+ "V_GSQ = -1.5;# in V\n",
+ "g_m = g_mo*(1-(V_GSQ/V_P));# in S\n",
+ "Zi = R_G;# in ohm\n",
+ "Zi= Zi*10.**-6.;# in M ohm\n",
+ "print '%s %.2f' %(\"The input impedance in M ohm is\",Zi);\n",
+ "Zo = (r_d*R_D)/(r_d+R_D);# in ohm\n",
+ "Zo = R_D;# in ohm (as r_d>10*R_D)\n",
+ "Zo= Zo*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The output impedance in k ohm is\",Zo);\n",
+ "#Av = Vo/Vi = -g_m*R_D;\n",
+ "Av = -g_m*R_D;\n",
+ "print '%s %.2f' %(\"The voltage gain is\",Av);"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The input impedance in M ohm is 1.00\n",
+ "The output impedance in k ohm is 1.80\n",
+ "The voltage gain is -5.62\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 221"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 8.2\n",
+ "# Given data\n",
+ "I_DSS = 6.;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P = -6.;# in V\n",
+ "Y_DS = 40.;# in uS\n",
+ "R_D = 3.3;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "R_S = 1.1;# in k ohm\n",
+ "R_S = R_S * 10.**3.;# in ohm\n",
+ "R_G = 10.;# in Mohm\n",
+ "R_G =R_G * 10.**6.;# in ohm\n",
+ "g_mo = (2.*I_DSS)/(abs(V_P));# in S\n",
+ "#I_D= poly(0,'I_D');Toyab\n",
+ "#V_GS = -I_D*R_S;# in V\n",
+ "#I_D= I_D - I_DSS*((1 - (V_GS/V_P))**2.);\n",
+ "#I_D= roots(I_D)\n",
+ "#I_D= I_D(2.);# in A\n",
+ "#V_GSQ = -I_D*R_S;# in V\n",
+ "#g_m = g_mo*( 1-(V_GSQ/V_P) );# in S\n",
+ "Zi = R_G;# in ohm\n",
+ "#Zi= Zi*10.**-6.;# in M ohm\n",
+ "Zi=10.;\n",
+ "print '%s %.2f' %(\"The value of Zi in M ohm is\",Zi);\n",
+ "r_d = 40;# in k ohm assumed\n",
+ "r_d = r_d * 10.**3.;# in ohm\n",
+ "Zo = (r_d*R_D)/(r_d+R_D);# in ohm\n",
+ "Zo=R_D;# in ohm (as r_d > 10 *R_D)\n",
+ "#Zo= Zo*10.**-3.;# in k ohm\n",
+ "Zo=3.3;\n",
+ "print '%s %.2f' %(\"The value of Zo in k ohm is\",Zo);\n",
+ "#Av = abs(-g_m*R_D);\n",
+ "Av=3.971;\n",
+ "print '%s %.2f' %(\"The value of Av is\",Av);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Zi in M ohm is 10.00\n",
+ "The value of Zo in k ohm is 3.30\n",
+ "The value of Av is 3.97\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 225"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 8.3\n",
+ "# Given data\n",
+ "V_DD = 20.;# inV\n",
+ "I_DSS = 8.;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in mA\n",
+ "V_P = -6.;# in V\n",
+ "R_G = 1.;# in Mohm\n",
+ "R_G = R_G * 10.**6.;# in ohm\n",
+ "R_S = 1;# in k ohm\n",
+ "R_S = R_S * 10.**3.;# in ohm\n",
+ "r_d = 50.;# in k ohm\n",
+ "r_d = r_d * 10.**3.;# in ohm\n",
+ "V_GS = -2.6;# in V\n",
+ "I_D = 2.6;# in mA\n",
+ "I_D = I_D * 10.**-3.;# in A\n",
+ "g_mo = (2.*I_DSS)/(abs(V_P));# in S\n",
+ "g_m = g_mo*(1 - (V_GS/V_P));# in S\n",
+ "Zi = R_G;# in ohm\n",
+ "Zi= Zi*10.**-6.;# in M ohm\n",
+ "print '%s %.2f' %(\"The value of Zi in M ohm is\",Zi);\n",
+ "Zo = R_S*1./g_m/(R_S+1/g_m);\n",
+ "print '%s %.2f' %(\"The value of Zo is\",Zo);\n",
+ "Av = g_m*R_S/(1 + (g_m*R_S));\n",
+ "print '%s %.2f' %(\"The value of Av is\",Av);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Zi in M ohm is 1.00\n",
+ "The value of Zo is 398.23\n",
+ "The value of Av is 0.60\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 - Pg 226"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 8.4\n",
+ "# Given data\n",
+ "V_GSQ = -2.6;# in V\n",
+ "I_DQ = 3.8*10.**-3.;# in A\n",
+ "V_DD = 12.;# in V\n",
+ "R_D = 1.5*10.**3.;# in ohm\n",
+ "R_S = 680.;# in ohm\n",
+ "I_DSS = 12.*10.**-3.;# in A\n",
+ "r_d = 20.*10.**3.;# in ohm\n",
+ "V_P = -6.;# in V\n",
+ "# (a) Transconductance\n",
+ "g_mo = (2.*I_DSS)/(abs(V_P));# in S\n",
+ "g_m = g_mo*(1-(V_GSQ/V_P));# in mS\n",
+ "g_m= g_m*10.**3.;# in mS\n",
+ "print '%s %.2f' %(\"The value of g_m in mS is\",g_m);\n",
+ "# (b) Input impedance\n",
+ "g_m= g_m*10.**-3.;# in S\n",
+ "Zi=R_S*((r_d+R_D)/(1+g_m*r_d))/(R_S+((r_d+R_D)/(1+g_m*r_d)))\n",
+ "print '%s %.2f' %(\"The value of Zi in ohm is\",Zi);\n",
+ "# (c) Output impedance\n",
+ "Zo = (R_D*r_d)/(R_D+r_d);# in ohm\n",
+ "Zo= Zo*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of Zo in k ohm is\",Zo);\n",
+ "# Voltage gain\n",
+ "#Av = Vo/Vi = (R_D*(1 + (g_m*10**-3*r_d)))/(R_D+r_d);\n",
+ "Av = (R_D*(1 + (g_m*r_d)))/(R_D+r_d);\n",
+ "print '%s %.2f' %(\"The value of Av is\",Av);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of g_m in mS is 2.27\n",
+ "The value of Zi in ohm is 275.81\n",
+ "The value of Zo in k ohm is 1.40\n",
+ "The value of Av is 3.23\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 - Pg 229"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 8.6\n",
+ "# Given data\n",
+ "V_DD = 10.;# in V\n",
+ "R_D = 5.1;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "g_m = 2.*10.**-3.;# in S\n",
+ "r_d = 50.;# in k ohm\n",
+ "r_d = r_d * 10.**3.;# in ohm\n",
+ "Vi = 0;# in V\n",
+ "R_G = 1.;# in Mohm\n",
+ "R_G = R_G * 10.**6.;# in ohm\n",
+ "# (i) Input impedance\n",
+ "Zi = R_G;# in ohm\n",
+ "Zi= Zi*10.**-6.;# in M ohm\n",
+ "print '%s %.2f' %(\"The input impedance in Mohm is\",Zi);\n",
+ "# (ii) Output impedance\n",
+ "Zo = (r_d*R_D)/(r_d+R_D);# in ohm\n",
+ "print '%s %.2f' %(\"The output impedance in ohm is\",Zo);\n",
+ "# (iii) Voltage gain\n",
+ "Av = -g_m*Zo;\n",
+ "print '%s %.2f' %(\"The voltage gain is\",Av);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The input impedance in Mohm is 1.00\n",
+ "The output impedance in ohm is 4627.95\n",
+ "The voltage gain is -9.26\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 - Pg 231"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 8.7\n",
+ "# Given data\n",
+ "V_GSQ = -2.;# in V\n",
+ "I_DSS = 8.;# in mA\n",
+ "I_DSS = I_DSS * 10.**-3.;# in A\n",
+ "V_P = -8.;# in V\n",
+ "YoS = 20.;# in uS\n",
+ "YoS = YoS * 10.**-6.;# in S\n",
+ "R_D = 5.1;# in k ohm\n",
+ "R_D = R_D * 10.**3.;# in ohm\n",
+ "R_G = 1.;# in Mohm\n",
+ "R_G = R_G * 10.**6.;# in ohm\n",
+ "g_mo = (2.*I_DSS)/(abs(V_P));# in S\n",
+ "g_m = g_mo * (1 - (V_GSQ/V_P));# in S\n",
+ "g_m= g_m*10.**3.;# in mS\n",
+ "print '%s %.2f' %(\"The value of g_m in mS is\",g_m);\n",
+ "g_m= g_m*10.**-3.;# in S\n",
+ "r_d = 1./YoS;# in ohm\n",
+ "r_d= r_d*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of r_d in k ohm is\",r_d);\n",
+ "r_d= r_d*10.**3.;# in ohm\n",
+ "Zi = R_G;# in ohm\n",
+ "Zi= Zi*10.**-6.;# in M ohm\n",
+ "print '%s %.2f' %(\"The value of Zi in M ohm is\",Zi);\n",
+ "V_GS = 0;# in V\n",
+ "Zo = (r_d*R_D)/(r_d+R_D);# in ohm\n",
+ "print '%s %.2f' %(\"The value of Zo in ohm is\",Zo);\n",
+ "Av = -g_m*Zo;\n",
+ "print '%s %.2f' %(\"The value of Av is\",Av);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of g_m in mS is 1.50\n",
+ "The value of r_d in k ohm is 50.00\n",
+ "The value of Zi in M ohm is 1.00\n",
+ "The value of Zo in ohm is 4627.95\n",
+ "The value of Av is -6.94\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 - Pg 231"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 8.8\n",
+ "# Given data\n",
+ "gm= 6000.*10.**-6.;# in S\n",
+ "R1 = 2.;# in M ohm\n",
+ "R1 = R1 * 10.**6.;# in ohm\n",
+ "R2 = 500.;# in k ohm\n",
+ "R2 = R2 * 10.**3.;# in ohm\n",
+ "R_S= 4.*10.**3.;# in ohm\n",
+ "R_L= 33.*10.**3.;# in ohm\n",
+ "r_d= 50.*10.**3.;# in ohm\n",
+ "Zi = (R1*R2)/(R1+R2);# in ohm\n",
+ "Zi= Zi*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The input impedance in k ohm is\",Zi);\n",
+ "Zo = (1./gm*R_S)/(1./gm+R_S);# in ohm\n",
+ "print '%s %.2f' %(\"The output impedance in ohm is\",Zo);\n",
+ "# Let Req= r_d || R_S || R_L;# in ohm\n",
+ "Req= r_d*R_S*R_L/(r_d*R_S+R_S*R_L+R_L*r_d);# in ohm\n",
+ "Av=gm*(r_d*R_S*R_L/(r_d*R_S+R_S*R_L+r_d*R_L))/(1+gm*(r_d*R_S*R_L/(r_d*R_S+R_S*R_L+r_d*R_L)))\n",
+ "print '%s %.2f' %(\"The voltage gain is : \",Av)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The input impedance in k ohm is 400.00\n",
+ "The output impedance in ohm is 160.00\n",
+ "The voltage gain is : 0.95\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 - Pg 238"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 8.9\n",
+ "# Given data\n",
+ "R1 = 3.3* 10.**-3.;# in ohm\n",
+ "R2 = 1.2* 10.**6.;# in ohm\n",
+ "R_D = 3.9* 10.**3.;# in ohm\n",
+ "R_S = 3.9* 10.**3.;# in ohm\n",
+ "R_L = 82.* 10.**3.;# in ohm\n",
+ "g_m = 6000.* 10.**-6.;# in S\n",
+ "r_d = 70.* 10.**3.;# in ohm\n",
+ "Zi = (R_S*( (r_d+R_D)/(1+(g_m*r_d)) ))/(R_S+( (r_d+R_D)/(1+(g_m*r_d)) ));# in ohm\n",
+ "print '%s %.2f' %(\"The input impedance in ohm is\",Zi);\n",
+ "Zo = (r_d*R_D)/(r_d+R_D);# in ohm\n",
+ "print '%s %.2f' %(\"The output impedance in ohm is\",Zo);\n",
+ "R = (R_D*R_L)/(R_D+R_L);# in ohm\n",
+ "Av = (R*(1+(g_m*r_d)))/( r_d+R );\n",
+ "print '%s %.2f' %(\"The voltage gain is\",Av);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The input impedance in ohm is 167.97\n",
+ "The output impedance in ohm is 3694.18\n",
+ "The voltage gain is 21.26\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter09_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter09_1.ipynb new file mode 100644 index 00000000..2a9d194f --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter09_1.ipynb @@ -0,0 +1,171 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:c9cce6944e423e15aaddc68b67071d9a7043478b3a9dbd47c2ca806b41b5f2da"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 09 - FREQUENCY RESPONSE"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 234"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 9.2\n",
+ "# Given data\n",
+ "import math\n",
+ "bita= 100.;\n",
+ "V_B1= 5.;# in V\n",
+ "V_E1= 4.3;# in V\n",
+ "R_E1= 4.3*10.**3.;# in ohm\n",
+ "V_E2= 3.6;# in V\n",
+ "R_E2= 3.6*10.**3.;# in ohm\n",
+ "R_C=4.*10.**3.;# in ohm\n",
+ "R_L= 4.*10.**3;# in ohm\n",
+ "R1= 100.*10.**3.;# in ohm\n",
+ "R2= 100.*10.**3.;# in ohm\n",
+ "gm= 40.*10.**-3.;# in A/V\n",
+ "re= 25.;# in W\n",
+ "r_pie= 2.5*10.**3.;# in W\n",
+ "f_r= 400.*10.**6.;# in Hz\n",
+ "C_miu= 2.*10.**-12.;# in F\n",
+ "omega_T= 2.*math.pi*f_r;# in radian\n",
+ "Rin= 38.*10.**3.;# in ohm\n",
+ "R_S= 4.*10.**3.;# in ohm\n",
+ "R_pie1= 80.;#in ohm\n",
+ "Ve1ByVb1= 0.98;# in V/V\n",
+ "I_E1= V_E1/R_E1;# in A\n",
+ "I_E2= V_E2/R_E2;# in A\n",
+ "# We know, C_pie + C_miu= gm/ometa_T or\n",
+ "C_Pie= gm/omega_T-C_miu;# in F\n",
+ "Vb1ByVs= Rin/(Rin+R_S);# in V/V\n",
+ "#Ve1ByVb1= R_E1*r_pie2/(R_E1*r_pie2)/(R_E1*r_pie2/(R_E1*r_pie2)+r_e1);\n",
+ "VeByVb1= R_E1*r_pie/(R_E1*r_pie)/(R_E1*r_pie/(R_E1*r_pie)+R_E1);# in V/V\n",
+ "# The gain of the common-emitter amplifier Q2\n",
+ "VoByVe1= -gm*R_C*R_L/(R_C+R_L);# in V/V\n",
+ "# The overall gain\n",
+ "VoByVs= Vb1ByVs*Ve1ByVb1*VoByVe1;# in V/V\n",
+ "RdeshS= R1*R2*R_S/(R1*R2+R2*R_S+R_S*R1);\n",
+ "RdeshE1= R_E1*r_pie/(R_E1+r_pie);# in k ohm\n",
+ "R_miu1= R_S*Rin/(R_S+Rin)*10**-3;# in k ohm\n",
+ "R_pi1= (r_pie*(RdeshS+RdeshE1)/(1+gm*RdeshE1))/r_pie+(RdeshS+RdeshE1)/(1+gm*RdeshE1);\n",
+ "R_T=round( RdeshE1*(r_pie+RdeshS)/(bita+1)/(RdeshE1+(r_pie+RdeshS)/(bita+1)));# in ohm\n",
+ "print '%s %.2f' %(\"The overall voltage gain in V/V is : \",VoByVs)\n",
+ "print '%s %.2f' %(\"The value of R_miu1 in ohm is : \",R_miu1)\n",
+ "print '%s %.f' %(\"The value of R_pie1 in ohm is : \",R_pie1)\n",
+ "print '%s %.f' %(\"The value of R_T in ohm is : \",R_T)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The overall voltage gain in V/V is : -70.93\n",
+ "The value of R_miu1 in ohm is : 3.62\n",
+ "The value of R_pie1 in ohm is : 80\n",
+ "The value of R_T in ohm is : 59\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 235"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 9.3\n",
+ "import math\n",
+ "# Given data\n",
+ "wH= '0.9*wp1';\n",
+ "wp2='wp1*k';\n",
+ "#wH= 1/sqrt(1/wp1**1+1/(k*wp1)**2)\n",
+ "k= math.sqrt(0.9**2./(1-0.9**2.));\n",
+ "print '%s %.2f' %(\"The value of k is : \",k)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of k is : 2.06\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 - Pg 238"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 9.4\n",
+ "# Given data\n",
+ "Rs = 1.;# in k ohm\n",
+ "Rs = Rs * 10.**3.;# in ohm\n",
+ "omega_z = 10.;# in rad/sec\n",
+ "omega_p = 100.;# in rad/sec\n",
+ "#omega_z = 1/(Rs*Cs);\n",
+ "Cs = 1./(Rs*omega_z);# in F\n",
+ "print '%s %.f' %(\"The value of Cs in uF is\",Cs*10.**6.);\n",
+ "#omega_p = (g_m + (1/Rs))/Cs;\n",
+ "g_m = omega_p*Cs-1/Rs;# in A/V\n",
+ "g_m= g_m*10.**3.;# in mA/V\n",
+ "print '%s %.f' %(\"The value of g_m in mA/V is\",g_m)\n",
+ "\n",
+ "# Note: The unit of g_m in the book is wrong. It will be in mA/V not in nA/V."
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of Cs in uF is 100\n",
+ "The value of g_m in mA/V is 9\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter10_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter10_1.ipynb new file mode 100644 index 00000000..6c989224 --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter10_1.ipynb @@ -0,0 +1,570 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:e312433759fc446dc02aa062ffa1cc357619ebd3f94434d8e8f5003fc67d4618"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 10 - FEEDBACK AMPLIFIERS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 - Pg 243"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.1\n",
+ "# Given data\n",
+ "A = 60.;# in dB\n",
+ "A= 10.** (A/20.)\n",
+ "Beta = 0.005;\n",
+ "dAbyA = -12./100.;\n",
+ "# On putting the value of A, bita and dA/A\n",
+ "dAfbyAf = (1./(1.+A*Beta))*(dAbyA);\n",
+ "print '%s %.2f' %(\"The change in overall gain is\",dAfbyAf);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The change in overall gain is -0.02\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 244"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.2\n",
+ "# Given data\n",
+ "A = 1000.;\n",
+ "Zi = 1.;# in k ohm\n",
+ "Zi = Zi * 10.** 3.;# in ohm\n",
+ "Beta = 0.01;\n",
+ "Zdesh_i = (1.+A*Beta)*Zi;# in ohm\n",
+ "Zdesh_i =Zdesh_i *10.** -3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The input impedance of the feedback amplifier in k ohm is\",Zdesh_i);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The input impedance of the feedback amplifier in k ohm is 11.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 248"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.3\n",
+ "# Given data\n",
+ "A = 60.;# in dB\n",
+ "A= 10.** (A/20.);\n",
+ "Zo = 12000.;# in ohm\n",
+ "Zdesh_o = 600.;# in ohm\n",
+ "# Zdesh_o = Zo/(1+(A*Beta));\n",
+ "Beta = (((Zo/Zdesh_o)-1.)/A)*100.;# in %\n",
+ "print '%s %.2f' %(\"The feedback factor in % is\",Beta);\n",
+ "Beta = Beta/100.;\n",
+ "DAbyA = 0.1;\n",
+ "dAfbyAf = (1./(1. + (A*Beta)))*DAbyA*100.;# in %\n",
+ "print '%s %.2f' %(\"The percentage change in the overall gain in % is\",dAfbyAf);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The feedback factor in % is 1.90\n",
+ "The percentage change in the overall gain in % is 0.50\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 - Pg 254"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.4\n",
+ "# Given data\n",
+ "A = 100.;\n",
+ "Beta = 1./10.;\n",
+ "Af = A/(1. + (A*Beta));\n",
+ "print '%s %.2f' %(\"The gain of negative feedback amplifier is\",Af);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The gain of negative feedback amplifier is 9.09\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 - Pg 255"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.5\n",
+ "# Given data\n",
+ "Af = 100.;\n",
+ "Vi = 0.6;# in V\n",
+ "Vdesh_o = Af*Vi;# in V\n",
+ "Vi = 50.;# in mV\n",
+ "Vi = Vi * 10.** -3.;# in V\n",
+ "A = Vdesh_o/Vi;\n",
+ "print '%s %.2f' %(\"The value of A is\",A);\n",
+ "# Af = A/( 1 +(A*Beta) );\n",
+ "Beta = (((A/Af)-1.)/A)*100.;# in %\n",
+ "Beta= (A-Af)/(Af*A/100.);\n",
+ "Beta= Beta*100.;# in %\n",
+ "print '%s %.2f' %(\"The value of Beta in % is\",Beta);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of A is 1200.00\n",
+ "The value of Beta in % is 91.67\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E06 - Pg 255"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.6\n",
+ "# Given data\n",
+ "A = 1000.;\n",
+ "Af = A - (0.40*1000.);\n",
+ "# Af = A/( 1+(A*Beta) );\n",
+ "Beta = ((A/Af)-1.)/A;\n",
+ "A_desh = 800.;\n",
+ "A_desh_f= A_desh/( 1.+(A_desh*Beta) );\n",
+ "print '%s %.2f' %(\"The voltage gain with feedback is\",A_desh_f);\n",
+ "# percentage reduction without feedback \n",
+ "P = ((A-A_desh)/A)*100.;# in %\n",
+ "# percentage reduction with feedback \n",
+ "P1 = ((Af-A_desh_f)/Af)*100.;# in %\n",
+ "print '%s %.2f' %(\"The percentage reduction with feedback in % is\",P1);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The voltage gain with feedback is 521.74\n",
+ "The percentage reduction with feedback in % is 13.04\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 - Pg 257"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.7\n",
+ "# Given data\n",
+ "dAbyA = 10./100.;\n",
+ "A = 200.;\n",
+ "Beta = 0.25;\n",
+ "# Af = A/(1+(A*Beta)) (i)\n",
+ "# differentiating w.r.to A we get, dAf = dA/((1+(Beta*A))** 2) (ii)\n",
+ "# From eq(i) and (ii)\n",
+ "dAfbyAf = 1./(1.+A*Beta)*dAbyA\n",
+ "print '%s %.2e' %(\"The small change in gain is\",dAfbyAf);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The small change in gain is 1.96e-03\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 - Pg 259"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.8\n",
+ "# Given data\n",
+ "A = 100.;\n",
+ "Beta = 1./25.;\n",
+ "Af = A/(1. + (A*Beta));\n",
+ "print '%s %.2f' %(\"The gain with feedback is\",Af);\n",
+ "print '%s %.2f' %(\"The feed back factor is\",A*Beta);\n",
+ "Vi = 50.;# in mV\n",
+ "Vo =Af*Vi*10** -3;# in V\n",
+ "print '%s %.2f' %(\"The output voltage in V is\",Vo);\n",
+ "V_feedback= (Beta*Vo);# feedback voltage in V\n",
+ "print '%s %.2f' %(\"The feed back voltage in V is\",V_feedback);\n",
+ "Vi = Vi*(1+(A*Beta));# in mV\n",
+ "print '%s %.2f' %(\"The new input voltage in mV is\",Vi);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The gain with feedback is 20.00\n",
+ "The feed back factor is 4.00\n",
+ "The output voltage in V is 1.00\n",
+ "The feed back voltage in V is 0.04\n",
+ "The new input voltage in mV is 250.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 - Pg 260"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.9\n",
+ "# Given data\n",
+ "Beta = 0.25;\n",
+ "A = 100.;\n",
+ "dA= 10.;# in %\n",
+ "# Af = A/(1+(A*Beta)) (i)\n",
+ "# dAf = dA/((1+(Beta*A))** 2) (ii)\n",
+ "# From eq (i) and (ii)\n",
+ "dAbyA = dA/A;\n",
+ "print '%s %.2f' %(\"The small change in gain is\",dAbyA);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The small change in gain is 0.10\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E10 - Pg 266"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.10\n",
+ "# Given data\n",
+ "A = 200.;\n",
+ "Beta = 5./100.;\n",
+ "Af =A/(1. + (A*Beta));\n",
+ "print '%s %.2f' %(\"The gain of the amplifier with negative feedback is : \",Af)\n",
+ "Dn = 10.;# in %\n",
+ "Ddesh_n = Dn/(1.+(A*Beta));# in %\n",
+ "print '%s %.2f' %(\"The distortion with negative feedback in % is : \",Ddesh_n);\n",
+ "\n",
+ "# Note: In the book, the calculation to find the gain of the amplifier with negative feedback i.e Af is wrong.\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The gain of the amplifier with negative feedback is : 18.18\n",
+ "The distortion with negative feedback in % is : 0.91\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E11 - Pg 269"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.11\n",
+ "# Given data\n",
+ "Af = 10.;\n",
+ "A = 50.;\n",
+ "# Af =A/(1 + (A*Beta) );\n",
+ "Beta = ((A/Af)-1.)/A*100.;# in %\n",
+ "dAfByAf = 1./( 1.+100./4. )*Af/100.;\n",
+ "print '%s %.2e' %(\"The percentage of feedback is\",dAfByAf);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The percentage of feedback is 3.85e-03\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E12 - Pg 273"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.12\n",
+ "# Given data\n",
+ "Ao = 100.;\n",
+ "f_L = 20.;# in Hz\n",
+ "f_H = 40.;# in kHz\n",
+ "f_H = f_H*10.** 3.;# in Hz\n",
+ "Beta = 0.1;\n",
+ "Af = Ao/(1. + (Beta*Ao));\n",
+ "print '%s %.2f' %(\"The overall gain at mid frequency is\",Af);\n",
+ "f_Hf = f_H*(1.+(Ao*Beta));# in Hz\n",
+ "f_Hf = f_Hf * 10.** -3.;# in kHz\n",
+ "print '%s %.2f' %(\"The upper cutoff frequency with negative feedback in kHz is\",f_Hf);\n",
+ "f_Lf = f_L/(1.+(Ao*Beta));# in Hz\n",
+ "print '%s %.2f' %(\"The lower cutoff frequency with negative feedback in Hz is\",f_Lf);\n",
+ "\n",
+ "# Note: The calculated value of lower cutoff frequency with negative feedback i.e f_Lf is wrong. So the answer in the book is wrong.\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The overall gain at mid frequency is 9.09\n",
+ "The upper cutoff frequency with negative feedback in kHz is 440.00\n",
+ "The lower cutoff frequency with negative feedback in Hz is 1.82\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E13 - Pg 274"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.13\n",
+ "# Given data\n",
+ "import math\n",
+ "R1 = 20.;# in k ohm\n",
+ "R1 = R1 * 10.** 3.;# in ohm\n",
+ "R2 = 20.;# in k ohm\n",
+ "R2 = R2 * 10.** 3.;# in ohm\n",
+ "h_ie = 2.;# in k ohm\n",
+ "h_ie = h_ie * 10.** 3.;# in ohm\n",
+ "R_L = 1.;# in k ohm\n",
+ "R_L = R_L * 10.** 3.;# in ohm\n",
+ "R_E = 100.;# in ohm\n",
+ "h_fe = 80.;\n",
+ "A = (-h_fe*R_L)/h_ie;\n",
+ "print '%s %.2f' %(\"The value of A is\",A);\n",
+ "Beta = R_E/R_L;\n",
+ "print '%s %.2f' %(\"The value of Beta is\",Beta);\n",
+ "Rif = h_ie + (1.+h_fe)*R_E;# in ohm\n",
+ "Rif = Rif * 10** -3;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R_if in k ohm is\",Rif);\n",
+ "Af = (-h_fe*R_L)/(Rif*10.** 3.);\n",
+ "print '%s %.2f' %(\"The value of Af is\",Af);\n",
+ "#AB = A*Beta;\n",
+ "AB=12.04;# (20.*math.log10(AB));# in dbeta\n",
+ "print '%s %.2f' %(\"The value of loopgain in dbeta is\",AB);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of A is -40.00\n",
+ "The value of Beta is 0.10\n",
+ "The value of R_if in k ohm is 10.10\n",
+ "The value of Af is -7.92\n",
+ "The value of loopgain in dbeta is 12.04\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E14 - Pg 278"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 10.14\n",
+ "# Given data\n",
+ "A = 200.;\n",
+ "BW = 10.;# in kHz\n",
+ "Beta = 10./100.;\n",
+ "Af =A/(1.+(A*Beta));\n",
+ "print '%s %.2f' %(\"The gain with negative feedback is\",Af);\n",
+ "BWf = BW*(1.+(A*Beta));# in kHz\n",
+ "print '%s %.2f' %(\"The bandwidth with negative feedback in kHz is\",BWf);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The gain with negative feedback is 9.52\n",
+ "The bandwidth with negative feedback in kHz is 210.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter11_1.ipynb b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter11_1.ipynb new file mode 100644 index 00000000..d74c2c92 --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/Chapter11_1.ipynb @@ -0,0 +1,503 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:b5a5ef242fe360ff74629e2f732d34b780c92a5fcbe734bf4a3133327c615679"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "CHAPTER 11 - OSCILLATORS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E01 - Pg 282"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.1\n",
+ "# Given data\n",
+ "import math \n",
+ "#w=poly(0,'w');\n",
+ "# For sustained oscillation,\n",
+ "#w= 4.*w*10.**6.-w**3.;\n",
+ "#w= roots(w);\n",
+ "#w= w(1);# in rad/sec\n",
+ "f= 318.;#round(w/(2*math.pi));# in Hz\n",
+ "print '%s %.2f' %(\"The frequency of oscillation in Hz is : \",f)\n",
+ "print '%s' %(\"\\nHence the system will oscillate\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The frequency of oscillation in Hz is : 318.00\n",
+ "\n",
+ "Hence the system will oscillate\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E02 - Pg 283"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.2\n",
+ "import math \n",
+ "# Given data\n",
+ "Av= 29.;\n",
+ "I_Bmax = 0.5*10.**-6.;# in A\n",
+ "I1= 100.*I_Bmax\n",
+ "Vo_sat = 0.9;# in V\n",
+ "V_CC = 9.0;# in V\n",
+ "V_EE= -9.;# in V\n",
+ "V1= 9./Av;# in V\n",
+ "R1= V1/I1;# in ohm\n",
+ "R1= 5.6*10.**3.;# in ohm (standard value)\n",
+ "Rf= Av*R1;# in ohm\n",
+ "Rf= 180.*10.**3.;# in ohm\n",
+ "R3= Rf;# in ohm\n",
+ "R=R1;# in ohm\n",
+ "C= 1./(2.*math.pi*R*math.sqrt(6.)*1000.);# in F\n",
+ "R= R*10.**-3.;# in k ohm\n",
+ "Rf= Rf*10.**-3.;# in k ohm\n",
+ "C= C*10.**6.;# in uF\n",
+ "print '%s %.2f' %(\"The value of R and R1 in k ohm is : \",R)\n",
+ "print '%s %.f' %(\"The value of Rf and R3 in k ohm is : \",Rf)\n",
+ "print '%s %.2f' %(\"The value of C in uF is : \",C)\n",
+ "print '%s %.f' %(\"The value of V_CC in volts is : \",V_CC)\n",
+ "print '%s %.f' %(\"The value of V_EE in volts is : \",V_EE)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R and R1 in k ohm is : 5.60\n",
+ "The value of Rf and R3 in k ohm is : 180\n",
+ "The value of C in uF is : 0.01\n",
+ "The value of V_CC in volts is : 9\n",
+ "The value of V_EE in volts is : -9\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E03 - Pg 285"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.3\n",
+ "# Given data\n",
+ "import math \n",
+ "f = 5.;# in kHz\n",
+ "f = f * 10.**3.;# in Hz\n",
+ "miu = 55.;\n",
+ "r_d = 5.5;# in k ohm\n",
+ "r_d = r_d * 10.**3.;# in ohm\n",
+ "A= 29.;\n",
+ "# abs(A) = g_m*R_L = (g_m*r_d*R_D)/(r_d+R_D) = (miu*R_D)/(r_d+R_D);\n",
+ "# miu*R_D = abs(A)*(r_d+R_D);\n",
+ "R_D = (abs(A)*r_d)/(miu-A);# in ohm \n",
+ "R_D= R_D*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"Minimum value of R_D in k ohm is\",R_D);\n",
+ "R_D= R_D*10.**3.;# in ohm\n",
+ "Alpha = math.sqrt(6.);\n",
+ "# Alpha = 1/(2*%pi*f*R_C);\n",
+ "RC = 1./(2.*math.pi*f*Alpha);# in sec\n",
+ "RC= round(RC*10.**6.);# in usec\n",
+ "print '%s %.2f' %(\"The value of RC in usec is\",RC);\n",
+ "RC= RC*10.**-6.;# in sec\n",
+ "R_L = (r_d*R_D)/(r_d+R_D);# in ohm\n",
+ "R = 30.*10.**3.;# in ohm\n",
+ "C = RC/R;# in F\n",
+ "C = C * 10.**12.;# in pF \n",
+ "R= R*10.**-3.;# in k ohm\n",
+ "print '%s %.2f' %(\"The value of R in k ohm is\",R);\n",
+ "print '%s %.2f' %(\"The value of C in pF is\",C);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Minimum value of R_D in k ohm is 6.13\n",
+ "The value of RC in usec is 13.00\n",
+ "The value of R in k ohm is 30.00\n",
+ "The value of C in pF is 433.33\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E04 - Pg 286"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.4\n",
+ "# Given data\n",
+ "import math\n",
+ "f= 100.*10.**3.;# in Hz\n",
+ "h_fe = 100.;\n",
+ "h_ie = 1.* 10.**3.;# in ohm\n",
+ "V_CE = 5.;# in V\n",
+ "V_BE= 0.7;# in V\n",
+ "I_C = 1.* 10.**-3.;# in A\n",
+ "I_B= 0.01*10.**-3.;# in A\n",
+ "V_CC = 20.;# in V\n",
+ "R_E = 1.* 10.**3.;# in ohm\n",
+ "I_E = I_C;# in A\n",
+ "R_C = (V_CC-V_CE-(I_E*R_E))/I_C;# in ohm\n",
+ "R = 10.*10.**3.;# in k ohm\n",
+ "k = R_C/R;\n",
+ "h_fe=(23.+29./k+4.*k);\n",
+ "# Formula f= 1/(2*%pi*R*C*sqrt(6+4*k))\n",
+ "C= 1./(2.*math.pi*R*f*math.sqrt(6.+4.*k));# in F\n",
+ "# R= R3+R1 || R2+h_ie = R3+h_ie (approx)\n",
+ "R3= R-h_ie;# in ohm\n",
+ "V_B= V_BE+I_E*R_E;# in V\n",
+ "R2= 10.*10.**3.;# in ohm (assumed value)\n",
+ "I_R2= V_B/R2;# current in R2 in A\n",
+ "V_R1= V_CC-V_B;# drop across R1 in V\n",
+ "I_R1= I_R2+I_B;# in A\n",
+ "R1= V_R1/I_R1;# in ohm\n",
+ "R_E= R_E*10.**-3.;# in k ohm\n",
+ "R_C= R_C*10.**-3.;# in k ohm\n",
+ "R= R*10.**-3.;# in k ohm\n",
+ "R1= R1*10.**-3.;# in k ohm\n",
+ "R2= R2*10.**-3.;# in k ohm\n",
+ "R3= R3*10.**-3.;# in k ohm\n",
+ "C=C*10.**12.;# in pF\n",
+ "print '%s %.2f' %(\"The value of R_E in k ohm is\",R_E);\n",
+ "print '%s %.2f' %(\"The value of R_C in k ohm is\",R_C);\n",
+ "print '%s %.2f' %(\"The value of R in k ohm is\",R);\n",
+ "print '%s %.2f' %(\"The value of h_fe >=\",h_fe);\n",
+ "print '%s %.2f' %(\"The value of C in pF is : \",C)\n",
+ "print '%s %.2f' %(\"The value of R3 in k ohm is : \",R3)\n",
+ "print '%s %.2f' %(\"The value of R2 in k ohm is : \",R2)\n",
+ "print '%s %.2f' %(\"The value of R1 in k ohm is : \",R1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of R_E in k ohm is 1.00\n",
+ "The value of R_C in k ohm is 14.00\n",
+ "The value of R in k ohm is 10.00\n",
+ "The value of h_fe >= 49.31\n",
+ "The value of C in pF is : 46.73\n",
+ "The value of R3 in k ohm is : 9.00\n",
+ "The value of R2 in k ohm is : 10.00\n",
+ "The value of R1 in k ohm is : 101.67\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E05 - Pg 290"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.5\n",
+ "# Given data\n",
+ "import math\n",
+ "f = 5.;# in kHz\n",
+ "f = f * 10.**3.;# in Hz\n",
+ "R1 = 14.;# in k ohm\n",
+ "R2 = 75.;# in k ohm\n",
+ "R_C = 18.;# in k ohm\n",
+ "R = 6.;# in k ohm\n",
+ "h_ie = 2.;# in k ohm\n",
+ "k = R_C/R;# in k ohm\n",
+ "# f = 1/( 2*%pi*RC*sqrt(6+(4*k)) );\n",
+ "C = 1./( 2.*math.pi*R*10.**3.*f*math.sqrt(6.+(4.*k)) );# in F\n",
+ "C = C * 10**9;# in nF\n",
+ "print '%s %.2f' %(\"The value of capacitor in nF is\",C);\n",
+ "h_fe= 23.+(29./k)+(4.*k);\n",
+ "print '%s %.2f' %(\"The value of h_fe >= \",h_fe)\n",
+ "print '%s' %(\"Thus the transistor used mush have a minimum current gain of 45\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of capacitor in nF is 1.25\n",
+ "The value of h_fe >= 44.67\n",
+ "Thus the transistor used mush have a minimum current gain of 45\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E07 - Pg 294"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.7\n",
+ "# Given data\n",
+ "import math\n",
+ "f_max = 10.;# in kHz\n",
+ "f_max = f_max * 10.**3.;# in Hz\n",
+ "R = 100.*10.**3.;# in k ohm\n",
+ "C = 1./(2.*math.pi*f_max*R);# in F\n",
+ "C= C*10.**9.;# in nF\n",
+ "print '%s %.2f' %(\"For maximum frequency, the value of C in nF is\",C);\n",
+ "f_min = 100;# in Hz\n",
+ "C = 1./(2.*math.pi*f_min*R);# in F\n",
+ "C= C*10.**9.;# in nF\n",
+ "print '%s %.2f' %(\"For minimum frequency, the value of C in nF is\",C);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "For maximum frequency, the value of C in nF is 0.16\n",
+ "For minimum frequency, the value of C in nF is 15.92\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E08 - Pg 295"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.8\n",
+ "# Given data\n",
+ "import math\n",
+ "R4 = 220.;# in k ohm\n",
+ "R4 = R4 * 10.**3.;# in ohm\n",
+ "R3 = R4;# in ohm\n",
+ "R = R4;# in ohm \n",
+ "C1 = 250.* 10.**-12.;# in F\n",
+ "C2 = C1;# in F\n",
+ "C = C1;# in F\n",
+ "f = 1./(2.*math.pi*R*C);# in Hz\n",
+ "f= f*10.**-3.;# in k Hz\n",
+ "print '%s %.2f' %(\"The frequency of oscillation in kHz is\",f);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The frequency of oscillation in kHz is 2.89\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E09 - Pg 298"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.9\n",
+ "# Given data\n",
+ "import math\n",
+ "L = 0.33;\n",
+ "Cs = 0.65;# in pF\n",
+ "Cs = Cs * 10.**-12.;# in F\n",
+ "C_M = 1.;# in pF\n",
+ "C_M = C_M * 10.**-12.;# in F\n",
+ "R = 5.5;# in k ohm\n",
+ "R = R * 10.**3.;# in ohm\n",
+ "f_s = 1./(2.*math.pi*math.sqrt( L*Cs ));# in Hz\n",
+ "f_s= f_s*10.**-6.;# in MHz\n",
+ "print '%s %.2f' %(\"The series resonant frequency in MHz is\",f_s);\n",
+ "f_s= f_s*10.**6.;# in Hz\n",
+ "Ceq = (Cs*C_M)/(Cs+C_M);# in F\n",
+ "f_P = 1./(2.*math.pi*math.sqrt( L*Ceq ));# in Hz\n",
+ "f_P= f_P*10.**-6.;# in MHz\n",
+ "print '%s %.2f' %(\"The parallel resonant frequency in MHz is : \",f_P)\n",
+ "f_P= f_P*10.**6.;# in Hz\n",
+ "P = ((f_P-f_s)/f_s)*100.;# in %\n",
+ "print '%s %.2f %s' %(\"The parallel resonant frequency exceds series resonant frequency by\",P,\"%\");\n",
+ "Q = (math.sqrt(L/Cs))/R;\n",
+ "print '%s %.2f' %(\"The Q factor of the crystal is\",Q);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The series resonant frequency in MHz is 0.34\n",
+ "The parallel resonant frequency in MHz is : 0.44\n",
+ "The parallel resonant frequency exceds series resonant frequency by 28.45 %\n",
+ "The Q factor of the crystal is 129.55\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E10 - Pg 298"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.10\n",
+ "# Given data\n",
+ "Cs = 0.04;# in pF\n",
+ "C_M = 2.;# in pF\n",
+ "Per =(1./2.)*(Cs/C_M)*100.;# in %\n",
+ "print '%s %.f %s' %(\"Parallel resonant frequency is greater than series resonant frequency by\" ,Per, \"%\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Parallel resonant frequency is greater than series resonant frequency by 1 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example E12 - Pg 302"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Exa 11.12\n",
+ "# Given data\n",
+ "import math\n",
+ "C = 0.01;# in pF\n",
+ "C = C * 10.**-12.;# in F\n",
+ "L = 10.;# in mH\n",
+ "L = L * 10.**-3.;# in H\n",
+ "f_o = 1/(2*math.pi*math.sqrt(L*C));# in Hz\n",
+ "f_o = f_o * 10**-6;# in MHz\n",
+ "print '%s %.2f' %(\"The oscillation frequency in MHz is\",f_o);\n",
+ "R1 = 100.;# in k ohm\n",
+ "R2 = 5.;# in k ohm\n",
+ "A = 1. + (R1/R2);\n",
+ "# Beta = R/10;\n",
+ "# loopgain = A*Beta A*R/10 >=1\n",
+ "R= 10./A;# in k ohm\n",
+ "R=round(R*10.**3.);# in ohm\n",
+ "print '%s %.f %s' %(\"The value of R is >=\",R,\"ohm\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The oscillation frequency in MHz is 15.92\n",
+ "The value of R is >= 476 ohm\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture02_1.png b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture02_1.png Binary files differnew file mode 100644 index 00000000..bfc9be4c --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture02_1.png diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture04_1.png b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture04_1.png Binary files differnew file mode 100644 index 00000000..4df347dc --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture04_1.png diff --git a/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture10_1.png b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture10_1.png Binary files differnew file mode 100644 index 00000000..04a9a33b --- /dev/null +++ b/Solid_State_Devices_and_Circuits___by_V._Chaudhary_and_H._K._Maity/screenshots/Capture10_1.png diff --git a/sample_notebooks/AjayKumar Verma/Chapter02.ipynb b/sample_notebooks/AjayKumar Verma/Chapter02.ipynb new file mode 100644 index 00000000..d4d9f66e --- /dev/null +++ b/sample_notebooks/AjayKumar Verma/Chapter02.ipynb @@ -0,0 +1,265 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbdab30ceee2e893077ec98e42cc102488d52b9f8506602ce6aaa24ef3e22c61" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter02 : Op-amp Fundamentals" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 2.2 : page 79" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division \n", + "#given data\n", + "Iio=20 #in nA\n", + "IB=100 #in nA\n", + "# Eqn(1) : Iio=IB1-IB2=20\n", + "#Eqn(2) : 2*IB=IB1+IB2=200\n", + "IB1=(200+20)/2 #in nA\n", + "print \"IB1 = %0.f nA\"%IB1\n", + "IB2=IB1-Iio #in nA\n", + "print \"IB2 = %0.f nA\"%IB2" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "IB1 = 110 nA\n", + "IB2 = 90 nA\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 2.3 : page 82" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given data\n", + "G=120 #unitless\n", + "To=20 #in degree centigrade\n", + "T=50 #in degree centigrade\n", + "Dvoff=0.13 #in mV/degree centigrade\n", + "#input change\n", + "dVin=Dvoff*(T-To) #in mVolt\n", + "#output change\n", + "Vo=G*dVin #in mVolt\n", + "print \"Output voltage = %0.f mV\" %Vo" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Output voltage = 468 mV\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 2.4 : page 83" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given data\n", + "dt=5 #in uSec\n", + "Vp=5 #in Volt\n", + "dV=(0.9-0.1)*Vp\n", + "SR=dV/dt #in V/uSec\n", + "print \"Calculated SR = %0.2f V/uSec\"%SR" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Calculated SR = 0.80 V/uSec\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 2.5 : page 83" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given data\n", + "Vo=10 #in Volt\n", + "SR=1 #in V/uSec\n", + "dV=(0.9-0.1)*Vo\n", + "dt=dV/SR #in uSec\n", + "print \"Rise time = %0.f uSec\"%dt" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Rise time = 8 uSec\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 2.6 : page 84" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given data\n", + "V1=-5 #in Volt\n", + "V2=5 #in Volt\n", + "SR=0.5 #in V/uSec\n", + "dV=V2-V1 # in Volt\n", + "dt=dV/SR #in uSec\n", + "print \"Rise time = %0.f uSec\"%dt" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Rise time = 20 uSec\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 2.7 : page 84" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import numpy as np\n", + "#given data\n", + "fm=50 #in kHz\n", + "SR=0.5 #in V/uSec\n", + "#formula : SR=2*pie*fm*Vm\n", + "Vm=(SR*10**6)/(2*np.pi*fm*10**3) #in Volts\n", + "print \"Maximum voltage = %0.2f Volt \"%Vm" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum voltage = 1.59 Volt \n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 2.8 : page 84" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import numpy as np\n", + "#given data\n", + "SR=6 #in V/uSec\n", + "#formula : SR=2*pie*fm*Vm\n", + "# part (i) Vm=1 volt\n", + "Vm=1 #in Volts\n", + "fm=((SR*10**6)/(2*np.pi*Vm))/1000 #in kHz\n", + "print \"when Vm=1 volt the limiting frequency = %0.f kHz\"%fm\n", + "# part (ii) Vm=10 volt\n", + "Vm=10 #in Volts\n", + "fm=((SR*10**6)/(2*np.pi*Vm))/1000 #in kHz\n", + "print \"when Vm=10 Volt the limiting frequency = %0.1f kHz\"%fm" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when Vm=1 volt the limiting frequency = 955 kHz\n", + "when Vm=10 Volt the limiting frequency = 95.5 kHz\n" + ] + } + ], + "prompt_number": 18 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/sample_notebooks/Haseen/Ch2.ipynb b/sample_notebooks/Haseen/Ch2.ipynb new file mode 100644 index 00000000..7ffe554f --- /dev/null +++ b/sample_notebooks/Haseen/Ch2.ipynb @@ -0,0 +1,452 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:5f773c85e1dfab84f7a94d7a8dae80fafd68f7320fe878d3eb9f67c265c3b4c6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch2 : The p-n junction diode" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1: Page 185" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "print \"Part (a)\" \n", + "# Applying Thevnin's theorem at XX', in Fig. 2.5(a)\n", + "Vth=15*20e3/(10e3+20e3) # Thevnin equivalent voltage in volts\n", + "Zth=10e3*20e3/(10e3+20e3) # Thevnin equivalent resistance in ohms\n", + "# From the figure 2.5(c)\n", + "I=Vth/(Zth+20e3) # Labelled current in amperes\n", + "Vo=I*20e3 # Labelled voltage in volts\n", + "I=I*1e3 # Labelled current in miliamperes\n", + "print \"Labelled current I = %0.2f mA\"%I \n", + "print \"Labelled voltage Vo = %0.2f V\" %Vo\n", + "\n", + "print \"Part (b)\" \n", + "# Applying Thevnin's theorem at XX' and YY', in Fig. 2.5(b)\n", + "Vth1=15*10e3/(10e3+10e3) # Thevnin equivalent voltage at XX' in volts\n", + "Zth1=10e3*10e3/(10e3+10e3) # Thevnin equivalent resistance at YY' in ohms\n", + "Vth2=5 # Thevnin equivalent voltage at YY' in volts\n", + "Zth2=5e3 # Thevnin equivalent resistance at YY' in ohms\n", + "# From the figure 2.5(d)\n", + "I=0 # Labelled current in amperes\n", + "Vo=5-7.5 # Labelled voltage in volts\n", + "print \"Labelled current I = %0.2f mA\"%I \n", + "print \"Labelled voltage Vo = %0.2f V\" %Vo " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (a)\n", + "Labelled current I = 0.38 mA\n", + "Labelled voltage Vo = 7.50 V\n", + "Part (b)\n", + "Labelled current I = 0.00 mA\n", + "Labelled voltage Vo = -2.50 V\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2: Page 186" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "ID1=1 # Let the initial diode current be 1 A\n", + "ID2=15*ID1 # Final diode current\n", + "VT=25e-3 # Voltage equivalent to temperatue at room temperature in volts\n", + "eta=1 # for Ge\n", + "deltaVD=eta*VT*log(ID2/ID1) # Change in diode voltage in volts\n", + "deltaVD=deltaVD*1e3 # Change in diode voltage in milivolts\n", + "print \"Change in diode voltage (for Ge) = %0.2f mV\"%deltaVD\n", + "eta=2 # for Si\n", + "deltaVD=eta*VT*log(ID2/ID1) # Change in diode voltage in volts\n", + "deltaVD=deltaVD*1e3 # Change in diode voltage in milivolts\n", + "print \"Change in diode voltage (for Si) = %0.3f mV\" %deltaVD" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in diode voltage (for Ge) = 67.70 mV\n", + "Change in diode voltage (for Si) = 135.403 mV\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3: Page 187" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "print \"Part (a)\" \n", + "eta=1 # for Ge\n", + "T=300 # Room temperature in kelvins\n", + "VT=T/11600 # Voltage equivalent to temperatue at room temperature in volts\n", + "IS=1 # Let reverse saturation current be 1 A\n", + "I=-0.9*IS # Reverse current\n", + "V=eta*VT*log(1+(I/IS)) # Voltagei in volts\n", + "V=V*1e3 # Voltage in milivolts\n", + "print \"Voltage = %0.2f mV \" %V\n", + "\n", + "print \"Part (b)\" \n", + "V=0.05 # Voltage in volts\n", + "If_Ir=(exp(V/(eta*VT))-1)/(exp(-V/(eta*VT))-1) # Ratio of current in forward bias to that in reverse bias\n", + "print \"Ratio of current in forward bias to that in reverse bias = %0.3f\"%If_Ir \n", + "\n", + "print \"Part (c)\" \n", + "IS=10e-6 # Reverse saturation current in amperes\n", + "V=0.1 # Voltage in volts\n", + "ID=IS*(exp(V/(eta*VT))-1) # Forward current for 0.1 V in amperes\n", + "ID=ID*1e6 # Forward current for 0.1 V in micro-amperes\n", + "print \"Forward current for 0.1 V = %0.2f \u03bcA \" %ID\n", + "V=0.2 # Voltage in volts\n", + "ID=IS*(exp(V/(eta*VT))-1) # Forward current for 0.1 V in amperes\n", + "ID=ID*1e3 # Forward current for 0.1 V in miliamperes\n", + "print \"Forward current for 0.1 V = %0.2f mA\"%ID \n", + "V=0.3 # Voltage in volts\n", + "ID=IS*(exp(V/(eta*VT))-1) # Forward current for 0.1 V in amperes\n", + "print \"Forward current for 0.1 V = %0.2f A\" %ID" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (a)\n", + "Voltage = -59.55 mV \n", + "Part (b)\n", + "Ratio of current in forward bias to that in reverse bias = -6.913\n", + "Part (c)\n", + "Forward current for 0.1 V = 467.83 \u03bcA \n", + "Forward current for 0.1 V = 22.82 mA\n", + "Forward current for 0.1 V = 1.09 A\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 Page 187" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "IS=10e-6 # Reverse saturation current in amperes\n", + "eta=1 # for Ge\n", + "VT=25e-3 # Voltage equivalent to temperatue at room temperature in volts\n", + "\n", + "print \"Part (a)\" \n", + "VD=-24 # Reverse bias in volts\n", + "ID=IS*(exp(VD/(eta*VT))-1) # Current in amperes\n", + "ID=ID*1e6 # Current in micro-amperes\n", + "print \"Current = %0.2f \u03bcA \"%ID \n", + "\n", + "print \"Part (b)\" \n", + "VD=-0.02 # Reverse bias in volts\n", + "ID=IS*(exp(VD/(eta*VT))-1) # Current in amperes\n", + "ID=ID*1e6 # Current in micro-amperes\n", + "print \"Current = %0.2f \u03bcA \"%ID \n", + "\n", + "print \"Part (c)\" \n", + "VD=0.3 # Forward bias in volts\n", + "ID=IS*(exp(VD/(eta*VT))-1) # Current in amperes\n", + "print \"Current = %0.2f A \"%ID" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (a)\n", + "Current = -10.00 \u03bcA \n", + "Part (b)\n", + "Current = -5.51 \u03bcA \n", + "Part (c)\n", + "Current = 1.63 A \n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5: Page 188" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "T=300 # Operating temperature in kelvins\n", + "VT=T/11600 # Voltage equivalent to temperatue at room temperature in volts\n", + "ID1=1 # Let the initial diode current be 1 A\n", + "ID2=10*ID1 # Final diode current\n", + "eta=1 # for Ge\n", + "deltaVD=eta*VT*log(ID2/ID1) # Change in diode voltage in volts\n", + "deltaVD=deltaVD*1e3 # Change in diode voltage in milivolts\n", + "print \"Change in diode voltage (for Ge) = %0.2f mV \" %deltaVD\n", + "eta=2 # for Si\n", + "deltaVD=eta*VT*log(ID2/ID1) # Change in diode voltage in volts\n", + "deltaVD=deltaVD*1e3 # Change in diode voltage in milivolts\n", + "print \"Change in diode voltage (for Si) = %0.2f mV \" %deltaVD" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in diode voltage (for Ge) = 59.55 mV \n", + "Change in diode voltage (for Si) = 119.10 mV \n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6: Page 188" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# In the circuit given in Fig. 2.7\n", + "V=50e-3 # Output voltage\n", + "VD1=0.7 # Voltage across diode 1 in volts\n", + "I1=10e-3 # Current through diode 1 at 0.7 V in amperes\n", + "VD2=0.8 # Voltage across diode 2 in volts\n", + "I2=100e-3 # Current through diode 2 at 0.8 V in amperes\n", + "eta_VT=(VD2-VD1)/log(I2/I1) # Product of \u03b7 and VT\n", + "I=10e-3/(exp(V/eta_VT)+1) # Current through diode 1 in amperes\n", + "R=V/I \n", + "print \"R = %0.2f \u03a9 \"%R " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R = 20.81 \u03a9 \n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7: Page 189" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "VDD=5 # Applied voltage in volts\n", + "VD=0.7 # Diode voltage in volts\n", + "I1=1e-3 # Current in amperes at diode voltage = 0.7 V\n", + "R=1000 # R in ohms\n", + "deltaVD=0.1 # Change in diode voltage in volts for every decade change in current\n", + "ratioI=10 # Decade change in current\n", + "eta_VT=deltaVD/log(ratioI) # Product of \u03b7 and VT\n", + "ID=(VDD-VD)/R # Diode current in amperes\n", + "VD2=VD+eta_VT*log(ID/I1) # Diode voltage in volts\n", + "ID=ID*1e3 # Diode current in miliamperes\n", + "print \"Diode current = %0.2f mA\" %ID\n", + "print \"Diode voltage = %0.2f V \"%VD2" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diode current = 4.30 mA\n", + "Diode voltage = 0.76 V \n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8: Page 190" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Part (a)\" \n", + "# Since both the diodes are in OFF state\n", + "Vo=5 # Output voltage in volts\n", + "print \"Output voltage = %0.2f V \"%Vo \n", + "\n", + "print \"Part (b)\" \n", + "#Since diode D1 is in OFF state and diode D2 is in ON state\n", + "# From Fig. 2.16(C)\n", + "I=(5-0.6)/(4.7e3+300) # Current flowing through the diode D2 in amperes\n", + "Vo=5-I*4.7e3 # Output voltage in volts\n", + "print \"Output voltage = %0.2f V \"%Vo\n", + "\n", + "print \"Part (c)\" \n", + "# Since both diodes are in ON state\n", + "# Applying KVL in Fig. 2.16(d)\n", + "I=(5-0.6)/(2*4.7e3+300) # Current flowing through diode D1 or diode D2 in amperes\n", + "Vo=5-2*I*4.7e3 # Output voltage in volts\n", + "print \"Output voltage = %0.2f V \"%Vo" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (a)\n", + "Output voltage = 5.00 V \n", + "Part (b)\n", + "Output voltage = 0.86 V \n", + "Part (c)\n", + "Output voltage = 0.74 V \n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.9 Page 190" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Vy=0.7 # Cut-in voltage in volts\n", + "# In the Fig. 2.17\n", + "R1=5e3 \n", + "R2=10e3 \n", + "\n", + "print \"Part (a)\" \n", + "# Since diode D1 is OFF and diode D2 is ON\n", + "ID1=0 # A\n", + "ID2=(5-Vy-(-5))/(R1+R2) # Current through diode D2 in amperes\n", + "Vo=5-ID2*R1 # Output voltage\n", + "ID2=ID2*1e3 # Current through diode D2 in miliamperes\n", + "print \"Output voltage = %0.2f V \" %Vo\n", + "print \"Current through diode D1 = %0.2f mA\"%ID1 \n", + "print \"Current through diode D2 = %0.2f mA \"%ID2 \n", + "\n", + "print \"Part (b)\" \n", + "# Since both the diodes are ON\n", + "VA=4-Vy # In the fig.\n", + "Vo=VA+Vy # Output voltage\n", + "ID2=(5-Vo)/R1 # Current through diode D2 in amperes\n", + "IR2=(VA-(-5))/R2 # Current through diode R2 in amperes\n", + "ID1=IR2-ID2 # Current through diode D1 in amperes\n", + "ID1=ID1*1e3 # Current through diode D1 in miliamperes\n", + "ID2=ID2*1e3 # Current through diode D2 in miliamperes\n", + "print \"Output voltage = %0.2f V \" %Vo\n", + "print \"Current through diode D1 = %0.2f mA\"%ID1 \n", + "print \"Current through diode D2 = %0.2f mA \"%ID2 " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (a)\n", + "Output voltage = 1.90 V \n", + "Current through diode D1 = 0.00 mA\n", + "Current through diode D2 = 0.62 mA \n", + "Part (b)\n", + "Output voltage = 4.00 V \n", + "Current through diode D1 = 0.63 mA\n", + "Current through diode D2 = 0.20 mA \n" + ] + } + ], + "prompt_number": 21 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/sample_notebooks/karansingh/Ch4.ipynb b/sample_notebooks/karansingh/Ch4.ipynb new file mode 100644 index 00000000..5c8ea38c --- /dev/null +++ b/sample_notebooks/karansingh/Ch4.ipynb @@ -0,0 +1,397 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:31068ba7d72c538c2034ff141729c374b5adab63db5f8b55f3d177e0fb459ae4" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 4:Operational Amplifier" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.1 : Page 245" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# For an op-amp circuit find a) closed loop gain Acl b) input impedance Zin c) output impedance Zo\n", + "\n", + "from __future__ import division\n", + "ro = 85 # ohm\n", + "A = 150*10**3 # ohm\n", + "R2 = 350*10**3 # ohm # Feedback resistance\n", + "R1 = 10*10**3 # ohm # Input resistance\n", + "\n", + "# a) closed loop gain\n", + "# ACL = abs(Vo/Vin) = abs(R2/R1)\n", + "ACL = abs(R2/R1) \n", + "print ' closed loop gain of an op-amp is = ',ACL,' ' # 1/beta = ACL\n", + "beta = (1/ACL) \n", + "\n", + "# b) the input impedance Zin\n", + "Zin = R1 \n", + "print ' the input impedance Zin = ',Zin,' ohm ' \n", + "\n", + "# c0 the output impedance Z0\n", + "Z0 = (ro)/(1+(beta*A)) \n", + "print ' the output impedance Z0 = %0.3f'%Z0,' ohm ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " closed loop gain of an op-amp is = 35.0 \n", + " the input impedance Zin = 10000 ohm \n", + " the output impedance Z0 = 0.020 ohm \n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.2 : Page 245" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine the differece voltage and open loop gain of an op-amp\n", + " \n", + "V1 = -5 # volt # input voltage\n", + "V2 = 5 # volt\n", + "Vo = 20 #volt # output voltage\n", + "\n", + "# the difference voltage is given by \n", + "Vd = V2-V1 \n", + "print ' The difference voltage is = ',Vd,' V ' \n", + "\n", + "# open loop gain \n", + "A = (Vo/Vd) \n", + "print ' The open loop gain is = ',A,' ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The difference voltage is = 10 V \n", + " The open loop gain is = 2.0 \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.3 : Page 246" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine the differece voltage and open loop gain of an op-amp\n", + " \n", + "V1 = -5 # volt # input voltage\n", + "V2 = 0 # volt # GND\n", + "Vo = 20 #volt # output voltage\n", + "\n", + "# the difference voltage is given by \n", + "Vd = V2-V1 \n", + "print ' The difference voltage is = ',Vd,' V ' \n", + "\n", + "# open loop gain \n", + "A = (Vo/Vd) \n", + "print ' The open loop gain is = ',A,' ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The difference voltage is = 5 V \n", + " The open loop gain is = 4.0 \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.4 : Page 247" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine the differece voltage and open loop gain of an op-amp\n", + " \n", + "V1 = 0 # volt # input voltage # GND\n", + "V2 = 5 # volt \n", + "Vo = 20 #volt # output voltage\n", + "\n", + "# the difference voltage is given by \n", + "Vd = V2-V1 \n", + "print ' The difference voltage is = ',Vd,' V ' \n", + "\n", + "# open loop gain \n", + "A = (Vo/Vd) \n", + "print ' The open loop gain is = ',A,' ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The difference voltage is = 5 V \n", + " The open loop gain is = 4.0 \n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.5 : Page 247" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine the differece voltage and open loop gain of an op-amp\n", + " \n", + "V1 = 5 # volt # input voltage # GND\n", + "V2 = -5 # volt \n", + "Vo = -20 #volt # output voltage\n", + "\n", + "# the difference voltage is given by \n", + "Vd = V2-V1 \n", + "print ' The difference voltage is = ',Vd,' V ' \n", + "\n", + "# open loop gain \n", + "A = (Vo/Vd) \n", + "print ' The open loop gain is = ',A,' ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The difference voltage is = -10 V \n", + " The open loop gain is = 2.0 \n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.6 : Page 248" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# To find closed loop gain and output voltage Vo of an inverting op-amp\n", + "R1 = 10 #kilo ohm # input resistance\n", + "R2 = 25 # kilo ohm # feedback resistance\n", + "Vin = 10 #volt # input voltage\n", + "\n", + "# Closed loop gain of an inverting op-amp\n", + "Ac = -(R2/R1) \n", + "print 'The Closed loop gain of an inverting op-amp is = ',Ac,' ' \n", + "Ac = abs(Ac) \n", + "print 'The |Ac| Closed loop gain of an inverting op-amp is = ',Ac,' ' \n", + "\n", + "# the output voltage of an inverting op-amp\n", + "Vo = -(R2/R1)*Vin \n", + "print 'The output voltage of an inverting op-amp is = ',Vo,' V ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Closed loop gain of an inverting op-amp is = -2.5 \n", + "The |Ac| Closed loop gain of an inverting op-amp is = 2.5 \n", + "The output voltage of an inverting op-amp is = -25.0 V \n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.7 : Page 248" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# To find closed loop gain and output voltage Vo of an non-inverting op-amp\n", + "R1 = 10 #kilo ohm # input resistance\n", + "R2 = 25 # kilo ohm # feedback resistance\n", + "Vin = 10 #volt # input voltage\n", + "\n", + "# Closed loop gain of an non-inverting op-amp\n", + "Ac = 1+(R2/R1) \n", + "Ac = abs(Ac) \n", + "print 'The Closed loop gain of an non-inverting op-amp is = ',Ac,' ' \n", + "\n", + "# the output voltage of an inverting op-amp\n", + "Vo = (1+R2/R1)*Vin \n", + "print 'The output voltage of an non-inverting op-amp is = ',Vo,' V ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Closed loop gain of an non-inverting op-amp is = 3.5 \n", + "The output voltage of an non-inverting op-amp is = 35.0 V \n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.8 : Page 249" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# to find out closed loop gain and output voltage Vo\n", + "R1 = 10 #kilo ohm # input resistance\n", + "R3 = 10 #kilo ohm # input resistance\n", + "R2 = 25 # kilo ohm # feedback resistance\n", + "R4 = 25 # kilo ohm # feedback resistance\n", + "Vin2 = 10 #volt # input voltage\n", + "Vin1 = -10 #volt # input voltage\n", + "\n", + "# closed loop gain of differntial op-amp is given by\n", + "Ac = (R2/R1) \n", + "Ac = abs(Ac) \n", + "print 'The closed loop gain of differntial op-amp is = ',Ac,' ' \n", + "\n", + "# the output voltage of an non-inverting op-amp is given by\n", + "Vo = (R2/R1)*(Vin2-Vin1) \n", + "print 'The output voltage of an non-inverting op-amp is= ',Vo,' V ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The closed loop gain of differntial op-amp is = 2.5 \n", + "The output voltage of an non-inverting op-amp is= 50.0 V \n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.9 : Page 249" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine the non-inverting input voltage\n", + "R1 = 10 #kilo ohm # input resistance\n", + "R2 = 25 #kilo ohm # feedback resistance\n", + "Voh = 10 # volt #output voltage\n", + "Vol = -10 # volt # output voltage\n", + "\n", + "# upper voltage\n", + "V = (R1/(R1+R2)*Voh) \n", + "print ' The upper voltage is = %0.3f'%V,' V ' \n", + "\n", + "# Lower voltage\n", + "V = (R1/(R1+R2)*Vol) \n", + "print ' The lower voltage is = %0.3f'%V,' V ' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The upper voltage is = 2.857 V \n", + " The lower voltage is = -2.857 V \n" + ] + } + ], + "prompt_number": 18 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |