0% found this document useful (0 votes)
32 views

Mathema'cs in Computer Science: Presented By: Sadia Marium

The document discusses the role of mathematics in computer science. It explains that mathematics is important at every layer of computing, from the lowest hardware level to application software. Mathematics is used for tasks like arithmetic operations, memory management, algorithms, and rendering user interfaces. Cryptography is presented as one example application that relies heavily on mathematical concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Mathema'cs in Computer Science: Presented By: Sadia Marium

The document discusses the role of mathematics in computer science. It explains that mathematics is important at every layer of computing, from the lowest hardware level to application software. Mathematics is used for tasks like arithmetic operations, memory management, algorithms, and rendering user interfaces. Cryptography is presented as one example application that relies heavily on mathematical concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Mathema'cs

in Computer Science
Presented by : Sadia Marium
Sep 18, 2018
Revision : Computer
Organiza'on
Parts of a Basic Computer
Von Neumann Basic Structure
1. Central Processing Unit (CPU)
2. Main Memory Unit (RAM)
3. Input/Output Devices
Von Neumann Basic Structure
•  Control Unit
–  A control unit (CU) handles all processor control signals. It directs all input
and output flow, fetches code for instruc'ons and controlling how data
moves around the system.
•  Arithme.c and Logic Unit (ALU)
–  The arithme'c logic unit is that part of the CPU that handles all the
calcula'ons the CPU may need, e.g. Addi'on, Subtrac'on, Comparisons.
–  It performs Logical Opera'ons, Bit ShiTing Opera'ons, and Arithme'c
Opera'on.
Arithme'c and Logic Unit (ALU)
•  Basic Opera'ons of ALU
–  Arithme'c Opera'ons
•  Circuits for performing Arithme'c
opera'ons
–  Logic Opera'ons
•  Circuits for performing Arithme'c
opera'ons

•  Registers
–  Special purpose storage inside ALU
•  Input A, Input B, Output

•  What is 64/32/16/8 bit ALU?
Arithme'c and Logic Unit (ALU)

•  Typical schema'c diagram of ALU


–  A and B are Inputs
–  R is result or output
–  F control signals from CU
–  D is status of the opera'on
CPU Registers
A processor register (CPU register) is one of a small set of
data holding places that are part of the computer processor.
A register may hold an instruc'on, a storage address, or any
kind of data (such as a bit sequence or individual characters).
CPU Registers
•  Accumulator: Stores the results of
calcula'ons made by ALU.
•  Program Counter (PC): Keeps track of the
memory loca'on of the next instruc'ons to
be dealt with. The PC then passes this next
address to Memory Address Register (MAR).
•  Memory Address Register (MAR): It stores
the memory loca'ons of instruc'ons that
need to be fetched from memory or stored
into memory.
•  Memory Data Register (MDR): It stores
instruc'ons fetched from memory or any data
that is to be transferred to, and stored in,
memory.
•  Current Instruc.on Register (CIR): It stores
the most recently fetched instruc'ons while it
is wai'ng to be coded and executed.
•  Instruc.on Buffer Register (IBR): The
instruc'on that is not to be executed
immediately is placed in the instruc'on buffer
register IBR.
Buses
•  Buses
–  Data is transmi_ed from one part of
a computer to another, connec'ng
all major internal components to the
CPU and memory, by the means of
Buses.
•  Types:
–  Data Bus: It carries data among the
memory unit, the I/O devices, and
the processor.
–  Address Bus: It carries the address of
data (not the actual data) between
memory and processor.
–  Control Bus: It carries control
commands from the CPU (and status
signals from other devices) in order
to control and coordinate all the
ac'vi'es within the computer.
Random Access Memory
•  Computer memory is called random access
memory (RAM)
–  “Random access” is out-of-date and simply means
that the computer can refer to the memory
loca'ons in any order
•  RAM is measured in megabytes (MB) or
gigabytes (GB)
•  Lots of memory is need to handle the space
required of programs and data
Main Memory (Random Access Memory)
•  Memory is an array of bytes.
–  Each byte has a unique numeric address star'ng at
address 0

•  Contents stored in a byte are accessed using it’s


address.

•  Contents various bytes can be accessed


independently in any order therefore main
memory is also called Random Access Memory
(RAM)

•  RAM is outside the CPU and is connected to it


