MA/CSSE 473 Day 06 Mathematical Induction Modular Arithmetic Do question 1 on today's quiz (work with another person)

Slides:



Advertisements
Similar presentations
Discrete Mathematics Math 6A Homework 9 Solution.
Advertisements

Cryptography and Network Security
A simple example finding the maximum of a set S of n numbers.
Number Theory and Cryptography
Divide and Conquer. Recall Complexity Analysis – Comparison of algorithm – Big O Simplification From source code – Recursive.
CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Tyler Robison Summer
CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Dan Grossman Spring 2010.
1.  The set N = {1,2,3,4,……..} is known as natural numbers or the set of positive integers  The natural numbers are used mainly for :  counting  ordering.
Congruence class arithmetic. Definitions: a ≡ b mod m iff a mod m = b mod m. a  [b] iff a ≡ b mod m.
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
CSC 2300 Data Structures & Algorithms January 30, 2007 Chapter 2. Algorithm Analysis.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank. Modified By Mingwu Chen Induction.
CSE 321 Discrete Structures Winter 2008 Lecture 10 Number Theory: Primality.
Arithmetic.
BY MISS FARAH ADIBAH ADNAN IMK
Data Representation Number Systems.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,

Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
MA/CSSE 473 Day 05 Factors and Primes Recursive division algorithm.
Mathematics of Cryptography Part I: Modular Arithmetic
MA/CSSE 473 Day 03 Asymptotics A Closer Look at Arithmetic With another student, try to write a precise, formal definition of “t(n) is in O(g(n))”
1 Lecture 2: Parallel computational models. 2  Turing machine  RAM (Figure )  Logic circuit model RAM (Random Access Machine) Operations supposed to.
CS 312: Algorithm Analysis Lecture #3: Algorithms for Modular Arithmetic, Modular Exponentiation This work is licensed under a Creative Commons Attribution-Share.
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
Analysis Tools Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
Mathematics in OI Prepared by Ivan Li. Mathematics in OI Greatest Common Divisor Finding Primes High Precision Arithmetic Partial Sum and Differencing.
MA/CSSE 473 Day 02 Some Numeric Algorithms and their Analysis.
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Fundamentals CSE 373 Data Structures Lecture 5. 12/26/03Fundamentals - Lecture 52 Mathematical Background Today, we will review: ›Logs and exponents ›Series.
MA/CSSE 473 Day 02 Some Numeric Algorithms and their Analysis.
Chinese Remainder Theorem Dec 29 Picture from ………………………
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Nicki Dell Spring 2014.
MA/CSSE 473 Day 06 Euclid's Algorithm. MA/CSSE 473 Day 06 Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm.
MA/CSSE 473 Day 08 Extended Euclid's Algorithm Modular Division Fermat's little theorem.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Modular Arithmetic and the RSA Cryptosystem Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 9Sept 27, 2005Carnegie.
ADVANCED ALGORITHMS REVIEW OF ANALYSIS TECHNIQUES (UNIT-1)
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
MA/CSSE 473 Day 09 Modular Division Revisited Fermat's Little Theorem Primality Testing.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
MA/CSSE 473 Day 06 DivisionPrimes Modular Arithmetic.
MA/CSSE 473 Day 05 More induction Factors and Primes Recursive division algorithm.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Winter 2015.
CSE 311 Foundations of Computing I Lecture 12 Modular Arithmetic and Applications Autumn 2012 CSE
CSE 311 Foundations of Computing I Lecture 11 Modular Exponentiation and Primes Autumn 2011 CSE 3111.
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division Fermat's little theorem intro.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
MA/CSSE 473 Day 05 Factors and Primes Recursive division algorithm.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
Thinking Mathematically
MA/CSSE 473 Day 06 Euclid's Algorithm.
MA/CSSE 473 Day 05 Factors and Primes Recursive division algorithm.
MA/CSSE 473 Day 06 Euclid's Algorithm.
Congruence class arithmetic
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015.
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
Number Theory (Chapter 7)
Mathematical Induction Recursion
Lecture 20 Guest lecturer: Neal Gupta
CSE 311 Foundations of Computing I
Applied Discrete Mathematics Week 9: Integer Properties
Section 10.3 Modular Arithmetic
Mathematical Induction
Cryptography Lecture 16.
Section 9.3 Modular Arithmetic.
Presentation transcript:

MA/CSSE 473 Day 06 Mathematical Induction Modular Arithmetic Do question 1 on today's quiz (work with another person)

MA/CSSE 473 Day 06 Student Questions Another induction example (odd pie fight) Modular Arithmetic Algorithms/Analysis ANNOUNCEMENTS: HW4 assignment has been updated for this term. Some ICQ 5 papers have "gone missing", so I am not returning that quiz today.

