Higher engineering-mathematics-b-s-grewal-companion-text

26,334 views 190 slides Oct 12, 2015
Slide 1
Slide 1 of 197
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92
Slide 93
93
Slide 94
94
Slide 95
95
Slide 96
96
Slide 97
97
Slide 98
98
Slide 99
99
Slide 100
100
Slide 101
101
Slide 102
102
Slide 103
103
Slide 104
104
Slide 105
105
Slide 106
106
Slide 107
107
Slide 108
108
Slide 109
109
Slide 110
110
Slide 111
111
Slide 112
112
Slide 113
113
Slide 114
114
Slide 115
115
Slide 116
116
Slide 117
117
Slide 118
118
Slide 119
119
Slide 120
120
Slide 121
121
Slide 122
122
Slide 123
123
Slide 124
124
Slide 125
125
Slide 126
126
Slide 127
127
Slide 128
128
Slide 129
129
Slide 130
130
Slide 131
131
Slide 132
132
Slide 133
133
Slide 134
134
Slide 135
135
Slide 136
136
Slide 137
137
Slide 138
138
Slide 139
139
Slide 140
140
Slide 141
141
Slide 142
142
Slide 143
143
Slide 144
144
Slide 145
145
Slide 146
146
Slide 147
147
Slide 148
148
Slide 149
149
Slide 150
150
Slide 151
151
Slide 152
152
Slide 153
153
Slide 154
154
Slide 155
155
Slide 156
156
Slide 157
157
Slide 158
158
Slide 159
159
Slide 160
160
Slide 161
161
Slide 162
162
Slide 163
163
Slide 164
164
Slide 165
165
Slide 166
166
Slide 167
167
Slide 168
168
Slide 169
169
Slide 170
170
Slide 171
171
Slide 172
172
Slide 173
173
Slide 174
174
Slide 175
175
Slide 176
176
Slide 177
177
Slide 178
178
Slide 179
179
Slide 180
180
Slide 181
181
Slide 182
182
Slide 183
183
Slide 184
184
Slide 185
185
Slide 186
186
Slide 187
187
Slide 188
188
Slide 189
189
Slide 190
190
Slide 191
191
Slide 192
192
Slide 193
193
Slide 194
194
Slide 195
195
Slide 196
196
Slide 197
197

About This Presentation

SOLUTION


Slide Content

Scilab Textbook Companion for
Higher Engineering Mathematics
by B. S. Grewal
1
Created by
Karan Arora and Kush Garg
B.Tech. (pursuing)
Civil Engineering
Indian Institute of Technology Roorkee
College Teacher
Self
Cross-Checked by
Santosh Kumar, IIT Bombay
August 10, 2013
1
Funded by a grant from the National Mission on Education through ICT,
http://spoken-tutorial.org/NMEICT-Intro. This Textbook Companion and Scilab
codes written in it can be downloaded from the "Textbook Companion Project"
section at the website http://scilab.in

Book Description
Title:Higher Engineering Mathematics
Author:B. S. Grewal
Publisher:Khanna Publishers, New Delhi
Edition:40
Year:2007
ISBN:8174091955
1

Scilab numbering policy used in this document and the relation to the
above book.
ExaExample (Solved example)
EqnEquation (Particular equation of the above book)
APAppendix to Example(Scilab Code that is an Appednix to a particular
Example of the above book)
For example, Exa 3.51 means solved example 3.51 of this book. Sec 2.3 means
a scilab code whose theory is explained in Section 2.3 of the book.
2

Contents
List of Scilab Codes
1 Solution of equation and curve tting
2 Determinants and Matrices
4 Dierentiation and Applications
5 Partial Dierentiation And Its Applications
6 Integration and its Applications
9 Innite Series
10 Fourier Series
13 Linear Dierential Equations
21 Laplace Transform
22 Integral Transform
23 Statistical Methods
24 Numerical Methods
26 Dierence Equations and Z Transform
27 Numerical Solution of Ordinary Dierential Equations
3

28 Numerical Solution of Partial Dierential Equations
34 Probability and Distributions
35 Sampling and Inference
4

List of Scilab Codes
Exa 1.1 nding the roots of quadratic equations
Exa 1.2 nding the roots of equation containing one variable
Exa 1.3 nding the roots of equation containing one variable
Exa 1.6 nding the roots of equation containing one variable
Exa 1.7 nding the roots of equation containing one variable
Exa 1.11 forming an equation with known roots
Exa 1.12 forming an equation under restricted conditions
Exa 1.13 nding the roots of equation containing one variable
Exa 1.14 nding the roots of equation containing one variable
Exa 1.15 nding the roots of equation containing one variable
Exa 1.16 nding the roots of equation containing one variable
Exa 1.17 nding the roots of equation containing one variable
Exa 1.18 Finding the roots of equation containing one variable
Exa 1.19 Finding the roots of equation containing one variable
Exa 1.20 Finding the roots of equation containing one variable
Exa 1.21 Finding the roots of equation containing one variable
Exa 1.22 Finding the roots of equation containing one variable
Exa 1.23 Finding the solution of equation by drawing graphs
Exa 1.24 Finding the solution of equation by drawing graphs
Exa 1.25 Finding the solution of equation by drawing graphs
Exa 2.1 Calculating Determinant
Exa 2.2 Calculating Determinant
Exa 2.3 Calculating Determinant
Exa 2.4 Calculating Determinant
Exa 5.8 Partial derivative of given function
Exa 2.16 product of two matrices
Exa 2.17 Product of two matrices
Exa 2.18 Product and inverse of matrices
5

Exa 2.19 Solving equation of matrices
Exa 2.20 Nth power of a given matrix
Exa 2.23 Inverse of matrix
Exa 2.24.1 Rank of a matrix
Exa 2.24.2 Rank of a matrix
Exa 2.25 Inverse of matrix
Exa 2.26 eigen values vectors rank of matrix
Exa 2.28 Inverse of a matrix
Exa 2.31 Solving equation using matrices
Exa 2.32 Solving equation using matrices
Exa 2.34.1 predicting nature of equation using rank of matrix
Exa 2.34.2 predicting nature of equation using rank of matrix
Exa 2.38 Inverse of a matrix
Exa 2.39 Transpose and product of matrices
Exa 2.42 eigen values and vectors of given matrix
Exa 2.43 eigen values and vectors of given matrix
Exa 2.44 eigen values and vectors of given matrix
Exa 2.45 eigen values and characteristic equation
Exa 2.46 eigen values and characteristic equation
Exa 2.47 eigen values and characteristic equation
Exa 2.48 eigen values and vectors of given matrix
Exa 2.49 eigen values and vectors of given matrix
Exa 2.50 eigen values and vectors of given matrix
Exa 2.51 eigen values and vectors of given matrix
Exa 2.52 Hermitian matrix
Exa 2.53 tranpose and inverse of complex matrix
Exa 2.54 Unitary matrix
Exa 4.4.1 nding nth derivative
Exa 4.5 nding nth derivative
Exa 4.6 nding nth derivative
Exa 4.7 nding nth derivative
Exa 4.8 proving the given dierential equation
Exa 4.9 proving the given dierential equation
Exa 4.10 proving the given dierential equation
Exa 4.11 verify roles theorem
Exa 4.16 expansion using maclaurins series
Exa 4.17 expanding function as fourier series of sine term
Exa 4.18 expansion using maclaurins series
6

Exa 4.19 expansion using maclaurins series
Exa 4.20 expansion using taylors series
Exa 4.21 taylor series
Exa 4.22 evaluating limit
Exa 4.32 tangent to curve
Exa 4.34 nding equation of normal
Exa 4.35 nding angle of intersection of curve
Exa 4.37 prove given tangent statement
Exa 4.39 nding angle of intersection of curve
Exa 4.41 nding pedal equation of parabola
Exa 4.43 nding radius of curvature of cycloid
Exa 4.46 radius of curvature of cardoid
Exa 4.47 cordinates of centre of curvature
Exa 4.48 proof statement cycloid
Exa 4.52 maxima and minima
Exa 4.61 nding the asymptotes of curve
Exa 5.5 Partial derivative of given function
Exa 5.14 Partial derivative of given function
Exa 5.25.1 Partial derivative of given function
Exa 5.25.2 Partial derivative of given function
Exa 5.25.3 Partial derivative of given function
Exa 5.26 Partial derivative of given function
Exa 5.30 Partial derivative of given function
Exa 6.1.1 indenite integral
Exa 6.1.2 indenite integral
Exa 6.2.1 denite integral
Exa 6.2.2 Denite Integration of a function
Exa 4.2.3 denite integral
Exa 6.2.3 denite integral
Exa 6.4.1 denite integral
Exa 4.4.2 denite integral
Exa 6.5 denite integral
Exa 6.6.1 reducing indenite integral to simpler form
Exa 6.7.1 Indenite Integration of a function
Exa 6.8 Getting the manual input of a variable and integration
Exa 6.9.1 Denite Integration of a function
Exa 6.9.2 Denite Integration of a function
Exa 6.10 denite integral
7

Exa 6.12 Denite Integration of a function
Exa 6.13 sum of innite series
Exa 6.14 nding the limit of the function
Exa 6.15 Denite Integration of a function
Exa 6.16 Denite Integration of a function
Exa 6.24 Calculating the area under two curves
Exa 9.1 to nd the limit at innity
Exa 9.1.3 to nd the limit at innity
Exa 9.2.1 to nd the sum of series upto innity
Exa 9.2.2 to check for the type of series
Exa 9.5.1 to check the type of innite series
Exa 9.5.2 to check the type of innite series
Exa 9.7.1 to check the type of innite series
Exa 9.7.3 to check the type of innite series
Exa 9.8.1 to nd the sum of series upto innity
Exa 9.8.2 to nd the limit at innity
Exa 9.10.1 to nd the limit at innity
Exa 9.10.2 to nd the limit at innity
Exa 9.11.1 to nd the limit at innity
Exa 9.11.2 to nd the limit at innity
Exa 10.1 nding fourier series of given function
Exa 10.2 nding fourier series of given function
Exa 10.3 nding fourier series of given function
Exa 10.4 nding fourier series of given function
Exa 10.5 nding fourier series of given function in interval minus
pi to pi
Exa 10.6 nding fourier series of given function in interval minus
l to l
Exa 10.7 nding fourier series of given function in interval minus
pi to pi
Exa 10.8 nding fourier series of given function in interval minus
pi to pi
Exa 10.9 nding half range sine series of given function
Exa 10.10 nding half range cosine series of given function
Exa 10.11 expanding function as fourier series of sine term
Exa 10.12 nding fourier series of given function
Exa 10.13 nding complex form of fourier series
Exa 10.14 practical harmonic analysis
8

Exa 10.15 practical harmonic analysis
Exa 10.16 practical harmonic analysis
Exa 10.17 practical harmonic analysis
Exa 13.1 solvinf linear dierential equation
Exa 13.2 solving linear dierential equation
Exa 13.3 solving linear dierential equation
Exa 13.4 solving linear dierential equation
Exa 13.5 nding particular integral
Exa 13.6 nding particular integral
Exa 13.7 nding particular integral
Exa 13.8 nding particular integral
Exa 13.9 nding particular integral
Exa 13.10 nding particular integral
Exa 13.11 solving the given linear equation
Exa 13.12 solving the given linear equation
Exa 13.13 solving the given linear equation
Exa 13.14 solving the given linear equation
Exa 21.1.1 nding laplace transform
Exa 21.1.2 nding laplace transform
Exa 21.1.3 nding laplace transform
Exa 21.2.1 nding laplace transform
Exa 21.2.2 nding laplace transform
Exa 21.2.3 nding laplace transform
Exa 21.4.1 nding laplace transform
Exa 21.4.2 nding laplace transform
Exa 21.5 nding laplace transform
Exa 21.7 nding laplace transform
Exa 21.8.1 nding laplace transform
Exa 21.8.2 nding laplace transform
Exa 21.8.3 nding laplace transform
Exa 21.8.4 nding laplace transform
Exa 21.9.1 nding laplace transform
Exa 21.9.2 nding laplace transform
Exa 21.10.1nding laplace transform
Exa 21.10.3nding laplace transform
Exa 21.11.1nding inverse laplace transform
Exa 21.11.2nding inverse laplace transform
Exa 21.12.1nding inverse laplace transform
9

Exa 21.12.3nding inverse laplace transform
Exa 21.13.1nding inverse laplace transform
Exa 21.13.2nding inverse laplace transform
Exa 21.14.1nding inverse laplace transform
Exa 21.14.2nding inverse laplace transform
Exa 21.15.1nding inverse laplace transform
Exa 21.15.2nding inverse laplace transform
Exa 21.16.1nding inverse laplace transform
Exa 21.16.2nding inverse laplace transform
Exa 21.16.3nding inverse laplace transform
Exa 21.17.1nding inverse laplace transform
Exa 21.17.2nding inverse laplace transform
Exa 21.19.1nding inverse laplace transform
Exa 21.19.2nding inverse laplace transform
Exa 21.28.1nding laplace transform
Exa 21.28.2nding laplace transform
Exa 21.34 nding laplace transform
Exa 22.1 nding fourier sine integral
Exa 22.2 nding fourier transform
Exa 22.3 nding fourier transform
Exa 22.4 nding fourier sine transform
Exa 22.5 nding fourier cosine transform
Exa 22.6 nding fourier sine transform
Exa 23.1 Calculating cumulative frequencies of given using itera-
tions on matrices
Exa 23.2 Calculating mean of of statistical data performing iter-
ations matrices
Exa 23.3 Analysis of statistical data performing iterations on ma-
trices
Exa 23.4 Analysis of statistical data
Exa 23.5 Finding the missing frequency of given statistical data
using given constants
Exa 23.6 Calculating average speed
Exa 23.7 Calculating mean and standard deviation performing it-
erations on matrices
Exa 23.8 Calculating mean and standard deviation performing it-
erations on matrices
10

Exa 23.9 Analysis of statistical data performing iterations on ma-
trices
Exa 23.10 Calculating mean and standard deviation of dierent
statistical data when put together
Exa 23.12 Calculating median and quartiles of given statistical data
performing iterations on matrices
Exa 23.13 Calculating coecient of correlation
Exa 24.1 nding the roots of equation
Exa 24.3 nding the roots of equation by the method of false
statement
Exa 24.4 nding rea roots of equation by regula falsi method
Exa 24.5 real roots of equation by newtons method
Exa 24.6 real roots of equation by newtons method
Exa 24.7 evaluating square root by newtons iterative method
Exa 24.10 solving equations by guass elimination method
Exa 24.12 solving equations by guass elimination method
Exa 24.13 solving equations by guass elimination method
Exa 26.2 nding dierence equation
Exa 26.3 solving dierence equation
Exa 26.4 solving dierence equation
Exa 26.6 rming bonacci dierence equation
Exa 26.7 solving dierence equation
Exa 26.8 solving dierence equation
Exa 26.10 solving dierence equation
Exa 26.11 solving dierence equation
Exa 26.12 solving simultanious dierence equation
Exa 26.15.2Z transform
Exa 26.16 evaluating u2 and u3
Exa 27.1 solving ODE with picards method
Exa 27.2 solving ODE with picards method
Exa 27.5 solving ODE using Eulers method
Exa 27.6 solving ODE using Eulers method
Exa 27.7 solving ODE using Modied Eulers method
Exa 27.8 solving ODE using Modied Eulers method
Exa 27.9 solving ODE using Modied Eulers method
Exa 27.10 solving ODE using runge method
Exa 27.11 solving ODE using runge kutta method
Exa 27.12 solving ODE using runge kutta method
11

Exa 27.13 solving ODE using runge kutta method
Exa 27.14 solving ODE using milnes method
Exa 27.15 solving ODE using runge kutta and milnes method
Exa 27.16 solving ODE using adamsbashforth method
Exa 27.17 solving ODE using runge kutta and adams method
Exa 27.18 solving simultanious ODE using picards method
Exa 27.19 solving ssecond ODE using runge kutta method
Exa 27.20 solving ODE using milnes method
Exa 28.1 classication of partial dierential equation
Exa 28.2 solving elliptical equation
Exa 28.3 evaluating function satisfying laplace equation
Exa 28.4 solution of poissons equation
Exa 28.5 solving parabolic equation
Exa 28.6 solving heat equation
Exa 28.7 solving wave equation
Exa 28.8 solving wave equation
Exa 34.1 Calculating probability
Exa 34.2.1 Calculating the number of permutations
Exa 34.2.2 Number of permutations
Exa 34.3.1 Calculating the number of committees
Exa 34.3.2 Finding the number of committees
Exa 34.3.3 Finding the number of committees
Exa 34.4.1 Finding the probability of getting a four in a single
throw of a die
Exa 34.4.2 Finding the probability of getting an even number in a
single throw of a die
Exa 34.5 Finding the probability of 53 sundays in a leap year
Exa 34.6 probability of getting a number divisible by 4 under
given conditions
Exa 34.7 Finding the probability
Exa 34.8 Finding the probability
Exa 34.9.1 Finding the probability
Exa 34.9.2 Finding the probability
Exa 34.9.3 Finding the probability
Exa 34.13 probability of drawing an ace or spade from pack of 52
cards
Exa 34.14.1Finding the probability
Exa 34.15.1Finding the probability
12

Exa 34.15.2Finding the probability
Exa 34.15.3Finding the probability
Exa 34.16 Finding the probability
Exa 34.17 Finding the probability
Exa 34.18 Finding the probability
Exa 34.19.1Finding the probability
Exa 34.19.2Finding the probability
Exa 34.19.3Finding the probability
Exa 34.20 Finding the probability
Exa 34.22 Finding the probability
Exa 34.23 Finding the probability
Exa 34.25 nding the probability
Exa 34.26 nding the probability
Exa 34.27 nding the probability
Exa 34.28 nding the probability
Exa 34.29 nding the probability
Exa 34.30 nding the probability
Exa 34.31 nding the probability
Exa 34.33 nding the probability
Exa 34.34 nding the probability
Exa 34.35 nding the probability
Exa 34.38 nding the probability
Exa 34.39 nding the probability
Exa 34.40 nding the probability
Exa 35.1 calculating the SD of given sample
Exa 35.2 Calculating SD of sample
Exa 35.3 Analysis of sample
Exa 35.4 Analysis of sample
Exa 35.5 Checking whether real dierence will be hidden
Exa 35.6 Checking whether given sample can be regarded as a
random sample
Exa 35.9 Checking whethet samples can be regarded as taken
from the same population
Exa 35.10 calculating SE of dierence of mean hieghts
Exa 35.12 Mean and standard deviation of a given sample
Exa 35.13 Mean and standard deviation of a given sample
Exa 34.15 Standard deviation of a sample
13

List of Figures
1.1 Finding the solution of equation by drawing graphs
1.2 Finding the solution of equation by drawing graphs
1.3 Finding the solution of equation by drawing graphs
6.1 Calculating the area under two curves
14

Chapter 1
Solution of equation and curve
tting
Scilab code Exa 1.1nding the roots of quadratic equations
1clear
2clc
3x= ' x ');
4p=2*(x^3)+x^2 -13*x+6
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.2nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=3*(x^3) -4*(x^2)+x+88
5disp " the r o o t s of above equation are ")
6roots
15

Scilab code Exa 1.3nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=x^3 -7*(x^2) +36
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.6nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=x^4 -2*(x^3) -21*(x^2) +22*x+40
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.7nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=2*(x^4) -15*(x^3) +35*(x^2) -30*x+8
5disp " the r o o t s of above equation are ")
6roots
16

Scilab code Exa 1.11forming an equation with known roots
1clear
2clc
3x= ' x ');
4x1= ' x1 ');
5x2= ' x2 ');
6x3= ' x3 ');
7p=x^3 -3*(x^2)+1
8disp " the r o o t s of above equation are ")
9roots
10disp " l e t ")
11x1 =0.6527036
12x2 = -0.5320889
13x3 =2.8793852
14disp " so the equation whose r o o t s are cube of the
r o o t s of above equation i s ( xx1 ^3)( xx2 ^3)( x
x3 ^3)=0 =>")
15p1=(x-x1^3)*(x-x2^3)*(x-x3^3)
Scilab code Exa 1.12forming an equation under restricted conditions
1clear
2clc
3x= ' x ');
4x1= ' x1 ');
5x2= ' x2 ');
6x3= ' x3 ');
7x4= ' x4 ');
8x5= ' x5 ');
9x6= ' x6 ');
10p=x^3 -6*(x^2) +5*x+8
11disp " the r o o t s of above equation are ")
12roots
13disp " l e t ")
17

14x1 = -0.7784571
15x2 =2.2891685
16x3 =4.4892886
17disp " now , s i n c e we want equation whose sum of
r o o t s i s 0 . sum of r o o t s of above equation i s 6 , so
we w i l l d e c r e a s e ")
18disp " value of each root by 2 i . e . x4=x1 2 ")
19x4=x1 -2
20disp "x5=x22")
21x5=x2 -2
22disp "x6=x32")
23x6=x3 -2
24disp " hence , the r e q u i r e d equation i s ( xx4 )( xx5 )(
xx6 )=0 >")
25p1=(x-x4)*(x-x5)*(x-x6)
Scilab code Exa 1.13nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=6*(x^5) -41*(x^4) +97*(x^3) -97*(x^2) +41*x-6
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.14nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=6*(x^6) -25*(x^5) +31*(x^4) -31*(x^2) +25*x-6
5disp " the r o o t s of above equation are ")
6roots
18

