summaryrefslogtreecommitdiff
path: root/48/CH2
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /48/CH2
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '48/CH2')
-rwxr-xr-x48/CH2/EX2.1/eg_2_1.sce22
-rwxr-xr-x48/CH2/EX2.11/eg_2_11.sce23
-rwxr-xr-x48/CH2/EX2.12/eg_2_12.sce34
-rwxr-xr-x48/CH2/EX2.15/eg_2_15.sce31
-rwxr-xr-x48/CH2/EX2.16/eg_2_16.sce12
-rwxr-xr-x48/CH2/EX2.2/eg_2_2.sce85
-rwxr-xr-x48/CH2/EX2.4/eg_2_4.sce25
-rwxr-xr-x48/CH2/EX2.5/eg_2_5.sce61
-rwxr-xr-x48/CH2/EX2.6/eg_2_6.sce34
-rwxr-xr-x48/CH2/EX2.7/eg_2_7.sce31
10 files changed, 358 insertions, 0 deletions
diff --git a/48/CH2/EX2.1/eg_2_1.sce b/48/CH2/EX2.1/eg_2_1.sce
new file mode 100755
index 000000000..21e773b09
--- /dev/null
+++ b/48/CH2/EX2.1/eg_2_1.sce
@@ -0,0 +1,22 @@
+clear;
+clc;
+//lower=input("input the lower limit of the set");
+//upper=input("input the upper limit of the set");
+lower=1; //lower limit of the set
+upper=10; //upper limit of the set
+temp=lower;
+h=1;i=1;
+while(temp<=upper)
+ if(modulo(temp,2)==0) //checking whether a number is even or not
+ e(h)=temp;
+ h=h+1;
+ else
+ o(i)=temp; //odd number
+ i=i+1;
+ end
+ temp=temp+1;
+end;
+disp("the set of even number between the limits")
+disp(e);
+disp("the set of odd number between the limits")
+disp(o);
diff --git a/48/CH2/EX2.11/eg_2_11.sce b/48/CH2/EX2.11/eg_2_11.sce
new file mode 100755
index 000000000..520598f91
--- /dev/null
+++ b/48/CH2/EX2.11/eg_2_11.sce
@@ -0,0 +1,23 @@
+clear;
+clc;
+//N=input("enter the number for which divisibilty ");
+N=45; //divident
+h=1;
+for i=1:N //finding all the divisors of 45
+ if(modulo(N,i)==0)
+ r(h)=i;
+ h=h+1;
+ end
+end
+n=max(size(r));
+disp("Hasse Diagram") //displaying in the form of hasse diagram
+disp("------------")
+disp(r(n));
+h=2;
+for i=n-1:-2:3
+ disp("-----------");
+ disp(r(i),r(i-1));
+ h=h+1;
+end
+disp("----------")
+disp(r(1));
diff --git a/48/CH2/EX2.12/eg_2_12.sce b/48/CH2/EX2.12/eg_2_12.sce
new file mode 100755
index 000000000..2378410ee
--- /dev/null
+++ b/48/CH2/EX2.12/eg_2_12.sce
@@ -0,0 +1,34 @@
+clear
+clc
+N=4;
+//defining all the partial ordered sets
+s(1,:)=[1 0];
+s(2,:)=[0 1];
+s(3,:)=[0 0];
+s(4,:)=[1 1];
+//Finding
+a=1;b=1;
+for i=1:1:N //sorting based on the level
+ for j=i:1:N
+ if(i~=j)
+ u=s(i,1)+s(i,2);
+ v=s(j,1)+s(j,2);
+ if(u<v)
+ temp(1)=s(i,1);
+ temp(2)=s(i,2);
+ s(i,1)=s(j,1);
+ s(i,2)=s(j,2);
+ s(j,1)=temp(1);
+ s(j,2)=temp(2);
+ end
+ end
+ end
+end
+// displaying in the form of hasse graph form
+disp("1st stage of Hasse diagram");
+disp(s(1,:));
+disp("2nd stage of Hasse diagram");
+disp(s(2,:));
+disp(s(3,:));
+disp("3rd stage of Hasse diagram");
+disp(s(4,:)); \ No newline at end of file
diff --git a/48/CH2/EX2.15/eg_2_15.sce b/48/CH2/EX2.15/eg_2_15.sce
new file mode 100755
index 000000000..c7a250e6c
--- /dev/null
+++ b/48/CH2/EX2.15/eg_2_15.sce
@@ -0,0 +1,31 @@
+clear
+clc
+N=3;
+s=['a' 'b' 'c']; //set for which lattice should be defined
+for i=2:2^3
+ s(i,:)=s(1,:);
+end
+//defining 2nd level vertices of the lattice
+for i=2:4
+ s(i,i-1)='0';
+end
+//defining 3rd level vertices of the lattice
+for i=5:6
+ s(i,i-4)='0';
+ s(i,i-3)='0';
+end
+s(7,1)='0';s(7,3)='0';
+//defining the final level of vertices of the lattice
+s(8,:)=['0' '0' '0'];
+disp("1st level");
+disp(s(1,:));
+disp("2nd level");
+disp(s(2,:));
+disp(s(3,:));
+disp(s(4,:));
+disp("3rd level");
+disp(s(5,:));
+disp(s(6,:));
+disp(s(7,:));
+disp("4th level");
+disp(s(8,:)); \ No newline at end of file
diff --git a/48/CH2/EX2.16/eg_2_16.sce b/48/CH2/EX2.16/eg_2_16.sce
new file mode 100755
index 000000000..dd4507ba8
--- /dev/null
+++ b/48/CH2/EX2.16/eg_2_16.sce
@@ -0,0 +1,12 @@
+clear;
+clc;
+par1=['ab','cde','fh','gi']; //initial partitions par1
+par2=['abc','de','fg','hi']; //partition 2
+//par=par1+par2;
+//lub-lower upper bound
+par_lub=['abcde','fghi'];
+disp(par_lub);
+//par=par1.par2
+//glb-greatest lower bound
+par_glb=['ab','c','de','f','g','h','i'];
+disp(par_glb); \ No newline at end of file
diff --git a/48/CH2/EX2.2/eg_2_2.sce b/48/CH2/EX2.2/eg_2_2.sce
new file mode 100755
index 000000000..a8d16dadc
--- /dev/null
+++ b/48/CH2/EX2.2/eg_2_2.sce
@@ -0,0 +1,85 @@
+clear;
+clc;
+//N=input("enter the elements in the set");
+//n=1;
+//while(n<=N)
+// i(n)=input("enter the elements of first set");
+// n=n+1;
+//end;
+N=6;
+i(1)='f1';i(2)='f2';i(3)='f3';i(4)='f4';i(5)='f5';i(6)='f6';
+disp("null set"); //since null set is subset of any set.
+for a=1:1:N //set of single elements
+ disp(i(a));
+end
+c=1;
+for a=1:1:N-1 //set of two elements
+ for b=a:1:N
+ if(a~=b)
+ m(c,1)=i(a);
+ m(c,2)=i(b);
+ c=c+1;
+ end
+ end;
+end;
+disp(m);
+d=1;
+for a=1:1:N //set of three elements
+ for b=a:1:N
+ for c=b:1:N
+ if((a~=b)&(b~=c)&(c~=a))
+ p(d,1)=i(a);
+ p(d,2)=i(b);
+ p(d,3)=i(c);
+ d=d+1;
+ end
+ end
+ end
+end
+disp(p);
+e=1;
+for a=1:1:N //set of four elements
+ for b=a:1:N
+ for c=b:1:N
+ for d=c:1:N
+ if((a~=b)&(b~=c)&(c~=d)&(d~=a)&(b~=d)&(a~=c))
+ q(e,1)=i(a);
+ q(e,2)=i(b);
+ q(e,3)=i(c);
+ q(e,4)=i(d)
+ e=e+1;
+ end
+ end
+ end
+ end
+end
+disp(q);
+f=1;
+for a=1:1:N //set of five elements
+ for b=a:1:N
+ for c=b:1:N
+ for d=c:1:N
+ for e=d:1:N
+ if((a~=b)&(b~=c)&(c~=d)&(d~=e)&(e~=a)&(a~=c)&(a~=d)&(b~=d)&(c~=e)&(b~=e))
+ r(f,1)=i(a);
+ r(f,2)=i(b);
+ r(f,3)=i(c);
+ r(f,4)=i(d);
+ r(f,5)=i(e);
+ f=f+1;
+ end
+ end
+ end
+ end
+ end
+end
+disp(r);
+for a=1:1:N //set of six elements
+ s(1,1)=i(1);
+ s(1,2)=i(2);
+ s(1,3)=i(3);
+ s(1,4)=i(4);
+ s(1,5)=i(5);
+ s(1,6)=i(6);
+end
+disp(s); \ No newline at end of file
diff --git a/48/CH2/EX2.4/eg_2_4.sce b/48/CH2/EX2.4/eg_2_4.sce
new file mode 100755
index 000000000..131e07aaf
--- /dev/null
+++ b/48/CH2/EX2.4/eg_2_4.sce
@@ -0,0 +1,25 @@
+clear;
+clc;
+N1=2;
+N2=3;
+//n=1;
+//while(n<=N1)
+// i(n)=input("enter the elements of first set");
+// n=n+1;
+//end;
+i=['p' 'q']; //set A
+//n=1;
+//while(n<=N2)
+// j(n)=input("enter the elements of second set");
+// n=n+1;
+//end;
+j=['r' 's' 't']; //set B
+c=1;d=1;
+for a=1:1:N1 //realtion between sets A and B
+ for b=1:1:N2
+ m(c,d)=i(a);
+ m(c,d+1)=j(b);
+ c=c+1;
+ end;
+end;
+disp(m); \ No newline at end of file
diff --git a/48/CH2/EX2.5/eg_2_5.sce b/48/CH2/EX2.5/eg_2_5.sce
new file mode 100755
index 000000000..a43c42d09
--- /dev/null
+++ b/48/CH2/EX2.5/eg_2_5.sce
@@ -0,0 +1,61 @@
+clear;
+clc;
+//N=input("enter the no of elements in the set :");
+//for i=1:1:N
+// s(1,i)=input("enter the elements in the set :");
+//end;
+//n=input("enter the number of pairs in the relation :");
+//for j=1:1:n
+// for k=1:1:2
+// r(j,k)=input("enter the elements in the relation :");
+// end
+//end
+N=2;
+s=['a' 'b']; //elements in the set
+n=3;
+r=['a' 'a';'b' 'b';'a' 'b']; //realtion between the elements in the above set.
+ref=zeros(1,N);
+for a=1:1:N
+ for b=1:1:n
+ if(r(b,1)==s(1,a)&r(b,2)==s(1,a))
+ ref(1,a)=1;
+ end
+ end
+end
+for i=1:1:N //checking whether above relation is reflexive or not
+ if(ref(1,i)==1)
+ disp("the above relation is reflexive with elements ");
+ disp(s(1,i));
+ disp(" ");
+ end
+end
+sym=zeros(1,(N*N-1)/2);
+s(1,N+1)=s(1,1);
+for a=1:1:N //checking whether above relation is symmetric or not
+ for b=1:1:n
+ if(r(b,1)==s(1,a)&r(b,2)==s(1,a+1))
+ for d=1:1:n
+ if(r(d,1)==s(1,a+1)&r(d,2)==s(1,a))
+ sym(1,a)=1;
+ disp("the above relation is symmetric for these pairs :");
+ disp(")",s(1,a+1),s(1,a),"(");
+ end
+ end
+ end
+ end
+end
+for a=1:1:n //checking whether it is transtive or not.
+ u=r(a,1);
+ v=r(a,2);
+ for b=a:1:n
+ if(r(b,1)==v)
+ w=r(b,2);
+ for c=b:1:n
+ if(r(c,1)==w&r(c,2)==u)
+ disp("satisfies transtitve property");
+ abort;
+ end
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/48/CH2/EX2.6/eg_2_6.sce b/48/CH2/EX2.6/eg_2_6.sce
new file mode 100755
index 000000000..bc5faded8
--- /dev/null
+++ b/48/CH2/EX2.6/eg_2_6.sce
@@ -0,0 +1,34 @@
+clear;
+clc;
+//N=input("enter the elements in the set :");
+//for i=1:1:N
+// s(i)=input("enter the elements :");
+//end
+N=2;
+s=['a' 'b'];
+disp("The equivalence relation of above set is :");
+h=1;
+for i=1:1:N //to satisfy reflexive property
+ ref(h,1)=s(i);
+ ref(h,2)=s(i);
+ h=h+1;
+end
+for i=1:1:N //to satisfy symmetric property
+ for j=i:1:N
+ if(i~=j)
+ ref(h,1)=s(i);
+ ref(h,2)=s(j);
+ h=h+1;
+ end
+ end
+end
+m=1;
+for i=1:max(size(ref(:,1))) //to satisfy transtive property
+ if(ref(i,1)~=ref(i,2))
+ ref1(m,1)=ref(i,2);
+ ref1(m,2)=ref(i,1);
+ m=m+1;
+ end
+end
+disp(ref);
+disp(ref1); \ No newline at end of file
diff --git a/48/CH2/EX2.7/eg_2_7.sce b/48/CH2/EX2.7/eg_2_7.sce
new file mode 100755
index 000000000..5977bd696
--- /dev/null
+++ b/48/CH2/EX2.7/eg_2_7.sce
@@ -0,0 +1,31 @@
+clc;
+clear;
+//n1=input("enter the no of elements in the 1st set");
+//for i=1:1:n1
+// s1(i)=input("enter the elements of 1st set:");
+//end
+n1=3;
+s1=['a1' 'a2' 'a3']; //set A
+//n2=input("enter the no of elements in the 2nd set");
+//for i=1:1:n2
+// s2(i)=input("enter the elements of 2ns set:");
+//end
+n2=2;
+s1=['b1' 'b2']; //set B
+//N=input("enter the pairs in the relation which you want to check whether is a function");
+//for i=1:1:N
+// for j=1:1:2
+// r(i,j)=input("enter the elements in the relation:");
+// end
+//end
+N=3;
+r=['a1' 'b1';'a2' 'b2';'a2' 'b1']; //Realtion r
+for i=1:1:N //checks whether the relation is function or not
+ for j=i:1:N
+ if(r(i,1)==r(j,1) & i~=j)
+ disp("the relation is not a function");
+ abort;
+ end
+ end
+end
+disp("the realtion is a fucntion"); \ No newline at end of file