Mechi Multiple Campus
Tribhuvan University
Bhadrapur, Jhapa, Nepal
Lab Report of Mathematics-II (CAMT-154)
Faculty of Humanities and Social Sciences
Tribhuvan University
Kritipur, Nepal
Submitted By
Name: - Tirtha Bahadur Rajbanshi
Roll no: - 66
Submitted To
Mechi Multiple Campus
Department of Bachelor in Computer Applications
Bhadrapur, Jhapa, Nepal
Submission date: - Signature
Internal Examiner External Examine
DECLARATION
I hereby declare that the project work entitled “MATHEMATICA and
MATLAB” is a general concept of mathematical software, original work done by
me, and this project is submitted in the requirements for the award of the degree
of
Bachelor Second Semester. The results enrolled in the report have not been
submitted to any other university or institute for the award of degree of BCA.
Tirtha Bahadur Rajbanshi
BCA Second Semester
Roll no: - 66
i
CERTIFICATE FROM THE SUPERVISOR
This is to certify that the Lab Report entitled “Mathematics-II (CAMT-154)” is
an academic work done by “Tirtha Bahadur Rajbanshi” submitted in the partial
fulfilment of requirement for the degree of Bachelor of Computer Application at
Faculty of Humanities and Social Science, Tribhuvan University under my
guidance and supervision. To the best of my knowledge, the work performed by
him in the Lab report is his own creation.
Signature of the supervisor
Kumar Subedi
Designation: - Lecturer
Date: -
ii
PREFACE
The Lab report of BCA 2nd semester is the implementation of theoretical and
practical knowledge of various topics of mathematics on software’s such as
‘MATHEMATICA’ and ‘MATLAB’. This project is especially designed to
familiarize, develop and enhance the knowledge of students in software like
MATHEMATICA and MATLAB.
This lab report is assigned to students as they lag behind in fair result
processing
and to solve the current problem of various academic institutions. The report is
made by using MATLAB and MATHEMATICA and also using my own related
knowledge which I gained from the theory and practical classes of
‘MATHEMATICS-II’.
This Lab report is made to obtain the information about various uses of
mathematical software tools. The main objective of this report is to make BCA
students capable of using mathematical software and perform related problems in a
systematic way.
The report includes all features of lab practicals which is essential in enhancing
the
skill of students for the fruitful career ahead in future. Finally, I welcome
valuable
and constructive suggestions and comments from all the readers on any aspects of
this for improving my logic.
iii
ACKNOWLEDGEMENT
This lab report is especially assigned by the academic institution to the students
of
BCA 2nd semester for the partial fulfilment of the course and designed for the
systematic and accurate use of mathematical software’s i.e. ‘MATLAB’ and
‘MATHEMATICA’.
For successful completion of this lab report there are various hands to help me out
to whom I am greatly thankful.
I would like to thank BCA director Mr. Krishna Prasad Acharya sir who granted
our project work by understanding the needs of students. I am highly indebted to
my subject teacher Mr. Kumar Subedi sir for his guidance and constant supervision
as well as for providing necessary information regarding the project & also for the
support in completing the lab report. Similarly, I am thankful to the institution
and
faculty management for providing essential resources and remarkable support in
this report.
Lastly, I would express heartfelt gratitude to the TU board for innovation of such
a
wonderful course structure which can surely help to enhance the skill and career of
student’s ahead in future.
iv
TABLE OF CONTENT
Part A: Mathematica (Wolfram
Mathematica)..........................................................1
Introduction.......................................................................
.............................................. 1
Limit and
Continuity.........................................................................
..............................2
Limit of Trigonometric
Function...........................................................................
......4
Some Graphs of
Limits.............................................................................
...................5
One Sided
Limits.............................................................................
............................6
Differentiation....................................................................
............................................. 7
Derivatives........................................................................
........................................... 7
Application of
Derivatives........................................................................
...................9
Maxima and
Minima.............................................................................
......................9
Some Graphs of
Derivatives........................................................................
..............10
Integration........................................................................
............................................. 13
Definite
integrals..........................................................................
.............................14
Improper
Integrals..........................................................................
...........................15
Part A: MATLAB (Matrix
Laboratory)...................................................................16
Introduction.......................................................................
............................................16
Assigning Scalars, Array, Vectors &
Matrix.................................................................17
Linear
Programming........................................................................
.............................19
Simpson’s 1/3
Rule...............................................................................
........................20
Trapezodial
Rule...............................................................................
............................21
v
Part A: Mathematica (Wolfram Mathematica)
Introduction
Language-based Mathematica programming software. Therefore, it is a digital too
for mathematics education. It helps in computation and visualization. Mathematica
is the Mathematica is a CUI (Character User Interface) based programming
language. It is the creation of Stephen Wolfram.
How to run Mathematica:
i. Open Mathematica notebook.
ii. Type the instructions/command.
iii. Press Shift + Enter
Note:
a. Parentheses i.e. ()
Parentheses are used only for grouping expressions. Mostly, it is used to prove
arithmetic expressions. Like (2 + 3).
b. Brackets i.e. []
Brackets are used to enclose the arguments of a function. Like cos[x]
c. Braces i.e. {}
Braces are used only to enclose the elements of list/ranges. The list can be a set,
order pair or even a matrix.
1
Limit and Continuity
In [2]: = Limit [ 3+ x , x →1 ]
Out [2] = 4
In [3]: = Limit
[ ( 5 ∗ x3 +3 ∗ x )
x
, x →0 ]
Out [3] = 3
In [4]: = Limit
[ (√ x − 4 )
( x −6 )
,x →9
]
−1
Out [4] =
3
In [8]: = Limit
Out [8] = 4
[ ( x − √ 8− x 2)
( √ x 2 +12− 4 )
, x→2
]
In [9]: = Limit [ ( x 8 −256 )
( x − 2)
, x →1 ]
Out [9] = 255
In [14]: = Limit
[ ( x 2+ 7∗ x+ 3 )
( 9∗ x 2+7 ∗ x+ 2)
, x →1
]
11
Out [14] =
18
In [16]: = Limit [ ( √ x −1 − √ x ) , x → 1 ]
Out [16] =−1
In [17]: = Limit
[ ( √ x 2 +1 )
( x+ 1)
, x→∞
]
Out [17]: =1
2
3
Limit of Trigonometric Function
In [1]: = Limit [ sin [ x ]
x
, x→0 ]
Out [1] =1
In [3]: = Limit [ sin [ 3 x ]
sin [ 4 x ]
,x →0
]
3
Out [3] =
4
[
In [4]: = Limit tan [ 4 ∗ x ] −
3∗x
( 3 ∗ x −sin [ 3 ∗ x ] )
, x→0
]
Out [4] =− ∞
[ ]
( sin [ x ] − cos [ x ] ) π
Limit ,x →
In [5]: =
(x − π4 ) 4
Out [5] =√ 2
4
Some Graphs of Limits
GraphicsRow [Plot [Sin[x]/x, {x,-2, 2}]}]
GraphicsRow [Plot [Sin[x]/x^2, {x,-2, 2}]}]
5
One Sided Limits
In [1]: = (*From the left*) Limit [ sin [ x ]
x
2
, x → 0 , Direction→1
]
Out [1] =− ∞
In [2]: =(*From the left*) Limit [ sin [ x ]
x
2
, x → 0 , Direction →− 1
]
Out [2] =∞
In [3]: =(*From the left*) Limit [ x
|[ x ]|
, x →0 , Direction → 1
]
Out [3] =−1
In [4]: =(*From the left*) Limit [|[ ]|
x
x
, x →0 , Direction→ −1
]
Out [4] =∞
6
Differentiation
Derivatives
In [1]: = D [ 4 ∗ x +4 , x ]
Out [1] =4
In [2]: = D [ √ [ x ] , x ]
1
Out [2] =
2√ x
In [3]: = D [ 4 ∗ x 10 +4 ∗ x 5 −10 , x ]
Out [3] =20 x 4 +40 x 9
In [4]: = D [ ( x 4 + 3∗ x )( 5 ∗ x 4 − x ) , x ]
Out [4] =( − 1+ 20 x 3 )( 3 x + x 4 ) + ( 3+ 4 x 3)( − x +5 x 4 )
In [5]: = D [ sin [ x ] , x ]
Out [5] =cos [ x ]
In [6]: = D [ cos [ x ] , x ]
Out [6] =− sin [ x ]
Out [7] = ⅇ x
In [7]: = D [ exp [ x ] , x ]
In [8]: = D [ log [ x ] , x ]
1
Out [8] =
x
In [9]: ={sin' [ x ] ,cos ' [ x ] }
Out [9] ={cos [ x ] , −sin [ x ] }
7
8
Application of Derivatives
Maxima and Minima
In [1]: = Minimize [ 9 ∗ x 4 − 36 ∗ x +16 , x ]
Out [1] ={−11 , { x → 1 }}
In [2]: = Maximize [ −9 ∗ x 4 − 36 ∗ x +16 , x ]
Out [ 2] ={43 , {x → −1 }}
9
Some Graphs of Derivatives
Plot [ x , { x , −2,2 } ]
2
Plot [ 6 −2 ∗ x − x ,{x , −5,3 }]
2
10
Plot [ x 3 , {x , −1,1 }]
Plot [ −2 ∗ x +6 ∗ x −3 , { x , −4,5 }]
3 2
11
Plot [ x −2 ∗ x − 3 ,{ x , −10,10 }]
4 2
Plot [ x 4 −7 ∗ x 2 +3 , { x , −3,5 } ]
12
Integration
In [1]: = Integrate [ ( x+3 ) , x ]
x2
Out [1] =3 x+
2
In [2]: = ∫ ( x+ 9 ) ⅆx
x2
Out [2] =9 x +
2
In [3]: = Integrate
[ ( 4 ∗ x 3 +2 ∗ x +5 )
x
2
,x
]
−5
Out [3] = +2 x 2 +2 log [ x ]
x
13
Definite integrals
In [1]: = Integrate [ ( x+6 ) , { x , 0,2 } ]
Out [2] =14
In [2]: = Integrate [ sin [ x ] , { x , 0 , π }]
Out [2] =2
In [3]: = Integrate [ 2 ∗ x ( x2 +6 ) , {x , 0,2}]
Out [3] =32
In [5]: = Integrate [ √16 − x 2 , { x ,0,4 } ]
Out [5] =4 π
14
Improper Integrals
In [1]: =∫ ⅆ
2
ⅆx
0 ( x +2 )
2
π
Out [1] =
√2
1
2
In [6]: =∫ ❑ ⅆx
0 √x
Out [6] =4
∞
2
In [7]: = ∫ ❑ ⅆx
−∞ ( 1+ x 2)
Out [7] =2 π
15
Part A: MATLAB (Matrix Laboratory)
Introduction
MATLAB is a multi-paradigm numerical computing environment and proprietary
programming language developed by Math Works. MATLAB allows matrix
manipulations, plotting of functions and data, implementation of algorithms,
creation of user interfaces and interfacing with programs written in other
languages. For example: C, C++, Java, Python, FORTRAN, etc. Moreover,
MATLAB is an interactive matrix-based system for scientific and engineering
numerical computation as well as visualization. It is a high-level programming
language.
When the MATLAB software is started, a window is opened. MATLAB uses three
primary windows:
i. Command window: It is used to enter commands and data. ii. Graphics window:
It is used to display plots and graphs. iii. Edit window: It is used to create and
edit
files.
The main part is the command window. In the command window, we see “>>” i.e.
called command prompt.
If we type
>> 8 + 5
Press Enter
MATLAB will display: -
Ans =13
16
Assigning Scalars, Array, Vectors & Matrix
>> x=4
x=
>> a=[1 2 3 4]
a=
1 2 3 4
>> b=[1; 2; 3; 4]
b=
1
2
3
4
>> A=[1 2 3; 4 3 2; 5 6
7]
A=
1 2 3
4 3 2
5 6 7
17
>> A=[1 2 3
432
5 6 7]
A=
1 2 3
4 3 2
5 6 7
>> A(1, 2)
ans =
18
Linear Programming
>>F=[-7; -5];
>>b=[6; 6; 0; 0];
>>A=[1 2; 4 3; -1 0; 0 -1];
>>[x, fmin]= linprog(f, A, b)
Optimal solution found.
X=
1.5000
0
fmin=
-10.5000
19
Simpson’s 1/3 Rule
f = @(x)(1/(1+x^2));
a = 0;
b = 1;
n = 4;
h = (b-a)/n;
s=(f(a)+f(b));
for i=1:n-1
s=s+4*f(a+i*h);
end
for k=2:2:n-2;
s=s-2*f(a+k*h);
end
I=(h/3)*s
>>Simpson
I=
0.7854
20
Trapezodial Rule
f = @(x) sin (x);
a = 0;
b = pi;
n = 4;
h = (b-a)/n;
s=0.5*(f(a)+f(b));
for i=1:n-1
s=s+f(a+i*h);
end
I=h*s
>>Trapezodial
I=
1.8961
21