Scilab code Exa 1.15nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=x^3 -3*(x^2) +12*x+16
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.16nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=28*(x^3) -9*(x^2)+1
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.17nding the roots of equation containing one variable
1clear
2clc
3x= ' x ');
4p=x^3+x^2 -16*x+20
5disp " the r o o t s of above equation are ")
6roots
19

Scilab code Exa 1.18Finding the roots of equation containing one vari-
able
1clear
2clc
3x= ' x ');
4p=x^3 -3*(x^2)+3
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.19Finding the roots of equation containing one vari-
able
1clear
2clc
3x= ' x ');
4p=x^4 -12*(x^3) +41*(x^2) -18*x-72
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.20Finding the roots of equation containing one vari-
able
1clear
2clc
3x= ' x ');
4p=x^4 -2*(x^3) -5*(x^2) +10*x-3
5disp " the r o o t s of above equation are ")
6roots
20

Scilab code Exa 1.21Finding the roots of equation containing one vari-
able
1clear
2clc
3x= ' x ');
4p=x^4 -8*(x^2) -24*x+7
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.22Finding the roots of equation containing one vari-
able
1clear
2clc
3x= ' x ');
4p=x^4 -6*(x^3) -3*(x^2) +22*x-6
5disp " the r o o t s of above equation are ")
6roots
Scilab code Exa 1.23Finding the solution of equation by drawing graphs
1clear
2clc
3xset ' window ',1)
4xtitle "My Graph","X a x i s ","Y a x i s ")
5x=
6y1=3-x
7y2=%e^(x-1)
8plot "o")
9plot "+")
10legend("3x","%e^( x1)")
21

Figure 1.1: Finding the solution of equation by drawing graphs
11disp " from the graph , i t i s c l e a r that the point of
i n t e r s e c t i o n i s n e a r l y x=1.43 ")
Scilab code Exa 1.24Finding the solution of equation by drawing graphs
1clear
2clc
3xset ' window ',2)
4xtitle "My Graph","X a x i s ","Y a x i s ")
5x=
6y1=x
7y2=
8plot "o")
9plot "+")
10legend("x"," s i n ( x )+%pi/2 ")
11disp " from the graph , i t i s c l e a r that the point of
i n t e r s e c t i o n i s n e a r l y x=2.3 ")
22

Figure 1.2: Finding the solution of equation by drawing graphs
Scilab code Exa 1.25Finding the solution of equation by drawing graphs
1clear
2clc
3xset ' window ',3)
4xtitle "My Graph","X a x i s ","Y a x i s ")
5x=
6y1=-sec(x)
7y2=
8plot "o")
9plot "+")
10legend("sec ( x ) "," cosh ( x ) ")
11disp " from the graph , i t i s c l e a r that the point of
i n t e r s e c t i o n i s n e a r l y x=2.3 ")
23

Figure 1.3: Finding the solution of equation by drawing graphs
24

Chapter 2
Determinants and Matrices
Scilab code Exa 2.1Calculating Determinant
1clc
2syms a;
3syms h;
4syms g;
5syms b;
6syms f;
7syms c;
8A=[a h g;h b f;g f c]
9det
Scilab code Exa 2.2Calculating Determinant
1clear
2clc
3a=[0 1 2 3;1 0 3 0;2 3 0 1;3 0 1 2]
4disp " determinant of a i s ")
5det
25

Scilab code Exa 2.3Calculating Determinant
1clc
2syms a;
3syms b;
4syms c;
5A=[a a^2 a^3-1;b b^2 b^3-1;c c^2 c^3-1]
6det
Scilab code Exa 2.4Calculating Determinant
1clear
2clc
3a=[21 17 7 10;24 22 6 10;6 8 2 3;6 7 1 2]
4disp " determinant of a i s ")
5det
Scilab code Exa 5.8Partial derivative of given function
1clc
2syms x y
3u=x^y
4a=
5b=
6c=
7d=
8e=
9f=
10disp ' c l e a r l y , c=f ')
26

Scilab code Exa 2.16product of two matrices
1clear
2clc
3A=[0 1 2;1 2 3;2 3 4]
4B=[1 -2;-1 0;2 -1]
5disp "AB= ")
6A*B
7disp "BA= ")
8B*A
Scilab code Exa 2.17Product of two matrices
1clear
2clc
3A=[1 3 0;-1 2 1;0 0 2]
4B=[2 3 4;1 2 3;-1 1 2]
5disp "AB= ")
6A*B
7disp "BA= ")
8B*A
9disp " c l e a r l y AB i s not equal to BA")
Scilab code Exa 2.18Product and inverse of matrices
1clear
2clc
3A=[3 2 2;1 3 1;5 3 4]
4C=[3 4 2;1 6 1;5 6 4]
27

5disp "AB=C >B=inv (A)C")
6B=
Scilab code Exa 2.19Solving equation of matrices
1clear
2clc
3A=[1 3 2;2 0 -1;1 2 3]
4I=
5disp "A^34A^23A+11 I=")
6A^3-4*A*A-3*A+11*I
Scilab code Exa 2.20Nth power of a given matrix
1clc
2A=[11 -25;4 -9]
3n= ' Enter the value of n ") ;
4disp ( 'calculating A^n ' ) ;
5A^n
Scilab code Exa 2.23Inverse of matrix
1clear
2clc
3A=[1 1 3;1 3 -3;-2 -4 -4]
4disp " i n v e r s e of A i s ")
5inv
28

Scilab code Exa 2.24.1Rank of a matrix
1clear
2clc
3A=[1 2 3;1 4 2;2 6 5]
4disp "Rank of A i s ")
5rank
Scilab code Exa 2.24.2Rank of a matrix
1clear
2clc
3A=[0 1 -3 -1;1 0 1 1;3 1 0 2;1 1 -2 0]
4disp "Rank of A i s ")
5rank
Scilab code Exa 2.25Inverse of matrix
1clear
2clc
3A=[1 1 3;1 3 -3;-2 -4 -4]
4disp " i n v e r s e of A i s ")
5inv
Scilab code Exa 2.26eigen values vectors rank of matrix
1clear
2clc
3A=[2 3 -1 -1;1 -1 -2 -4;3 1 3 -2;6 3 0 -7]
4[R P]=
29

5disp " rank of A")
6rank
Scilab code Exa 2.28Inverse of a matrix
1clear
2clc
3A=[1 1 1;4 3 -1;3 5 3]
4disp " i n v e r s e of A =")
5inv
Scilab code Exa 2.31Solving equation using matrices
1clear
2clc
3disp " the e q u a t io n s can be re w r i t t e n as AX=B where
X=[x1 ; x2 ; x3 ; x4 ] and ")
4A=[1 -1 1 1;1 1 -1 1;1 1 1 -1;1 1 1 1]
5B=[2; -4;4;0]
6disp " determinant of A=")
7det
8disp " i n v e r s e of A =")
9inv
10disp "X=")
11inv
Scilab code Exa 2.32Solving equation using matrices
1clear
2clc
30

3disp " the e q u a t io n s can be re w r i t t e n as AX=B where
X=[x ; y ; z ] and ")
4A=[5 3 7;3 26 2;7 2 10]
5B=[4;9;5]
6disp " determinant of A=")
7det
8disp " Since det (A) =0, hence , t h i s system of equation
w i l l have i n f i n i t e s o l u t i o n s . . hence , the system i s
c o n s i s t e n t ")
Scilab code Exa 2.34.1predicting nature of equation using rank of matrix
1clc
2A=[1 2 3;3 4 4;7 10 12]
3disp ' rank of A i s ')
4p=
5if
6 disp ' e q u a t i o ns have only a t r i v i a l s o l u t i o n : x=y=z
=0 ')
7else
8 disp ' e q u a t i o ns have i n f i n i t e no . of s o l u t i o n s . ')
9 end
Scilab code Exa 2.34.2predicting nature of equation using rank of matrix
1clc
2A=[4 2 1 3;6 3 4 7;2 1 0 1]
3disp ' rank of A i s ')
4p=
5if
6 disp ' e q u a t i o ns have only a t r i v i a l s o l u t i o n : x=y=z
=0 ')
7else
31

8 disp ' e q u a t i o n s have i n f i n i t e no . of s o l u t i o n s . ')
9 end
Scilab code Exa 2.38Inverse of a matrix
1clear
2clc
3disp " the given e q u a t i o n s can be w r i t t e n as Y=AX
where ")
4A=[2 1 1;1 1 2;1 0 -2]
5disp " determinant of A i s ")
6det
7disp " since , i t s nons i n g u l a r , hence t r a n s f o r m a t i o n i s
r e g u l a r ")
8disp " i n v e r s e of A i s ")
9inv
Scilab code Exa 2.39Transpose and product of matrices
1clear
2clc
3A=[ -2/3 1/3 2/3;2/3 2/3 1/3;1/3 -2/3 2/3]
4disp "A t r a n s p o s e i s equal to ")
5A'
6disp "A( t r a n s p o s e of A)=")
7A*A'
8disp " hence ,A i s orthogonal ")
Scilab code Exa 2.42eigen values and vectors of given matrix
32

1clear
2clc
3A=[5 4;1 2]
4disp " l e t R r e p r e s e n t s the matrix of t r a n s f o r m a t i o n
and P r e p r e s e n t s a d i a g o n a l matrix whose v a l u e s
are the e i g e n v a l u e s of A. then ")
5[R P]=
6disp "R i s normalised . l e t U r e p r e s e n t s unnormalised
v e r s i o n of r ")
7U(:,1)=R(:,1)*
8U(:,2)=R(:,2)*
9disp "two e i g e n v e c t o r s are the two columns of U")
Scilab code Exa 2.43eigen values and vectors of given matrix
1clear
2clc
3A=[1 1 3;1 5 1;3 1 1]
4disp " l e t R r e p r e s e n t s the matrix of t r a n s f o r m a t i o n
and P r e p r e s e n t s a d i a g o n a l matrix whose v a l u e s
are the e i g e n v a l u e s of A. then ")
5[R P]=
6disp "R i s normalised . l e t U r e p r e s e n t s unnormalised
v e r s i o n of r ")
7U(:,1)=R(:,1)*
8U(:,2)=R(:,2)*
9U(:,3)=R(:,3)*
10disp " t h r e e e i g e n v e c t o r s are the t h r e e columns of U
")
Scilab code Exa 2.44eigen values and vectors of given matrix
1clear
33

2clc
3A=[3 1 4;0 2 6;0 0 5]
4disp " l e t R r e p r e s e n t s the matrix of t r a n s f o r m a t i o n
and P r e p r e s e n t s a d i a g o n a l matrix whose v a l u e s
are the e i g e n v a l u e s of A. then ")
5[R P]=
6disp "R i s normalised . l e t U r e p r e s e n t s unnormalised
v e r s i o n of r ")
7U(:,1)=R(:,1)*
8U(:,2)=R(:,2)*
9U(:,3)=R(:,3)*
10disp " t h r e e e i g e n v e c t o r s are the t h r e e columns of U
")
Scilab code Exa 2.45eigen values and characteristic equation
1clear
2clc
3x= ' x ')
4A=[1 4;2 3]
5I=
6disp " e i g e n v a l u e s of A are ")
7spec
8disp " l e t ")
9a=-1;
10b=5;
11disp " hence , the c h a r a c t e r i s t i c equation i s ( xa ) ( xb
) ")
12p=(x-a)*(x-b)
13disp "A^24A5I=")
14A^2-4*A-5*I
15disp " i n v e r s e of A= ")
16inv
34

Scilab code Exa 2.46eigen values and characteristic equation
1clear
2clc
3x= ' x ')
4A=[1 1 3;1 3 -3;-2 -4 -4]
5disp " e i g e n v a l u e s of A are ")
6spec
7disp " l e t ")
8a=4.2568381;
9b=0.4032794;
10c= -4.6601175;
11disp " hence , the c h a r a c t e r i s t i c equation i s ( xa ) ( xb
) ( xc ) ")
12p=(x-a)*(x-b)*(x-c)
13disp " i n v e r s e of A= ")
14inv
Scilab code Exa 2.47eigen values and characteristic equation
1clear
2clc
3x= ' x ')
4A=[2 1 1;0 1 0;1 1 2]
5I=
6disp " e i g e n v a l u e s of A are ")
7spec
8disp " l e t ")
9a=1;
10b=1;
11c=3;
35

12disp " hence , the c h a r a c t e r i s t i c equation i s ( xa ) ( xb
) ( xc ) ")
13p=(x-a)*(x-b)*(x-c)
14disp "A^85A^7+7A^63A^5+A^45A^3+8A^22A+I ="
)
15A^8-5*A^7+7*A^6-3*A^5+A^4-5*A^3+8*A^2-2*A+I
Scilab code Exa 2.48eigen values and vectors of given matrix
1clear
2clc
3A=[-1 2 -2;1 2 1;-1 -1 0]
4disp "R i s matrix of t r a n s f o r m a t i o n and D i s a
d i a g o n a l matrix ")
5[R D]=
Scilab code Exa 2.49eigen values and vectors of given matrix
1clear
2clc
3A=[1 1 3;1 5 1;3 1 1]
4disp "R i s matrix of t r a n s f o r m a t i o n and D i s a
d i a g o n a l matrix ")
5[R D]=
6disp "R i s normalised , l e t P denotes unnormalised
v e r s i o n of R. Then ")
7P(:,1)=R(:,1)*
8P(:,2)=R(:,2)*
9P(:,3)=R(:,3)*
10disp "A^4=")
11A^4
36

Scilab code Exa 2.50eigen values and vectors of given matrix
1clear
2clc
3disp "3x^2+5y^2+3z^22yz+2zx2xy")
4disp "The matrix of the given q u a d r a t i c form i s ")
5A=[3 -1 1;-1 5 -1;1 -1 3]
6disp " l e t R r e p r e s e n t s the matrix of t r a n s f o r m a t i o n
and P r e p r e s e n t s a d i a g o n a l matrix whose v a l u e s
are the e i g e n v a l u e s of A. then ")
7[R P]=
8disp " so , c a n o n i c a l form i s 2x^2+3y^2+6z ^2")
Scilab code Exa 2.51eigen values and vectors of given matrix
1clear
2clc
3disp "2x1x2+2x1x32x2x3 ")
4disp "The matrix of the given q u a d r a t i c form i s ")
5A=[0 1 1;1 0 -1;1 -1 0]
6disp " l e t R r e p r e s e n t s the matrix of t r a n s f o r m a t i o n
and P r e p r e s e n t s a d i a g o n a l matrix whose v a l u e s
are the e i g e n v a l u e s of A. then ")
7[R P]=
8disp " so , c a n o n i c a l form i s2x^2+y^2+z ^2 ")
Scilab code Exa 2.52Hermitian matrix
1clear
37

2clc
3A=[2+ %i 3 -1+3*%i;-5 %i 4-2*%i]
4disp "A=")
5A'
6disp "AA=")
7A*A'
8disp " c l e a r l y ,AAi s hermitian matrix ")
Scilab code Exa 2.53tranpose and inverse of complex matrix
1clear
2clc
3A=[(1/2) *(1+ %i) (1/2) *(-1+%i);(1/2) *(1+ %i) (1/2) *(1-
%i)]
4disp "A=")
5A'
6disp "AA=")
7A*A'
8disp "AA=")
9A'*A
10disp " i n v e r s e of A i s ")
11inv
Scilab code Exa 2.54Unitary matrix
1clear
2clc
3A=[0 1+2* %i; -1+2*%i 0]
4I=
5disp " IA= ")
6I-A
7disp " i n v e r s e of ( I+A)= ")
8inv
38

9disp " ( ( IA) ( i n v e r s e ( I+A) ) )(( IA) ( i n v e r s e ( I+A) ) )=")
10(((I-A)*(
11disp " ( ( IA) ( i n v e r s e ( I+A) ) ) ( ( IA) ( i n v e r s e ( I+A) ) )=")
12((I-A)*(
13disp " c l e a r l y , the product i s an i d e n t i t y matrix .
hence , i t i s a un ita ry matrix ")
39

Chapter 4
Dierentiation and
Applications
Scilab code Exa 4.4.1nding nth derivative
1//
2//
3//
4//
5//
6//
7clc
8disp ' we have to f i n d yn f o r F=cosxcos2xcos3x ' );
9syms x
10F=
11n= ' Enter the order of d i f f e r e n t i a t i o n ") ;
12disp ( 'calculating yn ' ) ;
13yn=d i f f (F , x , n )
14disp ( 'the expression ' ) ;
15disp ( yn ) ;
40

Scilab code Exa 4.5nding nth derivative
1//
2//
3//
4//
5//
6//
7clc
8disp ' we have to f i n d yn f o r F=cosxcos2xcos3x ' );
9syms x
10F=x/((x-1) *(2*x+3));
11n= ' Enter the order of d i f f e r e n t i a t i o n : ") ;
12disp ( 'calculating yn ' ) ;
13yn=d i f f (F , x , n )
14disp ( 'the expression ' ) ;
15disp ( yn ) ;
Scilab code Exa 4.6nding nth derivative
1//
2//
3//
4//
5//
6//
7clc
8disp ' we have to f i n d yn f o r F=cosxcos2xcos3x ' );
9syms x a
10F=x/(x^2+a^2);
11n= ' Enter the order of d i f f e r e n t i a t i o n : ") ;
12disp ( 'calculating yn ' ) ;
13yn=d i f f (F , x , n )
14disp ( 'the expression ' ) ;
15disp ( yn ) ;
41

Scilab code Exa 4.7nding nth derivative
1//
2//
3//
4//
5//
6//
7clc
8disp ' we have to f i n d yn f o r F=cosxcos2xcos3x ' );
9syms x a
10F=%e^(x)*(2*x+3) ^3;
11//
12disp ' c a l c u l a t i n g yn ');
13yn=
14disp ' the e x p r e s s i o n f o r yn i s ');
15disp
Scilab code Exa 4.8proving the given dierential equation
1//
2//
3//
4//
5//
6//
7clc
8disp ' y=( s i n ^1)x ) s i g n i n v e r s e x ');
9syms x
10y=(
11disp 'we have to prove (1x ^2) y ( n+2)(2n+1)xy ( n+1)n
^2yn ') ;
42

12//
13disp ' c a l c u l a t i n g yn f o r v a r i o u s v a l u e s of n ');
14for
15
16 F=(1-x^2)*
^2+a^2)*
17 disp
18 disp ' the e x p r e s s i o n f o r yn i s ');
19 disp
20 disp ' Which i s equal to 0 ');
21
22end
23disp ' Hence proved ');
Scilab code Exa 4.9proving the given dierential equation
1//
2//
3//
4//
5//
6//
7clc
8disp ' y=e ^( a ( s i n ^1)x ) ) s i g n i n v e r s e x ');
9syms x a
10y=%e^(a*(
11disp 'we have to prove (1x ^2) y ( n+2)(2n+1)xy ( n+1)(
n^2+a ^2) yn ') ;
12//
13disp ' c a l c u l a t i n g yn f o r v a r i o u s v a l u e s of n ');
14for
15
16 //
17 F=(1-x^2)*
^2+a^2)*
43

18 disp
19 disp ' the e x p r e s s i o n f o r yn i s ');
20 disp
21 disp ' Which i s equal to 0 ');
22
23end
24disp ' Hence proved ');
Scilab code Exa 4.10proving the given dierential equation
1clc
2disp ' y ^(1/m)+y^(1/m)=2x ');
3disp ' OR y ^(2/m)2xy ^(1/m)+1 ');
4disp 'OR y=[x+(x^21) ] ^m and y=[x(x^21) ] ^m ');
5
6syms x m
7disp ' For y=[x+(x^21) ] ^m ');
8y=(x+(x^2-1))^m
9disp 'we have to prove ( x^21)y ( n+2)+(2n+1)xy ( n+1)+(
n^2m^2) yn ') ;
10//
11disp ' c a l c u l a t i n g yn f o r v a r i o u s v a l u e s of n ');
12for
13
14 //
15 F=(x^2-1)*
^2-m^2)*
16 disp
17 disp ' the e x p r e s s i o n f o r yn i s ');
18 disp
19 disp ' Which i s equal to 0 ');
20
21end
22disp ' For y=[x(x^21) ] ^m ');
23y=(x-(x^2-1))^m
44