using Address, Data and Control Busses.
Main Memory (Random Access Memory)
•  Two main flavors of RAM are SRAM (Sta'c) and DRAM (Dynamic)
•  SRAM
–  is constructed from technology that can retain informa'on as long as
power(electricity) is provided to it.
–  provides faster access than DRAM but requires large circuit and hence
is more expensive
•  DRAM
–  is constructed from technology that retain informa'on for short
periods and hence frequently refreshed.
–  frequent refresh requires more power
•  RAM (both SRAM and DRAM) are vola'le
–  i.e. contents are lost if the power is cut-off
Read Only Memory (ROM)
•  ROM is memory like RAM but it is non-vola'le
–  i.e. retain its contents even when electricity is switched off
–  is read only
•  i.e. once data is wri_en onto it we can only read it and may need
special devices to erase and then write new data onto it
•  is used to carry permanent programs/data along with machines
–  Comes in many flavors
•  ROM, PROM, EPROM, EEPROM
–  ROM: Come as read only and its contents can not be modified
–  PROM: (Programmable) Blank ini'ally and can be wri_en once
–  EPROM: Erasable Programmable ROM
–  EEPROM: Electrically Erasable Programmable ROM
Input / Output (IO)
•  Input/Output Devices
–  Program or data is read into main
memory from the input device or
secondary storage under the
control of CPU input instruc'on.
–  Output devices are used to output
the informa'on from a computer. If
some results are evaluated by
computer and it is stored in the
computer, then with the help of
output devices, we can present it to
the user.

•  Basic I/O using Interrupts


–  CPU ask the I/O device to do the work

–  When the device is finished it generates a
signal for the CPU.

–  The CPU uses the data bus to transfers the


data from/to the temporary storage(buffer) of
I/O device into/from the main memory
–  Processor is involved in the en're data
transfer process
The Fetch/Execute Cycle
•  “Instruc.on Execu.on Engine”…a
machine that cycles through a series 1.Instruc1on Fetch (IF)

of opera'ons
•  Series is called: Fetch/Execute Cycle 2.Instruc1on Decode(ID)
1.  Get the next instruc'on
2.  Figure out what to do 3.Data Fetch(FD)/
3.  Gathering the data needed to do it Operand Fetch(OF)

4.  Do it
5.  Save the result, and 4.Execute(EX)

6.  Repeat (billions of 'mes/second)!


5.Result Return(RR)/
Store(ST)
Opera'on of a Control Unit
•  Input (FETCH)
–  Read Data and Instruc.ons from Memory
•  Process (EXECUTE)
–  Decode the instruc'on
•  Determine the opera'ons to be
performed
–  Read Operands
•  Bring Data From general registers into
input registers
(if needed) and ac'vate appropriate
Circuits in ALU
–  Execute Instruc'on
•  Ac'vate appropriate Circuits in ALU
–  Output
•  Write the results back to general
register
•  This opera'on is carried out repeatedly
(Millions of 'me per second) and is called
FETCH-EXECUTE CYCLE
OR
FETCH-DECODE-EXECUTE CYCLE
MATHEMATICS IN CS
What is mathema'cs?
•  Mathema'cs is defined as the
science which deals with logic
of shape, quan'ty and
arrangement.
•  During ancient 'mes in Egypt, the Egyp'ans
used math's and complex mathema'c
equa'ons like geometry and algebra. That is
how they managed to build the pyramids.

•  Mathema'cs is basically related to


understanding structure. It is used to do
logical analysis, make relevant calcula'ons and
eventually to deduce conclusions and pa_ern.
Role of Math in CS
•  What is the importance of the ground in building?
•  If you don’t have an understanding of the founda'on on
which you place a structure, that structure may be fairly
wobbly and will fail over 'me.
•  Same is the case here with Computer Science
Func'ons

A func'on relates an input to


an output.
It is like a machine that has
an input and an output. And
the output is related
somehow to the input


Map of Computer Science
Mathema'cs is prominent at every layer of
Compu'ng:
•  The lowest layer with ALU performing the Arithme'c and
logical opera'ons.
•  The middle layer with Opera'ng system making use of
mathema'cs and algorithms for process management,
memory management, disk management, networking
opera'ons and more.
•  The upper layer with all sort of applica'on and system
soTware using all sort of algorithms to create all sort of
magic.
•  Right now, when you are reading this text, there is
mathema'cs going on behind the scenes to render it on your
screen taking into account specific font face/size/color/
monitor's resolu'on/aspect ra'o/X,Y coordinates etc. with
different algorithms contribu'ng to the final result.
Mathema'cs applica'ons
Mathema'cs in Cryptography
•  Cryptography is a method of storing and transminng data in a par'cular
form so that only those for whom it is intended can read and process it.

Plain Text: meet me aTer the toga party


Cipher: PHHW PH DIWHU WKH WRJD SDUWB
Each element is shiTed 3 'mes to the right
Maths and Gaming
Image Processing & Computer Vision
•  Detec'ng/tracking
Hurricanes
•  Cancer/Tumor Detec'on
•  Anomaly Detec'on
•  Movement detec'on from
satellite images
•  …and many more

All these applica'ons required
heavy mathema'cal opera'ons
Robo'cs
•  In robo'cs 3D linear and rota'onal mo'on are involved
•  Understanding of different coordinate systems are necessary
to describe posi'on
–  Coordinates to describe posi'on.
•  rectangular (x,y,z)
•  cylindrical (r,θ,z)
•  spherical (r,θ,ϕ)
•  Similarly pose es'ma'on and object holding
required complex maths

Simple rotation Rotation &


translation
Epidemiology
•  Epidemiology is the branch of medicine
which deals with the incidence,
distribu'on, and possible control of
diseases and other factors rela'ng to
health.
•  What is your hearth rate now? How you
measure it? 100 beats/min
•  How smart devices measure blood
pressure, heart rate and sugar?
•  How the computerized eye-sight
checking machine (Auto-Refractometer)
works?
•  All these techniques required math at
backend.
Math in CS
Civil Engineering Apps

•  WAGmob brings you, Simple and Easy, on-the-go learning app


for "Civil Engineering". The byte sized app helps you to
understand the basics of "Civil Engineering".

How to develop such applica'ons without


understanding of mathema'cs?

Math in CS
Mechanical Engineering apps

•  Some applica'ons for 3D designing in the


field of Mechanical Engineering
–  AUTODESK
–  INVENTOR
–  Etc.
•  All these applica'on needs heavy math at
back end.
•  As in given figure there are Force,
Rota'on, Momentum and Velocity
involved.
•  By changing one quan'ty effects other
quan''es and the changes can be
measured/observed through computer
Concept of Op'miza'on
•  In mathema'cal terms, an op#miza#on problem is the
problem of finding the best solu'on from among the set of
all feasible solu'ons.
•  In compu'ng, op'miza'on is the process of modifying a
system to make some features of it work more efficiently or
use fewer resources.
•  In simple terms op'miza'on is choosing INPUTS that will
result in the best possible OUTPUTS
Op'miza'on
•  Let’s take a look at a very
simple example of an
op'miza'on problem:
•  Given a parabola, chose x to get
the largest y. We can try
different x values to see the
resul'ng y value.
•  Eventually we can find the
maximum y value by choosing
Best X.
•  You may also have solved this
type of problem in calculus class
by taking the deriva've of the
parabola and senng it equal to
zero.
Where can we use
OPTIMIZATION?
Bridge Construc'on
–  Designing a bridge that can carry the maximum load possible for a given
cost.
–  Input is Design and output is to Maximize Load Bearing
Airplane Wing Design
–  Design an airplane wing to minimize weight while maintaining
strength.
–  Input is Wing Design and output is to Minimize Weight
Stock Market
•  Selec'ng the best set of stocks to invest in to maximize returns based on
predicted performance.
•  Input is Stock Poruolio and Output is to maximize returns on investment
Warehouse placement
•  Choosing the op'mal loca'on for a warehouse to minimize shipment
'mes to poten'al customers.

Temperature control of a chemical
reac'on
•  Controlling the temperature of a chemical reac'on throughout a process
to maximize the purity of a desired product.

Space Shu_le / Suborbital Vehicle
trajectory op'miza'on
•  Even op'miza'on is involved
in life cri'cal missions
•  Trajectory of space shu_le is
calculated and op'mized to its
target posi'on by minimizing
fuel cost and 'me.
Op'miza'on
Con'nue…
•  As you can see, op'miza'on is a powerful tool in many
applica'ons.
•  This is just a small sampling of the many fields that make use
of op'miza'on techniques to improve the quality of their
solu'ons.
•  If something can be modeled mathema'cally, it can usually
be op'mized.
Introduc'on to Graph
•  In Computer Science, graph is a collec'on
of connected NODES (ver'ces) with the
help of EDGES (links)
•  A node is a thing or an en'ty and we
can assign some value to it, so a
person, a car and a city are examples
of a node.
•  An edge can be define as a rela'on of
some sort between two or more nodes
•  A perfect layman's example might
be Facebook.
•  The network of you, your friends, and their
friends etc. are collec'vely referred to as
the social graph
•  Here people are nodes connected through
friendship edges

Graph
•  Similarly we can shows
connected ci'es using graph as
in given figure
•  Ci'es are represented as nodes
(ver'ces) and the road’s
distance is represented on
edges.
Working with
Graphs
Point to Ponder

•  Do you know:
–  How does facebook suggest friends?
Finding shortest path between two nodes

•  Finding shortest path


•  Can you find the shortest path between node 1 and 5 in given
graph?
Ac'vity
•  Can you find the shortest path from Lahore to Gujrat?
Solu'on
Thank you

You might also like