Download MATHEMATICAL IN COMPUTER SCIENCE

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Computer simulation wikipedia , lookup

Algorithm wikipedia , lookup

Theoretical computer science wikipedia , lookup

Transcript
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
MATHEMATICAL IN COMPUTER SCIENCE
Hieu Vu, Ph.D.
American University of Nigeria
98 LamidoZubairu Way
Yola by Pass, P.M.B. 2250,
Yola, Adamawa State, Nigeria
Abstract
Mathematics has been known for proving services for the other fields. We all learned mathematics from early
childhood, and it is a very important skill in problem solving. Mathematics penetrates deeper in scientific
disciplines such as: engineering, physics, statistics, etc… and computer science is not an exception.Some
mathematics courses are taught by computer science professors and listed under computer science
curriculum.
Keywords
Computer science, Mathematics, Algorithms, Numerical Analysis, Discrete Mathematics, Computer Logic
I. INTRODUCTION
The great ancient Greek philosopher Aristotle (384-322 BC) defined mathematics as “The science of
quantity”, and this definition held until the 18th century. Starting in the 19th century, the study of mathematics
increased and introduced the concept of abstract topics: group theory and projective geometry which made no
distinct between quantity and measurement. Today the only distinction in Mathematics is “Pure mathematics”
and “Applied mathematics”[1]
Mathematics is regarded throughout the world as an essential tool, the key to open the doors for other fields,
such as engineering, natural science, finance, physics, statistics, etc…It is obvious that without mathematics
contributions, science and technology cannot advance.
We all know, no matter on what type of professions, we have been using some form of mathematics on our
daily job. It could involve a simple calculation, computing, or studying, analyzing an engineering blueprint or
a spreadsheet, and general problem solving…This research paper presents the important role of mathematics
in the field of computer science.
53
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
II. THE ROLE OF MATHEMATICS IN COMPUTER SCIENCE
Computer science has root from mathematics, the Atanasoff-Berry computer (ABC) was the first automatic
electronic digital computer. Some historians believed mathematics and physics professor John Vincent
Atanasoff from Iowa State College built the ABC computer with the help of graduate student Clifford Berry,
hence they named the electronic digital device “Atanasoff-Berry computer”. Conceived in 1937, the machine
was designed to solve systems of linear equations, not programmable, and was sucessfully tested in 1942.
According to Mollenhoff in 1988 “Atanasoff: Forgotten Father of the Computer” published by Iowa State
University Press. [2]
To understand the role of mathematics in computer science, there are some questions arise about the
relationship between the two fields.
1. What is Computer Science? One definition of computer science is “The study of algorithms”. An algorithm
defines a finite sequence of rules how to produce an output of information from a given input. In fact no two
computer scientists would give the same definition, the same for two mathematicians in defining mathematics.
2. Is Computer Science part of Mathematics? In the early days, computer science was a small group of
professors and students that was housed inside mathematics department. Today computer science courses are
actively studied by computer science students. But if we focus on the study of algorithms then computer
science merely be a branch of mathematics, isn’t it?
3. How Mathematics and Computer Science interact? Computer science affects mathematics in many ways.
Computers can be used for computing in mathematical research when manual computations are too difficult,
time consuming and error prone. Also, there are some connections between computer science and mathematics
in the areas of numerical analysis, logic, and number theory. [3]
III. MATHEMATICAL STUDIES IN COMPUTER SCIENCE
In many universities across the U.S. and the world, computer science curriculum usually includes some real
mathematics courses such as Discrete Mathematics, Numerical Analysis, and math-oriented course such as
Digital Logic (Boolean Algebra).
III. 1. DISCRETE MATHEMATICS
Discrete mathematics provides the mathematical foundations for several computer science courses such as:
algorithms, automata, data structures, database theory, computer security, and operating systems.
- Logic: mathematical reasoning, the rules of logic gives precise meaning to a mathematical statement. Logic
has many applications to computer science: rules are used in the design of computer circuit, computer
program’s construction, the verification of program’s correctness… Prolog (Programming Logic) was
developed in the 1970s by computer scientists working in the area of artificial intelligence (AI).
- Algorithms: the study of algorithms can be used to solve many different types of problems. The two most
important problems in computer science are searching for an element in a list, and sorting the list into order.
54
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
Example 1: Finding the Maximum element in a finite sequence
procedure max(a1, a2, …, an: integers)
max := a1
for i := 2 to n
if max <ai then max := ai
return max {max is the largest element}
Example 2: The Linear Search algorithm
procedurelinearSearch(x: integer, a1, a2, …, an: distinct integer)
i := 1
while(i ≤ n and x ≠ ai)
i := i + 1
if i ≤ n then location := i
else location := 0
return location {location is the subscript of the item = x}
Example 3: The Binary Search algorithm
procedurebinarySearch(x: integer, a1, a2, …, an: ascending integers)
i := 1 {i is the left endpoint of search interval}
j := n {j is the right endpoint of the search interval}
while i < j
m := (i + j) / 2
if x > am then i := m + 1
else if x < am then j := m – 1
else return m
return 0
{location found}
{location not found}
Example 4: The Bubble Sort algorithm
procedurebubbleSort(a1, a2, …, an: real numbers with n ≥ 2)
for i := 1 to n – 1
for j := 1 to n – i
ifaj> aj+1 then exchange two elements
{a1, a2, …, an is in ascending order}
55
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
Example 5: The Insertion Sort algorithm
procedureinsertionSort(a1, a2, …, an: real numbers with n ≥ 2)
for j := 2 to n
i := 1
whileaj>ai
i := i + 1
m := aj
for k := 0 to j – i – 1
aj-k := aj-k-1
ai := m
{a1, a2, …, an is in ascending order}
- Database: most databases are relational databases, from mathematical concept “Relations” which are the
relationships between elements of a set. Tables in a relational database deal with relationships such as a person
(customer) and his/her telephone number.
Example: Table Students which contains student records
(Student_name, ID_number, Major, GPA)
(Ackerman, 123456, Computer Science, 3.8)
(Chou, 888324, Mathematics, 3.45)
(Adams, 231455, Physics, 3.70)
(Stevens, 789654, Psychology, 2.99)
- Computer security: Mathematics provides algorithms for encryption, description, hashing functions to
protect the databases, computing environments.
Example: In practice, many hashing functions are used. One of the most common is:
h(k) = k mod m
h(064212848) = 064212848 mod 111 = 14
[4]
h(037149212) = 037149212 mod 111 = 65
56
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
III. 2. NUMERICAL ANALYSIS
Numerical analysis is the study of how functions, derivatives, integrals, and differential equations are handled
as a string of numbers in a computer system. Numerical analysis also deals with series of expansions such as
Taylor series, Fourier series… Mathematicians, computer scientists and engineers have to work with a huge
computing tasks and that is why numerical analysis involves deeply with the use of computer for solving
problems.
Example 1: The Taylor expansion is:
=1+
!
+
!
+
!
+ ⋯ , −∞ <
<∞
Example 2: The Fourier series:
=
+
#
cos
$
+
sin
"
To solve the two problems above (example 1 and 2) which expands to 10 terms is already a tremendous task.
This is why numerical analysis requires to use a computer software package such as Mathlab, Linpack,
Eispack,…
Example 3: Newton’s divided-difference formula:
To obtain the divided-difference coefficients of the interpolatory polynomial P(x), for x indexed from 0 to n
(x0, x1, x2, …,xn).
INPUT: numbers x0, x1, …,xn: values f(x0), f(x1),… f(xn) as F0.0, F1.0,…
OUTPUT: the numbers F0.0, F1.1,…,Fn.n where
Pn(x) = F0.0 +
Step 1:
+$
%&. ( ∏+,
-$
− (
(Fi.j = f|x0,x1,… xi|)
for i = 1, 2, …, n
for j = 1, 2, …, i
setFi.j =
.+.-, ,/0, .1,
Step 2:
OUTPUT (F0.0, F1.1,…,Fn.n)
+, +,-
STOP
(Fi.j = f|xi-j,… xi|)
[5]
57
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
III. 3. DIGITAL LOGIC
Digital circuit technology has changed rapidly. Very Large Scale Integrated (VLSI) circuit chips now can
contain millions of transistors. Digital logic theory is applied in the design and analysis of circuit, and Boolean
algebra is the basic mathematical tool needed to analyze and synthesize an important class of switching
circuit.
Example: Design a binary adder
Truth table for a full adder
X
Y
CinCout
Sum
----------------------------------0
0
0
0
0
0
0
1
0
1
0
1
0
0
1
0
1
1
1
0
1
0
0
0
1
1
0
1
1
0
1
1
0
1
0
1
1
1
1
1
Sum = X ' Y ' Cin + X ' YC 'in + XY ' C 'in + XYCin
= X ' (Y ' Cin + YC 'in ) + X (Y ' C 'in +YCin )
= X ' (Y ⊕ Cin ) + X (Y ⊕ Cin )' = X ⊕ Y ⊕ Cin
Cout = X ' YCin + XY ' Cin + XYC 'in + XYCin
= ( X ' YCin + XYCin ) + ( XY ' Cin + XYCin ) + ( XYC 'in + XYCin )
= YCin + XCin + XY
58
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
When 1’s complement is used, the end-around carry is accomplished by connecting C4 to C0 input.
Binary Subtracter using full adder
Subtraction is done by adding the 2’s complemented number to be subtracted
[6]
The 2’s complement represents a negative number in binary. It is form by inverting all bits (1’s) then add by 1,
as you can see in the diagram above. (c1 = 1)
59
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
III. 4. ALGORITHMS
Mathematics provides the capability, effectiveness in problem solving skills. This capability allows computer
programmers to build effective algorithms for solving particular problems. Some popular, frequently used
algorithms were developed very long time ago by famous ancient Greek mathematicians.
III. 4. 1. Euclid’s algorithm to find the greatest common divisor (GCD)
It is one of the earliest known numerical algorithm developed by Euclid in around 300 B.C. for finding the
greatest common divisor (GCD) of two positive integers. Euclid lived in Alexandria during the reign of
Ptolemy (323-283 BC) and regarded as the father of geometry.
Let gcd(x, y) be the greatest common divisor of two positive integers x and y.
If x = y, thengcd(x, y) = gcd(x, x) = x
If x > y, then gcd(x, y) = gcd(x-y, y)
Proof:
Suppose that d is a divisor of both x and y, then there exist integers q1 and q2
such that x = q1d, y = q2d. Then
x – y = q1d - q2d = (q1 – q2)d => d is also a divisor of x – y
In a similar fashion, we can prove that any divisor of x – y and y is also a divisor of
x.
Java implementation Euclid’GCD algorithm
publicintgcd(int x, int y){
int p = x;
//preserve original value x, y
int q = y;
while(p != q)
if(p > q)
p -= q;
else
q -= p;
return p;
}
// or q (p = q)
[7]
60
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
III. 4.2. Sieve of Eratosthenes for collecting prime numbers
Eratosthenes (276 – 194 BC) was the third librarian of the famous Alexandria library. He is known for his
measurement of the earth’s perimeter and estimating the distances to the sun and the moon. In mathematics, he
developed an algorithm to collect prime numbers. This algorithm is known as the “Sieve of Eratosthenes”
To find all prime numbers which are smaller than a given number N?
1. Write all integers from 1 to N in order
2. Since 1 is not a prime number so cross it out
Then the algorithm proceeds sequentially in steps, on each step:
3. Find the first number that is not crossed yet, mark it as a prime,
then cross out all of its remaining multiples
Repeat step 3 above while the least available number does not exceed √3, because, for a
number A = a.b less than or equal to N, the factors a, b cannot exceed √3. When the
algorithm stops, the prime numbers are not crossed.
[8]
Java implementation of Sieve Eratosthenes algorithm
public static void getPrimes(int a[]){
for(int i=2; i*i<a.length; i++)
if (a[i] != 0)
for(int j=i+i; j<a.length; j+=i)
a[j] = 0;
}
IV. CONCLUSION
We have been using some form of mathematics in our daily lives, either at work or do some mentally analysis,
calculations on a shopping day. Mathematics penetrates into other fields in many different ways such as
mathematical models and methods can be used to analyze some particular problems that arise in computer
science. [9]
No-one can deny the important role of mathematics in computer science. However, as the computer
technology improves rapidly, mathematicians, engineers can now rely on computer to solve their problems,
making their works easier, faster, and reliable.
61
International Journal of Scientific Research and Innovative Technology ISSN: 2313-3759 Vol. 2 No. 12; December 2015
REFERENCES:
[1]http://en.wikipedia.org/wiki/Mathematics
3/3/2015
19:34
[2]http://en.wikipedia.org/wiki/Atanasoff%E2%80%93Berry_computer
3/2/2015
20:17
[3] Donald E. Knuth, “Computer Science and its relation to Mathematics”,
https://www.maa.org/sites/default/files/pdf/upload_library/22/Ford/DonaldKnuth.pdf
[4] Kenneth H. Rosen, “Discrete Mathematics and its Applications”, 7e, Mc. Graw
Hill companies, New York, NY., 2012, ISBN: 978-0-07-338309-5, pages:
Xviii, 1, 51, 191-198, 297, 311-314
[5] Burden, Faires, “Numerical Analysis”, 9e, Cengage Learning, Boston, MA., 2011,
ISBN-10: 0-538-73351-9, pages: 126
[6] Roth, Kinney “Fundamentals of Logic Design”, 6e, Cengage Learning, MA., 2010,
ISBN-10: 0-495-47169-0, pages: xv, 104-106
[7] http://people.cis.ksu.edu/~schmidt/301s12/Exercises/euclid_alg.html
3/5/15
11:01
[8] http://www.cut-the-knot.org/Curriculum/Arithmetic/Eratosthenes.shtml
3/5/15 21:09
[9] Lehman, Leighton, Meyer, “Mathematics for Computer Science”, MIT, 2010, Page 3
62
3/3/2015
20:44