Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 45

Introduction to

Computational
Mathematics
CT4032
Week 1 – Computational Mathematics
Dr Nasreen Anjum
Lecturer in Computing University of Gloucestershire
PhD in Computer Science , Kings College London, UK
Learning Outcomes
• To understand how the
course will progress, and
what is required of you
with your assignment.

• To start thinking about


Learning how mathematical
problems can be done
Outcomes through computer
systems.

• To get a grasp of how a


computer is able to read
and use programming
language to perform
certain tasks.
Module Title: Computational Math’s

Module Code: CT4032

Computation Level of Study: 4

Mathematics Scheduled Contact Hours: 36

Independent Learning Hour: 114

Assessment: 100% individual coursework; 2000


words or equivalent
Module Content
Lecture Topic Practical
Introduction to Computational Math Mathematical Computations in Python
Number Theory Python Calculation Functions
Modular Arithmetic Calculating Clocks
Sequences and Series Sequences and Series in Python
Computational Linear Algebra Computational Linear Algebra Python
Vectors and Matrices Mathematics in Cryptography
Limits and Differential Calculus Limits and differential calculus Python
Integral Calculus Integral Calculus Python
Computational Complexity Computational complexity Python
Mathematical Programming & Optimization Mathematical programming & optimization Python
Computational Probability and Inferencing Modeling and Calculating Probabilities
Assessment Workshop Assessment Workshop
Lecture Structure
Lecture (Theory)
Discussing the mathematical concept/topic theory and
processes.
Lecturer (Practical)
Coding the different mathematical processes to see how they
are implemented through computer systems.
A brief Visit to
Moodle Page
• Course: CT4032 Computational Maths (SEM1 - 202
3/24) (glos.ac.uk)
Assignment Brief

Pick four of the different mathematical topics that we have talked about throughout the course. You will discuss the theory behind each of the
topics you have chosen and demonstrate the mathematical processes. Finally, an in-depth discussion of a real-world example for the topic being
applied.

An overview of the topics discussed are:


 Number theory
 Modular arithmetic
 Sequences and series
 Computational linear algebra
 Vectors and matrices
 Limits and differential calculus
 Integral calculus
 Computational complexity
 Mathematical Programming & Optimization
 Computational Probability and Inferencing

The word count for this assessment is 2000(+/-10%). The Deadline:


Include all literature used within this assignment into your references section.
Any
Questions
What do you currently know?

What is current knowledge in computation science?

How good is your math's?

Have you ever coded?


What is Computational
Mathematics

Computational mathematics is the area of


technology involving the application of
mathematical topics using computing technology.

Simplify: Math's on computer


What are Real Life Applications of Computational Maths

1. Internet Security- 2. Searching shortest and


Encryption Algorithms Reliable Routes to
Destinations
(Google Map)

3. Science and Engineering 4. Digital Logic and Design


Applications
• Encryption Algorithms
• Use to provide confidentiality
• Encryption Algorithm: Transforms the plaintext into ciphertext
• Decryption Algorithm: Transform the ciphertext into plaintext
• Plain Text: Hello World
• Ciphertext: hjhdkjfhdkjhjfdhfdhfhkdhjkhjdkhkjhjk
• Example
• Substitution Algorithms: Ceaser cipher algorithm
• A, B C…..1 2 3
1. Internet • Attack….. 1 1

Security (1)
• Encryption Algorithms
 Ceaser cipher algorithm is
the classical simple
encryption algorithm.
 Easily breakable
 Involve little mathematics
 Advanced Encrpytion
Algorithm (AES)
1. Internet  Moderan and complicated
algorithm
Security (2)  Involves many mathematical
simple and complex
operatons such as logical
addition, multiplication,
division, Exclusive OR,
Exclusive not operations etc.
 Matrix calculation, mixing
rows, shaping digits,
swapping columns, dropping
bits and adding bits etc.
2. Searching shortest and
Reliable Routes to Destinations

Searching Algorithms
Google Map uses A*
algorithm to find the
shortest paths to desired
destinations.
3. Science and Engineering