24disp 'we have to prove ( x^21)y ( n+2)+(2n+1)xy ( n+1)+(
n^2m^2) yn ') ;
25//
26disp ' c a l c u l a t i n g yn f o r v a r i o u s v a l u e s of n ');
27for
28
29 //
30 F=(x^2-1)*
^2-m^2)*
31 disp
32 disp ' the e x p r e s s i o n f o r yn i s ');
33 disp
34 disp ' Which i s equal to 0 ');
35
36end
37disp ' Hence proved ');
Scilab code Exa 4.11verify roles theorem
1clc
2disp ' f o r r o l e s theorem F9x ) should be
d i f f e r e n t i a b l e in ( a , b ) and f ( a )=f ( b ) ');
3disp ' Here f ( x )=s i n ( x ) / e ^x ');
4disp ' ');
5syms x
6y=
7
8y1=
9disp
10disp ' putting t h i s to zero we get tan ( x )=1 i e x=pi /4
');
11disp ' value pi /2 l i e s b/w 0 and pi . Hence r o l e s
theorem i s v e r i f i e d ');
45

Scilab code Exa 4.16expansion using maclaurins series
1//
2disp ' Maclaurins s e r i e s ');
3disp ' f ( x )=f ( 0 )+xf1 ( 0 )+x ^2/2!f2 ( 0 )+x ^3/3!f3 ( 0 )
+ . . . . . . ');
4syms x a
5//
6 y=
7//
8n= ' e n t e r the number of e x p r e s s i o n in s e r i e s :
');
9a=1;
10t=
11a=0;
12for
13 y1= ' a ',i-1);
14 t=t+x^(i-1)*
15end
16disp
Scilab code Exa 4.17expanding function as fourier series of sine term
1//
2disp ' Maclaurins s e r i e s ');
3disp ' f ( x )=f ( 0 )+xf1 ( 0 )+x ^2/2!f2 ( 0 )+x ^3/3!f3 ( 0 )
+ . . . . . . ');
4syms x a
5
6 y=%e^(
7 n= ' e n t e r the number of e x p r e s s i o n in s e r i s :
');
46

8 a=0;
9t=
10a=0;
11for
12 y1= ' a ',i-1);
13 t=t+x^(i-1)*
14end
15disp
Scilab code Exa 4.18expansion using maclaurins series
1//
2disp ' Maclaurins s e r i e s ');
3disp ' f ( x )=f ( 0 )+xf1 ( 0 )+x ^2/2!f2 ( 0 )+x ^3/3!f3 ( 0 )
+ . . . . . . ');
4syms x a
5
6 y=
7 n= ' e n t e r the number of d i f f e r e n t i a t i o n
i n v o l v e d in maclaurins s e r i e s : ');
8 a=0;
9t=
10a=0;
11for
12 y1= ' a ',i-1);
13 t=t+x^(i-1)*
14end
15disp
Scilab code Exa 4.19expansion using maclaurins series
1//
2disp ' Maclaurins s e r i e s ');
47

3disp ' f ( x )=f ( 0 )+xf1 ( 0 )+x ^2/2!f2 ( 0 )+x ^3/3!f3 ( 0 )
+ . . . . . . ');
4syms x a b
5
6 y=%e^(a*
7 n= ' e n t e r the number of e x p r e s s i o n in s e r i s :
');
8 b=0;
9t=
10
11for
12 y1= ' b ',i-1);
13 t=t+x^(i-1)*
14end
15disp
Scilab code Exa 4.20expansion using taylors series
1//
2disp ' Advantage of s c i l a b i s that we can c a l c u l a t e
log1 . 1 d i r e c t l y without using Taylor s e r i e s ');
3disp ' Use of t a y l o r s e r i e s are given in subsequent
examples ');
4y=
5disp ' l o g ( 1 . 1 )= ');
6disp
Scilab code Exa 4.21taylor series
1//
2disp ' Taylor s e r i e s ');
3disp ' f ( x+h )=f ( x )+hf1 ( x )+h ^2/2!f2 ( x )+h ^3/3!f3 ( x )
+ . . . . . . ');
48

4disp 'To f i n f the t a y l o r expansion of tan1(x+h ) ')
5syms x h
6
7 y=
8 n= ' e n t e r the number of e x p r e s s i o n in s e r i s :
');
9
10t=y;
11
12for
13 y1= ' x ',i-1);
14 t=t+h^(i-1)*(y1)/factorial(i-1);
15end
16disp
Scilab code Exa 4.22evaluating limit
1//
2disp ' Here we need to f i n d f i n d the l i m i t of f ( x ) at
x=0 ')
3syms x
4y=(x*%e^x-
5//
6//
7//
8f=1;
9while
10yn=x*%e^x-
11yd=x^2;
12yn1= ' x ',1);
13yd1= ' x ',1);
14x=0;
15a=
16b=
17if
49

18 yn=yn1;
19 yd=yd1;
20else
21 f=0;
22
23end
24end
25h=a/b;
26disp
Scilab code Exa 4.32tangent to curve
1//
2disp ' Equation of tangent ');
3syms x a y;
4f=(a^(2/3) -x^(2/3))^(3/2);
5s=
6
7Y1=s*(-x)+y;
8X1=-y/s*x;
9g=x-(Y1 -s*(X1 -x));
10disp ' Equation i s g=0 where g i s ');
11disp
Scilab code Exa 4.34nding equation of normal
1//
2disp ' Equation of tangent ');
3syms x a t y
4xo=a*(
5yo=a*(
6s=
7y=yo+s*(x-xo);
50

8disp ' y= ');
9disp
Scilab code Exa 4.35nding angle of intersection of curve
1//
2disp "The two given curves are x^=4y and y^2=4x
which i n t e r s e c t s at ( 0 , 0 ) and ( 4 , 4 ) ') ;
3disp ( ' f o r ( 4 , 4 ) ') ;
4x=4;
5syms x
6y1=x ^2/4;
7y2=2x ^(1/2) ;
8m1=d i f f ( y1 , x , 1 ) ;
9m2=d i f f ( y2 , x , 1 ) ;
10x=4;
11m1=e v a l (m1) ;
12m2=e v a l (m2) ;
13
14disp ( ' Angle between them i s ( r a d i a n s ) :') ;
15t=atan ( (m1m2) /(1+m1m2) ) ;
16disp ( t ) ;
Scilab code Exa 4.37prove given tangent statement
1//
2syms a t
3x=a*(
4y=a*
5s=
6disp ' length of tangent ');
7l=y*(1+s)^(0.5);
8disp
51

9disp ' checking f o r i t s dependency on t ')
10
11f=1
12t=0;
13k=
14for
15 t=i;
16 if
17 f=0;
18 end
19end
20if
21 disp " v e r i f i e d and equal to a");
22 disp ' subtangent ');
23 m=y/s;
24 disp
Scilab code Exa 4.39nding angle of intersection of curve
1//
2clc
3disp ' Angle of i n t e r s e c t i o n ');
4disp ' point of i n t e r s e c t i o n of r=s i n t+c o s t and r=2
s i n t i s t=pi /4 ');
5disp ' tanu=dQ/ drr ');
6syms Q ;
7
8r1=2*
9r2=
10u=
11Q=%pi /4;
12u=
13disp ' The angle at point of i n t e r s e c t i o n in r a d i a n s
i s : ');
14disp
52

Scilab code Exa 4.41nding pedal equation of parabola
1//
2clc
3disp ' tanu=dQ/ drr ');
4syms Q a;
5
6r=2*a/(1-
7
8u=
9u=
10p=r*
11syms r;
12Q=
13
14// 2a
15p=
16disp
Scilab code Exa 4.43nding radius of curvature of cycloid
1//
2syms a t
3x=a*(t+
4y=a*(1-
5s2=
6s1=
7
8r=(1+ s1^2) ^(3/2)/s2;
9disp ' The r a d i u s of curvature i s : ');
10disp
53

Scilab code Exa 4.46radius of curvature of cardoid
1//
2disp ' r a d i u s of curvature ');
3syms a t
4r=a*(1-
5r1=
6l=(r^2+r1^2) ^(3/2) /(r^2+2* r1^2-r*r1);
7syms r;
8t=
9l=
10disp
11disp ' Which i s p r o p o r t i o n a l to r ^0.5 ');
Scilab code Exa 4.47cordinates of centre of curvature
1//
2disp ' The c e n t r e of curvature ');
3syms x a y
4y=2*(a*x)^0.5;
5y1=
6y2=
7xx=x-y1 *(1+ y1)^2/y2;
8yy=y+(1+ y1^2)/y2;
9disp ' the c o o r d i n a t e s x , y are resp : ');
10
11disp
12disp
54

Scilab code Exa 4.48proof statement cycloid
1//
2disp ' c e n t r e of curvature of given c y c l o i d ');
3syms a t
4x=a*(t-
5y=a*(1-
6y1=
7y2=
8xx=x-y1 *(1+ y1)^2/y2;
9yy=y+(1+ y1^2)/y2;
10
11disp ' the c o o r d i n a t e s x , y are resp : ');
12disp
13disp
14disp ' which another parametric equation of c y c l o i d '
);
Scilab code Exa 4.52maxima and minima
1//
2//
3disp 'To f i n d the maxima and minima of given
f u n c t i o n put f1 ( x )=0 ');
4syms x
5//
6f=3*x^4-2*x^3-6*x^2+6*x+1;
7k=
8x= ' x ');
9k=
Scilab code Exa 4.61nding the asymptotes of curve
55

1//
2clc
3disp ' to f i n d the assymptote of given curve ' );
4syms x y
5f=x^2*y^2-x^2*y-x*y^2+x+y+1;
6//
7f1=coeffs(f,x,2);
8disp ' assymptotes p a r a l l e l to xx i s i s given by f1=0
where f1 i s : ');
9disp
10f2=coeffs(f,y,2);
11disp ' assymptotes p a r a l l e l to ya x i s i s given by f2
=0 and f2 i s : ');
12disp
56

Chapter 5
Partial Dierentiation And Its
Applications
Scilab code Exa 5.5Partial derivative of given function
1clc
2syms x y z
3v=(x^2+y^2+z^2) ^( -1/2)
4a=
5b=
6c=
7a+b+c
Scilab code Exa 5.14Partial derivative of given function
1clc
2syms x y
3u=
4a=
5b=
6c=
57

7d=
8e=
9x*a+y*b
10(1/2)*
11(x^2)*c+2*x*y*e+(y^2)*d
12(-
Scilab code Exa 5.25.1Partial derivative of given function
1clc
2syms r l
3x=r*
4y=r*
5a=
6b=
7c=
8d=
9A=[a b;c d]
10det
Scilab code Exa 5.25.2Partial derivative of given function
1clc
2syms r l z
3x=r*
4y=r*
5m=z
6a=
7b=
8c=
9d=
10e=
11f=
58

12g=
13h=
14i=
15A=[a b c;d e f;g h i]
16det
Scilab code Exa 5.25.3Partial derivative of given function
1clc
2syms r l m
3x=r*
4y=r*
5z=r*
6a=
7b=
8c=
9d=
10e=
11f=
12g=
13h=
14i=
15A=[a b c;d e f;g h i]
16det
Scilab code Exa 5.26Partial derivative of given function
1clc
2syms x1 x2 x3
3y1=(x2*x3)/x1
4y2=(x3*x1)/x2
5y3=(x1*x2)/x3
6a=
59

7b=
8c=
9d=
10e=
11f=
12g=
13h=
14i=
15A=[a b c;d e f;g h i]
16det
Scilab code Exa 5.30Partial derivative of given function
1clc
2syms x y
3u=x*(1-y^2) ^0.5+y*(1-x^2) ^0.5
4v=
5a=
6b=
7c=
8d=
9A=[a b; c d ]
10det
60

Chapter 6
Integration and its Applications
Scilab code Exa 6.1.1indenite integral
1//
2disp ' I n d e f i n i t e i n t e g r a l ');
3syms x
4f=integ ((
5disp
Scilab code Exa 6.1.2indenite integral
1//
2disp ' I n d e f i n i t e i n t e g r a l ');
3syms x
4f=integ ((
5disp
Scilab code Exa 6.2.1denite integral
61

1//
2disp ' d e f i n i t e i n t e g r a l ');
3syms x
4f=integ ((
5disp
Scilab code Exa 6.2.2Denite Integration of a function
1//
2//
3clc
4disp ' d e f i n i t e i n t e g r a l ');
5syms x a
6g=x^7/(a^2-x^2) ^1/2
7f=integ(g,x,0,a);
8disp
Scilab code Exa 4.2.3denite integral
1//
2//
3clc
4disp ' d e f i n i t e i n t e g r a l ');
5syms x a
6g=x^3*(2*a*x-x^2) ^(1/2);
7f=integ(g,x,0,2*a);
8disp
Scilab code Exa 6.2.3denite integral
62

1//
2//
3clc
4disp ' d e f i n i t e i n t e g r a l ');
5syms x a n
6g=1/(a^2+x^2)^n;
7f=integ(g,x,0,%inf);
8disp
Scilab code Exa 6.4.1denite integral
1//
2clc
3disp ' d e f i n i t e i n t e g r a l ');
4syms x
5g=(
6f=integ(g,x,0,%pi /6);
7disp
Scilab code Exa 4.4.2denite integral
1//
2clc
3disp ' d e f i n i t e i n t e g r a l ');
4syms x
5g=x^4*(1 -x^2) ^(3/2);
6f=integ(g,x,0,1);
7disp
Scilab code Exa 6.5denite integral
63

1//
2//
3clc
4disp ' d e f i n i t e i n t e g r a l ');
5syms x m n
6n= ' Enter n : ');
7m= ' Enter m : ');
8g=(
9f=integ(g,x,0,%pi /2);
10disp
11g2=(
12f2=m/(m+n)*integ(g2 ,x,0,%pi /2);
13disp
14disp ' Equal ');
Scilab code Exa 6.6.1reducing indenite integral to simpler form
1//
2clc
3disp ' d e f i n i t e i n t e g r a l ');
4syms x a
5n= ' Enter n : ');
6g=
7
8f=integ(g,x);
9disp
Scilab code Exa 6.7.1Indenite Integration of a function
1clc
2syms x
3disp
64

Scilab code Exa 6.8Getting the manual input of a variable and integra-
tion
1clc
2n= ' Enter the value of n ") ;
3p=i n t e g r a t e ( '( ' x ',0,%pi /4)
4q= ' ( tan ( x ) ) ^( n+1) ',' x ',0,%pi /4)
5disp ' n ( p+q )= ')
6disp
Scilab code Exa 6.9.1Denite Integration of a function
1clear
2clc
3integrate ' sec ( x ) ^4 ',' x ',0,%pi /4)
Scilab code Exa 6.9.2Denite Integration of a function
1clear
2clc
3integrate ' 1/ s i n ( x ) ^3 ',' x ',%pi/3,%pi /2)
Scilab code Exa 6.10denite integral
1
2//
3clc
65

4syms x
5g=x*
6f=integ(g,x,0,%pi);
7disp
Scilab code Exa 6.12Denite Integration of a function
1clear
2clc
3integrate ' s i n ( x ) ^ 0 . 5 / ( s i n ( x ) ^0.5+ cos ( x ) ^ 0 . 5 ) ',' x '
,0,%pi /2)
Scilab code Exa 6.13sum of innite series
1
2//
3clc
4syms x
5disp ' The summation i s e q u i v a l e n t to i n t e g r a t i o n of
1/(1+x ^2) from 0 to 1 ' );
6g=1/(1+x^2);
7f=integ(g,x,0,1);
8disp
Scilab code Exa 6.14nding the limit of the function
1//
2clc
3syms x
66

4disp ' The summation i s e q u i v a l e n t to i n t e g r a t i o n of
l o g (1+x ) from 0 to 1 ');
5g=
6f=integ(g,x,0,1);
7disp
Scilab code Exa 6.15Denite Integration of a function
1clear
2clc
3integrate ' xs i n ( x ) ^8cos ( x ) ^4 ',' x ',0,%pi)
Scilab code Exa 6.16Denite Integration of a function
1clear
2clc
3integrate ' l o g ( s i n ( x ) ) ',' x ',0,%pi /2)
Scilab code Exa 6.24Calculating the area under two curves
1clear
2clc
3xset ' window ',1)
4xtitle "My Graph","X a x i s ","Y a x i s ")
5x=
6y1=(x+8)/2
7y2=x^2/8
8plot "o")
9plot "+")
10legend(" ( x+8)/2 ","x ^2/8 ")
67

Figure 6.1: Calculating the area under two curves
11disp " from the graph , i t i s c l e a r that the p o i n t s of
i n t e r s e c t i o n are x=4 and x=8.")
12disp "So , our r e g i o n of i n t e g r a t i o n i s from x=4 to x
=8")
13integrate ' ( x+8)/2x ^2/8 ',' x ',-4,8)
68

Chapter 9
Innite Series
Scilab code Exa 9.1to nd the limit at innity
1clc
2syms n;
3f=((1/n)^2 -2*(1/n))/(3*(1/n)^2+(1/n))
4disp
Scilab code Exa 9.1.3to nd the limit at innity
1clc
2syms n;
3f=3+( -1)^n
4limit(f,n,%inf)
Scilab code Exa 9.2.1to nd the sum of series upto innity
1clc
2syms n
69

3disp ' 1+2+3+4+5+6+7+....+n + . . . . . = ')
4p=1/n*(1/n+1)/2
5disp
Scilab code Exa 9.2.2to check for the type of series
1clc
2disp ' 541+541+541+541+.........=0,5,1
according to the no . of terms . ' )
3disp ' c l e a r l y , in t h i s case sum doesnt tend to a
unique l i m i t . hence , s e r i e s i s o s c i l l a t o r y . ')
Scilab code Exa 9.5.1to check the type of innite series
1clc
2syms n;
3v=1/((1/n)^2)
4u=(2/n-1) /(1/n*(1/n+1) *(1/n+2))
5disp
6disp ' both u and v converge and d i v e r g e together ,
hence u i s convergent ')
Scilab code Exa 9.5.2to check the type of innite series
1clc
2syms n;
3v=n
4u=((1/n)^2) /((3/n+1) *(3/n+4) *(3/n+7))
5disp
6disp ' both u and v converge and d i v e r g e together ,
hence u i s d i v e r g e n t ')
70

Scilab code Exa 9.7.1to check the type of innite series
1clc
2syms n
3disp ' u=((n+1) ^0.51) / ( ( n+2)^31)=>')
4//
5u=((1+1/(1/n)) -(1/n)^( -0.5))/(((1/n)^5/2) *((1+2/(1/n
))^3 -(1/n)^(-3)))
6v=(1/n)^( -5/2)
7disp
8//
9disp ' s i n c e , v i s convergent , so u i s a l s o
conzavergent . ')
Scilab code Exa 9.7.3to check the type of innite series
1clc
2syms n
3disp
Scilab code Exa 9.8.1to nd the sum of series upto innity
1clc
2syms x n;
3//
4u=(x^(2*(1/n) -2))/(((1/n)+1) *(1/n)^0.5)
5v=(x^(2*(1/n)))/((1/n+2) *(1/n+1) ^0.5)
6disp
71

Scilab code Exa 9.8.2to nd the limit at innity
1clc
2syms x n;
3//
4u=((2^(1/n) -2)*(x^(1/n-1)))/(2^(1/n)+1)
5v=((2^((1/n)+1) -2)*(x^(1/n)))/(2^(1/n+1) +1)
6disp
Scilab code Exa 9.10.1to nd the limit at innity
1clc
2syms x n;
3u=1/(1+x^(-n));
4v=1/(1+x^(-n-1));
5disp
Scilab code Exa 9.10.2to nd the limit at innity
1clc
2syms a b n;
3l=(b+1/n)/(a+1/n)
4disp
Scilab code Exa 9.11.1to nd the limit at innity
72

1clc
2syms x n;
3disp ' u = ( ( 4 . 7 . . . . ( 3 n+1) )x^n ) / ( 1 . 2 . . . . . n ) ')
4disp ' v = ( ( 4 . 7 . . . . ( 3 n+4)x ^( n+1) ) / ( 1 . 2 . . . . . ( n+1) ) ')
5disp ' l=u/v=>')
6l=(1+n)/((3+4*n)*x)
7disp
Scilab code Exa 9.11.2to nd the limit at innity
1clc
2syms x n;
3u=((( factorial(n))^2)*x^(2*n))/factorial (2*n)
4v=((( factorial(n+1))^2)*x^(2*(n+1)))/factorial (2*(n
+1))
5limit(u/v,n,%inf)
73