Accidentally skipped last time Find a simple big-Theta expression (as a function of n) for the following sum –when 0 < c < 1 –when c = 1 –when c > 1 f(n) = 1 + c + c 2 + c 3 + … + c n Q1

Another Induction Example Pie survivor –An odd number of people stand in various positions (2D or 3D) such that no two distances between people are equal. Each person has a pie A whistle blows, and each person simultaneously and accurately throws his/her pie at the nearest neighbor –Claim: No matter how the people are arranged, at least one person does not get hit by a pie –Let P(n) denote the statement: "There is a survivor in every odd pie fight with 2n + 1 people" –Prove by induction that P(n) is true for all n ≥ 1 Q2

Algorithm for Integer Division Let's work through divide(19, 4). Analysis?

Modular arithmetic definitions x modulo N is the remainder when x is divided by N. I.e., –If x = qN + r, where 0 ≤ r < N ( q and r are unique! ), –then x modulo N is equal to r. x and y are congruent modulo N, which is written as x  y (mod N), if and only if N divides (x-y). –i.e., there is an integer k such that x-y = kN. –In a context like this, a divides b means "divides with no remainder", i.e. "a is a factor of b." Example: 253  13 (mod 60)

Modular arithmetic properties Substitution rule – If x  x' (mod N) and y  y' (mod N), then x + y  x' + y' (mod N), and xy  x'y' (mod N) Associativity – x + (y + z)  (x + y) + z (mod N) Commutativity – xy  yx (mod N) Distributivity – x(y+z)  xy +yz (mod N)

Modular Addition and Multiplication To add two integers x and y modulo N (where k =  log N  (the number of bits in N) where 0≤x<N and 0≤y<N, begin with regular addition. –x and y are in the range_____, so x + y is in range _______ –If the sum is greater than N-1, subtract N. –Run time is Ѳ ( ) To multiply x and y modulo N, begin with regular multiplication, which is quadratic in k. –The result is in range ______ and has at most ____ bits. –Compute the remainder when dividing by N, quadratic time. So entire operation is Ѳ( ) Q3-4

Modular Addition and Multiplication To add two integers x and y modulo N (where k =  log N , begin with regular addition. –x and y are in the range 0 to N-1, so x + y is in range 0 to 2N-1 –If the sum is greater than N-1, subtract N. –Run time is Ѳ (k ) To multiply x and y, begin with regular multiplication, which is quadratic in n. –The result is in range 0 to (N-1) 2 and has at most 2k bits. –Then compute the remainder when dividing by N, quadratic time in n. So entire operation is Ѳ(k 2 )

Modular Exponentiation In some cryptosystems, we need to compute x y modulo N, where all three numbers are several hundred bits long. Can it be done quickly? Can we simply take x y and then figure out the remainder modulo N? Suppose x and y are only 20 bits long. –x y is at least (2 19 ) (2 19 ), which is about 10 million bits long. –Imagine how big it will be if y is a 500-bit number! To save space, we could repeatedly multiply by x, taking the remainder modulo N each time. If y is 500 bits, then there would be multiplications. This algorithm is exponential in the length of y. Ouch!

Modular Exponentiation Algorithm Let k be the maximum number of bits in x, y, or N The algorithm requires at most ___ recursive calls Each call is Ѳ( ) So the overall algorithm is Ѳ( ) Integer division

Modular Exponentiation Algorithm Let k be the maximum number of bits in x, y, or N The algorithm requires at most k recursive calls Each call is Ѳ(k 2 ) So the overall algorithm is Ѳ(k 3 ) Q5-9

Efficient Fibonacci Algorithm? Let X be the matrix Then also How many additions and multiplications of numbers are necessary to multiply two 2x2 matrices? If n = 2 k, how many matrix multiplications does it take to compute X n ? –O(log n), it seems. But there is a catch!

Reconsider our Fibonacci algorithms Hidden because not ready for prime time yet. Refine T(n) calculations, (the time for computing the n th Fibonacci number) for each of our three algorithms –Recursive (fib1) We originally had T(n)  Ѳ(F(n)) ≈ Ѳ( n ) We assumed that addition was constant time. Since each addition is Ѳ(n), the whole thing is Ѳ(n∙F(n)) –Array (fib2) We originally had T(n)  Ѳ(n), because of n additions. Since each addition is Ѳ(n), the whole thing is Ѳ(n 2 ) –Matrix multiplication approach (fib3) We saw that Ѳ(log n) 2x2 matrix multiplications give us F n. Let M(k) be the time required to multiply two k-bit numbers. M(k)  Ѳ(k a ) for some a with 1 ≤ a ≤ 2. It's easy to see that T(n)  O(Ml(n) log n) Can we show that T(n)  O(M(n)) ? –Do it for a = 2 and a = log 2 (3) –If the multiplication of numbers is better than O(n 2 ), so is finding the n th Fibonacci number.