DNA and RNA sequencing Machine learning and AI techniques to Machine learning and AI techniques to
predict a determined health problem in predict the weather forecasting, stock
humans exchange forecasting, pandemic forecasting
• Digital logic design is used to develop hardware, such as circuit
boards and microchip processors
• Microprocessor chips comprises of millions of components such
as logical gates and circuitry to carryout arithmetic operations
such as logical addition, subtraction, multiplication, and division
etc.
• Logical And Gate, Logical OR gate, Logical Nor Gate, Adder,
4. Digital Subtractor,

Logic and
Design
Computers are powerful machines…
…but also stupid on their own
How computers know what to do with data?
How Solving Problems with Computational Math’s?

Obviously with simpler problems solutions can be solved normally, but how computer will solve these simple problems?

1+1=? 123 – 86 = ?

36 + 85 = ? 8x7=?

74 – 39 = ? 144 ÷ 4 = ?

but how computer will solve these simple problems?


More Complex Problems?
What is an
algorithm?
• In mathematics and computer science, an algorithm is a finite sequence of
rigorous instructions, typically used to solve a class of specific problems or
to perform a computation.
• Advantages
• It is a step-wise representation of a solution to a given problem,
which makes it easy to understand.
• An algorithm uses a definite procedure.
• It is not dependent on any programming language, so it is easy to
understand for anyone even without programming knowledge.
• Every step in an algorithm has its own logical sequence so it is easy
to debug.
• By using algorithm, the problem is broken down into smaller
pieces or steps hence, it is easier for programmer to convert it into
an actual program.
• Disadvantages
• Time consuming
• Difficult to show Branching and Looping in Algorithms.
• Big tasks are difficult to put in Algorithms.
There are three key points towards designing an algorithm.

• Accuracy

Algorithms • Efficiency

• Stability
Brute Force Algorithm

• trying all possibilities until a result


is found.
• simplest and most basic
algorithm.
• Allow for the detection of the
ideal or best solution, since they
check all possible solutions.
• Used to crack the password and
encryption keys
Writing Algorithms

• C++ • Javascript
• Python • Scala
• Java • MATLAB
• Ruby • R
Decimal Binary Octal Hexadecimal

0 0000 000 00
1 0001 001 01
2 0010 002 02
3 0011 003 03
Computer 4 0100 004 04

Number
5 0101 005 05
6 0110 006 06

System 7
8
0111
1000
007
010
07
08
9 1001 011 09
10 1010 012 0A
11 1011 013 0B
12 1100 014 0C
13 1101 015 0D
14 1110 016 0E
15 1111 017 0F
Research
What are the
Activity- 10 applications of four
number systems you

Minutes studied in previous


slide?
Some Number Theory
 The branch of mathematics that deals with the properties and relationships of
numbers, especially the positive integers
 Since ancient times, people have separated the natural numbers into a variety of
different types.
 odd 1, 3, 5, 7, 9, 11, . . .
 Even 2, 4, 6, 8, 10, . . .
 square 1, 4, 9, 16, 25, 36, . . .
 cube 1, 8, 27, 64, 125, . . .
 prime 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, . . .
 composite 4, 6, 8, 9, 10, 12, 14, 15, 16, . . .
 1 (modulo 4) 1, 5, 9, 13, 17, 21, 25, . . .
 3 (modulo 4) 3, 7, 11, 15, 19, 23, 27, . . .
 triangular 1, 3, 6, 10, 15, 21, . . .
 perfect 6, 28, 496, . . .
 Fibonacci 1, 1, 2, 3, 5, 8, 13, 21, . . .
PRIME NUMBER
• In math, prime numbers are whole
numbers greater than 1, that have only two
factors – 1 and the number itself.
• Prime numbers are divisible only by the
number 1 or itself.
• For example, 2, 3, 5, 7 and 11 are the first
few prime numbers.
• Here’s a list of all the prime numbers up to
100, marked in yellow.
Prime Factors

• Start with the number 12.


• Divide it by the smallest prime number, which is 2. Since 12 is
divisible by 2 (12 ÷ 2 = 6), we write down 2 as a prime factor.
• Now, we continue with the quotient, which is 6.
• Divide 6 by the smallest prime number again, which is 2 (6 ÷
2 = 3), and write down another 2 as a prime factor.
• Now, we have 3 left, which is a prime number itself. So, write
down 3 as a prime factor.
• At this point, we have factored 12 completely into its prime
factors: 2 × 2 × 3.
• So, the prime factors of 12 are 2 and 3. This means that 12
can be expressed as the product of these prime numbers: 2 ×
2 × 3.
Practice
• Find the prime factor of following
• 24