Chapter 10
Fourier Series
Scilab code Exa 10.1nding fourier series of given function
1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x
5ao=1/ %pi*integ(
6s=ao/2;
7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9 ai=1/ %pi*integ(
10 bi=1/ %pi*integ(
11 s=s+float(ai)*
12end
13disp
Scilab code Exa 10.2nding fourier series of given function
74

1//
2//
3disp 'To f i n d the f o u r i e r transform of given
f u n c t i o n ');
4syms x s
5F=integ(
6disp
7// >
8F1=integ(
Scilab code Exa 10.3nding fourier series of given function
1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x
5ao=1/ %pi*( integ (-1*%pi*x^0,x,-%pi ,0)+integ(x,x,0,%pi
));
6s=ao/2;
7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9 ai=1/ %pi*( integ (-1*%pi*
x*
10 bi=1/ %pi*( integ (-1*%pi*x^0*
integ(x*
11 s=s+float(ai)*
12end
13disp
Scilab code Exa 10.4nding fourier series of given function
75

1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x l
5ao=1/l*integ(
6s=ao/2
7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9 ai=1/l*integ(
10 bi=1/l*integ(
11 s=s+float(ai)*
/l);
12end
13disp
Scilab code Exa 10.5nding fourier series of given function in interval
minus pi to pi
1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x l
5s=0;
6n= ' e n t e r the no of terms upto each of s i n
terms in the expansion : ' );
7for
8
9 bi=2/ %pi*integ(x*
10 s=s+float(bi)*
11end
12disp
76

Scilab code Exa 10.6nding fourier series of given function in interval
minus l to l
1//
2//
3clc
4disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
5syms x l
6ao=2/l*integ(x^2,x,0,l);
7s=float(ao)/2;
8n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
9for
10 ai=2/l*integ(x^2*
11 // i n t e g xs i n x l
12 s=s+float(ai)*
13 end
14disp
Scilab code Exa 10.7nding fourier series of given function in interval
minus pi to pi
1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x
5ao=2/ %pi*( integ(
%pi/2,%pi));
6s=ao/2;
77

7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9 ai=2/ %pi*( integ(
cos
10 // ( 1%pixs i n x 1%pi
i n t e g s i n x
11 s=s+float(ai)*
12end
13disp
Scilab code Exa 10.8nding fourier series of given function in interval
minus pi to pi
1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x
5ao=2/ %pi*( integ ((1 -2*x/%pi),x,0,%pi));
6s=ao/2;
7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9 ai=2/ %pi*( integ ((1 -2*x/%pi)*
10 // ( 1%pixs i n x 1%pi
i n t e g s i n x
11 s=s+float(ai)*
12end
13disp
Scilab code Exa 10.9nding half range sine series of given function
78

1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x l
5
6s=0;
7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9// i n t e g xcos %pix l
10 bi=integ(x*
11 s=s+float(bi)*
12end
13disp
Scilab code Exa 10.10nding half range cosine series of given function
1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x
5ao =2/2*( integ(x,x,0,2));
6s=ao/2;
7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9 ai =2/2*( integ(x*
10 // ( 1%pixs i n x 1%pi
i n t e g s i n x
11 s=s+float(ai)*
12end
13disp
79

Scilab code Exa 10.11expanding function as fourier series of sine term
1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x
5ao=0;
6s=ao;
7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9 bi =2/1*( integ ((1/4 -x)*
integ ((x -3/4)*
10 s=s+float(bi)*
11end
12disp
Scilab code Exa 10.12nding fourier series of given function
1//
2clc
3disp ' f i n d i n g the f o u r i e r s e r i e s of given f u n c t i o n ')
;
4syms x
5ao=1/ %pi*integ(x^2,x,-%pi ,%pi);
6s=ao/2;
7n= ' e n t e r the no of terms upto each of s i n or
cos terms in the expansion : ' );
8for
9 ai=1/ %pi*integ ((x^2)*
10 bi=1/ %pi*integ ((x^2)*
80

11 s=s+float(ai)*
12end
13disp
Scilab code Exa 10.13nding complex form of fourier series
1//
2clc
3disp ' The complex form of s e r i e s i s summation of f (n
, x ) where n v a r i e s from%inf to %inf and f (n , x )
i s given by : ');
4syms n x
5cn =1/2* integ(
6fnx=float(cn)*
7
8disp
Scilab code Exa 10.14practical harmonic analysis
1//
2//
1.52
3// %pi %pi %pi
/6 %pi %pi %pi %pi
4disp ' P r a c t i c a l harmonic a n a l y s i s ');
5syms x
6xo= ' Input xo matrix : ');
7yo= ' Input yo matrix : ');
8ao=2*
9s=ao/2;
10n= 'No of s i n or cos term in expansion : ' );
11for
12 an=2*
81

13 bn=2*
14 s=s+float(an)*
15
16 end
17 disp
Scilab code Exa 10.15practical harmonic analysis
1//
2//
3// 0.88.25
4//
5disp ' P r a c t i c a l harmonic a n a l y s i s ');
6syms x T
7xo= ' Input xo matrix ( in f a c t o r of T) : ');
8yo= ' Input yo matrix : ');
9ao=2*
10s=ao/2;
11n= 'No of s i n or cos term in expansion : ' );
12i=1
13 an =2*( yo.*
14 bn =2*( yo.*
15 s=s+float(an)*
*2* %pi/T);
16
17 disp
18 disp ' D i r e c t c u r r e n t : ');
19i=
Scilab code Exa 10.16practical harmonic analysis
1//
2//
82

3// 0.88.25
4//
5disp ' P r a c t i c a l harmonic a n a l y s i s ');
6syms x T
7xo= ' Input xo matrix ( in f a c t o r of T) : ');
8yo= ' Input yo matrix : ');
9ao=2*
10s=ao/2;
11n= 'No of s i n or cos term in expansion : ' );
12i=1
13 an =2*( yo.*
14 bn =2*( yo.*
15 s=s+float(an)*
*2* %pi/T);
16
17 disp
18 disp ' D i r e c t c u r r e n t : ');
19i=
Scilab code Exa 10.17practical harmonic analysis
1//
2//
3// 0.88.25
4//
5disp ' P r a c t i c a l harmonic a n a l y s i s ');
6syms x T
7xo= ' Input xo matrix ( in f a c t o r of T) : ');
8yo= ' Input yo matrix : ');
9ao=2*
10s=ao/2;
11n= 'No of s i n or cos term in expansion : ' );
12i=1
13 an =2*( yo.*
14 bn =2*( yo.*
83

15 s=s+float(an)*
*2* %pi/T);
16
17 disp
18 disp ' D i r e c t c u r r e n t : ');
19i=
84

Chapter 13
Linear Dierential Equations
Scilab code Exa 13.1solvinf linear dierential equation
1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4syms c1 c2 x
5m= 'm');
6f=m^2+m-2;
7r=
8disp
9y=0;
10//
11 //
12 // exp x
13 //
14 y=c1*
15 disp ' y= ');
16 disp
Scilab code Exa 13.2solving linear dierential equation
85

1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4syms c1 c2 x;
5m= 'm');
6f=m^2+6*m+9;
7r=
8disp
9disp ' r o o t s are equal so s o l u t i o n i s given by : ');
10disp ' y= ');
11y=(c1+x*c2)*
12disp
Scilab code Exa 13.3solving linear dierential equation
1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4syms c1 c2 c3 x
5m= 'm');
6f=m^3+m^2+4*m+4;
7r=
8disp
9y=c1*
10disp ' y= ');
11disp
Scilab code Exa 13.4solving linear dierential equation
1//
2clc
86

3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4m= 'm');
5syms c1 c2 c3 c4 x
6f=m^4+4;
7r=
8disp
9y=c1*
exp
10disp ' y= ');
11disp
Scilab code Exa 13.5nding particular integral
1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4m= 'm');
5f=m^2+5*m+6;
6//
7y=
8disp 'y');
9disp
Scilab code Exa 13.6nding particular integral
1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4m= 'm');
5f=(m+2)*(m-1) ^2;
87

6r=
7disp
8disp ' y=1/ f (D)[ exp(2x )+exp ( x )exp(x ) ');
9disp ' using 1/ f (D) exp ( ax )=x/ f1 (D)exp ( ax ) i f f (m)=0 '
);
10y1=x*
11y2=
12y3=x^2*
13y=y1+y2+y3;
14disp ' y= ');
15disp
Scilab code Exa 13.7nding particular integral
1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4m= 'm');
5f=m^3+1;
6disp ' Using the i d e n t i t y 1/ f (D^2)s i n ( ax+b ) [ or cos (
ax+b ) ]=1/ f (a ^2)s i n ( ax+b ) [ or cos ( ax+b ) ] t h i s
equation can be reduced to ' );
7disp ' y=(4D+1) /65cos (2 x1) ');
8y=(
9disp ' y= ');
10disp
Scilab code Exa 13.8nding particular integral
1//
2clc
88

3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4m= 'm');
5f=m^3+4*m;
6disp ' using 1/ f (D) exp ( ax )=x/ f1 (D)exp ( ax ) i f f (m)=0 '
);
7disp ' y=x1/(3D^2+4)sin2x ');
8disp ' Using the i d e n t i t y 1/ f (D^2)s i n ( ax+b ) [ or cos (
ax+b ) ]=1/ f (a ^2)s i n ( ax+b ) [ or cos ( ax+b ) ] t h i s
equation can be reduced to ' );
9disp ' y=x/8sin2x ');
10disp ' y= ');
11y=-x*
12disp
Scilab code Exa 13.9nding particular integral
1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4m= 'm');
5
6disp ' y=1/(D(D+1) ) [ x^2+2x+4] can be w r i t t e n as (1D+
D^2) /D[ x^2+2x+4] which i s combination of
d i f f e r e n t i a t i o n and i n t e g r a t i o n ');
7g=x^2+2*x+4;
8f=g-
9y=integ(f,x);
10disp ' y= ');
11disp
Scilab code Exa 13.10nding particular integral
89

1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
Scilab code Exa 13.11solving the given linear equation
1//
2clc
3disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
4disp 'CF + PI ');
5syms c1 c2 x
6m= 'm');
7f=(m-2) ^2;
8r=
9disp
10disp 'CF i s given by ');
11cf=(c1+c2*x)*
12disp
13disp ' ');
14disp ' PI =8f1/(D2) ^ 2 [ exp (2 x ) ]+f1/(D2) ^ 2 [ s i n (2 x )
]+f1/(D2) ^ 2 [ x ^2]g');
15disp ' using i d e n t i t i e s i t reduces to : ');
16pi=4*x^2*
17disp
18y=cf+pi;
19disp ' The s o l u t i o n i s : y= ');
20disp
Scilab code Exa 13.12solving the given linear equation
1//
90

2clc
3
4disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
5disp 'CF + PI ');
6syms c1 c2 x
7m= 'm');
8f=(m^2-4);
9r=
10disp
11disp 'CF i s given by ');
12cf=c1*
13disp
14disp ' ');
15disp ' PI =8f1/(D^24) [ xsinh ( x ) ] ');
16disp ' using i d e n t i t i e s i t reduces to : ');
17pi=-x/6*(
18disp
19y=cf+pi;
20disp ' The s o l u t i o n i s : y= ');
21disp
Scilab code Exa 13.13solving the given linear equation
1//
2clc
3
4disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
5disp 'CF + PI ');
6syms c1 c2 x
7m= 'm');
8f=(m^2-1);
9r=
10disp
91

11disp 'CF i s given by ');
12cf=c1*
13disp
14disp ' ');
15disp ' PI =f1/(D^21) [ xs i n (3 x )+cos ( x ) ] ');
16disp ' using i d e n t i t i e s i t reduces to : ');
17pi = -1/10*(x*
18disp
19y=cf+pi;
20disp ' The s o l u t i o n i s : y= ');
21disp
Scilab code Exa 13.14solving the given linear equation
1//
2clc
3
4disp ' s o l u t i o n of the given l i n e a r d i f f e r e n t i a l
equation i s given by : ' );
5disp 'CF + PI ');
6syms c1 c2 c3 c4 x
7m= 'm');
8f=(m^4+2*m^2+1);
9r=
10disp
11disp 'CF i s given by ');
12cf=
;
13disp
14disp ' ');
15disp ' PI =f1/(D^4+2D+1) [ x^2cos ( x ) ] ');
16disp ' using i d e n t i t i e s i t reduces to : ');
17pi = -1/48*((x^4-9*x^2)*
18disp
19y=cf+pi;
92

20disp ' The s o l u t i o n i s : y= ');
21disp
93

Chapter 21
Laplace Transform
Scilab code Exa 21.1.1nding laplace transform
1//
2disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
3syms t s
4disp
Scilab code Exa 21.1.2nding laplace transform
1//
2disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
3syms t s
4disp
Scilab code Exa 21.1.3nding laplace transform
1//
2disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
94

3syms t s
4disp
Scilab code Exa 21.2.1nding laplace transform
1//
2disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
3syms t s
4f=
5disp
Scilab code Exa 21.2.2nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s
5f=
6disp
Scilab code Exa 21.2.3nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s
5f=
6disp
95

Scilab code Exa 21.4.1nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s a
5f=t*
6disp
Scilab code Exa 21.4.2nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s a
5f=t*
6l=laplace(f,t,s);
7disp
Scilab code Exa 21.5nding laplace transform
1//
2//
3clc
4syms t s u
5f=integ(
%inf);
6disp
96

Scilab code Exa 21.7nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s a
5f=
6disp
Scilab code Exa 21.8.1nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s a
5f=t*
6disp
Scilab code Exa 21.8.2nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s a
5f=t^2*
6disp
97

Scilab code Exa 21.8.3nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s a
5f=
6l=laplace(f,t,s)
7disp
Scilab code Exa 21.8.4nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s a
5f=
6l=laplace(f,t,s)
7disp
Scilab code Exa 21.9.1nding laplace transform
1//
2//
3clc
4disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
5syms t s a
6f=(1-
7
8l=laplace(f,t,s)
9disp
98

Scilab code Exa 21.9.2nding laplace transform
1//
2clc
3disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
4syms t s a b
5f=(
6
7l=laplace(f,t,s)
8disp
Scilab code Exa 21.10.1nding laplace transform
1//
2clc
3disp 'To f i n d the the given i n t e g r a l f i n d the
l a p l a c e of t s i n ( t ) and put s=2 ');
4syms t s m
5f=
6
7l=laplace(f,t,s)
8s=2
9
10disp
Scilab code Exa 21.10.3nding laplace transform
1//
2//
99

3clc
4disp 'To f i n d the l a p l a c e of given f u n c t i o n in t ');
5syms t s a b
6f=integ(
7
8l=laplace(f,t,s)
9disp
Scilab code Exa 21.11.1nding inverse laplace transform
1//
2disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
3syms s t
4f=(s^2-3*s+4)/s^3;
5il=ilaplace(f,s,t);
6disp
Scilab code Exa 21.11.2nding inverse laplace transform
1//
2disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
3syms s t
4f=(s+2) /(2*s^2-4*s+13));
5il=ilaplace(f,s,t);
6disp
Scilab code Exa 21.12.1nding inverse laplace transform
100

1//
2disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
3syms s t
4f=((2*s^2-6*s+5)/(s^3-6*s^2+11*s-6);
5il=ilaplace(f,s,t);
6disp
Scilab code Exa 21.12.3nding inverse laplace transform
1//
2disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
3syms s t
4f=(4*s+5) /((s-1) ^2*(s+2));
5il=ilaplace(f,s,t);
6disp
Scilab code Exa 21.13.1nding inverse laplace transform
1//
2disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
3syms s t
4f=(5*s+3) /((s-1)*(s^2+2*s+5));
5il=ilaplace(f,s,t);
6disp
Scilab code Exa 21.13.2nding inverse laplace transform
101

1//
2//
3
4disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
5syms s t a
6f=s/(s^4+4*a^4);
7il=ilaplace(f,s,t);
8disp
Scilab code Exa 21.14.1nding inverse laplace transform
1
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5f=s^2/(s-2) ^3;
6il=ilaplace(f,s,t);
7disp
Scilab code Exa 21.14.2nding inverse laplace transform
1
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5f=(s+3) /((s^2-4*s+13));
6il=ilaplace(f,s,t);
7disp
102

Scilab code Exa 21.15.1nding inverse laplace transform
1//
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5f=1/(s*(s^2+a^2));
6il=ilaplace(f,s,t);
7disp
Scilab code Exa 21.15.2nding inverse laplace transform
1
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5f=1/(s*(s+a)^3);
6il=ilaplace(f,s,t);
7disp
Scilab code Exa 21.16.1nding inverse laplace transform
1//
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
103

5f=s/((s^2+a^2) ^2);
6il=ilaplace(f,s,t);
7disp
Scilab code Exa 21.16.2nding inverse laplace transform
1//
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5f=s^2/((s^2+a^2) ^2);
6il=ilaplace(f,s,t);
7disp
Scilab code Exa 21.16.3nding inverse laplace transform
1//
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5
6f=1/((s^2+a^2) ^2);
7il=ilaplace(f,s,t);
8disp
Scilab code Exa 21.17.1nding inverse laplace transform
1//
104

2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5
6f=(s+2)/(s^2*(s+1)*(s-2));
7il=ilaplace(f,s,t);
8disp
Scilab code Exa 21.17.2nding inverse laplace transform
1//
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5
6f=(s+2)/(s^2+4*s+5) ^2;
7il=ilaplace(f,s,t);
8disp
Scilab code Exa 21.19.1nding inverse laplace transform
1//
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a
5
6f=s/(s^2+a^2) ^2;
7il=ilaplace(f,s,t);
8disp
105

Scilab code Exa 21.19.2nding inverse laplace transform
1//
2//
3disp 'To f i n d the i n v e r s e l a p l a c e transform of the
f u n c t i o n ');
4syms s t a b
5
6f=s^2/((s^2+a^2)*(s^2+b^2));
7il=ilaplace(f,s,t);
8disp
Scilab code Exa 21.28.1nding laplace transform
1//
2syms s t
3f=integ(
,t,2,3);
4disp ' Laplace of given f u n c t i o n i s ');
5disp
Scilab code Exa 21.28.2nding laplace transform
1//
2syms s t
3f=integ(
4disp ' Laplace of given f u n c t i o n i s ');
5disp
106

Scilab code Exa 21.34nding laplace transform
1//
2//
3disp ' to f i n d the l a p l a c e transform of p e r i o d i c
f u n c t i o n ');
4syms w t s
5f=1/(1 -
,0,%pi/w);
6disp
107

Chapter 22
Integral Transform
Scilab code Exa 22.1nding fourier sine integral
1//
2//
3disp 'To f i n d the f o u r i e r s i n e i n t e g r a l ');
4syms x t u
5fs=2/ %pi*integ(
),t,0,%inf));
6disp
Scilab code Exa 22.2nding fourier transform
1//
2//
3disp 'To f i n d the f o u r i e r transform of given
f u n c t i o n ');
4syms x s
5F=integ(
6disp
7// >
8F1=integ(
108

Scilab code Exa 22.3nding fourier transform
1//
2//
3disp 'To f i n d the f o u r i e r transform of given
f u n c t i o n ');
4syms x s
5F=integ(
6disp
7// >
8F1=integ ((x*
Scilab code Exa 22.4nding fourier sine transform
1//
2//
3disp 'To f i n d the f o u r i e r s i n e transform ');
4syms x s m
5//
6fs=integ(
7disp
8//
9f=integ(x*
10disp
Scilab code Exa 22.5nding fourier cosine transform
1//
2syms x s
109

3disp ' Fourier c o s i n e transform ');
4f=integ(x*
,1,2);
5disp
Scilab code Exa 22.6nding fourier sine transform
1//
2syms x s a
3disp ' Fourier c o s i n e transform ');
4f=integ(
5disp
110

Chapter 23
Statistical Methods
Scilab code Exa 23.1Calculating cumulative frequencies of given using
iterations on matrices
1clear
2clc
3disp ' the f i r s t row of A denotes the no . of students
f a l l i n g in the marks group s t a r t i n g from (510)
. . . t i l l (4045) ')
4A(1,:) =[5 6 15 10 5 4 2 2];
5disp ' the second row denotes cumulative frequency (
l e s s than ) ')
6A(2,1) =5;
7for
8 A(2,i)=A(2,i-1)+A(1,i);
9end
10disp ' the t h i r d row denotes cumulative frequency (
more than ) ')
11A(3,1) =49;
12for
13 A(3,i)=A(3,i-1)-A(1,i-1);
14end
15disp
111

Scilab code Exa 23.2Calculating mean of of statistical data performing
iterations matrices
1clc
2disp ' the f i r s t row of A r e p r e s e n t s the mid v a l u e s
of weekly e a r n i n g s having i n t e r v a l of 2 in each
c l a s s=x ')
3A(1,:) =[11 13 15 17 19 21 23 25 27 29 31 33 35 37 39
41]
4disp ' the second row denotes the no . of employees or
in other words frequency=f ' )
5A(2,:) =[3 6 10 15 24 42 75 90 79 55 36 26 19 13 9 7]
6disp ' t h i r d row denotes fx ')
7for
8 A(3,i)=A(1,i)*A(2,i);
9end
10disp ' f o u r t h row denotes u=(x25) /2 ')
11for
12 A(4,i)=(A(1,i) -25)/2
13end
14disp ' f i f t h row denotes fx ')
15for
16 A(5,i)=A(4,i)*A(2,i);
17end
18A
19b=0;
20disp 'sum of a l l elements of t h i r d row= ')
21for
22 b+=A(3,i)
23end
24disp
25f=0;
26disp 'sum of a l l elements of second row= ' )
27for
112

