summaryrefslogtreecommitdiff
path: root/sample_notebooks/DevikaRaj/Chapter1.ipynb
blob: 2e5de7740d8471d49f065057b39ae949b1c2d5a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 1 - Physics and Engineering"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 - pg 11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Percentage Error (percentage) =  4.0\n"
     ]
    }
   ],
   "source": [
    "#calculate the percentage error\n",
    "#Given:\n",
    "l=9.3; # length in cm\n",
    "b=8.5;# breadth in cm\n",
    "h=5.4;# height in cm\n",
    "#calculations\n",
    "V= l*b*h; # Volume in cm**3\n",
    "delta_l = 0.1; delta_b = 0.1; delta_h = 0.1; # scale has a least count = 0.1 cm\n",
    "# absolute error \n",
    "delta_V = (b*h*delta_l + l*h*delta_b +l*b*delta_h); # in cm**3\n",
    "#relative error \n",
    "re = delta_V/V;\n",
    "p= re*100; # Evaluating percentage error\n",
    "#results\n",
    "print \"Percentage Error (percentage) = \",round(p,0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2 - pg 12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Percentage error (percentage) =  2.86\n",
      "Result obtained differs from that in textbook, because delta_M walue is taken 0.1 g , instead of 0.2 g as mentioned in the problem statement.\n"
     ]
    }
   ],
   "source": [
    "#calculate the percentage error\n",
    "#Given :\n",
    "M= 10.0; #weight in g\n",
    "V= 5.80;#volume in cm**3\n",
    "#calculations\n",
    "Rho = M/V; # Density in g/cm**3\n",
    "delta_M= 0.2 #  apparatus has a least count of 0.2 g\n",
    "delta_V= 0.05# apparatus has a least count of 0.05 cm**3\n",
    "delta_Rho = (delta_M/V) +((M*delta_V)/V**2);# absolute error in g/cm**3\n",
    "re = delta_Rho/Rho ; #Evaluating Relative Error\n",
    "p = re*100;# Evaluating Percentage Error\n",
    "#results\n",
    "print \"Percentage error (percentage) = \",round(p,2)\n",
    "print'Result obtained differs from that in textbook, because delta_M walue is taken 0.1 g , instead of 0.2 g as mentioned in the problem statement.'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 - pg 16"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Actual Value of c/r ranges between 5.9 - 6.6  and Percentage error = 5.3  percentage. \n",
      "(b)Actual Value of c/r ranges between 6.281 - 6.288 and Percentage error = 0.06  percentage.\n"
     ]
    }
   ],
   "source": [
    "#calculate the Actual val of c/r ranges and percentage error\n",
    "#Given:\n",
    "#(a) \n",
    "import math\n",
    "lc = 0.1# least count in cm\n",
    "c = 6.9 #Circumference c in cm\n",
    "r= 1.1 # radius of circle in cm\n",
    "val =2*math.pi;\n",
    "# Circumference,c= 2*pi*r or  c/r = 2*pi\n",
    "# Error in c/r is , delta(c/r)= [(c/r**2)+(1/r)](LC/2) , LC is Least Count .\n",
    "E= ((c/r**2)+(1./r))*(lc/2.);#Error in c/r is delta(c/r)\n",
    "ob = c/r; # Observed Value\n",
    "#Actual Value of c/r ranges between\n",
    "ac1 = ob-E;# Evaluating Minimum value for c/r \n",
    "ac2 = ob+E;# Evaluating Maximum value for c/r\n",
    "p = (E/ob)*100.; #Evaluating percentage error\n",
    "#results\n",
    "print \"(a)Actual Value of c/r ranges between\",round(ac1,1), \"-\",round(ac2,1),\" and Percentage error =\",round(p,1),\" percentage. \"\n",
    "#(b)\n",
    "lc1 = 0.001;#Now the least count is 0.001 cm\n",
    "c1 = 6.316;#Circumference in cm\n",
    "r1=1.005;#Circle radius in cm \n",
    "E1 =((c1/r1**2) + (1/r1))*(lc1/2); # Error in c/r is delta(c/r)\n",
    "ob1= c1/r1; #Observed Value\n",
    "p1=(E1/ob1)*100.;#Evaluating percentage error\n",
    "#Actual Value of c/r ranges between\n",
    "a1= ob1-E1;#Evaluating Minimum value for c/r\n",
    "a2= ob1+E1;#Evaluating Maximum value for c/r\n",
    "print \"(b)Actual Value of c/r ranges between\",round(a1,3),\"-\",round(a2,3),\"and Percentage error =\",round(p1,2),\" percentage.\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4 - pg 17"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) It is is 15.0  percentage lower than the experimental value.\n",
      "(b) It is 0.6 percentage  higher than the experimental value.\n"
     ]
    }
   ],
   "source": [
    "#calculate the percentage lower or higher than experimental value\n",
    "#Given\n",
    "import math\n",
    "# (a) Newton's Theory\n",
    "# v= (P/rho)**2  , P= Pressure , rho = density\n",
    "P = 76.; # 76 cm of Hg pressure\n",
    "V= 330. ; # velocity of sound in m/s\n",
    "rho = 0.001293; # density for dry air at 0 degrees celsius in g/cm**3\n",
    "g = 980.;#gravitational acceleration in cm/s**2\n",
    "#Density of mercury at room temperature is 13.6 g/cm**3 \n",
    "# 1 cm**2 = 1.0*10**-4 m**2\n",
    "#calculations\n",
    "v = math.sqrt(((P*13.6*g)/rho)*10**-4); # velocity of sound in m/s\n",
    "p= ((V-v)/V)*100; # % lower than the experimental value\n",
    "#results\n",
    "print \"(a) It is is\",round(p,0),\" percentage lower than the experimental value.\"\n",
    "\n",
    "# (b) Laplace's Theory \n",
    "# v= ((gama*P)/rho)**2., gamma = adiabatic index Thus,\n",
    "#Given :\n",
    "gama = 1.41 # Adiabatic index\n",
    "#Density of mercury at room temperature is 13.6 g/cm**3 \n",
    "# 1 cm**2 = 1.0*10**-4 m**2\n",
    "v1 = math.sqrt(((gama*P*13.6*g)/rho)*10**-4);# velocity of sound in m/s\n",
    "p1 = ((V-round(v1))/V)*100;# % higher than the eperimental value\n",
    "#results\n",
    "print \"(b) It is\",round(abs(p1),1),\"percentage  higher than the experimental value.\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}