Pages
Wednesday, 30 December 2015
Sunday, 23 August 2015
Monday, 20 July 2015
Thursday, 2 July 2015
Contact Me
To,
Students/Parents/Guardians:
For queries fill following form
Thanks for your questions. I will reply to E-mail Add provided by you.
Tuesday, 30 June 2015
Saturday, 6 June 2015
MATLAB Code and Algorithms
Dear Student, Here you can find MATLAB code of some numerical techniques. You can modify the code if you find error in execution!!
BISECTION Algorithm:
>> x = [-3:0.1:3];
>> y = fnroot(x);
>> plot(x,y);
>> grid on;
>> ylabel('x^3 - x -1');
>> xlabel('x');
>> title('Graph of f(x) cuts x-axis');
>> ylabel('f(x)=x^3 - x -1');
>> x = [-3:0.1:3];
>> y = fnroot(x);
>> plot(x,y);
>> grid on;
>> ylabel('x^3 - x -1');
>> xlabel('x');
>> title('Graph of f(x) cuts x-axis');
>> ylabel('f(x)=x^3 - x -1');
function y = fnroot(x)
y = x.^3-x-1;
end
function [ c,err ] = bisectf(f,a,b,E)
fa = feval(f,a);
fb = feval(f,b);
for i=1 : 30
c(i) =(a+b)/2;
fc = feval(f,c(i));
err(i)= abs(a-b);
if abs(fc) < E
break
else if fa * fc < 0
b = c(i);
fb = fc;
else
a = c(i);
fa = fc;
end
end
end
end
>> [c ,err] = bisectf('fnroot',0,2,0.005);
>> [c' err']
ans =
1.0000 2.0000
1.5000 1.0000
1.2500 0.5000
1.3750 0.2500
1.3125 0.1250
1.3438 0.0625
1.3281 0.0313
1.3203 0.0156
1.3242 0.0078
NEWTON RAPHSON Algorithm
y = x.^3-x-1;
end
function y = df(x)
y = 3*x*x-1;
end
function [ n,c ] = ntr(f,df,a,E)
fa = feval(f,a);
dfa = feval(df,a);
for i=1 : 30
c(i) = a - fa/dfa;
fa = feval(f,c(i));
n(i) = i;
if abs(fa) < E
break
else if abs(a - c(i))< E
break
else
dfa = feval(df,c(i));
a = c(i);
end
end
end
end
>> [n,root]=ntr('fnroot','df',1,0.0005);
>> [n' root']
ans =
1.0000 1.5000
2.0000 1.3478
3.0000 1.3252
4.0000 1.3247
NEWTON'S FORWARD DIFFERENCE Interpolation Algorithm (File Name Forward_D.m)
x = input('Equidistant values of x:');
y = input('Values of y for each x:');
n = length(x);
d = zeros(n);
for i=1:n
d(i,1)=y(i);
end
for j=2:n
for i=1:n-(j-1)
d(i,j)=d(i+1,j-1)-d(i,j-1);
end
end
D = [x',d];
fprintf('The Forward Difference Table\n');
disp(D);
%disp(d);
a = input('Enter value of x to find y:');
h = x(2)-x(1);
product =1;
sum = d(1,1);
p = (a-x(1))/h;
for j=2:n
product = product * (p-(j-2))/(j-1);
sum = sum + product*d(1,j);
end
>> Forward_D
Equidistant values of x:[0 1 2 3]
Values of y for each x:[1 0 1 10]
The Forward Difference Table
0 1 -1 2 6
1 0 1 8 0
2 1 9 0 0
3 10 0 0 0
Enter value of x to find y:4
The Interpolating value y(4) is 33.000000
Solution to Linear System of Equation AX = b
Gauss Jacobi Algorithm
>> A = [10 -2 -1 -1;-2 10 -1 -1;-1 -1 10 -2;-1 -1 -2 10];
>> b = [3;15;27;-9];
>> A
A =
10 -2 -1 -1
-2 10 -1 -1
-1 -1 10 -2
-1 -1 -2 10
>> b
b =
3
15
27
-9
>>
function x = jacobinew( A,b,M,E)
n = length(b);
fprintf('The Solution to sytem of equation AX = b is \n');
for i=1:n
if i==1
B(i,:)=[A(i,2),A(i,3:n)]*(-1/A(i,i));
else if i==n
B(i,:)=[A(i,1:n-1)]*(-1/A(i,i));
else
B(i,:)=[A(i,1:i-1),A(i,i+1:n)]*(-1/A(i,i));
end
end
end
for i=1:n
C(i)=b(i)*(1/A(i,i));
end
C = C';
x = zeros(n,1);
u = zeros(n,1);
y = zeros(n);
temp = 0;
for j=2:M
for i=1:n
if i==1
y(i,j)= B(i,:)*u(2:n)+C(i);
x(i)=B(i,:)*u(2:n)+C(i);
else if i==n
y(i,j)=B(i,:)*u(1:n-1)+C(i);
x(i)=B(i,:)*u(1:n-1)+C(i);
else
w = [u(1:i-1);u(i+1:n)];
y(i,j)=B(i,:)*w+C(i);
x(i)=B(i,:)*w+C(i);
end
end
end
u = x;
disp(x')
for i=1:n
if abs(y(i,j)-y(i,j-1)) > E
temp = temp + 1;
end
end
if temp ==0
break;
end
temp = 0;
end
end
The Solution to sytem of equation AX = b is
0.3000 1.5000 2.7000 -0.9000
0.7800 1.7400 2.7000 -0.1800
0.9000 1.9080 2.9160 -0.1080
0.9624 1.9608 2.9592 -0.0360
0.9845 1.9848 2.9851 -0.0158
0.9939 1.9938 2.9938 -0.0060
0.9975 1.9975 2.9976 -0.0025
0.9990 1.9990 2.9990 -0.0010
0.9996 1.9996 2.9996 -0.0004
>> x = jacobinew(A,b,15,0.0001);
The Solution to sytem of equation AX = b is
0.3000 1.5000 2.7000 -0.9000
0.7800 1.7400 2.7000 -0.1800
0.9000 1.9080 2.9160 -0.1080
0.9624 1.9608 2.9592 -0.0360
0.9845 1.9848 2.9851 -0.0158
0.9939 1.9938 2.9938 -0.0060
0.9975 1.9975 2.9976 -0.0025
0.9990 1.9990 2.9990 -0.0010
0.9996 1.9996 2.9996 -0.0004
0.9998 1.9998 2.9998 -0.0002
0.9999 1.9999 2.9999 -0.0001
>> x = jacobinew(A,b,15,0.00001);
The Solution to sytem of equation AX = b is
0.3000 1.5000 2.7000 -0.9000
0.7800 1.7400 2.7000 -0.1800
0.9000 1.9080 2.9160 -0.1080
0.9624 1.9608 2.9592 -0.0360
0.9845 1.9848 2.9851 -0.0158
0.9939 1.9938 2.9938 -0.0060
0.9975 1.9975 2.9976 -0.0025
0.9990 1.9990 2.9990 -0.0010
0.9996 1.9996 2.9996 -0.0004
0.9998 1.9998 2.9998 -0.0002
0.9999 1.9999 2.9999 -0.0001
1.0000 2.0000 3.0000 -0.0000
1.0000 2.0000 3.0000 -0.0000
1.0000 2.0000 3.0000 -0.0000
>>
Gauss Seidel Algorithm
function x = gseidel(A,b,M,E)
n = length(b);
fprintf('The Solution to system of equation AX = b is \n');
for i=1:n
if i==1
B(i,:)=[A(i,2:n)]*(-1/A(i,i));
else if i==n
B(i,:)=[A(i,1:n-1)]*(-1/A(i,i));
else
B(i,:)=[A(i,1:i-1),A(i,i+1:n)]*(-1/A(i,i));
end
end
end
for i=1:n
C(i)=b(i)/A(i,i);
end
C = C';
x =zeros(n,1);
y = zeros(n);
temp = 0;
for j= 2:M
for i=1:n
if i==1
x(i) = B(i,:)*x(2:n)+C(i);
else if i==n
x(i)=B(i,:)*x(1:n-1)+C(i);
else
x(i)=B(i,:)*[x(1:i-1);x(i+1:n)]+C(i);
end
end
y(i,j) = x(i);
end
for i=1:n
if abs(y(i,j)-y(i,j-1)) > E
temp = temp + 1;
end
end
if temp ==0
break;
end
disp(x');
temp = 0;
end
end
>> x = gseidel(A,b,15,0.001);
The Solution to system of equation AX = b is
0.3000 1.5600 2.8860 -0.1368
0.8869 1.9523 2.9566 -0.0248
0.9836 1.9899 2.9924 -0.0042
0.9968 1.9982 2.9987 -0.0008
0.9994 1.9997 2.9998 -0.0001
>> x = gseidel(A,b,15,0.00001);
The Solution to system of equation AX = b is
0.3000 1.5600 2.8860 -0.1368
0.8869 1.9523 2.9566 -0.0248
0.9836 1.9899 2.9924 -0.0042
0.9968 1.9982 2.9987 -0.0008
0.9994 1.9997 2.9998 -0.0001
0.9999 1.9999 3.0000 -0.0000
1.0000 2.0000 3.0000 -0.0000
1.0000 2.0000 3.0000 -0.0000
>>
Numerical Integration Algorithm
function t = f(x)
t = (1+x).^(-1);
end
function I = simpson13(y,n,h)
sum13 = y(1)+y(n+1);
for i=2:n
if rem(i,2)==0
sum13 = sum13 + 4*y(i);
else
sum13 = sum13 + 2*y(i);
end
I = (h/3)*sum13;
end
function I = Simpson38(y,n,h)
sum38 = y(1)+y(n+1);
for i=2:n
if rem(i-1,3)==0
sum38 = sum38 + 2*y(i);
else
sum38 = sum38 + 3*y(i);
end
end
I = (3*h/8)*sum38;
end
function I = trapz(y,n,h)
sumtr = y(1)+y(n+1);
for i=2:n
sumtr = sumtr + 2*y(i);
end
I = (h/2)*sumtr;
end
function Itg = NumInteg(f)
a = input('Enter lower limit of integration:');
b = input('Enter Upper limit of integration:');
n = input('Number of Intervals:');
h = (b-a)/n;
x = a:h:b;
y = feval(f,x);
fprintf('Table values of (x,y) is\n');
[x' y']
fprintf('The Function is f(x) = 1/(1+x)\n');
if mod(n,2)== 0
fprintf('Simpson 1/3 Rule:\n');
Itg = simpson13(y,n,h);
elseif mod(n,3) == 0
fprintf('Simpson 3/8 Rule:\n');
Itg = Simpson38(y,n,h);
else
fprintf('Trapezoidal Rule:\n');
Itg = trapz(y,n,h);
end
>> I = NumInteg('f')
Enter lower limit of integration:0
Enter Upper limit of integration:1
Number of Intervals:4
Table values of (x,y) is
ans =
0 1.0000
0.2500 0.8000
0.5000 0.6667
0.7500 0.5714
1.0000 0.5000
The Function is f(x) = 1/(1+x)
Simpson 1/3 Rule:
I =
0.6933
>> I = NumInteg('f')
Enter lower limit of integration:0
Enter Upper limit of integration:1
Number of Intervals:6
Table values of (x,y) is
ans =
0 1.0000
0.1667 0.8571
0.3333 0.7500
0.5000 0.6667
0.6667 0.6000
0.8333 0.5455
1.0000 0.5000
The Function is f(x) = 1/(1+x)
Simpson 1/3 Rule:
I =
0.6932
>> I = NumInteg('f')
Enter lower limit of integration:0
Enter Upper limit of integration:1
Number of Intervals:7
Table values of (x,y) is
ans =
0 1.0000
0.1429 0.8750
0.2857 0.7778
0.4286 0.7000
0.5714 0.6364
0.7143 0.5833
0.8571 0.5385
1.0000 0.5000
The Function is f(x) = 1/(1+x)
Trapezoidal Rule:
I =
0.6944
>>
Dear Student, you can download here Simple Algorithms of some numerical techniques that you know. You can use them to write a simple C/C++ program or MATLAB Program.
Friday, 5 June 2015
Basic Mathematics
Dear Student, you can find here the discussions on topics of Elementary Mathematics. This notes are constructed for students of CHARUSAT studying in courses: First Semester B Pharm, First Semester B. Sc. as per prescribed syllabus and teaching scheme.
I have referred several text book to construct these notes. In many places I have compiled the material available in textbooks that discuss the theories (without proof!) and concepts described by author/s. Interested students can read in more details about the topic/s from the Book mentioned here. Also students can download the PDF document of topics which I have not posted here. At the end I am collecting the exercise problems,some Quiz questions from these resources for practice purpose.
Send your comments and suggestions for better improvement in these posts if any!!!
Thank You all
Few Books that are used:
- "Naive Set Theory": By Paul R Halmos, Van Nostrand Reinhold Comp
- "Sets, Functions, and Logic An Introduction to Abstract Mathematics": By Keith Devlin, Chapman & Hall/CRC
- "The Mathematics of Matrices" A First Book of Matrix Theory and Linear Algebra, by Philip J. Davis,John Wiley and Sons, Inc. Second Edition
- "Theory and Problems of Set Theory and Related Topics" by Seymour Lipschutz, Schaum's Outline Series,Second Edition
- "Calculus and Analytical Geometry" by Thomas G B and R. L. Finney, Addison Wesley $9^{th}$ Edition
- "Advanced Engineering Mathematics" by Erwin Kreyszig, John Wiley and Sons, India $8^{th}$ Edition
- Numbers and Set Theory Introduction
- Relations and Functions Introduction only (Contains Some Quiz Questions)
- Introduction to Matrices Some Basics
- Introduction to Determinants (Upto Order 3 only)
Solution to the Questions will be displayed at the end of topic discussion.
Relations and Functions
Dear Student after discussion of Sets and related properties of Sets, We shall now discuss the Relations and Functions.
Ordered Pairs
Suppose, for instance, that the set $A= \{a, b, c, d\}$ of distinct elements, and suppose that we want to consider its elements in the order $cb d a$. We may have the sets $\{c\}, \{c, b\}, \{c, b, d\}, \{c, b, d, a\}$. We can go on then to consider the set (or collection) ,
$ $$\mathcal{C}$$ = \{\{a,b, c, d\}, \{b,c\}, \{b, c, d\}, \{c\}\}$
If $A =\{a, b\}$ and if, in the desired order, $a$ comes first, then $ $$\mathcal{C}$$= \{\{a\}, \{a, b\}\}$; if, however, $b$ comes first, then $ $$\mathcal{C}$$= \{\{b\}, \{a, b\}\}$
The ordered pair of $a$ and $b$, with first coordinate $a$ and second coordinate $b$, is the set $(a, b)$ defined by $(a, b) = \{\{a\}, \{a, b\}\}$.
Note that
If $(a, b)$ and $(x, y)$ are ordered pairs and if $(a, b) = (x, y)$, then $a = x$ and $b = y$.
Cartesian product of $A$ and $B$ is characterized by $A \times B= \{ x \mid x =(a, b)$ for some $a \in A$ and for some $b \in B\}$.
The Cartesian product of two sets is a set of ordered pairs (that is, a set each of whose elements is an ordered pair), and the same is true of every subset of a Cartesian product.
For example, if $A = \{1, 2\}$ and $B = \{2, 3, 4\}$, then $A \times B = \{(1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4)\}$ and $B \times A = \{(2, 1), (2, 2), (3, 1), (3, 2), (4, 1), (4, 2)\}$
Therefore , for instance, we have $(1, 2) \in A\times B$ and $(1, 2) \notin B \times A$
If $A, B, C$, and $D$ are sets, then
(i) $(A \cup B)\times C = (A \times C) \cup (B\times C)$,
(ii) $(A \cap B) \times (C \cap D) = (A \times C) \cap (B\times D)$
(iii) $(A- B) \times C = (A\times C) - (B\times C)$
If either $A = \varnothing $ or $B = \varnothing $, then $A\times B =\varnothing $, and conversely. If $A \subset C, B \subset D$, then $A \times B \subset C \times D$, and (provided $A \times B \neq \varnothing$) conversely.
RELATIONS:
A set $R$ is a relation if each element of $R$ is an ordered pair; this means, if $z \in R$, then there exist $x$ and $y$ so that $z = (x, y)$ . If $R$ is a relation, it is sometimes convenient to express the fact that $(x,y)\in R$ by writing $x R y$ For example: let $A$ be any set, and let $R$ be the set of all those pairs $(x, y)$ in $ A \times A $ for which $x = y$. The relation $R$ is just the relation of equality between elements of $A$; if $x$ and $y$ are in $A$, then $x R y$ means the same as $x = y$.
Domain and Range of $R$: We define dom $R = \{ x \mid $ for some $y (x R y)\}$ and Range $R = \{ y \mid $ for some $x (x R y)\}$
Both the domain and the range of $\varnothing$ are equal to $\varnothing$. If $R = A\times B$, then dom $R = A$ and ran $R = B$. If $R$ is equality in $A$, then dom $R = $ range $R = A$
If $ R $ is belonging, between $A$ and $ $$\mathcal{P}$$ (A) $, then dom $R = A$ and ran $R = $$\mathcal{P}$$ (A) - \{\varnothing\}$
If $R$ is a relation included in a Cartesian product $A\times B$ (so that dom $R \subset A$ and ran $R \subset B$), it is sometimes convenient to say that $R$ is a relation from $A$ to $B$; instead of a relation from $A$ to $A$ we may speak of a relation in $A$. A relation $R$ in $A$ is reflexive if $x R x$ for every $x$ in $A$; it is symmetric if $x R y$ implies that $y R x$; and it is transitive if $x R y$ and $y R z$ imply that $x R z$.
FUNCTIONS
If $A$ and $B$ are sets, a, function from (or on) $A$ to (or into) $B$ is a relation $f$ such that dom $f = A$ and such that for each $x$ in $A$ there is a unique element $y$ in $B$ with $(x, y) \in f $. The uniqueness condition can be formulated explicitly as follows: if $(x, y) \in f $ and $(x, z) \in f $, then $y = z$. For each $x$ in $A$, the unique $y$ in $B$ such that $(x, y) \in f $ is denoted by $f(x)$. From now on, if $f$ is a function, we shall write $f(x) = y$ instead of $(x, y) \in f $ or $x f y$. The element $y$ is called the value that the function $f$ assumes (or takes on) at the argument $x$; equivalently we may say that $f$ sends or maps or transforms $x$ onto $y$. The words map or mapping, transformation, correspondence, and operator are among some of the many that are sometimes used as synonyms for function. The symbol $f:A \rightarrow B $ is sometimes used as an abbreviation for "$f$ is a function from $A$ to $B$." The set of all functions from $A$ to $B$ is a subset of the power set $ $$\mathcal{P}$$(A \times B)$; it will be denoted by $B^{A}$.
The domain of a function $f$ from $A$ into $B$ is, by definition, equal to $A$, but its range need not be equal to $B$; the range consists of those elements $y$ of $B$ for which there exists an $x$ in $A$ such that $f(x) = y$. If the range of $f$ is equal to $B$, we say that $f$ maps $A$ onto $B$. If $E$ is a subset of $A$, we may want to consider the set of all those elements $y$ of $B$ for which there exists an $x$ in the subset $E$ such that $f(x) = y$. This subset of $B$ is called the image of $E$ under $f$ and is frequently denoted by $f(E)$. (this means we consider the set of values of $f$ at the elements of $E$ ). Note that the image of $A$ itself is the range of $f$; the "onto" character of $f$ can be expressed by writing $f(A) = B$.
If $A$ is a subset of a set $B$, the function $f$ defined by $f(x) = x$ for each $x$ in $A$ is called the inclusion map (or the embedding, or the injection) of $A$ into $B$. The inclusion map of $A$ into $A$ is called the identity map on $A$.
If $f$ is a function from $B$ to $C$, say, and if $A$ is a subset of $B$, then there is a natural way of constructing a function $g$ from $A$ to $C$; define $g(x)$ to be equal to $f(x)$ for each $x$ in $A$. The function $g$ is called the restriction of $f$ to $A$, and $f$ is called an extension of $g$ to $B$; The definition of restriction can be expressed by writing $(f \mid A)(x) = f(x)$ for each $x$ in $A$; observe also that ran $(f \mid A) = f(x) $.
A function that always maps distinct elements onto distinct elements is called one-to-one (usually a one-to-one correspondence).
INVERSE FUNCTION
Associated with every function $f$, from $A$ to $B$, say, there is a function from $ $$\mathcal{P}$$ (A) $ to $ $$\mathcal{P}$$ (B)$, namely the function (frequently called $f$ also) that assigns to each subset $E$ of $A$ the image subset $f(E)$ of $B$.
Given a function $f$ from $A$ to $B$, let $f^{-1}$, the inverse of $f$, be the function from $ $$\mathcal{P}$$ (B)$ to $ $$\mathcal{P}$$ (A) $ such that if $D \subset B$ , then $f^{-1}(D) = \{x \in A \mid f(x) \in D \}$.
In words: $f^{-1}(D)$ consists of exactly those elements of $A$ that $f$ maps into $D$; the set $f^{-1}(D)$ is called the inverse image of $D$ under $f$. A necessary and sufficient condition that $f$ map $A$ onto $B$ is that the inverse image under $f$ of each non-empty subset of $B$ be a non-empty subset of $A$.
Sample Quiz Questions
Back to Basic Mathematics
Ordered Pairs
Suppose, for instance, that the set $A= \{a, b, c, d\}$ of distinct elements, and suppose that we want to consider its elements in the order $cb d a$. We may have the sets $\{c\}, \{c, b\}, \{c, b, d\}, \{c, b, d, a\}$. We can go on then to consider the set (or collection) ,
$ $$\mathcal{C}$$ = \{\{a,b, c, d\}, \{b,c\}, \{b, c, d\}, \{c\}\}$
If $A =\{a, b\}$ and if, in the desired order, $a$ comes first, then $ $$\mathcal{C}$$= \{\{a\}, \{a, b\}\}$; if, however, $b$ comes first, then $ $$\mathcal{C}$$= \{\{b\}, \{a, b\}\}$
The ordered pair of $a$ and $b$, with first coordinate $a$ and second coordinate $b$, is the set $(a, b)$ defined by $(a, b) = \{\{a\}, \{a, b\}\}$.
Note that
If $(a, b)$ and $(x, y)$ are ordered pairs and if $(a, b) = (x, y)$, then $a = x$ and $b = y$.
Cartesian product of $A$ and $B$ is characterized by $A \times B= \{ x \mid x =(a, b)$ for some $a \in A$ and for some $b \in B\}$.
The Cartesian product of two sets is a set of ordered pairs (that is, a set each of whose elements is an ordered pair), and the same is true of every subset of a Cartesian product.
For example, if $A = \{1, 2\}$ and $B = \{2, 3, 4\}$, then $A \times B = \{(1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4)\}$ and $B \times A = \{(2, 1), (2, 2), (3, 1), (3, 2), (4, 1), (4, 2)\}$
Therefore , for instance, we have $(1, 2) \in A\times B$ and $(1, 2) \notin B \times A$
If $A, B, C$, and $D$ are sets, then
(i) $(A \cup B)\times C = (A \times C) \cup (B\times C)$,
(ii) $(A \cap B) \times (C \cap D) = (A \times C) \cap (B\times D)$
(iii) $(A- B) \times C = (A\times C) - (B\times C)$
If either $A = \varnothing $ or $B = \varnothing $, then $A\times B =\varnothing $, and conversely. If $A \subset C, B \subset D$, then $A \times B \subset C \times D$, and (provided $A \times B \neq \varnothing$) conversely.
RELATIONS:
A set $R$ is a relation if each element of $R$ is an ordered pair; this means, if $z \in R$, then there exist $x$ and $y$ so that $z = (x, y)$ . If $R$ is a relation, it is sometimes convenient to express the fact that $(x,y)\in R$ by writing $x R y$ For example: let $A$ be any set, and let $R$ be the set of all those pairs $(x, y)$ in $ A \times A $ for which $x = y$. The relation $R$ is just the relation of equality between elements of $A$; if $x$ and $y$ are in $A$, then $x R y$ means the same as $x = y$.
Domain and Range of $R$: We define dom $R = \{ x \mid $ for some $y (x R y)\}$ and Range $R = \{ y \mid $ for some $x (x R y)\}$
Both the domain and the range of $\varnothing$ are equal to $\varnothing$. If $R = A\times B$, then dom $R = A$ and ran $R = B$. If $R$ is equality in $A$, then dom $R = $ range $R = A$
If $ R $ is belonging, between $A$ and $ $$\mathcal{P}$$ (A) $, then dom $R = A$ and ran $R = $$\mathcal{P}$$ (A) - \{\varnothing\}$
If $R$ is a relation included in a Cartesian product $A\times B$ (so that dom $R \subset A$ and ran $R \subset B$), it is sometimes convenient to say that $R$ is a relation from $A$ to $B$; instead of a relation from $A$ to $A$ we may speak of a relation in $A$. A relation $R$ in $A$ is reflexive if $x R x$ for every $x$ in $A$; it is symmetric if $x R y$ implies that $y R x$; and it is transitive if $x R y$ and $y R z$ imply that $x R z$.
FUNCTIONS
If $A$ and $B$ are sets, a, function from (or on) $A$ to (or into) $B$ is a relation $f$ such that dom $f = A$ and such that for each $x$ in $A$ there is a unique element $y$ in $B$ with $(x, y) \in f $. The uniqueness condition can be formulated explicitly as follows: if $(x, y) \in f $ and $(x, z) \in f $, then $y = z$. For each $x$ in $A$, the unique $y$ in $B$ such that $(x, y) \in f $ is denoted by $f(x)$. From now on, if $f$ is a function, we shall write $f(x) = y$ instead of $(x, y) \in f $ or $x f y$. The element $y$ is called the value that the function $f$ assumes (or takes on) at the argument $x$; equivalently we may say that $f$ sends or maps or transforms $x$ onto $y$. The words map or mapping, transformation, correspondence, and operator are among some of the many that are sometimes used as synonyms for function. The symbol $f:A \rightarrow B $ is sometimes used as an abbreviation for "$f$ is a function from $A$ to $B$." The set of all functions from $A$ to $B$ is a subset of the power set $ $$\mathcal{P}$$(A \times B)$; it will be denoted by $B^{A}$.
The domain of a function $f$ from $A$ into $B$ is, by definition, equal to $A$, but its range need not be equal to $B$; the range consists of those elements $y$ of $B$ for which there exists an $x$ in $A$ such that $f(x) = y$. If the range of $f$ is equal to $B$, we say that $f$ maps $A$ onto $B$. If $E$ is a subset of $A$, we may want to consider the set of all those elements $y$ of $B$ for which there exists an $x$ in the subset $E$ such that $f(x) = y$. This subset of $B$ is called the image of $E$ under $f$ and is frequently denoted by $f(E)$. (this means we consider the set of values of $f$ at the elements of $E$ ). Note that the image of $A$ itself is the range of $f$; the "onto" character of $f$ can be expressed by writing $f(A) = B$.
If $A$ is a subset of a set $B$, the function $f$ defined by $f(x) = x$ for each $x$ in $A$ is called the inclusion map (or the embedding, or the injection) of $A$ into $B$. The inclusion map of $A$ into $A$ is called the identity map on $A$.
If $f$ is a function from $B$ to $C$, say, and if $A$ is a subset of $B$, then there is a natural way of constructing a function $g$ from $A$ to $C$; define $g(x)$ to be equal to $f(x)$ for each $x$ in $A$. The function $g$ is called the restriction of $f$ to $A$, and $f$ is called an extension of $g$ to $B$; The definition of restriction can be expressed by writing $(f \mid A)(x) = f(x)$ for each $x$ in $A$; observe also that ran $(f \mid A) = f(x) $.
A function that always maps distinct elements onto distinct elements is called one-to-one (usually a one-to-one correspondence).
INVERSE FUNCTION
Associated with every function $f$, from $A$ to $B$, say, there is a function from $ $$\mathcal{P}$$ (A) $ to $ $$\mathcal{P}$$ (B)$, namely the function (frequently called $f$ also) that assigns to each subset $E$ of $A$ the image subset $f(E)$ of $B$.
Given a function $f$ from $A$ to $B$, let $f^{-1}$, the inverse of $f$, be the function from $ $$\mathcal{P}$$ (B)$ to $ $$\mathcal{P}$$ (A) $ such that if $D \subset B$ , then $f^{-1}(D) = \{x \in A \mid f(x) \in D \}$.
In words: $f^{-1}(D)$ consists of exactly those elements of $A$ that $f$ maps into $D$; the set $f^{-1}(D)$ is called the inverse image of $D$ under $f$. A necessary and sufficient condition that $f$ map $A$ onto $B$ is that the inverse image under $f$ of each non-empty subset of $B$ be a non-empty subset of $A$.
A necessary and sufficient condition that $f$ be one-to-one is that the inverse image under $f$ of each singleton in the range of $f$ be a singleton in $A$, alternatively the function whose domain is the range of $f$, and whose value for each $y$ in the range of $f$ is the unique $x$ in $A$ for which $f(x) = y$. In other words, for one-to-one functions $f$ we may write $f^{-1}(y) = x$ if and only if $f(x) = y$. Note that if $D \subset B$ then $f(f^{-1}(D)) \subset D$
COMPOSITE FUNCTION
If $f$ is a function from $A$ to $B$ and $g$ is a function from $B$ to $C$, then every element in the range of $f$ belongs to the domain of $g$, and, consequently, $g(f(x))$ makes sense for each $x$ in $A$. The function $h$ from $A$ to $C$, defined by $h(x) = g(f(x))$ is called the composite of the functions $f$ and $g$; it is denoted by $ g \circ f $ or, more simply, by $gf$,
Examples of Functions
- $f :$$\mathcal{R}$$ \rightarrow $$\mathcal{R}$$ $ defined by polynomials, such as the example $f (x) = x^{2} + x + 1$
- The rational functions $f :$$\mathcal{R}$$ \rightarrow $$\mathcal{R}$$ $ such as $f(x) = \dfrac{x^{3}-4x^{2}+x -11}{(x^{2}+1)^{5}}$
- The absolute value $f :$$\mathcal{R}$$ \rightarrow $$\mathcal{R}$$+ $ such as $f(x) = \cases{x & \text{ if } x \geq 0 \\ -x & \text{ if } x < 0}$
- Analytic functions from $f :$$\mathcal{R}$$ \rightarrow $$\mathcal{R}$$ $ such as $f(x) = \sin{x}, f(x) = \log{x}$
Sample Quiz Questions
Back to Basic Mathematics
Wednesday, 3 June 2015
Introduction to MATLAB
Dear Student in this post, I discuss introduction to MATLAB bascis. One can learn MATLAB by following the link in.mathworks.com also.
Introduction
MATLAB(short name for MATrix LABoratory) is a special-purpose computer program optimized to perform engineering and scientific calculations. It started life as a program designed to perform matrix mathematics, but over the years it has grown into a flexible computing system capable of solving essentially any technical problem.
The fundamental unit of data in any MATLAB program is the array.An array is a collection of data values organised into rows and columns, and known by a single name. Individual data values within array may be accessed by including the name of the array followed by subscripts in parentheses that identify the row and column of the particular value.
The MATLAB Desktop
When you start MATLAB, a special window called MATLAB desktop appears. The default configuration of the MATLAB desktop is shown in figure. It integrates many tools for managing files, variables, and applications within the MATLAB environment. The major tools within or accessible from the MATLAB desktop are the following:
The middle of the MATLAB desktop contains the Command Window. A user can enter interactive commands at the command prompt ($\texttt{>>}$)in the Command Window, and they will be executed on the spot.
Suppose you type:
$\texttt{>>}$ area = pi * 2.5^2
area =
19.6350
MATLAB calculates the answer as soon as the Enter key is pressed and stores the answer in a variable ($1 \times 1$ array) called $\texttt{area}$
If a statement is too long to type on a single line, it may be continued on successive lines by typing an $\textbf{ellipsis}$($\ldots$) at the end of the first line, and then continuing the next line. For example, the following two statements are identical.
x1 = 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6;
x1 = 1 + 1/2 + 1/3 + 1/4 ...
+ 1/5 + 1/6;
A series of commands may be placed into a file, and then the entire file may be executed by typing its name in the Command Window. Such files are called $\textbf{script files}$. Script files are also known as M-files because they have a file extension of ".m"
Variables and Arrays
The fundamental unit of data in any MATLAB program is the $\textbf{array}$. Arrays can be classified as either $\textbf{vectors}$ or $\textbf{matrices}$. The $\textbf{size}$ of an array is specified by the number of rows and the number of columns in the array, with the number of rows mentioned first. The total number of elements in the array will be rows $\times$ columns. A MATLAB variable is a region of memory containing an array, which is known by a user-specified name. MATLAB variable names must begin with a letter, followed by any combination of letters,numbers, and the underscore ($\_$)character.
Initializing Variables
There are three common ways to initializing a variable in MATLAB.
See the Video for Assign Statement:
If an assignment statement is typed without the semicolon, the results of the statement are automatically displayed in the Command Window.
Shortcut Expressions: MATLAB provides a special shortcut notations when the array contains hundreds or even thousands of elements. The general expression is $\texttt{first:incr:last}$
Built-in Functions: Arrays can also be initialized using built-in MATLAB FUNCTIONS
$\texttt{zeros(n)}$ Generates an $n \times n$ matrix of zeros.
$\texttt{zeros(n, m)}$ Generates an $n \times m$ matrix of zeros.
$\texttt{zeros(size(arr))}$ Generates a matrix of zeros of the same size as arr.
$\texttt{ones(n)}$ Generates an $n \times n$ matrix of ones.
$\texttt{ones(n, m)}$ Generates an $n \times m$ matrix of ones.
$\texttt{ones(size(arr))}$ Generates a matrix of ones of the same size as arr.
$\texttt{eye(n)}$Generates an $n \times n$ identity matrix.
$\texttt{eye(n, m)}$ Generates an $n \times m$ identity matrix.
$\texttt{length(arr)}$ Returns the length of a vector or the longest dimension of a 2-D array.
$\texttt{size(arr)}$Returns two values specifying the number of rows and columns in arr.
$\texttt{reshape(A,m,n)}$ Rearrange a matrix A that has $r$ rows and $s$ columns to have $m$ rows and $n$ columns. $r \times s$ must be equal to $m \times n$.
$\texttt{diag(v)}$ When v is a vector creates a square matrix with the elements of v in the diagonal.
$\texttt{diag(A)}$ When A is matrix, creates a vector from the diagonal elements of $\texttt{A}$.
$\texttt{length(v)}$ Returns the number of elements in the vector $\texttt{v}$.
Keyboard Input
It is also possible to prompt a user and initialize a variable with data that he or she types directly at the keyboard by using $\texttt{input}$ function.
If $\texttt{input}$ function includes the character 's' as a second argument, then the input data is returned to the user as a character string.
Multidimensional Arrays
Multidimensional Arrays have one subscript for each dimension,and individual element is selected by specifying a value for each subscript. The total number of elements in the array will be the product of the maximum value of each subscript.
SubArrays
To select a portion of an array, just include a list of all the elements to be selected in the parentheses after the array name. When used in array subscript the $\texttt{end}$ function returns the highest value taken by that a subscript.
$\texttt{va(:)}$ Refers to all the elements of the vector $\texttt{va}$ (either a row or a column vector).
$\texttt{va(m:n)}$ Refers to elements $m$ through $n$ of the vector $\texttt{va}$.
$\texttt{A(:,n)}$ Refers to the elements in all the rows of column $n$ of the matrix $\texttt{A}$.
$\texttt{A(n,:)}$ Refers to the elements in all the columns of row $n$ of the matrix $\texttt{A}$.
$\texttt{A(:,m:n)}$ Refers to the elements in all the rows between columns $m$ and $n$ of the matrix $\texttt{A}$.
$\texttt{A(m:n,:)}$ Refers to the elements in all the columns between rows $m$ and $n$ of the matrix $\texttt{A}$.
$\texttt{A(m:n,p:q)}$ & Refers to the elements in rows $m$ through $n$ and columns $p$ through $q$ of the matrix $\texttt{A}$
Display Format and Function
The $\texttt{format}$ command changes the default format. The $\texttt{disp}$ function accepts an array argument and display the value of array in the Command Window. $\texttt{fprintf}$ function displays one or more values together with related text.
Output Display Formats
$\texttt{format short}$ 4 digits after decimal (default format)
$\texttt{format long}$ digits after decimal
$\texttt{format short e}$5 digits plus exponent
$\texttt{format short g}$ 5 total digits with or without exponent
$\texttt{format long e}$ 15 digits plus exponent
$\texttt{format long g }$ 15 total digits with or without exponent
$\texttt{format bank}$ dollars and cents format
$\texttt{format hex}$ hexadecimal display of bits
$\texttt{format rat}$ approximate ratio of small integers
$\texttt{format compact}$ suppress extra line feeds
$\texttt{format loose}$ restore extra line feeds
$\texttt{format +}$ Only the signs of the numbers are printed
Scalar and Array Operations
Calculations are specified in MATLAB with an assignment statement:
$\texttt{variable_name = expression;}$
Array and Matrix Operations
Array Addition : $\texttt{a + b}$ Array addition and matrix addition are identical.
Array Subtraction: $\texttt{a - b}$ Array subtraction and matrix subtraction are identical.
Array Multiplication: $\texttt{a . * b}$ Element-by-element multiplication of $\texttt{a}$ and $\texttt{b}$. Both arrays must be the same shape, or one of them must be a scalar.
Matrix Multiplication: $\texttt{a * b}$ Matrix multiplication of $\texttt{a}$ and $\texttt{b}$. The number of columns in $\texttt{a}$ must equal the number of rows in $\texttt{b}$.
Array Right Division: $\texttt{a . / b}$ Element-by-element division of $\texttt{a}$ and $\texttt{b}$: $\texttt{a (i , j ) / b (i, j )}$. Both arrays must be the same shape, or one of them must be a scalar.
Array Left Division: $\texttt{a . \ b}$ Element-by-element division of $\texttt{a}$ and $\texttt{b}$, but with $\texttt{b}$ in the numerator: $\texttt{b (i, j ) /a (i, j )}$. Both arrays must be the same shape, or one of them must be a scalar.
Matrix Right Division: $\texttt{a / b}$ Matrix division defined by $\texttt{a *inv(b)}$, where $\texttt{inv (b)}$ is the inverse of matrix $\texttt{b}$.
Matrix Left Division: $\texttt{a $\smallsetminus$ b}$ Matrix division defined by $\texttt{inv (a) * b}$, where $\texttt{inv (a)}$ is the inverse of matrix $\texttt{a}$.
Hierarchy of Arithmetic Operations
MATLAB has established a series of rules governing the hierarchy, or order, in which operations are calculated within an expression.
Built-in MATLAB Functions and Constants
One of MATLAB's greatest strengths is that it comes with an incredible variety of built-in functions for use.
$\texttt{pi}$ Contains $\pi$ to 15 significant digits.
$\texttt{i, j}$ Contain the value $i$ $\sqrt{-1}$.
$\texttt{Inf}$ This symbol represents machine infinity. It is usually generated as a result of a division by 0.
$\texttt{NaN}$ This symbol stands for Not-a-Number. It is the result of an undefined mathematical operation, such as the division of zero by zero.
$\texttt{clock}$ This special variable contains the current date and time in the form of a 6-element row vector containing the year, month, day, hour, minute, and second.
$\texttt{date}$ Contains the current data in a character string format, such as $\texttt{24-Nov-1999}$.
$\texttt{eps}$ This variable name is short for epsilon. It is the smallest difference between two numbers that can be represented on the computer.
$\texttt{ans}$ A special variable used to store the result of an expression if that result is not explicitly assigned to some other variable.
Plotting Data (Two dimensional Plots)
To plot a data set, create two vectors containing the $x$ and $y$ values to be plotted, and use the $\texttt{plot}$ function.
Multiple Plots Suppose that we want to plot the function $f(x)=\sin(2x)$ and its derivative $\dfrac{d}{dx}\sin(2x)=2\cos(2x)$
MATLAB Program:MATLAB Script
Temperature conversion Program
The relationship between temperature in degree Fahrenheit $(^{0}F)$ and temperature in kelvin(K) can be given by $T(K) = \dfrac{5}{9}\left(T(^{0}F) - 32.0\right)+273.15$ The evaluation of this formula can be done by creating a script file temp$\_$conversion.m (say)
Introduction
MATLAB(short name for MATrix LABoratory) is a special-purpose computer program optimized to perform engineering and scientific calculations. It started life as a program designed to perform matrix mathematics, but over the years it has grown into a flexible computing system capable of solving essentially any technical problem.
The fundamental unit of data in any MATLAB program is the array.An array is a collection of data values organised into rows and columns, and known by a single name. Individual data values within array may be accessed by including the name of the array followed by subscripts in parentheses that identify the row and column of the particular value.
The MATLAB Desktop
When you start MATLAB, a special window called MATLAB desktop appears. The default configuration of the MATLAB desktop is shown in figure. It integrates many tools for managing files, variables, and applications within the MATLAB environment. The major tools within or accessible from the MATLAB desktop are the following:
- The Command Window
- The Command History Window
- The Edit/Debug Window
- Figure Windows
- Workspace Browser and Array Editor
- Help Browser
- Current Directory Browser
The middle of the MATLAB desktop contains the Command Window. A user can enter interactive commands at the command prompt ($\texttt{>>}$)in the Command Window, and they will be executed on the spot.
Suppose you type:
$\texttt{>>}$ area = pi * 2.5^2
area =
19.6350
MATLAB calculates the answer as soon as the Enter key is pressed and stores the answer in a variable ($1 \times 1$ array) called $\texttt{area}$
If a statement is too long to type on a single line, it may be continued on successive lines by typing an $\textbf{ellipsis}$($\ldots$) at the end of the first line, and then continuing the next line. For example, the following two statements are identical.
x1 = 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6;
x1 = 1 + 1/2 + 1/3 + 1/4 ...
+ 1/5 + 1/6;
A series of commands may be placed into a file, and then the entire file may be executed by typing its name in the Command Window. Such files are called $\textbf{script files}$. Script files are also known as M-files because they have a file extension of ".m"
Variables and Arrays
The fundamental unit of data in any MATLAB program is the $\textbf{array}$. Arrays can be classified as either $\textbf{vectors}$ or $\textbf{matrices}$. The $\textbf{size}$ of an array is specified by the number of rows and the number of columns in the array, with the number of rows mentioned first. The total number of elements in the array will be rows $\times$ columns. A MATLAB variable is a region of memory containing an array, which is known by a user-specified name. MATLAB variable names must begin with a letter, followed by any combination of letters,numbers, and the underscore ($\_$)character.
Initializing Variables
There are three common ways to initializing a variable in MATLAB.
- Assign data to the variable in an assignment statement.
- Input data into the variable from the keyboard.
- Read data from file.
See the Video for Assign Statement:
If an assignment statement is typed without the semicolon, the results of the statement are automatically displayed in the Command Window.
Shortcut Expressions: MATLAB provides a special shortcut notations when the array contains hundreds or even thousands of elements. The general expression is $\texttt{first:incr:last}$
Built-in Functions: Arrays can also be initialized using built-in MATLAB FUNCTIONS
$\texttt{zeros(n)}$ Generates an $n \times n$ matrix of zeros.
$\texttt{zeros(n, m)}$ Generates an $n \times m$ matrix of zeros.
$\texttt{zeros(size(arr))}$ Generates a matrix of zeros of the same size as arr.
$\texttt{ones(n)}$ Generates an $n \times n$ matrix of ones.
$\texttt{ones(n, m)}$ Generates an $n \times m$ matrix of ones.
$\texttt{ones(size(arr))}$ Generates a matrix of ones of the same size as arr.
$\texttt{eye(n)}$Generates an $n \times n$ identity matrix.
$\texttt{eye(n, m)}$ Generates an $n \times m$ identity matrix.
$\texttt{length(arr)}$ Returns the length of a vector or the longest dimension of a 2-D array.
$\texttt{size(arr)}$Returns two values specifying the number of rows and columns in arr.
$\texttt{reshape(A,m,n)}$ Rearrange a matrix A that has $r$ rows and $s$ columns to have $m$ rows and $n$ columns. $r \times s$ must be equal to $m \times n$.
$\texttt{diag(v)}$ When v is a vector creates a square matrix with the elements of v in the diagonal.
$\texttt{diag(A)}$ When A is matrix, creates a vector from the diagonal elements of $\texttt{A}$.
$\texttt{length(v)}$ Returns the number of elements in the vector $\texttt{v}$.
Keyboard Input
It is also possible to prompt a user and initialize a variable with data that he or she types directly at the keyboard by using $\texttt{input}$ function.
If $\texttt{input}$ function includes the character 's' as a second argument, then the input data is returned to the user as a character string.
Multidimensional Arrays
Multidimensional Arrays have one subscript for each dimension,and individual element is selected by specifying a value for each subscript. The total number of elements in the array will be the product of the maximum value of each subscript.
SubArrays
To select a portion of an array, just include a list of all the elements to be selected in the parentheses after the array name. When used in array subscript the $\texttt{end}$ function returns the highest value taken by that a subscript.
$\texttt{va(:)}$ Refers to all the elements of the vector $\texttt{va}$ (either a row or a column vector).
$\texttt{va(m:n)}$ Refers to elements $m$ through $n$ of the vector $\texttt{va}$.
$\texttt{A(:,n)}$ Refers to the elements in all the rows of column $n$ of the matrix $\texttt{A}$.
$\texttt{A(n,:)}$ Refers to the elements in all the columns of row $n$ of the matrix $\texttt{A}$.
$\texttt{A(:,m:n)}$ Refers to the elements in all the rows between columns $m$ and $n$ of the matrix $\texttt{A}$.
$\texttt{A(m:n,:)}$ Refers to the elements in all the columns between rows $m$ and $n$ of the matrix $\texttt{A}$.
$\texttt{A(m:n,p:q)}$ & Refers to the elements in rows $m$ through $n$ and columns $p$ through $q$ of the matrix $\texttt{A}$
Display Format and Function
The $\texttt{format}$ command changes the default format. The $\texttt{disp}$ function accepts an array argument and display the value of array in the Command Window. $\texttt{fprintf}$ function displays one or more values together with related text.
Output Display Formats
$\texttt{format short}$ 4 digits after decimal (default format)
$\texttt{format long}$ digits after decimal
$\texttt{format short e}$5 digits plus exponent
$\texttt{format short g}$ 5 total digits with or without exponent
$\texttt{format long e}$ 15 digits plus exponent
$\texttt{format long g }$ 15 total digits with or without exponent
$\texttt{format bank}$ dollars and cents format
$\texttt{format hex}$ hexadecimal display of bits
$\texttt{format rat}$ approximate ratio of small integers
$\texttt{format compact}$ suppress extra line feeds
$\texttt{format loose}$ restore extra line feeds
$\texttt{format +}$ Only the signs of the numbers are printed
Scalar and Array Operations
Calculations are specified in MATLAB with an assignment statement:
$\texttt{variable_name = expression;}$
Array and Matrix Operations
Array Addition : $\texttt{a + b}$ Array addition and matrix addition are identical.
Array Subtraction: $\texttt{a - b}$ Array subtraction and matrix subtraction are identical.
Array Multiplication: $\texttt{a . * b}$ Element-by-element multiplication of $\texttt{a}$ and $\texttt{b}$. Both arrays must be the same shape, or one of them must be a scalar.
Matrix Multiplication: $\texttt{a * b}$ Matrix multiplication of $\texttt{a}$ and $\texttt{b}$. The number of columns in $\texttt{a}$ must equal the number of rows in $\texttt{b}$.
Array Right Division: $\texttt{a . / b}$ Element-by-element division of $\texttt{a}$ and $\texttt{b}$: $\texttt{a (i , j ) / b (i, j )}$. Both arrays must be the same shape, or one of them must be a scalar.
Array Left Division: $\texttt{a . \ b}$ Element-by-element division of $\texttt{a}$ and $\texttt{b}$, but with $\texttt{b}$ in the numerator: $\texttt{b (i, j ) /a (i, j )}$. Both arrays must be the same shape, or one of them must be a scalar.
Matrix Right Division: $\texttt{a / b}$ Matrix division defined by $\texttt{a *inv(b)}$, where $\texttt{inv (b)}$ is the inverse of matrix $\texttt{b}$.
Matrix Left Division: $\texttt{a $\smallsetminus$ b}$ Matrix division defined by $\texttt{inv (a) * b}$, where $\texttt{inv (a)}$ is the inverse of matrix $\texttt{a}$.
Hierarchy of Arithmetic Operations
MATLAB has established a series of rules governing the hierarchy, or order, in which operations are calculated within an expression.
Built-in MATLAB Functions and Constants
One of MATLAB's greatest strengths is that it comes with an incredible variety of built-in functions for use.
$\texttt{pi}$ Contains $\pi$ to 15 significant digits.
$\texttt{i, j}$ Contain the value $i$ $\sqrt{-1}$.
$\texttt{Inf}$ This symbol represents machine infinity. It is usually generated as a result of a division by 0.
$\texttt{NaN}$ This symbol stands for Not-a-Number. It is the result of an undefined mathematical operation, such as the division of zero by zero.
$\texttt{clock}$ This special variable contains the current date and time in the form of a 6-element row vector containing the year, month, day, hour, minute, and second.
$\texttt{date}$ Contains the current data in a character string format, such as $\texttt{24-Nov-1999}$.
$\texttt{eps}$ This variable name is short for epsilon. It is the smallest difference between two numbers that can be represented on the computer.
$\texttt{ans}$ A special variable used to store the result of an expression if that result is not explicitly assigned to some other variable.
Plotting Data (Two dimensional Plots)
To plot a data set, create two vectors containing the $x$ and $y$ values to be plotted, and use the $\texttt{plot}$ function.
Multiple Plots Suppose that we want to plot the function $f(x)=\sin(2x)$ and its derivative $\dfrac{d}{dx}\sin(2x)=2\cos(2x)$
MATLAB Program:MATLAB Script
Temperature conversion Program
The relationship between temperature in degree Fahrenheit $(^{0}F)$ and temperature in kelvin(K) can be given by $T(K) = \dfrac{5}{9}\left(T(^{0}F) - 32.0\right)+273.15$ The evaluation of this formula can be done by creating a script file temp$\_$conversion.m (say)
Dear Student,after watching these videos, you can write simple MATLAB programs from your area of study. The above videos show basic commands and their respective outputs which are summarized in following document with additional commands for your reference. Send your comments about these posts.
Tuesday, 2 June 2015
Numbers and Sets
Dear Students, here we shall discuss brief introduction to numbers.
We begin with counting numbers $1,2,3,\ldots$ which are called natural numbers
Integer numbers consist of natural numbers together with their negatives and zero $\ldots,-3,-2,-1,0,1,2,3,\ldots$
We shall use $a,b,\ldots,n$, $p,q,\ldots, x,y, \ldots$ to denote integers, positive or negative.
An integer $a$ is said to be divisible by another integer $b$, not $0$, if there is a third integer $c$ such that $a=bc$.
A rational number is a number that can be expressed as $\dfrac{a}{b}$ in which $a$ is an integer and $b$ is natural number.
The numbers that are not ratios (numbers that are not rational) are called irrational numbers
Real numbers are all "decimal numbers" that correspond to points on number line.
An integer $n$ is called prime number if $n > 1$ and if the only positive divisors of $n$ are $1$ and $n$. If $n > 1$ and if $n$ is not prime, then $n$ is called composite.
Geometric Progression and Exponential Growth:
An arithmetic progression is a list of numbers with the property that to get from any number to the next we need to add a fixed number. In case when addition is replaces by multiplication it is called Geometric progression.
To generate Geometric progression we must be given first number and the constant multiple (known as ratio) that generates successive numbers on the list.
For example we start with $1$ and the ratio is $2$, then geometric progression is: $1,2,4,8,16,32,\ldots$
Note that $\dfrac{2}{1}=2, \dfrac{4}{2}=2, \dfrac{8}{4}=2, \dfrac{16}{8}=2, \dots$ hence the constant multiple is called ratio. It is easy to see that the generic term in this geometric progression is $2^{n}$ for some natural number $n$.
In general if we start with $1$ and have a ratio $r$, then geometric progression is $1,r,r^{2},r^{3},\ldots r^{n},\ldots$. Since the varying quantities is the exponent $n$, we say that $r^{n}$ grows exponentially if $r > 1$ ; for $0 < r < 1$ we say $r^{n}$ decays exponentially
If we start with $1$ and the ratio is $\dfrac{1}{2}$, then geometric progression is: $1,\dfrac{1}{2},\dfrac{1}{4},\dfrac{1}{8},\dfrac{1}{16},\dfrac{1}{32},\ldots$
SET THEORY
Any well-defined collection of objects is a set.If $A$ is a set, then the objects in the collection $A$ are called either the members of $A$ or the elements of $A$.
A set consists of elements (we use numbers) Notation: $x \in M$ means that $x$ is an element of a set $M$ (belongs to $M$).
Some sets occur frequently in mathematics, and it is convenient to adopt a standard notation for them:
$ $$\mathcal{N}$$ $ : the set of all natural numbers (i.e., the numbers 1, 2, 3, etc.)
$ $$\mathcal{Z}$$ $ : the set of all integers (i.e., 0 and all positive and negative whole numbers)
$ $$\mathcal{Q}$$ $: the set of all rational numbers (i.e., fractions)
$ $$\mathcal{R}$$ $: the set of all real numbers
$ $$\mathcal{R+}$$ $ : the set of all non-negative real numbers
There are several ways of specifying a set. If it has a small number of elements we can list them. In this case we denote the set by enclosing the list of the elements in curly brackets; thus, for example, $\{1, 2, 3, 4, 5\}$ denotes the set consisting of the natural numbers 1, 2, 3, 4, and 5. By use of “dots” we can extend this notation to any finite set, e.g., $\{1, 2, 3,\ldots,n\}$ denotes the set of the first $n$ natural numbers. Again $\{2, 3, 5, 7, 11, 13, 17, . . ., 53\}$ could be used to denote the set of all primes up to 53.
Certain infinite sets can also be described by the use of dots (only now the dots have no end), e.g.,
$\{2, 4, 6, 8,\ldots , 2n, \ldots\}$ denotes the set of all even natural numbers. Again, $\{\ldots ,−8,−6,−4,−2, 0, 2, 4, 6, 8, \ldots \}$ denotes the set of all even integers.
In general, however, except for finite sets with only a small number of elements, sets are best described by giving the property which defines the set. If $S(x)$ is some property, the set of all those $x$ that satisfy $S(x)$ is denoted by $\{x \mid S(x)\}$, Or, if we wish to restrict the $x $ to those which are members of a certain set $A$, we would write $\{x \in A \mid S(x)\}$
This is read “the set of all $x$ in $A$ such that $S(x)$”. For example:
$ $$\mathcal{N}$$ = \{x \in $$\mathcal{Z}$$ \mid x > 0\}$
$ $$\mathcal{Q}$$ = \{m/n \mid m, n \in $$\mathcal{Z}$$, n \neq 0 \}$
$\{\sqrt{2}, -\sqrt{2} \} = \{x \in $$\mathcal{R}$$ \mid x^{2} = 2\}$
$\{1, 2, 3\} = \{x \in $$\mathcal{N}$$ \mid x < 4\}$
A set $A$ is a subset of a set $B$ $(A \subset B)$ if each element of $A$ is also an element of $B$. In this case $B$ is called a superset of $A$.
Power Set: For each set there exists a collection of sets that contains among its elements all the subsets of the given set. In other words, if $E$ is a set, then there exists a set (collection) $ $$\mathcal{P}$$ $ such that if $D \subset E$, then $D \in $$\mathcal{P}$$ $
The set $ $$\mathcal{P}$$ = \{D: D \subset E\} $ is called power set of $E$
For example, if $E = \{1, 2, 3\}$, then $ $$\mathcal{P}$$(E) = \{\varnothing, \{1\}, \{2\}, \{3\}, \{1, 2\}, \{1, 3\}, \{2, 3\}, \{1, 2, 3\}\}$
Two sets $A$ and $B$ are equal $(A = B)$ if they consist of the same elements (i.e., if $A \subset B$ and $B \subset A$).
If $A$ is a subset of $B$ and $A \neq B$, then $A$ is called a proper subset of B (notation: $A \subsetneq B$).
The empty set $\varnothing$ (called also the null set) contains no elements. It is a subset of any set.
The empty set can be specified in many
ways, e.g.,
$\varnothing = \{x \in $$\mathcal{R}$$ \mid x^{2} < 0\}$
$\varnothing = \{x \in $$\mathcal{N}$$ \mid 1 < x < 2\}$
$\varnothing = \{x \mid x \neq x\}$
Notice that $\varnothing$ and $ \{\varnothing \}$ are quite different sets. $\varnothing$ is the empty set: it has NO members. $ \{\varnothing \}$ is a set that has ONE member. Hence $\varnothing \neq \{\varnothing \}$
The intersection $A \cap B$ of two sets $A$ and $B$ consists of all elements that belong both to $A$ and to $B$:
$A \cap B = \{x | x \in A$ and $x \in B\}$.
The basic facts about intersections:
$A \cap \varnothing = \varnothing$
$A \cap B = B \cap A$ (commutativity),
$A \cap (B \cap C) = (A \cap B) \cap A$ (associativity),
$A \cap A = A $ (idempotence),
$A \subset B$ if and only if $A \cap B = A$
The union $A \cup B$ consists of all elements of $A$ and all elements of $B$ (and no other elements):
$A \cup B = \{x | x \in A$ or $x \in B\}$.
Here are some facts about the unions of pairs:
$A \cup \varnothing = A$
$A \cup B = B \cup A$ (commutativity),
$A \cup (B \cup C) = (A \cup B) \cup A$ (associativity),
$A \cup A = A $ (idempotence),
$A \subset B$ if and only if $A \cup B = B$
Two useful facts about unions and intersections involve both the operations at the same time:
$A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$,
$A \cup (B \cap C) = (A \cup B) \cap (A \cup C)$
These identities are called the distributive laws.
The set difference $A \setminus B$ (or $A-B$, as the relative complement of $B$ in $A$,) consists of elements of $A$ that are not elements of $B$:
$A\setminus B = \{x | x \in A$ and $x \notin B\}$. Note that in this definition it is not necessary to assume that $B \subset A$.
There is a special case: if $B$ is a subset of $A$, the difference $A\setminus B$ is also called a complement of $B$ in $A$.
We assume that all the sets to be mentioned are subsets of one and the same set $U$ and that all complements (unless otherwise specified) are formed relative to that $U$.
An often used symbol for the temporarily absolute (as opposed to relative) complement of $A$ is $A^{\prime}$. In terms of this symbol the basic facts about complementation can be stated as follows:
$(A^{\prime})^{\prime} = A$
$\varnothing^{\prime}=U, U^{\prime} = \varnothing$
$A \cap A^{\prime} = \varnothing, A \cup A^{\prime} = U$
$A \subset B$ if and only if $B^{\prime} \subset A^{\prime}$
The most important statements about complements are the so-called De -Morgan laws:
$(A \cup B)^{\prime} = A^{\prime} \cap B^{\prime}$ and $(A \cap B)^{\prime} = A^{\prime} \cup B^{\prime}$
Here are some easy exercises on complementation.
$A - B = A \cap B^{\prime}$.
$A \subset B$ if and only if $A-B = \varnothing $.
$A- (A-B) = A \cap B$.
$A \cap (B - C) = (A \cap B) - (A \cap C)$.
$A \cap B \subset (A \cap C)\cup (B \cap C^{\prime})$
$(A \cup C)\cap (B \cup C^{\prime}) \subset A \cup B$
The symmetric difference $A\bigtriangleup B$ consists of all elements that belong to exactly one of the sets $A$ and $B$:
$A\bigtriangleup B = (A \setminus B) \cup (B \setminus A) = (A \cup B) \setminus (A \cap B)$.
By $\{a, b, c\}$ we denote the set that contains $a, b, c$ and no other elements. Some of the elements $a, b, c$ may coincide; it this case $\{a, b, c\}$ consists of one or two elements. This notation is also used in a less formal way. For example, the set of all elements of a sequence $a_{1}, a_{2},\ldots, $ is denoted by $\{a_{1}, a_{2},\ldots \}$ (and sometimes even $\{a_{i}\}$). More pedantic notation would be $\{a_{i} \mid i \in $$\mathcal{N}$$ \}$,
Where $ $$\mathcal{N}$$ $ is the set of all natural numbers $($$\mathcal{N}$$ = \{1, 2, . . . \})$
Venn Diagrams:
Real Intervals
By an interval we mean an uninterrupted stretch of the real line. There are a number of different kinds of interval, for which there is a fairly widespread standard notation.
Let $a, b \in $$\mathcal{R}$$, a < b$ The open interval $(a, b)$ is the set $(a, b) = \{x \in $$\mathcal{R}$$ \mid a < x < b\}$
The closed interval $[a, b]$ is the set $[a, b] = \{x \in $$\mathcal{R}$$ \mid a \leq x \leq b \}$
We call $[a, b) = \{x \in $$\mathcal{R}$$ \mid a \leq x < b\}$ a left-closed, right-open interval, and
$(a, b] = \{x \in $$\mathcal{R}$$ \mid a < x \leq b\}$ a left-open, right-closed interval.
Both $[a, b)$ and $(a, b]$ are sometimes referred to as half-open (or half-closed) intervals.
And we set
$(-\infty, a) = \{x \in $$\mathcal{R}$$ \mid x < a\}$
$(-\infty, a] = \{x \in $$\mathcal{R}$$ | x \leq a\}$
$(a,\infty) = \{x \in $$\mathcal{R}$$ | x > a\}$
$[a,\infty) = \{x \in $$\mathcal{R}$$ | x \geq a\}$
We begin with counting numbers $1,2,3,\ldots$ which are called natural numbers
Integer numbers consist of natural numbers together with their negatives and zero $\ldots,-3,-2,-1,0,1,2,3,\ldots$
We shall use $a,b,\ldots,n$, $p,q,\ldots, x,y, \ldots$ to denote integers, positive or negative.
An integer $a$ is said to be divisible by another integer $b$, not $0$, if there is a third integer $c$ such that $a=bc$.
A rational number is a number that can be expressed as $\dfrac{a}{b}$ in which $a$ is an integer and $b$ is natural number.
The numbers that are not ratios (numbers that are not rational) are called irrational numbers
Real numbers are all "decimal numbers" that correspond to points on number line.
An integer $n$ is called prime number if $n > 1$ and if the only positive divisors of $n$ are $1$ and $n$. If $n > 1$ and if $n$ is not prime, then $n$ is called composite.
Geometric Progression and Exponential Growth:
An arithmetic progression is a list of numbers with the property that to get from any number to the next we need to add a fixed number. In case when addition is replaces by multiplication it is called Geometric progression.
To generate Geometric progression we must be given first number and the constant multiple (known as ratio) that generates successive numbers on the list.
For example we start with $1$ and the ratio is $2$, then geometric progression is: $1,2,4,8,16,32,\ldots$
Note that $\dfrac{2}{1}=2, \dfrac{4}{2}=2, \dfrac{8}{4}=2, \dfrac{16}{8}=2, \dots$ hence the constant multiple is called ratio. It is easy to see that the generic term in this geometric progression is $2^{n}$ for some natural number $n$.
In general if we start with $1$ and have a ratio $r$, then geometric progression is $1,r,r^{2},r^{3},\ldots r^{n},\ldots$. Since the varying quantities is the exponent $n$, we say that $r^{n}$ grows exponentially if $r > 1$ ; for $0 < r < 1$ we say $r^{n}$ decays exponentially
If we start with $1$ and the ratio is $\dfrac{1}{2}$, then geometric progression is: $1,\dfrac{1}{2},\dfrac{1}{4},\dfrac{1}{8},\dfrac{1}{16},\dfrac{1}{32},\ldots$
SET THEORY
Any well-defined collection of objects is a set.If $A$ is a set, then the objects in the collection $A$ are called either the members of $A$ or the elements of $A$.
A set consists of elements (we use numbers) Notation: $x \in M$ means that $x$ is an element of a set $M$ (belongs to $M$).
Some sets occur frequently in mathematics, and it is convenient to adopt a standard notation for them:
$ $$\mathcal{N}$$ $ : the set of all natural numbers (i.e., the numbers 1, 2, 3, etc.)
$ $$\mathcal{Z}$$ $ : the set of all integers (i.e., 0 and all positive and negative whole numbers)
$ $$\mathcal{Q}$$ $: the set of all rational numbers (i.e., fractions)
$ $$\mathcal{R}$$ $: the set of all real numbers
$ $$\mathcal{R+}$$ $ : the set of all non-negative real numbers
There are several ways of specifying a set. If it has a small number of elements we can list them. In this case we denote the set by enclosing the list of the elements in curly brackets; thus, for example, $\{1, 2, 3, 4, 5\}$ denotes the set consisting of the natural numbers 1, 2, 3, 4, and 5. By use of “dots” we can extend this notation to any finite set, e.g., $\{1, 2, 3,\ldots,n\}$ denotes the set of the first $n$ natural numbers. Again $\{2, 3, 5, 7, 11, 13, 17, . . ., 53\}$ could be used to denote the set of all primes up to 53.
Certain infinite sets can also be described by the use of dots (only now the dots have no end), e.g.,
$\{2, 4, 6, 8,\ldots , 2n, \ldots\}$ denotes the set of all even natural numbers. Again, $\{\ldots ,−8,−6,−4,−2, 0, 2, 4, 6, 8, \ldots \}$ denotes the set of all even integers.
In general, however, except for finite sets with only a small number of elements, sets are best described by giving the property which defines the set. If $S(x)$ is some property, the set of all those $x$ that satisfy $S(x)$ is denoted by $\{x \mid S(x)\}$, Or, if we wish to restrict the $x $ to those which are members of a certain set $A$, we would write $\{x \in A \mid S(x)\}$
This is read “the set of all $x$ in $A$ such that $S(x)$”. For example:
$ $$\mathcal{N}$$ = \{x \in $$\mathcal{Z}$$ \mid x > 0\}$
$ $$\mathcal{Q}$$ = \{m/n \mid m, n \in $$\mathcal{Z}$$, n \neq 0 \}$
$\{\sqrt{2}, -\sqrt{2} \} = \{x \in $$\mathcal{R}$$ \mid x^{2} = 2\}$
$\{1, 2, 3\} = \{x \in $$\mathcal{N}$$ \mid x < 4\}$
A set $A$ is a subset of a set $B$ $(A \subset B)$ if each element of $A$ is also an element of $B$. In this case $B$ is called a superset of $A$.
Power Set: For each set there exists a collection of sets that contains among its elements all the subsets of the given set. In other words, if $E$ is a set, then there exists a set (collection) $ $$\mathcal{P}$$ $ such that if $D \subset E$, then $D \in $$\mathcal{P}$$ $
The set $ $$\mathcal{P}$$ = \{D: D \subset E\} $ is called power set of $E$
For example, if $E = \{1, 2, 3\}$, then $ $$\mathcal{P}$$(E) = \{\varnothing, \{1\}, \{2\}, \{3\}, \{1, 2\}, \{1, 3\}, \{2, 3\}, \{1, 2, 3\}\}$
Two sets $A$ and $B$ are equal $(A = B)$ if they consist of the same elements (i.e., if $A \subset B$ and $B \subset A$).
If $A$ is a subset of $B$ and $A \neq B$, then $A$ is called a proper subset of B (notation: $A \subsetneq B$).
The empty set $\varnothing$ (called also the null set) contains no elements. It is a subset of any set.
The empty set can be specified in many
ways, e.g.,
$\varnothing = \{x \in $$\mathcal{R}$$ \mid x^{2} < 0\}$
$\varnothing = \{x \in $$\mathcal{N}$$ \mid 1 < x < 2\}$
$\varnothing = \{x \mid x \neq x\}$
Notice that $\varnothing$ and $ \{\varnothing \}$ are quite different sets. $\varnothing$ is the empty set: it has NO members. $ \{\varnothing \}$ is a set that has ONE member. Hence $\varnothing \neq \{\varnothing \}$
The intersection $A \cap B$ of two sets $A$ and $B$ consists of all elements that belong both to $A$ and to $B$:
$A \cap B = \{x | x \in A$ and $x \in B\}$.
The basic facts about intersections:
$A \cap \varnothing = \varnothing$
$A \cap B = B \cap A$ (commutativity),
$A \cap (B \cap C) = (A \cap B) \cap A$ (associativity),
$A \cap A = A $ (idempotence),
$A \subset B$ if and only if $A \cap B = A$
The union $A \cup B$ consists of all elements of $A$ and all elements of $B$ (and no other elements):
$A \cup B = \{x | x \in A$ or $x \in B\}$.
Here are some facts about the unions of pairs:
$A \cup \varnothing = A$
$A \cup B = B \cup A$ (commutativity),
$A \cup (B \cup C) = (A \cup B) \cup A$ (associativity),
$A \cup A = A $ (idempotence),
$A \subset B$ if and only if $A \cup B = B$
Two useful facts about unions and intersections involve both the operations at the same time:
$A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$,
$A \cup (B \cap C) = (A \cup B) \cap (A \cup C)$
These identities are called the distributive laws.
The set difference $A \setminus B$ (or $A-B$, as the relative complement of $B$ in $A$,) consists of elements of $A$ that are not elements of $B$:
$A\setminus B = \{x | x \in A$ and $x \notin B\}$. Note that in this definition it is not necessary to assume that $B \subset A$.
There is a special case: if $B$ is a subset of $A$, the difference $A\setminus B$ is also called a complement of $B$ in $A$.
We assume that all the sets to be mentioned are subsets of one and the same set $U$ and that all complements (unless otherwise specified) are formed relative to that $U$.
An often used symbol for the temporarily absolute (as opposed to relative) complement of $A$ is $A^{\prime}$. In terms of this symbol the basic facts about complementation can be stated as follows:
$(A^{\prime})^{\prime} = A$
$\varnothing^{\prime}=U, U^{\prime} = \varnothing$
$A \cap A^{\prime} = \varnothing, A \cup A^{\prime} = U$
$A \subset B$ if and only if $B^{\prime} \subset A^{\prime}$
The most important statements about complements are the so-called De -Morgan laws:
$(A \cup B)^{\prime} = A^{\prime} \cap B^{\prime}$ and $(A \cap B)^{\prime} = A^{\prime} \cup B^{\prime}$
Here are some easy exercises on complementation.
$A - B = A \cap B^{\prime}$.
$A \subset B$ if and only if $A-B = \varnothing $.
$A- (A-B) = A \cap B$.
$A \cap (B - C) = (A \cap B) - (A \cap C)$.
$A \cap B \subset (A \cap C)\cup (B \cap C^{\prime})$
$(A \cup C)\cap (B \cup C^{\prime}) \subset A \cup B$
The symmetric difference $A\bigtriangleup B$ consists of all elements that belong to exactly one of the sets $A$ and $B$:
$A\bigtriangleup B = (A \setminus B) \cup (B \setminus A) = (A \cup B) \setminus (A \cap B)$.
By $\{a, b, c\}$ we denote the set that contains $a, b, c$ and no other elements. Some of the elements $a, b, c$ may coincide; it this case $\{a, b, c\}$ consists of one or two elements. This notation is also used in a less formal way. For example, the set of all elements of a sequence $a_{1}, a_{2},\ldots, $ is denoted by $\{a_{1}, a_{2},\ldots \}$ (and sometimes even $\{a_{i}\}$). More pedantic notation would be $\{a_{i} \mid i \in $$\mathcal{N}$$ \}$,
Where $ $$\mathcal{N}$$ $ is the set of all natural numbers $($$\mathcal{N}$$ = \{1, 2, . . . \})$
Venn Diagrams:
Real Intervals
By an interval we mean an uninterrupted stretch of the real line. There are a number of different kinds of interval, for which there is a fairly widespread standard notation.
Let $a, b \in $$\mathcal{R}$$, a < b$ The open interval $(a, b)$ is the set $(a, b) = \{x \in $$\mathcal{R}$$ \mid a < x < b\}$
The closed interval $[a, b]$ is the set $[a, b] = \{x \in $$\mathcal{R}$$ \mid a \leq x \leq b \}$
We call $[a, b) = \{x \in $$\mathcal{R}$$ \mid a \leq x < b\}$ a left-closed, right-open interval, and
$(a, b] = \{x \in $$\mathcal{R}$$ \mid a < x \leq b\}$ a left-open, right-closed interval.
Both $[a, b)$ and $(a, b]$ are sometimes referred to as half-open (or half-closed) intervals.
And we set
$(-\infty, a) = \{x \in $$\mathcal{R}$$ \mid x < a\}$
$(-\infty, a] = \{x \in $$\mathcal{R}$$ | x \leq a\}$
$(a,\infty) = \{x \in $$\mathcal{R}$$ | x > a\}$
$[a,\infty) = \{x \in $$\mathcal{R}$$ | x \geq a\}$
*********
Back to Basic Mathematics
Subscribe to:
Posts (Atom)