28 f+=A(2,i)
29end
30disp
31disp ' mean= ')
32b/f
33d=0;
34disp 'sum of a l l elements of f i f t h row= ')
35for
36 d+=A(5,i)
37end
38disp ' mean by step d e v i a t i o n method= ')
3925+(2*d/f)
Scilab code Exa 23.3Analysis of statistical data performing iterations on
matrices
1clear
2clc
3disp ' the f i r s t row of A denotes the no . of students
f a l l i n g in the marks group s t a r t i n g from (510)
. . . t i l l (4045) ')
4A(1,:) =[5 6 15 10 5 4 2 2];
5disp ' the second row denotes cumulative frequency (
l e s s than ) ')
6A(2,:) =[5 11 26 36 41 45 47 49]
7disp ' the t h i r d row denotes cumulative frequency (
more than ) ')
8A(3,:) =[49 44 38 23 13 8 4 2]
9disp ' median f a l l s in the c l a s s (1520) = l +((n/2c )
h ) / f= ')
1015+((49/2 -11) *5) /15
11disp ' lower q u a r t i l e a l s o f a l l s in the c l a s s (1520)
= ')
12Q1 =15+((49/4 -11) *5) /15
13disp ' upper q u a r t i l e a l s o f a l l s in the c l a s s (2530)
113

= ')
14Q3 =25+((3*49/4 -36) *5)/5
15disp ' semi i n t e r q u a r t i l e range= ')
16(Q3 -Q1)/2
Scilab code Exa 23.4Analysis of statistical data
1clear
2clc
3disp ' the f i r s t row of A denotes the r o l l no . of
students form 1 to 10 and that of B denotes form
11 to 20 ')
4A(1,:) =[1 2 3 4 5 6 7 8 9 10];
5B(1,:) =[11 12 13 14 15 16 17 18 19 20];
6disp ' the second row of A annd B denotes the
co rr es po nd in g marks in p h y s i c s ')
7A(2,:) =[53 54 52 32 30 60 47 46 35 28];
8B(2,:) =[25 42 33 48 72 51 45 33 65 29];
9disp ' the t h i r d row denotes the cor re sp on di ng marks
in chemistry ')
10A(3,:) =[58 55 25 32 26 85 44 80 33 72];
11B(3,:) =[10 42 15 46 50 64 39 38 30 36];
12disp ' median marks in p h y s i c s =a r i t h m e t i c mean of 10
thand 11 th student = ' )
13(28+25) /2
14disp ' median marks in chemistry =a r i t h m e t i c mean of
10 thand 11 th student = ' )
15(72+10) /2
Scilab code Exa 23.5Finding the missing frequency of given statistical
data using given constants
1clear
114

2clc
3disp ' l e t the m i s s s i n g f r e q u e n c i e s be f1and f2 ')
4disp 'sum of given f r e q u e n c i e s =12+30+65+25+18= ')
5c=12+30+65+25+18
6disp ' so , f1+f2 =229c= ')
7229-c
8disp ' median =46=40+(114.5(12+30+ f1 ) )10/65) ')
9disp ' f1 =33.5=34 ')
10f1=34
11f2=45
Scilab code Exa 23.6Calculating average speed
1clear
2clc
3syms s;
4disp ' l e t the e q i d i s t a n c e be s , then ')
5t1=s/30
6t2=s/40
7t3=s/50
8disp ' average speed=t o t a l d i s t a n c e / t o t a l time taken '
)
93*s/(t1+t2+t3)
Scilab code Exa 23.7Calculating mean and standard deviation perform-
ing iterations on matrices
1clear
2clc
3disp ' the f i r s t row denotes the s i z e of item ')
4A(1,:) =[6 7 8 9 10 11 12];
5disp ' the second row denotes the c or re sp on di ng
frequency ( f ) ')
115

6A(2,:) =[3 6 9 13 8 5 4];
7disp ' the t h i r d row denotesthe c orr es po nd in g
d e v i a t i o n ( d ) ')
8A(3,:)=[-3 -2 -1 0 1 2 3];
9disp ' the f o u r t h row denotes the c or re sp ond in g fd '
)
10for
11 A(4,i)=A(2,i)*A(3,i);
12end
13disp ' the f i f t h row denotes the co rr es po nd in g fd^2 '
)
14for
15 A(5,i)=A(2,i)*(A(3,i)^2);
16end
17A
18b=0;
19disp 'sum of f o u r t h row elements= ')
20for
21 b=b+A(4,i);
22end
23disp
24c=0
25disp 'sum of f i f t h row elements= ')
26for
27 c=c+A(5,i);
28end
29disp
30d=0;
31disp 'sum of a l l f r e q u e n c i e s= ')
32for
33 d=d+A(2,i);
34end
35disp
36disp ' mean=9+b/d= ')
379+b/d
38disp ' standard d e v i a t i o n =(c /d ) ^0.5 ')
39(c/d)^0.5
116

Scilab code Exa 23.8Calculating mean and standard deviation perform-
ing iterations on matrices
1clc
2disp ' the f i r s t row of A r e p r e s e n t s the mid v a l u e s
of wage c l a s s e s having i n t e r v a l of 8 in each
c l a s s=x ')
3A(1,:) =[8.5 16.5 24.5 32.5 40.5 48.5 56.5 64.5 72.5]
4disp ' the second row denotes the no . of men or in
other words frequency=f ' )
5A(2,:) =[2 24 21 18 5 3 5 8 2]
6disp ' t h i r d row denotes fx ')
7for
8 A(3,i)=A(1,i)*A(2,i);
9end
10disp ' f o u r t h row denotes d=(x32.5) /8 ')
11for
12 A(4,i)=(A(1,i) -32.5)/8
13end
14disp ' f i f t h row denotes fd ')
15for
16 A(5,i)=A(4,i)*A(2,i);
17end
18disp ' s i x t h row denotes f( d ^2) ')
19for
20 A(6,i)=A(4,i)^2*A(2,i);
21end
22A
23b=0;
24disp 'sum of a l l elements of s i x t h row= ')
25for
26 b+=A(6,i)
27end
28disp
117

29f=0;
30disp 'sum of a l l elements of second row= ' )
31for
32 f+=A(2,i)
33end
34disp
35disp ' mean= ')
36b/f
37d=0;
38disp 'sum of a l l elements of f i f t h row= ')
39for
40 d+=A(5,i)
41end
42disp ' mean wage= ')
4332.5+(8*d/f)
44disp ' standard d e v i a t i o n= ')
458*(b/f-(d/f)^2)
Scilab code Exa 23.9Analysis of statistical data performing iterations on
matrices
1clear
2clc
3disp ' the f i r s t row of A denotes the s c o r e s of A
and that of B denotes that of B ' )
4A(1,:) =[12 115 6 73 7 19 119 36 84 29];
5B(1,:) =[47 12 16 42 4 51 37 48 13 0];
6disp ' the second row of A annd B denotes the
co rr es po nd in g d e v i a t i o n ')
7for
8 A(2,i)= A(1,i) -51;
9 B(2,i)=B(1,i) -51;
10 end
11disp ' the t h i r d row of A and B denotes the
co rr es po nd in g d e v i a t i o n square ')
118

12for
13 A(3,i)= A(2,i)^2;
14 B(3,i)=B(2,i)^2;
15end
16A
17B
18b=0;
19disp 'sum of second row elements of A=b= ' )
20for
21 b=b+A(2,i);
22 end
23 disp
24 c=0;
25disp 'sum of second row elements of B=c= ' )
26for
27 c=c+B(2,i);
28 end
29 disp
30 d=0;
31disp 'sum of t h i r d row elements of A=d= ' )
32for
33 d=d+A(3,i);
34 end
35 disp
36 e=0;
37disp 'sum of second row elements of B=e= ' )
38for
39 e=e+B(3,i);
40 end
41 disp
42 disp ' a r i t h m e t i c mean of A= ')
43 f=51+b/10
44 disp ' standard d e v i a t i o n of A= ')
45 g=(d/10-(b/10) ^2) ^0.5
46 disp ' a r i t h m e t i c mean of B= ')
47 h=51+c/10
48 disp ' standard d e v i a t i o n of A= ')
49 i=(e/10-(c/10) ^2) ^0.5
119

50 disp ' c o e f f i c i e n t of v a r i a t i o n of A= ')
51 (g/f)*100
52 disp ' c o e f f i c i e n t of v a r i a t i o n of B= ')
53 (i/h)*100
Scilab code Exa 23.10Calculating mean and standard deviation of dif-
ferent statistical data when put together
1clear
2clc
3disp ' i f m i s the mean of e n t i r e data , then ')
4m =(50*113+60*120+90*115) /(50+60+90)
5disp ' i f s i s the standard d e v i a t i o n of e n t i r e data ,
then ')
6s=(((50*6^2) +(60*7^2) +(90*8^2) +(50*3^2) +(60*4^2)
+(90*1^2))/200) ^0.5
Scilab code Exa 23.12Calculating median and quartiles of given statisti-
cal data performing iterations on matrices
1clear
2clc
3disp ' the f i r s t row of A denotes the no . of persons
f a l l i n g in the weight group s t a r t i n g from
(7080) . . . t i l l (140150) ')
4A(1,:) =[12 18 35 42 50 45 20 8];
5disp ' the second row denotes cumulative frequency ' )
6A(2,1) =12;
7for
8 A(2,i)=A(2,i-1)+A(1,i);
9 end
10disp ' median f a l l s in the c l a s s (110120) = l +((n/2
c )h ) / f= ')
120

11Q2 =110+(8*10) /50
12disp ' lower q u a r t i l e a l s o f a l l s in the c l a s s
(90100)= ')
13Q1 =90+(57.5 -30) *10/35
14disp ' upper q u a r t i l e a l s o f a l l s in the c l a s s
(120130)= ')
15Q3 =120+(172.5 -157) *10/45
16disp ' q u a r t i l e c o e f f i c i e n t of skewness= ')
17(Q1 +Q3 -2*Q2)/(Q3 -Q1)
Scilab code Exa 23.13Calculating coecient of correlation
1clear
2clc
3disp ' the f i r s t row of A denotes the co rr es po nd ing I
.R. of students ')
4A(1,:) =[105 104 102 101 100 99 98 96 93 92];
5disp ' the second row denotes the c or re sp on di ng
d e v i a t i o n of I .R. ')
6for
7 A(2,i)=A(1,i) -99;
8end
9disp ' the t h i r d row denotes the square of
co rr es po nd in g d e v i a t i o n of I .R. ')
10for
11 A(3,i)=A(2,i)^2;
12end
13disp ' the f o u r t h row denotes the c or re sp ond in g E.R.
of students ')
14 A(4,:) =[101 103 100 98 95 96 104 92 97 94];
15disp ' the f i f t h row denotes the co rr es po nd in g
d e v i a t i o n of E.R. ')
16for
17 A(5,i)=A(4,i) -98;
18end
121

19disp ' the s i x t h row denotes the square of
co rr es po nd in g d e v i a t i o n of E.R. ')
20for
21 A(6,i)=A(5,i)^2;
22end
23disp ' the seventh row denotes the product of the two
co rr es po nd in g d e v i a t i o n s ')
24for
25 A(7,i)=A(2,i)*A(5,i);
26end
27A
28a=0;
29disp ' the sum of elements of f i r s t row=a ')
30for
31 a=a+A(1,i);
32end
33a
34b=0;
35disp ' the sum of elements of second row=b ' )
36for
37 b=b+A(2,i);
38end
39b
40c=0;
41disp ' the sum of elements of t h i r d row=c ' )
42for
43 c=c+A(3,i);
44end
45c
46d=0;
47disp ' the sum of elements of f o u r t h row=d ')
48for
49 d=d+A(4,i);
50end
51d
52e=0;
53disp ' the sum of elements of f i f t h row=e ')
54for
122

55 e=e+A(5,i);
56end
57e
58f=0;
59disp ' the sum of elements of s i x t h row=d ')
60for
61 f=f+A(6,i);
62end
63f
64g=0;
65disp ' the sum of elements of seventh row=d ' )
66for
67 g=g+A(7,i);
68end
69g
70disp ' c o e f f i c i e n t of c o r r e l a t i o n= ')
71g/(c*f)^0.5
123

Chapter 24
Numerical Methods
Scilab code Exa 24.1nding the roots of equation
1clc
2clear
3x= ' x ');
4p=x^3-4*x-9
5disp " Finding r o o t s of t h i s equation by b i s e c t i o n
method");
6disp ' f ( 2 ) i sve and f ( 3 ) i s +ve so a root l i e s
between 2 and 3 ');
7l=2;
8m=3;
9function
10 y=x^3-4*x-9;
11endfunction
12for
13 k=1/2*(l+m);
14if
15 l=k;
16else
17 m=k;
18 end
19end
124

20disp
Scilab code Exa 24.3nding the roots of equation by the method of false
statement
1//
2disp ' f ( x )=xe ^xcos ( x ) ');
3function
4 y=x*%e^(x)-
5endfunction
6
7disp 'we are r e q u i r e d to f i n d the r o o t s of f ( x ) by
the method of f a l s e p o s i t i o n ');
8disp ' f ( 0 )=ve and f ( 1 )=+ve so s root l i e between 0
and 1 ');
9disp ' f i n d i n g the r o o t s by f a l s e p o s i t i o n method ');
10
11l=0;
12m=1;
13for
14 k=l-(m-l)*f(l)/(f(m)-f(l));
15 if
16 l=k;
17 else
18 m=k;
19 end
20end
21//
22disp ' The root of the equation i s : ');
23disp
Scilab code Exa 24.4nding rea roots of equation by regula falsi method
125

1//
2disp ' f ( x )=xl o g ( x )1.2 ');
3function
4 y=x*
5endfunction
6
7disp 'we are r e q u i r e d to f i n d the r o o t s of f ( x ) by
the method of f a l s e p o s i t i o n ');
8disp ' f ( 2 )=ve and f ( 3 )=+ve so s root l i e between 2
and 3 ');
9disp ' f i n d i n g the r o o t s by f a l s e p o s i t i o n method ');
10
11l=2;
12m=3;
13for
14 k=l-(m-l)*f(l)/(f(m)-f(l));
15 if
16 l=k;
17 else
18 m=k;
19 end
20end
21//
22disp ' The root of the equation i s : ');
23disp
Scilab code Exa 24.5real roots of equation by newtons method
1//
2disp ' To f i n d the r o o t s of f ( x )=3xcos ( x )1 by
newtons method ');
3disp ' f ( 0 )=ve and f ( 1 ) i s +ve so a root l i e s
between 0 and 1 ');
4l=0;
5m=1;
126

6function
7 y=3*x-
8endfunction
9x0 =0.6;
10disp ' l e t us take x0 =0.6 as the root i s c l o s e r to 1 '
);
11disp "Root i s given by r=x0f ( xn ) / der ( f ( xn ) ) ");
12disp ' approximated root in each s t e p s are ');
13for
14 k=x0 -f(x0)/
15 disp
16 x0=k;
17end
Scilab code Exa 24.6real roots of equation by newtons method
1//
2clear
3clc
4disp 'To f i n d s q u a r e r o o t of 28 by newtons method l e t
x=s q r t (28) i e x^228=0 ');
5function
6 y=x^2 -28;
7endfunction
8disp ' To f i n d the r o o t s by newtons method ');
9disp ' f ( 5 )=ve and f ( 6 ) i s +ve so a root l i e s
between 5 and 6 ');
10l=5;
11m=6;
12disp ' l e t us take x0 =5.5 ');
13disp "Root i s given by rn=xn f ( xn ) / der ( f ( xn ) ) ");
14disp ' approximated root in each s t e p s are ');
15x0 =5.5;
16for
17 k=x0 -f(x0)/
127

18 disp
19 x0=k;
20end
Scilab code Exa 24.7evaluating square root by newtons iterative method
1//
2clear
3clc
4disp 'To f i n d s q u a r e r o o t of 28 by newtons method l e t
x=s q r t (28) i e x^228=0 ');
5function
6 y=x^2 -28;
7endfunction
8disp ' To f i n d the r o o t s by newtons method ');
9disp ' f ( 5 )=ve and f ( 6 ) i s +ve so a root l i e s
between 5 and 6 ');
10l=5;
11m=6;
12disp ' l e t us take x0 =5.5 ');
13disp "Root i s given by rn=xn f ( xn ) / der ( f ( xn ) ) ");
14disp ' approximated root in each s t e p s are ');
15x0 =5.5;
16for
17 k=x0 -f(x0)/
18 disp
19 x0=k;
20end
Scilab code Exa 24.10solving equations by guass elimination method
1//
128

2//
method
3clc
4clear
5
6disp ' S o l u t i o n of Nequation [A ] [ X]=[ r ] ')
7n= ' Enter number of Equations : ' );
8A= ' Enter Matrix [A ] : ');
9r= ' Enter Matrix [ r ] : ');
10D=A;d=r;
11
12//
13s=0;
14for
15 if
16 k=j;
17 for
18 if
19 continue
20 end
21 break
22 end
23 B=A(j,:); C=r(j);
24 A(j,:)=A(k,:); r(j)=r(k);
25 A(k,:)=B; r(k)=C;
26 end
27 for
28 L=A(i+1,j)/A(j,j);
29 A(i+1,:)=A(i+1,:)-L*A(j,:);
30 r(i+1)=r(i+1)-L*r(j);
31 end
32 s=s+1;
33end
34//
35x(n)=r(n)/A(n,n);
36for
37 sum
38 for
129

39 sum
40 end
41 x(i)=(1/A(i,i))*(r(i)-
42end
43
44//
45p=
46//
47disp '@

@ ')
48disp ' Output [B ] [ x ]=[ b ] ')
49disp ' Upper r i a n g u l a r Matrix [B] = ');
50disp ' Matrix [ b ] = ');
51disp ' s o l u t i o n of l i n e a r e q u a t i o n s : ');
52disp ' s o l v e with matlab f u n c t i o n s ( f o r checking ) : ');
disp
Scilab code Exa 24.12solving equations by guass elimination method
1//
2//
method
3clc
4clear
5
6disp ' S o l u t i o n of Nequation [A ] [ X]=[ r ] ')
7n= ' Enter number of Equations : ' );
8A= ' Enter Matrix [A ] : ');
9r= ' Enter Matrix [ r ] : ');
10D=A;d=r;
11
12//
13s=0;
14for
130

15 if
16 k=j;
17 for
18 if
19 continue
20 end
21 break
22 end
23 B=A(j,:); C=r(j);
24 A(j,:)=A(k,:); r(j)=r(k);
25 A(k,:)=B; r(k)=C;
26 end
27 for
28 L=A(i+1,j)/A(j,j);
29 A(i+1,:)=A(i+1,:)-L*A(j,:);
30 r(i+1)=r(i+1)-L*r(j);
31 end
32 s=s+1;
33end
34//
35x(n)=r(n)/A(n,n);
36for
37 sum
38 for
39 sum
40 end
41 x(i)=(1/A(i,i))*(r(i)-
42end
43
44//
45p=
46//
47disp '@

@ ')
48disp ' Output [B ] [ x ]=[ b ] ')
49disp ' Upper r i a n g u l a r Matrix [B] = ');
50disp ' Matrix [ b ] = ');
131

51disp ' s o l u t i o n of l i n e a r e q u a t i o ns : ');
52disp ' s o l v e with matlab f u n c t i o n s ( f o r checking ) : ');
disp
Scilab code Exa 24.13solving equations by guass elimination method
1//
2//
method
3clc
4clear
5
6disp ' S o l u t i o n of Nequation [A ] [ X]=[ r ] ')
7n= ' Enter number of Equations : ' );
8A= ' Enter Matrix [A ] : ');
9r= ' Enter Matrix [ r ] : ');
10D=A;d=r;
11
12//
13s=0;
14for
15 if
16 k=j;
17 for
18 if
19 continue
20 end
21 break
22 end
23 B=A(j,:); C=r(j);
24 A(j,:)=A(k,:); r(j)=r(k);
25 A(k,:)=B; r(k)=C;
26 end
27 for
28 L=A(i+1,j)/A(j,j);
132

29 A(i+1,:)=A(i+1,:)-L*A(j,:);
30 r(i+1)=r(i+1)-L*r(j);
31 end
32 s=s+1;
33end
34//
35x(n)=r(n)/A(n,n);
36for
37 sum
38 for
39 sum
40 end
41 x(i)=(1/A(i,i))*(r(i)-
42end
43
44//
45p=
46//
47disp '@

@ ')
48disp ' Output [B ] [ x ]=[ b ] ')
49disp ' Upper r i a n g u l a r Matrix [B] = ');
50disp ' Matrix [ b ] = ');
51disp ' s o l u t i o n of l i n e a r e q u a t i o n s : ');
52disp ' s o l v e with matlab f u n c t i o n s ( f o r checking ) : ');
disp
133

Chapter 26
Dierence Equations and Z
Transform
Scilab code Exa 26.2nding dierence equation
1//
2syms n a b yn0 yn1 yn2
3yn=a*2^n+b*(-2)^n;
4disp ' yn= ');
5disp
6n=n+1;
7yn=
8disp ' y ( n+1)=yn1= ');
9disp
10n=n+1;
11yn=
12disp ' y ( n+2)=yn2= ');
13disp
14disp ' Eliminating a b fropm t h e s e e q u a t i o n s we get :
');
15A=[yn0 1 1;yn1 2 -2;yn2 4 4]
16y=
17disp ' The r e q u i r e d d i f f e r e n c e equation : ');
18disp
134

