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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 15: Compound Interest"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.1, Page number 15.4"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"amount is 4410.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"P=4000; #principal(Rs)\n",
"R=5; #rate(%)\n",
"T=2; #time(yrs)\n",
"n=1;\n",
"\n",
"#Calculation\n",
"A=P*(1+(R/(100*n)))**(n*T); #amount(Rs)\n",
"\n",
"#Result\n",
"print \"amount is\",A,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.2, Page number 15.4"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"compound interest is 662.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"P=2000; #principal(Rs)\n",
"R=10; #rate(%)\n",
"T=3; #time(yrs)\n",
"\n",
"#Calculation\n",
"x=R/100;\n",
"y=(1+x)**T;\n",
"CI=P*(y-1); #compound interest(Rs)\n",
"\n",
"#Result\n",
"print \"compound interest is\",CI,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.3, Page number 15.5"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"principal is 800.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"R=10; #rate(%)\n",
"T=2; #time(yrs)\n",
"A=968; #amount(Rs)\n",
"\n",
"#Calculation\n",
"P=A/(1+(R/100))**T; #principal(Rs)\n",
"\n",
"#Result\n",
"print \"principal is\",P,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.4, Page number 15.5"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"compound interest is 4921.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"P=64000; #principal(Rs)\n",
"R=2.5; #rate(%)\n",
"T=3; #time(yrs)\n",
"\n",
"#Calculation\n",
"x=R/100;\n",
"y=(1+x)**T;\n",
"CI=P*(y-1); #compound interest(Rs)\n",
"\n",
"#Result\n",
"print \"compound interest is\",CI,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.5, Page number 15.5"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"compound interest in 1st case is 122 Rs\n",
"compound interest in 2nd case is 121.2 Rs\n",
"answer given in the book is wrong\n",
"compound interest in 3rd case is 119.0 Rs\n",
"answer varies due to rounding off errors\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"P=2000; #principal(Rs)\n",
"R=8; #rate(%)\n",
"T=9/12; #time(yrs)\n",
"n1=4;\n",
"n2=2;\n",
"n3=1;\n",
"\n",
"#Calculation\n",
"A1=P*(1+(R/(100*n1)))**(n1*T); #amount(Rs)\n",
"CI1=A1-P; #compound interest in 1st case(Rs)\n",
"A2=P*(1+(R/(100*n2)))**(n2*T); #amount(Rs)\n",
"CI2=A2-P; #compound interest in 2nd case(Rs)\n",
"A3=P*(1+(R/(100*n3)))**(n3*T); #amount(Rs)\n",
"CI3=A3-P; #compound interest in 3rd case(Rs)\n",
"\n",
"#Result\n",
"print \"compound interest in 1st case is\",int(CI1),\"Rs\"\n",
"print \"compound interest in 2nd case is\",round(CI2,1),\"Rs\"\n",
"print \"answer given in the book is wrong\"\n",
"print \"compound interest in 3rd case is\",round(CI3),\"Rs\"\n",
"print \"answer varies due to rounding off errors\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.6, Page number 15.6"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"sum is 31250.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"R=4; #rate(%)\n",
"T=2; #time(yrs)\n",
"CI_SI=50; #difference between CI and SI(Rs)\n",
"\n",
"#Calculation\n",
"x=(R/100)**2;\n",
"P=CI_SI/x; #sum(Rs)\n",
"\n",
"#Result\n",
"print \"sum is\",P,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.7, Page number 15.6"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"difference between CI and SI is 20.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"R=10; #rate(%)\n",
"T=2; #time(yrs)\n",
"P=2000; #sum(Rs)\n",
"\n",
"#Calculation\n",
"x=(R/100)**2;\n",
"CI_SI=P*x; #difference between CI and SI(Rs)\n",
"\n",
"#Result\n",
"print \"difference between CI and SI is\",CI_SI,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.8, Page number 15.7"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rate per annum is 9.0 %\n",
"sum is 1500.0 Rs\n",
"answer given in the book is wrong\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"CI=282.15; #compound interest(Rs)\n",
"SI=270; #simple interest(Rs)\n",
"T=2; #time(yrs)\n",
"\n",
"#Calculation\n",
"R=(CI-SI)*100*T/SI; #rate per annum(%)\n",
"P=100*SI/(R*T); #sum(Rs)\n",
"\n",
"#Result\n",
"print \"rate per annum is\",R,\"%\"\n",
"print \"sum is\",P,\"Rs\"\n",
"print \"answer given in the book is wrong\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.9, Page number 15.7"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"sum is 500.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"R=10; #rate(%)\n",
"T=3; #time(yrs)\n",
"CI_SI=31/2; #difference between CI and SI(Rs)\n",
"\n",
"#Calculation\n",
"x=R/100;\n",
"y=(x**3)+(T*(x**2));\n",
"P=CI_SI/y; #sum(Rs) \n",
"\n",
"#Result\n",
"print \"sum is\",P,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.10, Page number 15.7"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "ValueError",
"evalue": "math domain error",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-26-97e4181a1568>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[0mDr\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m;\u001b[0m \u001b[1;31m#denominator of fraction\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[0md\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mNr\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mDr\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mNr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m \u001b[1;31m#discriminant\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m \u001b[0mq\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mNr\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0md\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mDr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m \u001b[1;31m#solution\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 14\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[1;31m#Result\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mValueError\u001b[0m: math domain error"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"a=434;\n",
"b=272;\n",
"\n",
"#Calculation\n",
"Nr=a-b; #numerator of fraction\n",
"Dr=b; #denominator of fraction\n",
"d=(Nr**2)-(4*Dr*Nr); #discriminant\n",
"q=(-Nr-math.sqrt(d))/(2*Dr); #solution\n",
"\n",
"#Result\n",
"print \"value of q is\",q\n",
"print \"solution for the problem does not exist and the answer given in the book is wrong\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.11, Page number 15.8"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"annual payment is 18522.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"R=5; #rate(%)\n",
"A=50440; #debt amount(Rs)\n",
"T=3; #time(yrs)\n",
"\n",
"#Calculation\n",
"x=100/(100+R);\n",
"y=x*(1+x+(x**2));\n",
"a=A/y; #annual payment(Rs)\n",
"\n",
"#Result\n",
"print \"annual payment is\",a,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.12, Page number 15.8"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"time is 5.0 years\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"P=1; #assume\n",
"A=1.44*P; #amount(Rs)\n",
"T=2; #time(yrs)\n",
"N=2;\n",
"\n",
"#Calculation\n",
"R=(math.sqrt(A/P)-1)*100; #rate(%)\n",
"T=(N-1)*100/R; #time(yrs)\n",
"\n",
"#Result\n",
"print \"time is\",T,\"years\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.13, Page number 15.8"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rate per annum is 6.0 %\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"I2=238.50; #interest in second year(Rs)\n",
"I1=225; #interest in first year(Rs)\n",
"T=1; #time(yrs)\n",
"\n",
"#Calculation\n",
"I=I2-I1; #interest on 1 year(Rs)\n",
"R=100*I/(I1*T); #rate per annum(%)\n",
"\n",
"#Result\n",
"print \"rate per annum is\",R,\"%\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.14, Page number 15.9"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"sum is 8000.0 Rs\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"CI_SI=20; #difference for 2 years(Rs)\n",
"CISI=61; #difference for 3 yrs(Rs)\n",
"T1=2; #time(yrs)\n",
"T2=3; #time(yrs)\n",
"\n",
"#Calculation\n",
"R=((CISI/CI_SI)-T2)*100; #rate(%)\n",
"P=CI_SI*(100/R)**2; #sum(Rs) \n",
"\n",
"#Result\n",
"print \"sum is\",P,\"Rs\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.15, Page number 15.9"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rate per annum is 10.0 %\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"T=3; #time(yrs)\n",
"P=1000; #sum(Rs)\n",
"A=1331; #amount(Rs)\n",
"\n",
"#Calculation\n",
"x=(A/P)**(1/T);\n",
"R=100*(x-1); #rate per annum(%)\n",
"\n",
"#Result\n",
"print \"rate per annum is\",R,\"%\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example number 15.16, Page number 15.9"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"time is 1.5 years\n"
]
}
],
"source": [
"#importing modules\n",
"import math\n",
"from __future__ import division\n",
"\n",
"#Variable declaration\n",
"P=64000; #sum(Rs)\n",
"CI=4921; #compound interest(Rs)\n",
"R=5; #rate(%)\n",
"n=2;\n",
"\n",
"#Calculation\n",
"A=P+CI; #amount(Rs)\n",
"x=A/P;\n",
"y=(1+(R/(100*n)))**n;\n",
"T=math.log(x)/math.log(y); #time(years)\n",
"\n",
"#Result\n",
"print \"time is\",T,\"years\""
]
}
],
"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
}
|