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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chapter 6 : FORMULAE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 6_1 pgno:69"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"expr=8*i-5\n",
"the number is 16\n"
]
}
],
"source": [
" #8 times a number is decreased by 5 the result is 123\n",
"#let x be the number\n",
"\n",
"print'expr=8*i-5'\n",
"x=0;\n",
"for x in range(0,100):\n",
" if((8*x-5)==123):\n",
" print\"the number is \",x\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 6_2 pgno:71"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"expr=(2*n+1)+(2*n+3)+(2*n+5)\n",
"n=%i \n",
"12\n",
"\n",
" the numbers are 199 201 203\n"
]
}
],
"source": [
"#sum of 3 consecutive odd no.'s is 81\n",
"\n",
"#let the 3 consecutive odd numbers be 2n+1,2n+3,2n+5\n",
"\n",
"print\"expr=(2*n+1)+(2*n+3)+(2*n+5)\"\n",
"n=0;\n",
"for n in range(0,100):\n",
" if((2*n+1)+(2*n+3)+(2*n+5)==81):\n",
" print\"n=%i \\n\",n \n",
"\n",
"n1=2*n+1;\n",
"n2=2*n+3;\n",
"n3=2*n+5;\n",
"print\"\\n the numbers are \",n1,n2,n3\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 6_3 pgno:72"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"p1=(6*x-5)\n",
"p2=(2*x+9)\n",
"p3=p1-p2\n",
"satisfies the equation \n"
]
}
],
"source": [
"import numpy\n",
"print\"p1=(6*x-5)\"\n",
"p1=numpy.array([6, -5])\n",
"print\"p2=(2*x+9)\"\n",
"p2=numpy.array([2, 9])\n",
"print\"p3=p1-p2\"\n",
"p3=p1-p2\n",
"\n",
"x1=numpy.roots(p3)\n",
"left=6*x1-5; #check by substituion \n",
"right=2*x1+9;\n",
"if(left==right):\n",
"\tprint'satisfies the equation '\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 6_4 pgno:73"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x is a polynomial function\n",
"by the law of sighs roots are [ 3.]\n"
]
}
],
"source": [
"print\"x is a polynomial function\"\n",
"import numpy\n",
"p1=numpy.array([3/5+1/2, 0])\n",
"p2=numpy.array([5/4, -3])\n",
"#p1=3*x/5+x/2;\n",
"#p2=5*x/4-3;\n",
"p3=p1-p2;\n",
"x=numpy.roots(p3) #by the law of signs\n",
"print\"by the law of sighs roots are\",x\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 6_5 pgno:75"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"p1=4*x-(x-2)/3\n",
"p2=5+(2*x+1)/4\n",
"p3=p1-p2\n",
"satisfies the equation \n"
]
}
],
"source": [
"import numpy\n",
"print\"p1=4*x-(x-2)/3\"\n",
"p1=numpy.array([11/3, 2/3])\n",
"print\"p2=5+(2*x+1)/4\"\n",
"p2=numpy.array([1/2, 21/4])\n",
"print\"p3=p1-p2\"\n",
"p3=p1-p2\n",
"\n",
"x=numpy.roots(p3)\n",
"left=4*x-(x-2)/3; #check by substituion \n",
"right=5+(2*x+1)/4;\n",
"if(left != right):\n",
"\tprint'satisfies the equation '\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"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
}
|