19disp '=0 ');
Scilab code Exa 26.3solving dierence equation
1//
2syms c1 c2 c3
3disp ' Cumulative f u n c t i o n i s given by E^32E^25E
+6 =0 ' );
4E= 'E ');
5f=E^3-2*E^2-5*E+6;
6r=
7disp
8disp ' There f o r the complete s o l u t i o n i s : ');
9un=c1*(r(1))^n+c2*(r(2))^n+c3*(r(3))^n;
10disp ' un= ');
11disp
Scilab code Exa 26.4solving dierence equation
1//
2syms c1 c2 c3 n
3disp ' Cumulative f u n c t i o n i s given by E^22E+1
=0 ');
4E= 'E ');
5f=E^2-2*E+1;
6r=
7disp
8disp ' There f o r the complete s o l u t i o n i s : ');
9un=(c1+c2*n)*(r(1))^n;
10disp ' un= ');
11disp
135

Scilab code Exa 26.6rming bonacci dierence equation
1//
2syms c1 c2 c3 n
3disp ' For Fibonacci S e r i e s yn2=yn1+yn0 ');
4disp ' so Cumulative f u n c t i o n i s given by E^2E1
=0 ');
5E= 'E ');
6f=E^2-E-1;
7r=
8disp
9disp ' There f o r the complete s o l u t i o n i s : ');
10un=(c1)*(r(1))^n+c2*(r(2))^n;
11disp ' un= ');
12disp
13disp 'Now p u t t t i n g n=1, y=0 and n=2 , y=1 we get ');
14disp ' c1=(5s q r t ( 5 ) ) /10 c2=(5+ s q r t ( 5 ) ) /10 ');
15c1=(5-
16c2 =(5+
17un=
18disp
Scilab code Exa 26.7solving dierence equation
1//
2syms c1 c2 c3 n
3disp ' Cumulative f u n c t i o n i s given by E^24E+3
=0 ');
4E= 'E ');
5f=E^2-4*E+3;
6r=
7disp
136

8disp ' There f o r the complete s o l u t i o n i s = c f + pi ')
;
9cf=c1*(r(1))^n+c2*r(2)^n;
10disp 'CF= ');
11disp
12disp ' PI = 1/(E^24E+3) [ 5 ^ n ] ');
13disp ' put E=5 ');
14disp 'We get PI=5^n/8 ');
15pi=5^n/8;
16un=cf+pi;
17disp ' un= ');
18disp
Scilab code Exa 26.8solving dierence equation
1//
2syms c1 c2 c3 n
3disp ' Cumulative f u n c t i o n i s given by E^24E+4
=0 ');
4E= 'E ');
5f=E^2-4*E+4;
6r=
7disp
8disp ' There f o r the complete s o l u t i o n i s = c f + pi ')
;
9cf=(c1+c2*n)*r(1)^n;
10disp 'CF= ');
11disp
12disp ' PI = 1/(E^24E+4) [ 2 ^ n ] ');
13disp 'We get PI=n(n1) /22^(n2) ');
14pi=n*(n-1)/factorial (2) *2^(n-2);
15un=cf+pi;
16disp ' un= ');
17disp
137

Scilab code Exa 26.10solving dierence equation
1//
2clc
3syms c1 c2 c3 n
4disp ' Cumulative f u n c t i o n i s given by E^24 =0 ' )
;
5E= 'E ');
6f=E^2-4;
7r=
8disp
9disp ' There f o r the complete s o l u t i o n i s = c f + pi ')
;
10cf=(c1+c2*n)*r(1)^n;
11disp 'CF= ');
12disp
13//
14disp ' PI = 1/(E^24) [ n^2+n1] ');
15disp 'We get PI=n^2/37/9n17/27 ');
16pi=-n^2/3 -7/9*n -17/27;
17un=cf+pi;
18disp ' un= ');
19disp
Scilab code Exa 26.11solving dierence equation
1//
2clc
3syms c1 c2 c3 n
4disp ' Cumulative f u n c t i o n i s given by E^22E+1
=0 ');
5E= 'E ');
138

6f=E^2+2*E-1;
7r=
8disp
9disp ' There f o r the complete s o l u t i o n i s = c f + pi ')
;
10cf=(c1+c2*n)*r(1)^n;
11disp 'CF= ');
12disp
13//
14disp ' PI = 1/(E1) ^ 2 [ n^22^n ] ');
15disp 'We get PI=2^n( n^28n+20 ');
16pi=2^n*(n^2-8*n+20);
17un=cf+pi;
18disp ' un= ');
19disp
Scilab code Exa 26.12solving simultanious dierence equation
1//
2clc
3disp ' s i m p l i f i e d e q u a t i o ns are : ');
4disp ' (E3)ux+vx=x . . . . . ( i ) 3ux+(E5)vx=4^x . . . . . . ( i i
) ');
5disp ' S i m p l i f y i n g we get (E^28E+12)ux=14x4^x ');
6syms c1 c2 c3 x
7disp ' Cumulative f u n c t i o n i s given by E^28E+12
=0 ');
8E= 'E ');
9f=E^2-8*E+12;
10r=
11disp
12disp ' There f o r the complete s o l u t i o n i s = c f + pi ')
;
13cf=c1*r(1)^x+c2*r(2)^x;
14disp 'CF= ');
139

15disp
16//
17disp ' s o l v i n g f o r PI ');
18disp 'We get PI= ');
19pi= -4/5*x -19/25+4^x/4;
20ux=cf+pi;
21disp ' ux= ');
22disp
23disp ' Putting in ( i ) we get vx= ');
24vx=c1*2^x-3*c2*6^x -3/5*x -34/25 -4^x/4;
25disp
Scilab code Exa 26.15.2Z transform
1//
2syms n z
3y=z^(-n);
4f=symsum(y,n,0,%inf);
5disp
Scilab code Exa 26.16evaluating u2 and u3
1//
2syms z
3// 1/
4f=(2/z^2+5/z+14) /(1/z-1)^4
5u0=limit(f,z,0);
6u1=limit (1/z*(f-u0),z,0);
7u2=limit (1/z^2*(f-u0 -u1*z),z,0);
8disp ' u2= ');
9disp
10u3=limit (1/z^3*(f-u0 -u1*z-u2*z^2),z,0);
11disp ' u3= ');
140

12disp
141

Chapter 27
Numerical Solution of Ordinary
Dierential Equations
Scilab code Exa 27.1solving ODE with picards method
1//
2syms x
3disp ' s o l u t i o n through p i c a r d s method ');
4n= ' The no of i t e r a t i o n s r e q u i r e d ');
5disp ' y ( 0 )=1 and y ( x )=x+y ');
6yo=1;
7yn=1;
8for
9 yn=yo+integ(yn+x,x,0,x);
10end
11disp ' y= ');
12disp
Scilab code Exa 27.2solving ODE with picards method
1//
142

2//
3syms x
4disp ' s o l u t i o n through p i c a r d s method ');
5n= ' The no of i t e r a t i o n s r e q u i r e d ');
6disp ' y ( 0 )=1 and y ( x )=x+y ');
7yo=1;
8y=1;
9for
10
11 f=(y-x)/(y+x);
12 y=yo+integ(f,x,0,x);
13end
14disp ' y= ');
15x=0.1;
16disp
Scilab code Exa 27.5solving ODE using Eulers method
1//
2clc
3disp ' S o l u t i o n using Eulers Method ');
4disp
5n= ' Input the number of i t e r a t i o n :');
6x=0;
7y=1;
8for
9
10y1=x+y;
11y=y+0.1* y1;
12x=x+0.1;
13end
14disp ' The value of y i s :');
15disp
143

Scilab code Exa 27.6solving ODE using Eulers method
1//
2clc
3disp ' S o l u t i o n using Eulers Method ');
4disp
5n= ' Input the number of i t e r a t i o n :');
6x=0;
7y=1;
8for
9
10y1=(y-x)/(y+x);
11y=y+0.02* y1;
12x=x+0.1;
13disp
14end
15disp ' The value of y i s :');
16disp
Scilab code Exa 27.7solving ODE using Modied Eulers method
1//
2clc
3disp ' S o l u t i o n using Eulers Method ');
4disp
5n= ' Input the number of i t e r a t i o n :');
6x=0.1;
7m=1;
8y=1;
9yn=1;
10y1=1;
11k=1;
144

12for
13
14yn=y;
15
16
17 for
18 m=(k+y1)/2;
19 yn=y+0.1*m;
20 y1=(yn+x);
21 disp
22end
23disp ' ');
24y=yn;
25m=y1;
26 yn=yn +0.1*m;
27 disp
28 x=x+0.1;
29 yn=y;
30 k=m;
31end
32disp ' The value of y i s :');
33disp
Scilab code Exa 27.8solving ODE using Modied Eulers method
1//
2clc
3disp ' S o l u t i o n using Eulers Method ');
4disp
5n= ' Input the number of i t e r a t i o n :');
6x=0.2;
7m=0.301;
8y=2;
9yn=2;
10y1=
145

11k=0.301;
12for
13
14yn=y;
15
16
17 for
18 m=(k+y1)/2;
19 yn=y+0.2*m;
20 y1=
21 disp
22end
23disp ' ');
24y=yn;
25m=y1;
26 yn=yn +0.2*m;
27 disp
28 x=x+0.2;
29 yn=y;
30 k=m;
31end
32disp ' The value of y i s :');
33disp
Scilab code Exa 27.9solving ODE using Modied Eulers method
1//
2clc
3disp ' S o l u t i o n using Eulers Method ');
4disp
5n= ' Input the number of i t e r a t i o n :');
6x=0.2;
7m=1;
8y=1;
9yn=1;
146

10y1=1;
11k=1;
12for
13
14yn=y;
15
16
17 for
18 m=(k+y1)/2;
19 yn=y+0.2*m;
20 y1=(
21 disp
22end
23disp ' ');
24y=yn;
25m=y1;
26 yn=yn +0.2*m;
27 disp
28 x=x+0.2;
29 yn=y;
30 k=m;
31end
32disp ' The value of y i s :');
33disp
Scilab code Exa 27.10solving ODE using runge method
1//
2disp ' Runges method ');
3function
4 y=x+y;
5endfunction
6
7x=0;
8y=1;
147

9h=0.2;
10k1=h*f(x,y);
11k2=h*f(x+1/2*h,y+1/2* k1);
12kk=h*f(x+h,y+k1);
13k3=h*f(x+h,y+kk);
14k=1/6*( k1+4*k2+k3);
15disp ' the r e q u i r e d approximate value i s :');
16y=y+k;
17disp
Scilab code Exa 27.11solving ODE using runge kutta method
1//
2disp ' Runga kutta method ');
3function
4 y=x+y;
5endfunction
6
7x=0;
8y=1;
9h=0.2;
10k1=h*f(x,y);
11k2=h*f(x+1/2*h,y+1/2* k1);
12k3=h*f(x+1/2*h,y+1/2* k2);
13k4=h*f(x+h,y+k3);
14k=1/6*( k1+2*k2+2*k3+k4);
15disp ' the r e q u i r e d approximate value i s :');
16y=y+k;
17disp
Scilab code Exa 27.12solving ODE using runge kutta method
1//
148

2clc
3disp ' Runga kutta method ');
4function
5 y=(y^2-x^2)/(x^2+y^2);
6endfunction
7
8x=0;
9y=1;
10h=0.2;
11k1=h*f(x,y);
12k2=h*f(x+1/2*h,y+1/2* k1);
13k3=h*f(x+1/2*h,y+1/2* k2);
14k4=h*f(x+h,y+k3);
15k=1/6*( k1+2*k2+2*k3+k4);
16disp ' the r e q u i r e d approximate value i s :');
17y=y+k;
18disp
19disp ' to f i n d y ( 0 . 4 ) put x=0.2 y=above value i e
1.196 h=0.2 ');
20x=0.2;
21h=0.2;
22k1=h*f(x,y);
23k2=h*f(x+1/2*h,y+1/2* k1);
24k3=h*f(x+1/2*h,y+1/2* k2);
25k4=h*f(x+h,y+k3);
26k=1/6*( k1+2*k2+2*k3+k4);
27disp ' the r e q u i r e d approximate value i s :');
28y=y+k;
29disp
Scilab code Exa 27.13solving ODE using runge kutta method
1//
2clc
3disp ' Runga kutta method ');
149

4function
5 yy=x+y^2;
6endfunction
7
8x=0;
9y=1;
10h=0.1;
11k1=h*f(x,y);
12k2=h*f(x+1/2*h,y+1/2* k1);
13k3=h*f(x+1/2*h,y+1/2* k2);
14k4=h*f(x+h,y+k3);
15k=1/6*( k1+2*k2+2*k3+k4);
16disp ' the r e q u i r e d approximate value i s :');
17y=y+k;
18disp
19disp ' to f i n d y ( 0 . 4 ) put x=0.2 y=above value i e
1.196 h=0.2 ');
20x=0.1;
21h=0.1;
22k1=h*f(x,y);
23k2=h*f(x+1/2*h,y+1/2* k1);
24k3=h*f(x+1/2*h,y+1/2* k2);
25k4=h*f(x+h,y+k3);
26k=1/6*( k1+2*k2+2*k3+k4);
27disp ' the r e q u i r e d approximate value i s :');
28y=y+k;
29disp
Scilab code Exa 27.14solving ODE using milnes method
1//
2clc
3syms x
4yo=0;
5y=0;
150

6h=0.2;
7f=x-y^2;
8y=integ(f,x,0,x);
9y1=
10disp ' y1= ');
11disp
12f=x-y^2;
13y=integ(f,x,0,x);
14y2=yo+y;
15disp ' y2= ');
16disp
17//
18 y=x-y^2;
19//
20
21y=integ(f,x,0,x);
22y3=yo+y;
23disp ' y3= ');
24disp
25disp ' determining the i n i t i a l v a l u e s f o r milnes
method using y3 ');
26disp ' x=0.0 y0 =0.0 f0=0 ');
27disp ' x=0.2 y1= ');
28x=0.2;
29disp
30y1=
31disp ' f1= ');
32f1=float(
33disp
34disp ' x=0.4 y2= ');
35x=0.4;
36disp
37disp ' f2= ');
38f2=float(
39disp
40
41disp ' x=0.6 y3= ');
42x=0.6;
151

43disp
44disp ' f3= ');
45f3=float(
46disp
47//
48disp ' Using p r e d i c t o r method to f i n d y4 ');
49x=0.8;
50y4=
51disp ' y4= ');
52disp
53f4=float(
54disp ' f4= ');
55disp
56disp ' Using p r e d i c t o r method to f i n d y5 ');
57x=1.0;
58y5=
59disp
60f5=float(
61disp ' f5= ');
62disp
63disp ' Hence y ( 1 )= ');
64disp
Scilab code Exa 27.15solving ODE using runge kutta and milnes method
1//
2clc
3disp ' Runga kutta method ');
4
5function
6 yy=x*y+y^2;
7endfunction
8y0=1;
9x=0;
10y=1;
152

11h=0.1;
12k1=h*f(x,y);
13k2=h*f(x+1/2*h,y+1/2* k1);
14k3=h*f(x+1/2*h,y+1/2* k2);
15k4=h*f(x+h,y+k3);
16ka =1/6*( k1+2*k2+2*k3+k4);
17disp ' the r e q u i r e d approximate value i s :');
18y1=y+ka;
19y=y+ka;
20disp
21//
22//
23
24disp ' to f i n d y ( 0 . 4 ) put x=0.2 y=above value i e
1.196 h=0.2 ');
25x=0.1;
26h=0.1;
27k1=h*f(x,y);
28k2=h*f(x+1/2*h,y+1/2* k1);
29k3=h*f(x+1/2*h,y+1/2* k2);
30k4=h*f(x+h,y+k3);
31kb =1/6*( k1+2*k2+2*k3+k4);
32disp ' the r e q u i r e d approximate value i s :');
33y2=y+kb;
34y=y+kb;
35disp
36//
37//
38
39disp ' to f i n d y ( 0 . 4 ) put x=0.2 y=above value i e
1.196 h=0.2 ');
40x=0.2;
41h=0.1;
42k1=h*f(x,y);
43k2=h*f(x+1/2*h,y+1/2* k1);
44k3=h*f(x+1/2*h,y+1/2* k2);
45k4=h*f(x+h,y+k3);
46kc =1/6*( k1+2*k2+2*k3+k4);
153

47disp ' the r e q u i r e d approximate value i s :');
48y3=y+kc;
49y=y+kc;
50disp
51//
52//
53f0=f(0,y0);
54f1=f(0.1,y1);
55f2=f(0.2,y2);
56f3=f(0.3,y3);
57disp ' y0 y1 y2 y3 are r e s p e c t i v e l y : ');
58disp
59disp ' f0 f1 f2 f3 are r e s p e c t i v e l y : ');
60disp
61disp ' f i n d i n g y4 using p r e d i c t o r s milne method x=0.4
');
62h=0.1;
63y4=y0+4*h/3*(2*f1 -f2+2*f3);
64disp ' y4= ');
65disp
66disp ' f4= ');
67f4=f(0.4,y4);
68
69disp ' using c o r r e c t o r method : ');
70y4=y2+h/3*( f2+4*f3+f4);
71disp ' y4= ');
72disp
73disp ' f4= ');
74f4=f(0.4,y4);
75disp
Scilab code Exa 27.16solving ODE using adamsbashforth method
1//
2clc
154

3function
4 yy=x^2*(1+y);
5endfunction
6
7y3=1
8y2 =1.233
9y1 =1.548
10y0 =1.979
11
12f3=f(1,y3)
13f2=f(1.1,y2)
14f1=f(1.2,y1)
15f0=f(1.3,y0)
16disp ' using p r e d i c t o r method ');
17h=0.1
18y11=y0+h/24*(55*f0 -59* f1 +37*f2 -9*f3)
19disp ' y11= ');
20disp
21x=1.4;
22f11=f(1.4, y11);
23disp ' using c o r r e c t o r method ');
24y11=y0+h/24*(9* f11 +19*f0 -5*f1+f2);
25disp ' y11= ');
26disp
27f11=f(1.4, y11);
28disp ' f11= ');
29disp
Scilab code Exa 27.17solving ODE using runge kutta and adams method
1//
2clc
3disp ' Runga kutta method ');
4
5function
155

6 yy=x-y^2;
7endfunction
8y0=1;
9x=0;
10y=1;
11h=0.1;
12k1=h*f(x,y);
13k2=h*f(x+1/2*h,y+1/2* k1);
14k3=h*f(x+1/2*h,y+1/2* k2);
15k4=h*f(x+h,y+k3);
16ka =1/6*( k1+2*k2+2*k3+k4);
17disp ' the r e q u i r e d approximate value i s :');
18y1=y+ka;
19y=y+ka;
20disp
21//
22//
23
24disp ' to f i n d y ( 0 . 4 ) put x=0.2 y=above value i e
1.196 h=0.2 ');
25x=0.1;
26h=0.1;
27k1=h*f(x,y);
28k2=h*f(x+1/2*h,y+1/2* k1);
29k3=h*f(x+1/2*h,y+1/2* k2);
30k4=h*f(x+h,y+k3);
31kb =1/6*( k1+2*k2+2*k3+k4);
32disp ' the r e q u i r e d approximate value i s :');
33y2=y+kb;
34y=y+kb;
35disp
36//
37//
38
39disp ' to f i n d y ( 0 . 4 ) put x=0.2 y=above value i e
1.196 h=0.2 ');
40x=0.2;
41h=0.1;
156

42k1=h*f(x,y);
43k2=h*f(x+1/2*h,y+1/2* k1);
44k3=h*f(x+1/2*h,y+1/2* k2);
45k4=h*f(x+h,y+k3);
46kc =1/6*( k1+2*k2+2*k3+k4);
47disp ' the r e q u i r e d approximate value i s :');
48y3=y+kc;
49y=y+kc;
50disp
51//
52//
53f0=f(0,y0);
54f1=f(0.1,y1);
55f2=f(0.2,y2);
56f3=f(0.3,y3);
57disp ' y0 y1 y2 y3 are r e s p e c t i v e l y : ');
58disp
59disp ' f0 f1 f2 f3 are r e s p e c t i v e l y : ');
60disp
61disp ' Using adams method ');
62disp ' Using the p r e d i c t o r ');
63h=0.1;
64y4=y3+h/24*(55*f3 -59* f2 +37*f1 -9*f0);
65x=0.4;
66f4=f(0.4,y4);
67disp ' y4= ');
68disp
69disp ' using c o r r e c t o r method ');
70y4=y3+h/24*(9* f4 +19*f3 -5*f2+f1);
71disp ' y4= ');
72disp
73f4=f(0.4,y4);
74disp ' f4= ');
75disp
157

