summaryrefslogtreecommitdiff
path: root/3808/CH1
diff options
context:
space:
mode:
Diffstat (limited to '3808/CH1')
-rw-r--r--3808/CH1/EX1.1/Ex1_1.sce12
-rw-r--r--3808/CH1/EX1.10/Ex1_10.sce26
-rw-r--r--3808/CH1/EX1.11/Ex1_11.sce17
-rw-r--r--3808/CH1/EX1.2/Ex1_2.sce10
-rw-r--r--3808/CH1/EX1.3/Ex1_3.sce8
-rw-r--r--3808/CH1/EX1.4/Ex1_4.sce9
-rw-r--r--3808/CH1/EX1.5/Ex1_5.sce10
-rw-r--r--3808/CH1/EX1.6/Ex1_6.sce11
-rw-r--r--3808/CH1/EX1.7/Ex1_7.sce10
-rw-r--r--3808/CH1/EX1.8/Ex1_8.sce15
-rw-r--r--3808/CH1/EX1.9/Ex1_9.sce15
11 files changed, 143 insertions, 0 deletions
diff --git a/3808/CH1/EX1.1/Ex1_1.sce b/3808/CH1/EX1.1/Ex1_1.sce
new file mode 100644
index 000000000..47dfb370e
--- /dev/null
+++ b/3808/CH1/EX1.1/Ex1_1.sce
@@ -0,0 +1,12 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+s1=1+1==2
+s2=2+2==3
+mprintf("The following sentences are Propositions\n") //Proposition should be a declarative sentence or should result in either a YES or a NO.
+mprintf("1. Washington D.C is the capital of the United States of America\n")
+mprintf("2. Toronto is the capital of Canada\n")
+mprintf("3. 1+1=2 %s ", string([%T]))
+mprintf("\n4. 2+2=3 %s ", string([%F]))
+//Since these statements are declarative and they answer the question YES or NO they are called propositions.
diff --git a/3808/CH1/EX1.10/Ex1_10.sce b/3808/CH1/EX1.10/Ex1_10.sce
new file mode 100644
index 000000000..7dd0f0179
--- /dev/null
+++ b/3808/CH1/EX1.10/Ex1_10.sce
@@ -0,0 +1,26 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+function atck(X)
+ if (X=='CS1') then
+ mprintf("\nA(%s) is true",X)
+ elseif (X=='MATH1') then
+ mprintf("\nA(%s) is true",X)
+ else
+ mprintf("\nA(%s) is false",X)
+ end
+endfunction
+
+//Defining systems to check whether they are under attack through a function.
+x1='CS1'
+x2='CS2'
+x3='MATH1'
+
+atck(x1)
+atck(x2)
+atck(x3)
+
+mprintf("\nSystems under attack are CS1 and MATH1.\nThe truth values for the same are calculated using functions.")
+
diff --git a/3808/CH1/EX1.11/Ex1_11.sce b/3808/CH1/EX1.11/Ex1_11.sce
new file mode 100644
index 000000000..4aa40650f
--- /dev/null
+++ b/3808/CH1/EX1.11/Ex1_11.sce
@@ -0,0 +1,17 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+v1=sqrt(2)
+v2=(3/2)
+
+//let p be the proposition that sqrt(2) > (3/2)
+if v1 > v2 then //which is false
+ z=v1**2 >v2**2
+ mprintf("(sqrt(2))^2 > (3/2)^2 %s ", string([%F]))//which is false and as a result will not be printed
+end
+
+//The conclusion is false,therefore final argument
+fin_arg=v1**2>v2**2//sqrt(2)^2 is less than (3/2)^2
+disp(fin_arg)
diff --git a/3808/CH1/EX1.2/Ex1_2.sce b/3808/CH1/EX1.2/Ex1_2.sce
new file mode 100644
index 000000000..8b6daded1
--- /dev/null
+++ b/3808/CH1/EX1.2/Ex1_2.sce
@@ -0,0 +1,10 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+mprintf("1. What time is it? \n")
+mprintf("2. Read this carefully. \n")
+mprintf("3. x+1=2.\n")
+mprintf("4. x+y=Z.\n")
+mprintf("Sentences 1 and 2 are not propositions since they are not declarative.\nSentences 3 and 4 are neither true nor false and so they are not propositions.")
diff --git a/3808/CH1/EX1.3/Ex1_3.sce b/3808/CH1/EX1.3/Ex1_3.sce
new file mode 100644
index 000000000..663236d7e
--- /dev/null
+++ b/3808/CH1/EX1.3/Ex1_3.sce
@@ -0,0 +1,8 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+mprintf("Propositon p=Michael s PC runs Linux.")
+mprintf("\n Negation of p is ~p : It is not the case that Michael s PC runs Linux.")
+mprintf("\n Negation of p is ~p : Michael s PC does not run.Linux")//Negation is opposite of the truth value of the proposition expressed with "it is not the case that" or with "not".
diff --git a/3808/CH1/EX1.4/Ex1_4.sce b/3808/CH1/EX1.4/Ex1_4.sce
new file mode 100644
index 000000000..fcb445ade
--- /dev/null
+++ b/3808/CH1/EX1.4/Ex1_4.sce
@@ -0,0 +1,9 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+mprintf( "Let p=Vandana s smartphone has at least 32GB of memory.")
+mprintf( "\nThe negation of p is ( ~p ) :It is not the case that Vandana s smartphone has at least 32GB of memory.")
+mprintf( "\nOr in simple English ( ~p ): Vandana s smartphone does not have at least 32GB of memory.")
+mprintf( "\nOr even more simple as ( ~p ): Vandana s smartphone has less than 32GB of memory.")
diff --git a/3808/CH1/EX1.5/Ex1_5.sce b/3808/CH1/EX1.5/Ex1_5.sce
new file mode 100644
index 000000000..60342f59f
--- /dev/null
+++ b/3808/CH1/EX1.5/Ex1_5.sce
@@ -0,0 +1,10 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+p="Rebecca s PC has more than 16GB free hard disk space"
+q="The processor in Rebecca s PC runs faster than 1GHz"
+mprintf("Let p,q be two propositions")
+mprintf("\nLet p=%s \n Let q=%s",p,q)
+mprintf("\nConjunction of p^q is : %s and %s",p,q) //conjunction combines two propositons with "and"
diff --git a/3808/CH1/EX1.6/Ex1_6.sce b/3808/CH1/EX1.6/Ex1_6.sce
new file mode 100644
index 000000000..6cba9e7e8
--- /dev/null
+++ b/3808/CH1/EX1.6/Ex1_6.sce
@@ -0,0 +1,11 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+p="Rebecca s PC has more than 16GB free hard disk space"
+q="The processor in Rebecca s PC runs faster than 1GHz"
+mprintf("Let p,q be two propositions")
+mprintf("\nLet p= %s\n Let q=%s",p,q)
+mprintf("\nDisjunction of pVq is : %s or %s",p,q) //cup symbol.= V
+//Disjunction combines two propositons using OR
diff --git a/3808/CH1/EX1.7/Ex1_7.sce b/3808/CH1/EX1.7/Ex1_7.sce
new file mode 100644
index 000000000..681c15a5e
--- /dev/null
+++ b/3808/CH1/EX1.7/Ex1_7.sce
@@ -0,0 +1,10 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+p="Maria learns discrete mathematics"
+q="Maria will find a good job"
+mprintf("Let p=%s \n Let q=%s",p,q)
+mprintf("\np->q is : If %s then %s",p,q) //p->q p implies q means If p then q.
+mprintf("\np->q is also expressed as :%s when %s",q,p)
diff --git a/3808/CH1/EX1.8/Ex1_8.sce b/3808/CH1/EX1.8/Ex1_8.sce
new file mode 100644
index 000000000..74bd443dc
--- /dev/null
+++ b/3808/CH1/EX1.8/Ex1_8.sce
@@ -0,0 +1,15 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+x = [0 1 1 0 1 1 0 1 1 0];
+y = [1 1 0 0 0 1 1 1 0 1];
+
+bit_and=bitand(x,y)
+bit_or=bitor(x,y)
+bit_xor=bitxor(x,y)
+
+disp(bit_and,"The bitwise AND is")
+disp(bit_or,"The bitwise OR is")
+disp(bit_xor,"The bitwise XOR is")
diff --git a/3808/CH1/EX1.9/Ex1_9.sce b/3808/CH1/EX1.9/Ex1_9.sce
new file mode 100644
index 000000000..0f9840b72
--- /dev/null
+++ b/3808/CH1/EX1.9/Ex1_9.sce
@@ -0,0 +1,15 @@
+//Chapter 01: The Foundations: Logic and Proofs
+
+clc;
+clear;
+
+function p(x) //function definition to check whether the given statements are true.
+if(x>3) then
+ mprintf("\np(%d) which is the statement %d > 3, is true",x,x)
+else
+ mprintf("\np(%d) which is the statement %d > 3, is false",x,x)
+end
+endfunction
+
+p(4)
+p(2)