Exercise • 36
• 64
 Repeated prime factors are discussed here.
 Since, 8 = 2 × 2 × 2; here 2 is said to be repeated prime factor of 8.
 A number can have two or more different repeated prime
factors.

Repeated  Let us consider some of the examples on repeated prime factors;

(i) The repeated prime factors of 16 = 2 × 2 × 2 × 2. ii) The

Prime
repeated prime factors of 36 = 2 × 2 × 3 × 3.

(iii) The repeated prime factors of 27 = 3 × 3 × 3. (iv) The repeated


prime factors of 25 = 5 × 5.

Factors (v) The repeated prime factors of 49 = 7 × 7. (vi) The repeated


prime factors of 32 = 2 × 2 × 2 × 2 × 2.

(vii) The repeated prime factors of 81 = 3 × 3 × 3 × 3. (viii) The


repeated prime factors of 108 = 2 × 2 × 3 × 3 × 3.

(ix) The repeated prime factors of 100 = 2 × 2 × 5 × 5. (x) The


repeated prime factors of 125 = 5 × 5 × 5.

(xi) The repeated prime factors of 225 = 3 × 3 × 5 × 5.


When two numbers have no common factors other than
1. In other words there is no value that you could divide
them both by exactly (without any remainder).
21 and 22 are relatively prime:
• The factors of 21 are 1, 3, 7 and 21
• The factors of 22 are 1, 2, 11 and 22
(the only common factor is 1)
Relative Prime But 21 and 24 are NOT relatively prime:
• The factors of 21 are 1, 3, 7 and 21
Factors • The factors of 24 are 1, 2, 3, 4, 6, 8, 12 and 24
(the common factors are 1 AND 3)
Relatively Prime is also called "coprime" or "mutually
prime".
Conversely can determine the greatest common divisor
by comparing their prime factorizations and using least
powers
 eg. 300=21×31×52 18=21×32 hence
GCD(18,300)=21×31×50=6
Practise • Find out if 21 and 22 are relatively prime?
• Find out if 6 and 9 are relative prime?
Exercise • Find out if 21 and 25 are relative prime?
Greatest Common Divisor (GCD)
• In mathematics, the greatest common divisor (gcd) of two or more
integers, which are not all zero, is the largest positive integer that divides
each of the integers.
• Example: What is the greatest common divisor of 54 and 24?
• The number 54 can be expressed as a product of two integers in
several different ways:
• 54 × 1 = 27 × 2 = 18 × 3 = 9 × 6.
• Thus the divisors of 54 are: 1 , 2 , 3 , 6 , 9 , 18 , 27 , 54.
• Similarly, the divisors of 24 are: 1 , 2 , 3 , 4 , 6 , 8 , 12 , 24.
• The numbers that these two lists share in common are the common
divisors of 54 and 24: 1,2,3,6.
• The greatest of these is 6. That is, the greatest common divisor of
54 and 24. One writes:
• gcd ( 54 , 24 ) = 6.
Practice Exercise

1. FIND THE GCD OF 45 AND 2. FIND THE GCD OF 25 AND


24 32
Practical Session
Practical
Session – We will be using Python is
Python demonstrate the different
mathematical concepts
Programming discussed in computational
form.
Usually, first problem
within a language just
writes a simple string.

Python “Hello {
World” print(“Hello World!")
}
There are a bunch of different variables that are used in
python to store data.
• Integers = 123

Python • Floating point


• String
=
=
23.678123
“String”
Variables • Character = “A”
• Lists = [12, 63, 35, 29,
33]
In python you don’t need to designate the variable type.
Writing “Hello World!” From a string variable.
Python Hello
World {
str = "Hello World!"
Variable
print(str)
}
We will be developing a
Python Python calculator to both
start learning python, and
Calculator a good way to see how
these mathematic topics
can be coded.
Basic introduction to python

Doing basic math's calculations


• Plus +
• Minus –
• Multiplication x
Practical • Division /
Session Other functionality that can be added
• R Squared (R2), R Cubed (R3), and further.
• Expand to more then two numbers being entered
• Brackets (BODMAS)
• (Brackets, Orders, Division, Multiplication,
Addition, and Subtraction)
Next Week
Number
Theory

You might also like