Scilab code Exa 27.18solving simultanious ODE using picards method
1//
2clc
3disp ' Picards method ');
4x0=0;
5y0=2;
6z0=1;
7syms x
8function
9 yy=x+z;
10endfunction
11
12function
13 yy=x-y^2;
14endfunction
15disp ' f i r s t approximation ');
16y1=y0+integ(f(x,y0 ,z0),x,x0 ,x);
17disp ' y1= ');
18disp
19z1=z0+integ(g(x,y0 ,z0),x,x0 ,x);
20disp ' z1= ');
21disp
22
23disp ' second approximation ');
24y2=y0+integ(f(x,y1 ,z1),x,x0 ,x);
25disp ' y2= ');
26disp
27z2=z0+integ(g(x,y1 ,z1),x,x0 ,x);
28disp ' z2= ');
29disp
30
31disp ' t h i r d approximation ');
32y3=y0+integ(f(x,y2 ,z2),x,x0 ,x);
33disp ' y3= ');
34disp
35z3=z0+integ(g(x,y2 ,z2),x,x0 ,x);
36disp ' z3= ');
158

37disp
38x=0.1;
39disp ' y ( 0 . 1 )= ');
40disp
41disp ' z ( 0 . 1 )= ');
42disp
Scilab code Exa 27.19solving ssecond ODE using runge kutta method
1//
2clc
3syms x
4function
5 yy=z;
6endfunction
7function
8 yy=x*y^2-y^2;
9endfunction
10x0=0;
11y0=1;
12z0=0;
13h=0.2;
14disp ' using k1 k2 . . f o r f and l 1 l 2 . . . f o r g runga
kutta formulae becomes ' );
15h=0.2;
16k1=h*f(x0 ,y0 ,z0);
17l1=h*g(x0 ,y0 ,z0);
18k2=h*f(x0 +1/2*h,y0 +1/2*k1 ,z0 +1/2* l1);
19l2=h*g(x0 +1/2*h,y0 +1/2*k1 ,z0 +1/2* l1);
20k3=h*f(x0 +1/2*h,y0 +1/2*k2 ,z0 +1/2* l2);
21l3=h*g(x0 +1/2*h,y0 +1/2*k2 ,z0 +1/2* l2);
22k4=h*f(x0+h,y0+k3 ,z0+l3);
23l4=h*g(x0+h,y0+k3 ,z0+l3);
24k=1/6*( k1+2*k2+2*k3+k4);
25l=1/6*( l1+2*l2+2*l3+2*l4);
159

26//
27x=0.2;
28y=y0+k;
29y1=z0+l;
30disp ' y= ');
31disp
32disp ' y1= ');
33disp
34
35y
Scilab code Exa 27.20solving ODE using milnes method
1//
2clc
160

Chapter 28
Numerical Solution of Partial
Dierential Equations
Scilab code Exa 28.1classication of partial dierential equation
1//
2clear
3clc
4disp 'D=B^24AC ');
5disp ' i f D<0 then e l l i p t i c i f D=0 then p a r a b o l i c
i f D>0 then hyperboic ');
6disp ' ( i ) A=x ^2 ,B1y^2 D=4^2 414=0 so The
equation i s PARABOLIC ');
7disp ' ( i i ) D=4x ^2( y^21) ');
8disp ' f o rinf<x<i n f and1<y<1 D<0 ');
9disp ' So the equation i s ELLIPTIC ');
10disp ' ( i i i ) A=1+x ^2 ,B=5+2x ^2 ,C=4+x^2 ');
11disp 'D=9>0 ');
12disp ' So the equation i s HYPERBOLIC ');
Scilab code Exa 28.2solving elliptical equation
161

1//
2disp ' See f i g u r e in q u e s t i o n ');
3disp 'From symmetry u7=u1 , u8=u2 , u9=u3 , u3=u1 ,
u6=u4 , u9=u7 ');
4disp ' u5 =1/4(2000+2000+1000+1000) =1500 ' );
5u5 =1500;
6disp ' u1 =1/4(0=1500+1000+2000)=1125 ');
7u1 =1125;
8disp ' u2 =1/4(1125+1125+1000+1500) =1188 ' );
9u2 =1188;
10disp ' u4 =1/4(2000+1500+1125+1125) =1438 ');
11u4 =1438;
12disp
13disp ' I t e r a t i o n s : ');
14//
')
15for
16u11 =1/4*(1000+ u2 +500+ u4);
17u22 =1/4*( u11+u1 +1000+ u5);
18u44 =1/4*(2000+ u5+u11+u1);
19u55 =1/4*( u44+u4+u22+u2);
20disp ' ');
21disp
22u1=u11;
23u2=u22;
24u4=u44;
25u5=u55;
26end
Scilab code Exa 28.3evaluating function satisfying laplace equation
1//
2clear
3clc
4disp ' See f i g u r e in q u e s t i o n ');
162

5disp 'To f i n d the i n i t i a l v a l u e s of u1 u2 u3 u4 we
assume u4=0 ');
6disp ' u1 =1/4(1000+0+1000+2000)=1000 ' );
7u1 =1000;
8disp ' u2 =1/4(1000+500+1000+500)=625 ');
9u2 =625;
10disp ' u3 =1/4(2000+0+1000+500)=875 ');
11u3 =875;
12disp ' u4=1/4(875+0+625+0)=375 ');
13u4 =375;
14disp
15disp ' I t e r a t i o n s : ');
16//
')
17for
18u11 =1/4*(2000+ u2 +1000+ u3);
19u22 =1/4*( u11 +500+1000+ u4);
20u33 =1/4*(2000+ u4+u11 +500);
21u44 =1/4*( u33 +0+ u22 +0);
22disp ' ');
23disp
24u1=u11;
25u2=u22;
26u4=u44;
27u3=u33;
28end
Scilab code Exa 28.4solution of poissons equation
1//
2clear
3clc
4disp ' See f i g u r e in q u e s t i o n ');
5disp ' using numerical p o i s s o n s equation u ( i1) ( j )+u (
i +1) ( j )+u ( i ) ( j1)+u ( i ) ( j +1)=h^2 f ( ih , jh ) ');
163

6disp ' Here f ( x , y )=10(x^2+y^2+10 ');
7disp ' Here f o r u1 i =1, j =2 putting in equation t h i s
g i v e s : ');
8disp ' u1=1/4(u2+u3+150 ');
9disp ' s i m i l a r l y ');
10disp ' u2=1/4(u1+u4+180 ');
11disp ' u3=1/4(u1+u4+120 ');
12disp ' u4=1/4(u2+u3+150 ');
13disp ' reducing t h e r s e e q u a t i o n s s i n c e u4=u1 ');
14disp ' 4u1u2u3150=0 ');
15disp ' u12u2+90=0 ');
16disp ' u12u3+60=0 ');
17disp ' Solvng t h e s e e q u a t i o n s by Gauss jordon method
');
18A=[4 -1 -1;1 -2 0;1 0 -2];
19r=[150; -90; -60];
20D=A;d=r;
21n=3;
22
23//
24s=0;
25for
26 if
27 k=j;
28 for
29 if
30 continue
31 end
32 break
33 end
34 B=A(j,:); C=r(j);
35 A(j,:)=A(k,:); r(j)=r(k);
36 A(k,:)=B; r(k)=C;
37 end
38 for
39 L=A(i+1,j)/A(j,j);
40 A(i+1,:)=A(i+1,:)-L*A(j,:);
41 r(i+1)=r(i+1)-L*r(j);
164

42 end
43 s=s+1;
44end
45//
46x(n)=r(n)/A(n,n);
47for
48 sum
49 for
50 sum
51 end
52 x(i)=(1/A(i,i))*(r(i)-
53end
54
55//
56p=
57//
58disp '@

@ ')
59disp ' Output [B ] [ x ]=[ b ] ')
60disp ' Upper r i a n g u l a r Matrix [B] = ');
61disp ' Matrix [ b ] = ');
62disp ' s o l u t i o n of l i n e a r e q u a t i o n s : ');
Scilab code Exa 28.5solving parabolic equation
1//
2clear
3clc
4disp ' Here c^2=4 , h=1 , k=1/8 , t h e r e f o r e alpha =(c
^2)k /( h ^2) ');
5disp ' Using bendres c h m i d i t s r e c u r r e n c e r e l a t i o n i e
u ( i ) ( j +1)=tu ( i1) ( j )+tu ( i +1) ( j )+(12t )u ( i , j ) ')
;
6disp 'Now s i n c e u (0 , t )=0=u (8 , t ) t h e r e f o r e u (0 , i )=0
165

and u (8 , j )=0 and u ( x , 0 ) =4x1/2x^2 ');
7c=2;
8h=1;
9k=1/8;
10t=(c^2)*k/(h^2);
11A=
12
13for
14 for
15 A(1,i)=0;
16 A(9,i)=0;
17 A(i,1) =4*(i-1) -1/2*(i-1) ^2;
18
19end
20end
21//
22//
23for
24 for
25// ( 1,1) 1)
26A(i,j)=t*A(i-1,j-1)+t*A(i+1,j-1) +(1 -2*t)*A(i-1,j-1)
;
27end
28end
29for
30 j=2;
31 disp
32
33end
Scilab code Exa 28.6solving heat equation
1//
2clear
3clc
166

4disp ' Here c^2=1 , h=1/3 , k=1/36 , t h e r e f o r e t =(c
^2)k /( h ^2) =1/4 ');
5disp ' So bendres c h m i d i t s r e c u r r e n c e r e l a t i o n i e u ( i
) ( j +1)=1/4(u ( i1) ( j )+u ( i +1) ( j )+2u ( i , j ) ');
6disp 'Now s i n c e u (0 , t )=0=u (1 , t ) t h e r e f o r e u (0 , i )=0
and u (1 , j )=0 and u ( x , 0 )=s i n ( %pi ) x ');
7c=1;
8h=1/3;
9k=1/36;
10t=(c^2)*k/(h^2);
11A=
12
13for
14 for
15 A(1,i)=0;
16 A(2,i)=0;
17 A(i,1)=
18
19end
20end
21//
22//
23for
24 for
25 // ( 1,1) 1) A1,
1)
26 A(i,j)=t*A(i-1,j-1)+t*A(i+1,j-1) +(1 -2*t)*A(i-1,
j-1);
27end
28end
29for
30 j=2;
31 disp
32
33end
167

Scilab code Exa 28.7solving wave equation
1//
2clear
3clc
4disp ' Here c ^2=16 , taking h=1 , f i n d i n g k such that
c ^2 t ^2=1 ');
5disp ' So bendres c h m i d i t s r e c u r r e n c e r e l a t i o n i e u ( i
) ( j +1)=(16 t ^2( u ( i1) ( j )+u ( i +1) ( j ) ) +2(116t ^2u ( i ,
j )u ( i ) ( j1) ');
6disp 'Now s i n c e u (0 , t )=0=u (5 , t ) t h e r e f o r e u (0 , i )=0
and u (5 , j )=0 and u ( x , 0 )=x^2(5x ) ');
7c=4;
8h=1;
9k=(h/c);
10t=k/h;
11A=
12disp ' Also from 1 s t d e r i v a t i v e ( u ( i ) ( j +1)u ( i , j1) )
/2k=g ( x ) and g ( x )=0 in t h i s case ');
13disp ' So i f j =0 t h i s g i v e s u ( i ) ( 1 ) =1/2(u ( i1) ( 0 )+u (
i +1) ( 0 ) ) ')
14for
15 for
16 A(1,i+1) =0;
17 A(6,i+1) =0;
18 A(i+1,1)=(i)^2*(5 -i);
19
20
21end
22end
23for
24 A(i+1,2) =1/2*(A(i,1)+A(i+2,1));
25
26 end
168

27 for
28 for
29
30 A(i-1,j)=(c*t)^2*(A(i-2,j-1)+A(i,j-1))+2*(1 -(c*t
)^2)*A(i-1,j-1)-A(i-1,j-2);
31end
32end
33
34for
35for
36 disp
37end
38end
Scilab code Exa 28.8solving wave equation
1//
2clear
3clc
4disp ' Here c^2=4 , taking h=1 , f i n d i n g k such that
c ^2 t ^2=1 ');
5disp ' So bendres c h m i d i t s r e c u r r e n c e r e l a t i o n i e u ( i
) ( j +1)=(16 t ^2( u ( i1) ( j )+u ( i +1) ( j ) ) +2(116t ^2u ( i ,
j )u ( i ) ( j1) ');
6disp 'Now s i n c e u (0 , t )=0=u (4 , t ) t h e r e f o r e u (0 , i )=0
and u (4 , j )=0 and u ( x , 0 )=x(4x ) ');
7c=2;
8h=1;
9k=(h/c);
10t=k/h;
11A=
12disp ' Also from 1 s t d e r i v a t i v e ( u ( i ) ( j +1)u ( i , j1) )
/2k=g ( x ) and g ( x )=0 in t h i s case ');
13disp ' So i f j =0 t h i s g i v e s u ( i ) ( 1 ) =1/2(u ( i1) ( 0 )+u (
i +1) ( 0 ) ) ')
169

14for
15 for
16 A(1,i+1) =0;
17 A(5,i+1) =0;
18 A(i+1,1)=(i)*(4-i);
19
20
21end
22end
23for
24 A(i+1,2) =1/2*(A(i,1)+A(i+2,1));
25
26 end
27 for
28 for
29
30 A(i-1,j)=(c*t)^2*(A(i-2,j-1)+A(i,j-1))+2*(1 -(c*t
)^2)*A(i-1,j-1)-A(i-1,j-2);
31end
32end
33
34for
35for
36 disp
37end
38end
170

Chapter 34
Probability and Distributions
Scilab code Exa 34.1Calculating probability
1clear
2clc
3disp ' from the p r i n c i p l e of counting , the r e q u i r e d no
. of ways are 1211109= ')
412*11*10*9
Scilab code Exa 34.2.1Calculating the number of permutations
1clear
2clc
3disp ' no . of permutations = 9 ! / ( 2 !2 !2 ! ) ')
4factorial (9)/( factorial (2)*factorial (2)*factorial (2)
)
Scilab code Exa 34.2.2Number of permutations
171

1clear
2clc
3disp ' no . of permutations = 9 ! / ( 2 !2 !3 !3 ! ) ')
4factorial (9)/( factorial (2)*factorial (2)*factorial (3)
*factorial (3))
Scilab code Exa 34.3.1Calculating the number of committees
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' no . of committees=C( 6 , 3 )C( 5 , 2 )= ')
7C(6,3)*C(5,2)
Scilab code Exa 34.3.2Finding the number of committees
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' no . of committees=C( 4 , 1 )C( 5 , 2 )= ')
7C(4,1)*C(5,2)
Scilab code Exa 34.3.3Finding the number of committees
1clear
2clc
172

3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' no . of committees=C( 6 , 3 )C( 4 , 2 )= ')
7C(6,3)*C(4,2)
Scilab code Exa 34.4.1Finding the probability of getting a four in a sin-
gle throw of a die
1clear
2clc
3disp ' the p r o b a b i l i t y of g e t t i n g a f o u r i s 1/6= ')
41/6
Scilab code Exa 34.4.2Finding the probability of getting an even number
in a single throw of a die
1clear
2clc
3disp ' the p r o b a b i l i t y of g e t t i n g an even no . 1/2= ')
41/2
Scilab code Exa 34.5Finding the probability of 53 sundays in a leap year
1clear
2clc
3disp ' the p r o b a b i l i t y of 53 sundays i s 2/7= ')
42/7
173

Scilab code Exa 34.6probability of getting a number divisible by 4 under
given conditions
1clear
2clc
3disp ' the f i v e d i g i t s can be arranged in 5 ! ways = ')
4factorial (5)
5disp ' of which 4 ! w i l l begin with 0= ')
6factorial (4)
7disp ' so , t o t a l no . of f i v e d i g i t numbers=5!4!= ')
8factorial (5)-factorial (4)
9disp ' the numbers ending in 04 ,12 ,20 ,24 ,32 ,40 w i l l
be d i v i s i b l e by 4 ')
10disp ' numbers ending in 04=3! ')
11factorial (3)
12disp ' numbers ending in 12=3! 2! ')
13factorial (3)-factorial (2)
14disp ' numbers ending in 20=3! ')
15factorial (3)
16disp ' numbers ending in 24=3! 2! ')
17factorial (3)-factorial (2)
18disp ' numbers ending in 32=3! 2! ')
19factorial (3)-factorial (2)
20disp ' numbers ending in 40=3! ')
21factorial (3)
22disp ' so , t o t a l no . of f a v o u r a b l e ways=6+4+6+4+4+6= ')
236+4+6+4+4+6
24disp ' p r o b a b i l i t y =30/96= ')
2530/96
Scilab code Exa 34.7Finding the probability
174

1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' t o t a l no . of p o s s i b l e c a s e s=C( 4 0 , 4 ) ')
7C(40 ,4)
8disp ' f a v o u r a b l e outcomes=C( 2 4 , 2 )C( 1 5 , 1 )= ')
9C(24 ,2)*C(15 ,1)
10disp ' p r o b a b i l i t y= ')
11(C(24 ,2)*C(15 ,1))/C(40 ,4)
Scilab code Exa 34.8Finding the probability
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' t o t a l no . of p o s s i b l e c a s e s=C( 4 0 , 4 ) ')
7C(15 ,8)
8disp ' f a v o u r a b l e outcomes=C( 2 4 , 2 )C( 1 5 , 1 )= ')
9C(5,2)*C(10 ,6)
10disp ' p r o b a b i l i t y= ')
11(C(5,2)*C(10 ,6))/C(15 ,8)
Scilab code Exa 34.9.1Finding the probability
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
175

6disp ' t o t a l no . of p o s s i b l e c a s e s=C( 9 , 3 ) ')
7C(9,3)
8disp ' f a v o u r a b l e outcomes=C( 2 , 1 )C( 3 , 1 )C( 4 , 1 )= ')
9C(2,1)*C(3,1)*C(4,1)
10disp ' p r o b a b i l i t y= ')
11(C(2,1)*C(3,1)*C(4,1))/C(9,3)
Scilab code Exa 34.9.2Finding the probability
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' t o t a l no . of p o s s i b l e c a s e s=C( 9 , 3 ) ')
7C(9,3)
8disp ' f a v o u r a b l e outcomes=C( 2 , 2 )C( 7 , 1 )+C( 3 , 2 )C
( 6 , 1 )+C( 4 , 2 )C( 5 , 1 )= ')
9C(2,2)*C(7,1)+C(3,2)*C(6,1)+C(4,2)*C(5,1)
10disp ' p r o b a b i l i t y= ')
11(C(2,2)*C(7,1)+C(3,2)*C(6,1)+C(4,2)*C(5,1))/C(9,3)
Scilab code Exa 34.9.3Finding the probability
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' t o t a l no . of p o s s i b l e c a s e s=C( 9 , 3 ) ')
7C(9,3)
8disp ' f a v o u r a b l e outcomes=C( 3 , 3 )+C( 4 , 3 )= ')
9C(3,3)+C(4,3)
176

10disp ' p r o b a b i l i t y= ')
115/84
Scilab code Exa 34.13probability of drawing an ace or spade from pack
of 52 cards
1clear
2clc
3disp ' p r o b a b i l i t y of drawing an ace or spade or both
from pack of 52 cards =4/52+13/52 1/52= ')
44/52+13/52 -1/52
Scilab code Exa 34.14.1Finding the probability
1clear
2clc
3disp ' p r o b a b i l i t y of f i r s t card being a king =4/52 ')
44/52
5disp ' p r o b a b i l i t y of second card being a queen =4/52 '
)
64/52
7disp ' p r o b a b i l i t y of drawing both cards in
s u c c e s s i o n =4/524/52= ')
84/52*4/52
Scilab code Exa 34.15.1Finding the probability
1clear
2clc
177

3disp ' p r o b a b i l i t y of g e t t i n g 7 in f i r s t t o s s and not
g e t t i n g i t in second t o s s =1/65/6 ')
41/6*5/6
5disp ' p r o b a b i l i t y of not g e t t i n g 7 in f i r s t t o s s and
g e t t i n g i t in second t o s s =5/61/6 ')
65/6*1/6
7disp ' r e q u i r e d p r o b a b i l i t y =1/65/6+5/61/6 ')
81/6*5/6+5/6*1/6
Scilab code Exa 34.15.2Finding the probability
1clear
2clc
3disp ' p r o b a b i l i t y of not g e t t i n g 7 in e i t h e r t o s s
=5/65/6 ')
45/6*5/6
5disp ' p r o b a b i l i t y of g e t t i n g 7 at l e a s t once
=15/65/6 ')
61 -5/6*5/6
Scilab code Exa 34.15.3Finding the probability
1clear
2clc
3disp ' p r o b a b i l i t y of g e t t i n g 7 twice =1/61/6 ')
41/6*1/6
Scilab code Exa 34.16Finding the probability
1clear
178

