Remarks on Fast Exp (4/2) How do we measure how fast any algorithm is? Definition. The complexity of an algorithm is a measure of the approximate number.

Slides:



Advertisements
Similar presentations
CS 1031 Recursion (With applications to Searching and Sorting) Definition of a Recursion Simple Examples of Recursion Conditions for Recursion to Work.
Advertisements

Recursive Definitions and Structural Induction
The Fundamental Theorem of Arithmetic (2/12) Definition (which we all already know). A number greater than 1 is called prime if its only divisors are 1.
Quotient-Remainder Theory, Div and Mod
Floating Point (FLP) Representation A Floating Point value: f = m*r**e Where: m – mantissa or fractional r – base or radix, usually r = 2 e - exponent.
Number Systems Standard positional representation of numbers:
1 Computing Functions with Turing Machines. 2 A function Domain: Result Region: has:
1 Section 2.5 Integers and Algorithms. 2 Euclidean algorithm for finding gcd Where L is a larger number, and S is a smaller number, to find gcd(L,S):
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
Simple Data Type Representation and conversion of numbers
3.4/3.5 The Integers and Division/ Primes and Greatest Common Divisors Let each of a and b be integers. We say that a divides b, in symbols a | b, provided.
Numerical Computations in Linear Algebra. Mathematically posed problems that are to be solved, or whose solution is to be confirmed on a digital computer.
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Decimal Number System We are used to the decimal number system which is a positional number system The decimal number 4386 represents the value: 41000.
IT253: Computer Organization
Lecture 2 Number Representation and accuracy
Complexity of the Euclidean Algorithm (2/7) The complexity of an algorithm is the approximate number of steps necessary for the algorithm to finish as.
Chapter 3 Section 1 Number Representation Modern cryptographic methods, unlike the classical methods we just learned, are computer based. Representation.
Bell Work3/23/15 Define the following : – Accuracy – Precision – Scientific Notation.
Vocabulary Chapter 4 unlike fractions unlike fractions terminating decimal - I will give you the definition for this one!! terminating decimal - I will.
Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Floating-Point (real) numbers Consider the Number:4,
Quest Review Unit 2. Get same bases; set exponents = 1. 2 x = x = 2 7 x = 7 2.  3 x = /2x = 3 5 1/2x = 5 x = x = x = 2 5 x.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
16. Binary Numbers Programming in C++ Computer Science Dept Va Tech August, 1999 © Barnette ND, McQuain WD, Keenan MA 1 Binary Number System Base.
Section 3.1: Number Representation Practice HW (not to hand in) From Barr Text p. 185 # 1-5.
Fast Exponentiation (3/31) What is the most efficient way to compute (mod 32591)? We will need an efficient algorithm in order to do “RSA cryptography”,
Complexity 20-1 Complexity Andrei Bulatov Parallel Arithmetic.
Scientific notation is a quick way of writing very large or very small numbers. Scientific Notation & Significant Digits Example #1 Write m/s.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Nicki Dell Spring 2014.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
NUMBER SYSTEMS TWSSP Wednesday. Wednesday Agenda Finish our work with decimal expansions Define irrational numbers Prove the existence of irrationals.
More on Logarithmic Functions 9.6
Introduction – Sets of Numbers (9/4) Z - integers Z + - positive integers Q - rational numbersQ + - positive rationals R - real numbersR + - positive reals.
Computing k th Roots Quickly (4/4) Via the Fast Exp algorithm, we know we can quickly compute large powers of large numbers modulo large numbers. What.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
Logarithms A logarithm find an exponent for a value that is not an integer. For example we know 2 x = 4 that x = 2 or 3 x = 81 x = 4, but what about …
Adding & Subtracting in Scientific Notation Exponents are SAME 1.) If exponents same, add or subtract the coefficients and keep the power of 10. Examples:
SCIENTIFIC NOTATION RULES. Rules for converting to Scientific Notation One non-zero number before the decimal One digit after the decimal If you are making.
Chapter 1 Algorithms with Numbers. Bases and Logs How many digits does it take to represent the number N >= 0 in base 2? With k digits the largest number.
Lecture 6: Floating Point Number Representation Information Representation: Floating Point Number Representation Lecture # 7.
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
Binary numbers. Primary memory Memory = where programs and data are stored – Unit = bit “BIT” is a contraction for what two words? Either a 1 or a 0 (because.
CSE 311 Foundations of Computing I Lecture 12 Modular Arithmetic and Applications Autumn 2012 CSE
1 Computing Functions with Turing Machines. 2 A function Domain Result Region has:
Starter Using two’s Complement form convert the following from Denary to Binary using 8 bits. Answer on mini whiteboard Using two’s.
Unary, Binary, and Beyond Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2003 Lecture 2Jan 16, 2003Carnegie Mellon University.
FractionsDecimalsPowers Answer  This is how you add fractions.
Number Systems Decimal Can you write 12,045 in expanded form? Base? Allowable digits for each place?
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Floating Point (FLP) Representation
CSCI206 - Computer Organization & Programming
Floating Point Representations
Objectives Today: P4 Data Types – Floating Points P4 Variable Quiz P3 Iteration and Selection Practical Are you logged on? Then come around the table Unit.
Introduction To Number Systems
Direct Proof and Counterexample IV: Division into Cases and the Quotient-Remainder Theorem For each of the following values of n and d, find integers q.
Recitation3: CS 3843 Computer Organization 4th week
Number Systems and Binary Arithmetic
Adding & Subtracting in Scientific Notation
Warm-Ups Many numbers can be re-written as the ratio of two integers. For example, . Can the following numbers can be re-written as the.
CSCI206 - Computer Organization & Programming
How to represent real numbers
ECEG-3202 Computer Architecture and Organization
Computing Functions with Turing Machines
Topic 1: Data Representation
Chapter 2: Number Systems
Chapter3 Fixed Point Representation
1.6) Storing Integer: 1.7) storing fraction:
Presentation transcript:

Remarks on Fast Exp (4/2) How do we measure how fast any algorithm is? Definition. The complexity of an algorithm is a measure of the approximate number of steps needed to finish as a function of the size of the input. For example, we showed a while back that the complexity of the Euclidean Algorithm is approximately 6.7 log 10 (b) where b is the smaller of the two numbers.

What about Fast Exp? What about Fast Exp? Since the exponent repeatedly doubles in Step 1 (and because we need to do Step 3 also), the complexity is approximately 2 log 2 (k) where k is the exponent. Example. If k = 12574, we need about 2(13) = 26 steps. Example. Suppose k has 100 decimal digits (i.e., log 10 (k)  100), then Fast Exp with require about 2(100 / log 10 (2))  664 steps.

About Binary Representations Why can any number be written as sum of powers of 2? It’s because mod 2, there are only two numbers, 0 and 1. In general, the base-b representation of a number k is given by k = C 0 b 0 + C 1 b 1 + C 2 b C n b n where n is the largest exponent such that b n  k (or, said another way log b (k) – 1 < n  log b (k)), and where all the coefficients C i lie in the range 0 to b – 1 (i.e., the coefficients are all the integers mod b). Example. The base-5 representation of 339 is 339 = 2(5 3 ) + 3(5 2 ) + 2(5 1 ) + 4(5 0 ) = What’s special about 2? All the coefficients C i are either 0 or 1. Hence any k is a sum of powers of 2!

Assignment for Friday “Absorb” Chapter 16 and the class notes from 3/31 and 4/2. Find the base-3 representation of 600. Use Fast Exp to compute (mod 333) “by hand”. (Answer is 229).