2clc
3disp ' p r o b a b i l i t y of e n g i n e e r i n g s u b j e c t being
chooosen =(1/33/8) +(2/35/8)= ')
4(1/3*3/8) +(2/3*5/8)
Scilab code Exa 34.17Finding the probability
1clear
2clc
3disp ' p r o b a b i l i t y of white b a l l being choosen
=2/66/13+4/65/13= ')
42/6*6/13+4/6*5/13
Scilab code Exa 34.18Finding the probability
1clear
2clc
3disp " chances of winning of A=1/2+(1/2) ^2 (1/2)
+(1/2) ^4(1/2) +(1/2) ^6(1/2) +..= ' )
4(1/2) /(1(1/2) ^2)
5disp ( ' chances of winning of B=1chances of winning
of A' )
612/3
Scilab code Exa 34.19.1Finding the probability
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
179

5endfunction
6disp ' t o t a l no . of p o s s i b l e outcomes=C( 1 0 , 2 )= ')
7C(10 ,2)
8disp ' no . of f a v o u r a b l e outcomes=55= ')
95*5
10disp ' p= ')
1125/49
Scilab code Exa 34.19.2Finding the probability
1clear
2clc
3disp ' t o t a l no . of p o s s i b l e outcomes=109= ')
410*9
5disp ' no . of f a v o u r a b l e outcomes=55+55= ')
65*5+5*5
7disp ' p= ')
850/90
Scilab code Exa 34.19.3Finding the probability
1clear
2clc
3disp ' t o t a l no . of p o s s i b l e outcomes=109= ')
410*10
5disp ' no . of f a v o u r a b l e outcomes=55+55= ')
65*5+5*5
7disp ' p= ')
850/100
180

Scilab code Exa 34.20Finding the probability
1clear
2clc
3A=1/4
4B=1/3
5AorB =1/2
6AandB=A+B-AorB
7disp ' p r o b a b i l i t y of A/B=AandB/B= ')
8AandB/B
9disp ' p r o b a b i l i t y of B/A=AandB/A= ')
10AandB/A
11disp ' p r o b a b i l i t y of AandBnot=AAandB= ')
12A-AandB
13disp ' p r o b a b i l i t y of A/Bnot=AandBnot/Bnot= ')
14(1/6) /(1 -1/3)
Scilab code Exa 34.22Finding the probability
1clear
2clc
3disp ' p r o b a b i l i t y of A h i t t i n g t a r g e t =3/5 ')
4disp ' p r o b a b i l i t y of B h i t t i n g t a r g e t =2/5 ')
5disp ' p r o b a b i l i t y of C h i t t i n g t a r g e t =3/4 ')
6disp ' p r o b a b i l i t y that two s h o t s h i t =3/52/5(13/4)
+2/53/4(13/5) +3/43/5(12/5) ')
73/5*2/5*(1 -3/4) +2/5*3/4*(1 -3/5) +3/4*3/5*(1 -2/5)
Scilab code Exa 34.23Finding the probability
1clear
2clc
181

3disp ' p r o b a b i l i t y of problem not g e t t i n g s o l v e d
=1/22/33/4= ')
41/2*2/3*3/4
5disp ' p r o b a b i l i t y of problem g e t t i n g s o l v e d
=1(1/22/33/4)= ')
61 -(1/2*2/3*3/4)
Scilab code Exa 34.25nding the probability
1clc
2disp ' t o t a l frequency= i n t e g r a t e ( f , x , 0 , 2 )= ')
3n= ' x^3 ',' x ',0,1)+ ' (2x ) ^3 ',' x '
,1,2)
4disp ' u1 about o r i g i n= ')
5u1 =(1/n)*( ' ( x )( x ^3) ',' x ',0,1)+
(' ( x )((2x ) ^3) ',' x ',1,2))
6disp ' u2 about o r i g i n= ')
7u2 =(1/n)*( ' ( x ^2)( x ^3) ',' x ',0,1)+
integrate ' ( x ^2)((2x ) ^3) ',' x ',1,2))
8disp ' standard d e v i a t i o n =(u2u1 ^2) ^0.5= ')
9(u2 -u1^2) ^0.5
10disp ' mean d e v i a t i o n about the mean=(1/n )( i n t e g r a t e
(jx1j( x ^3) ,x , 0 , 1 )+i n t e g r a t e (jx1j((2x ) ^3) ,x
, 1 , 2 ` ) ')
11(1/n)*( ' (1x )( x ^3) ',' x ',0,1)+ '
( x1)((2x ) ^3) ',' x ',1,2))
Scilab code Exa 34.26nding the probability
1clear
2clc
3disp ' p r o b a b i l i t y =(0.450.03)
/(0.450.03+0.250.05+0.30.04= ')
182

4(0.45*0.03) /(0.45*0.03+0.25*0.05+0.3*0.04)
Scilab code Exa 34.27nding the probability
1clear
2clc
3disp ' p r o b a b i l i t y =(1/32/63/5)
/(1/32/63/5+1/31/62/5+1/33/61/5 ')
4(1/3*2/6*3/5) /(1/3*2/6*3/5+1/3*1/6*2/5+1/3*3/6*1/5)
Scilab code Exa 34.28nding the probability
1clc
2disp ' p r o b a b i l i t y of no s u c c e s s =8/27 ')
3disp ' p r o b a b i l i t y of a s u c c e s s =1/3 ')
4disp ' p r o b a b i l i t y of one s u c c e s s =4/9 ')
5disp ' p r o b a b i l i t y of two s u c c e s s e s =2/9 ')
6disp ' p r o b a b i l i t y of t h r e e s u c c e s s e s =2/9 ')
7A=[0 1 2 3;8/27 4/9 2/9 1/27]
8disp ' mean=sum of ipi= ')
9A(1,1)*A(2,1)+A(1,2)*A(2,2)+A(1,4)*A(2,4)+A(1,3)*A
(2,3)
10disp 'sum of ipi ^2= ')
11A(1,1) ^2*A(2,1)+A(1,2) ^2*A(2,2)+A(1,4) ^2*A(2,4)+A
(1,3) ^2*A(2,3)
12disp ' v a r i a n c e =(sum of ipi ^2)1= ')
13A(1,1) ^2*A(2,1)+A(1,2) ^2*A(2,2)+A(1,4) ^2*A(2,4)+A
(1,3) ^2*A(2,3) -1
Scilab code Exa 34.29nding the probability
183

1clc
2syms k
3A=[0 1 2 3 4 5 6;k 3*k 5*k 7*k 9*k 11*k 13*k]
4disp ' sumof a l l pi=1 ')
5//
6disp ' hence , ')
7k=1/49
8disp ' p ( x<4)= ')
9a=A(2,1)+A(2,2)+A(2,4)+A(2,3)
10eval
11disp
12disp ' p ( x>=5)= ')
13b=A(2,6)+A(2,7)
14eval
15disp
16disp ' p(3<x<=6)= ')
17c=A(2,5)+A(2,6)+A(2,7)
18eval
19disp
20disp ' p ( x<=2)= ')
21c=A(2,1)+A(2,2) +A(2,3)
Scilab code Exa 34.30nding the probability
1clc
2syms k
3A=[0 1 2 3 4 5 6 7;0 k 2*k 2*k 3*k k^2 2*k^2 7*k^2+k
]
4disp ' sumof a l l pi=1 ')
5//
6disp ' hence , ')
7k=1/10
8disp ' p ( x<6)= ')
9a=A(2,1)+A(2,2)+A(2,4)+A(2,3)+A(2,4)+A(2,5)+A(2,6)
10eval
184

11disp
12disp ' p ( x>=6)= ')
13b=A(2,7)+A(2,8)
14eval
15disp
16disp ' p(3<x<5)= ')
17c=A(2,2)+A(2,3)+A(2,4)+A(2,5)
18eval
19disp
Scilab code Exa 34.31nding the probability
1clc
2syms x;
3f=%e^(-x)
4disp ' c l e a r l y , f>0 f o r every x in ( 1 , 2 ) and i n t e g r a t e
( f , x , 0 , %inf )= ')
5integrate '%e^(y ) ',' y ',0,%inf )
6disp ' r e q u i r e d p r o b a b i l i t y=p(1<=x<=2)=i n t e g r a t e ( f , x
, 1 , 2 )= ')
7integrate '%e^(y ) ',' y ',1,2)
8disp ' cumulative p r o b a b i l i t y f u n c t i o n f ( 2 )=i n t e g r a t e
( f , x,%inf , 2 )= ')
9integrate '%e^(y ) ',' y ',0,2)
Scilab code Exa 34.33nding the probability
1clc
2syms k;
3disp ' t o t a l p r o b a b i l i t y= i n t e g r a t e ( f , x , 0 , 6 )= ')
4p= ' kx ',' x ',0,2)
5q= ' 2k ',' x ',2,4)
6r= 'kx+6k ',' x ',4,6)
185

Scilab code Exa 34.34nding the probability
1clc
2A=[-3 6 9;1/6 1/2 1/3]
3disp ' f i r s t row of A d i s p l a y s the value of x ')
4disp ' the second row of x d i s p l a y s the p r o b a b i l i t y
of c or re sp on di ng to x ')
5disp 'E( x )= ')
6c=A(1,1)*A(2,1)+A(1,2) *(2 ,2)+A(1,3)*A(2,3)
7disp 'E( x )^2= ')
8b=A(1,1) ^2*A(2,1)+A(1,2) ^2*(2 ,2)+A(1,3) ^2*A(2,3)
9disp 'E(2x+1)^2=E(4x^2+4x+1) '
104*b+4*c+1
Scilab code Exa 34.35nding the probability
1clc
2disp ' t o t a l frequency= i n t e g r a t e ( f , x , 0 , 2 )= ')
3n= ' x^3 ',' x ',0,1)+ ' (2x ) ^3 ',' x '
,1,2)
4disp ' u1 about o r i g i n= ')
5u1 =(1/n)*( ' ( x )( x ^3) ',' x ',0,1)+
(' ( x )((2x ) ^3) ',' x ',1,2))
6disp ' u2 about o r i g i n= ')
7u2 =(1/n)*( ' ( x ^2)( x ^3) ',' x ',0,1)+
integrate ' ( x ^2)((2x ) ^3) ',' x ',1,2))
8disp ' standard d e v i a t i o n =(u2u1 ^2) ^0.5= ')
9(u2 -u1^2) ^0.5
10disp ' mean d e v i a t i o n about the mean=(1/n )( i n t e g r a t e
(jx1j( x ^3) ,x , 0 , 1 )+i n t e g r a t e (jx1j((2x ) ^3) ,x
, 1 , 2 ` ) ')
186

11(1/n)*( ' (1x )( x ^3) ',' x ',0,1)+ '
( x1)((2x ) ^3) ',' x ',1,2))
Scilab code Exa 34.38nding the probability
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' p r o b a b i l i t y that e x a c t l y two w i l l be d e f e c t i v e
=C( 1 2 , 2 )( 0 . 1 ) ^ 2( 0 . 9 ) ^10= ')
7C(12 ,2) *(0.1) ^2*(0.9) ^10
8disp ' p r o b a b i l i t y that at l e a s t two w i l l be
d e f e c t i v e =1(C( 1 2 , 0 )( 0 . 9 ) ^12+C( 1 2 , 1 )( 0 . 1 )( 0 . 9 )
^11)= ')
91-(C(12 ,0) *(0.9) ^12+C(12 ,1) *(0.1) *(0.9) ^11)
10disp ' the p r o b a b i l i t y that none w i l l be d e f e c t i v e =C
(12 ,12)( 0 . 9 ) ^12= ')
11C(12 ,12) *(0.9) ^12
Scilab code Exa 34.39nding the probability
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' p r o b a b i l i t y of 8 heads and 4 t a i l s in 12
t r i a l s=p ( 8 )=C( 1 2 , 8 )(1/2) ^8(1/2) ^4= ')
7C(12 ,8) *(1/2) ^8*(1/2) ^4
8disp ' the expected no . of such c a s e s in 256 s e t s
=256p ( 8 ) = ')
187

9256*(495/4096)
Scilab code Exa 34.40nding the probability
1clear
2clc
3function
4x=factorial(a)/( factorial(b)*factorial(a-b))
5endfunction
6disp ' p r o b a b i l i t y of a d e f e c t i v e part =2/20=0.1 ')
7disp ' p r o b a b i l i t y of a non d e f e c t i v e part =0.9 ')
8disp ' p r o b a b a i l i t y of at l e a s t t h r e e d e f e c t i v e s ina
sample = ')
91-(C(20 ,0) *(0.9) ^20+C(20 ,1) *(0.1) *(0.9) ^19+C(20 ,2)
*(0.1) ^2*(0.9) ^18')
10disp ' no . of samples having t h r e e d e f e c t i v e p a r t s
=10000.323= ')
111000*0.323
188

Chapter 35
Sampling and Inference
Scilab code Exa 35.1calculating the SD of given sample
1clc
2disp ' suppose the coin i s unbiased ' )
3disp ' then p r o b a b i l i t y of g e t t i n g the head in a t o s s
=1/2 ')
4disp ' then , expected no . of s u c c e s s e s=a=1/2400 ')
5a=1/2*400
6disp ' observed no . of s u c c e s s e s =216 ')
7b=216
8disp ' the e x c e s s of observed value over expected
value= ')
9b-a
10disp ' S .D. of simple sampling = ( npq ) ^0.5= c ')
11c=(400*0.5*0.5) ^0.5
12disp ' hence , z=(ba ) / c= ')
13(b-a)/c
14disp ' as z<1.96 , the h y p o t h e s i s i s accepted at 5%
l e v e l of s i g n i f i c a n c e ')
Scilab code Exa 35.2Calculating SD of sample
189

1clc
2disp ' suppose the d i e i s unbiased ')
3disp ' then p r o b a b i l i t y of g e t t i n g 5 or 6 with one
d i e =1/3 ')
4disp ' then , expected no . of s u c c e s s e s=a =1/39000 ')
5a=1/3*9000
6disp ' observed no . of s u c c e s s e s =3240 ')
7b=3240
8disp ' the e x c e s s of observed value over expected
value= ')
9b-a
10disp ' S .D. of simple sampling = ( npq ) ^0.5= c ')
11c=(9000*(1/3) *(2/3))^0.5
12disp ' hence , z=(ba ) / c= ')
13(b-a)/c
14disp ' as z>2.58 , the h y p o t h e s i s has to be r e j e c t e d
at 1% l e v e l of s i g n i f i c a n c e ')
Scilab code Exa 35.3Analysis of sample
1clc
2p=206/840
3disp ' q=1p ')
4q=1-p
5n=840
6disp ' standard e r r o r of the population of f a m i l i e s
having a monthly income of r s . 250 or l e s s =(p q/n
) ^0.5= ')
7(p*q/n)^0.5
8disp ' hence taking 103/420 to be the es tim ate of
f a m i l i e s having a monthly income of r s . 250 or
l e s s , the l i m i t s are 20% and 29% approximately ')
190

Scilab code Exa 35.4Analysis of sample
1clear
2clc
3n1 =900
4n2 =1600
5p1 =20/100
6p2 =18.5/100
7disp ' p=(n1p1+n2p2 ) /( n1+n2 ) ')
8p=(n1*p1+n2*p2)/(n1+n2)
9disp ' q=1p ')
10q=1-p
11disp ' e=(pq(1/ n1+1/n2 ) ) ^0.5 ')
12e=(p*q*((1/ n1)+(1/ n2)))^0.5
13z=(p1 -p2)/e
14disp ' as z<1, the d i f f e r e n c e between the p r o p o r t i o n s
i s not s i g n i f i c a n t . ')
Scilab code Exa 35.5Checking whether real dierence will be hidden
1clear
2clc
3p1 =0.3
4p2 =0.25
5disp ' q1=1p1 ')
6q1=1-p1
7disp ' q2=1p2 ')
8q2=1-p2
9n1 =1200
10n2 =900
11disp ' e =(( p1q1/n1 )+(p2q2/n2 ) ) ^0.5 ')
12e=((p1*q1/n1)+(p2*q2/n2))^0.5
13z=(p1 -p2)/e
14disp ' hence , i t i s l i k e l y that r e a l d i f f e r e n c e w i l l
be hidden . ')
191

Scilab code Exa 35.6Checking whether given sample can be regarded as
a random sample
1clear
2clc
3disp 'm and n r e p r e s e n t s mean and number of o b j e c t s
in sample r e s p e c t i v e l y ')
4m=3.4
5n=900
6M=3.25
7d=1.61
8disp ' z=(mM) /( d /( n ^ 0 . 5 ) ')
9z=(m-M)/(d/(n^0.5))
10disp ' as z>1.96 , i t cannot be regarded as a random
sample ")
Scilab code Exa 35.9Checking whethet samples can be regarded as taken
from the same population
1clc
2disp 'm1 and n1 r e p r e s e n t s mean and no . of o b j e c t s
in sample 1 ')
3disp 'm2 and n2 r e p r e s e n t s mean and no . of o b j e c t s
in sample 2 ')
4m1 =67.5
5m2=68
6n1 =1000
7n2 =2000
8d=2.5
9disp ' on the h y p o t h e s i s that the samples are drawn
from the same population of d =2.5 ,we get ' )
192

10z=(m1 -m2)/(d*((1/ n1)+(1/ n2))^0.5)
11disp ' s i n c ejzj>1 . 9 6 , thus samples cannot be
regarded as drawn from the same population ' )
Scilab code Exa 35.10calculating SE of dierence of mean hieghts
1clc
2disp 'm1, d1 and n1 denotes mean , d e v i a t i o n and no . of
o b j e c t s in f i r s t sample ')
3m1 =67.85
4d1 =2.56
5n1 =6400
6disp 'm2, d2 and n2 denotes mean , d e v i a t i o n and no . of
o b j e c t s in second sample ')
7m2 =68.55
8d2 =2.52
9n2 =1600
10disp ' S .E. of the d i f f e r e n c e of the mean h e i g h t s i s
')
11e=((d1^2/n1)+(d2^2/n2))^0.5
12m1 -m2
13disp 'jm1m2j>10e , t h i s i s h i g h l y s i g n i f i c a n t . hence
, the data i n d i c a t e s that the s a i l o r s are on the
average t a l l e r than the s o l d i e r s . ')
Scilab code Exa 35.12Mean and standard deviation of a given sample
1clear
2clc
3n=9
4disp ' f i r s t of row denotes the d i f f e r e n t v a l u e s of
sample ')
5A(1,:) =[45 47 50 52 48 47 49 53 51];
193

6disp ' the second row denotes the c or re sp on di ng
d e v i a t i o n ')
7for
8 A(2,i)=A(1,i) -48;
9end
10disp ' the t h i r d row denotes the cor re sp on di ng square
of d e v i a t i o n ')
11for
12 A(3,i)=A(2,i)^2;
13end
14disp ' the sum of second row elements = ' )
15a=0;
16for
17 a=a+A(2,i);
18end
19a
20disp ' the sum of t h i r d row elements ")
21b=0;
22f o r i =1:9
23 b=b+A(3 , i ) ;
24end
25b
26disp ( 'let m be the ' )
27m=48+a/n
28disp ( 'let d be the standard deviation ' )
29d=((b/n )(a/n ) ^2) ^0.5
30t=(m47.5)(n1) ^0.5/ d
Scilab code Exa 35.13Mean and standard deviation of a given sample
1clc
2disp ' d and n r e p r e s e n t s the d e v i a t i o n and no . of
o b j e c t s in given sample ')
3n=10
4d=0.04
194

5m=0.742
6M=0.700
7disp ' taking the h y p o t h e s i s that the product i s not
i n f e r i o r i . e . t h e r e i s no s i g n i f i c a n t d i f f e r e n e
between m and M')
8t=(m-M)*(n-1) ^0.5/d
9disp ' d e g r e e s of freedom= ')
10f=n-1
Scilab code Exa 34.15Standard deviation of a sample
1clear
2clc
3n=11
4disp ' the f i r s t row denotes the boy no . ')
5A(1,:) =[1 2 3 4 5 6 7 8 9 10 11];
6disp ' the second row denotes the marks in t e s t I ( x1
) ')
7A(2,:) =[23 20 19 21 18 20 18 17 23 16 19];
8disp ' the t h i r d row denotes the marks in t e s t I ( x2 )
')
9A(3,:) =[24 19 22 18 20 22 20 20 23 20 17];
10disp ' the f o u r t h row denotes the d i f f e r e n c e of marks
in two t e s t s ( d ) ')
11for
12 A(4,i)=A(3,i)-A(2,i);
13end
14disp ' the f i f t h row denotes the (d1) ')
15for
16 A(5,i)=A(4,i) -1;
17end
18disp ' the s i x t h row denotes the square of elements
of f o u r t h row ')
19for
20 A(6,i)=A(4,i)^2;
195

21end
22A
23a=0;
24disp ' the sum of elements of f o u r t h row= ')
25for
26 a=a+A(4,i);
27end
28a
29b=0;
30disp ' the sum of elements of s i x t h row= ')
31for
32 b=b+A(6,i);
33end
34b
35disp ' standard d e v i a t i o n ')
36d=(b/(n-1))^0.5
37t=(1 -0)*(n)^0.5/2.24
196
Tags