Lecture 8 Mathematics

Size: px
Start display at page:

Download "Lecture 8 Mathematics"

Transcription

1 CS 491 CAP Intro to Competitive Algorithmic Programming Lecture 8 Mathematics Uttam Thakore University of Illinois at Urbana-Champaign October 14, 2015

2 Outline Number theory Combinatorics & probability Exponentiation & recurring series Linear algebra & root-finding Language considerations CS 491 CAP Intro to Competitive Algorithmic Programming 2

3 Number Theory CS 491 CAP Intro to Competitive Algorithmic Programming 3

4 Outline Number theory Primality and prime factorization GCD/LCM and Euclid s algorithm Combinatorics & probability Exponentiation & recurring series Linear algebra & root-finding Language considerations CS 491 CAP Intro to Competitive Algorithmic Programming 4

5 Prime number Integer > 1 that has only two divisors, 1 and itself Rest of the positive integers are called composite First few prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, Is there an efficient algorithm to check if a given integer is prime? CS 491 CAP Intro to Competitive Algorithmic Programming 5

6 Primality testing algorithm Naively, can loop from 2 to N 1 and check if divisible VERY SLOW Better solution: for i = 2.. sqrt(n) if N % i == 0 return Composite return Prime CS 491 CAP Intro to Competitive Algorithmic Programming 6

7 Why it works Any composite number N can be expressed as N = a b WLOG, a b, then clearly a Thus, no need to loop through all N Complexity: O( N) There is a much faster algorithm based on probabilistic guarantees, but out of scope for this lecture Miller-Rabin algorithm N CS 491 CAP Intro to Competitive Algorithmic Programming 7

8 Sieve of Eratosthenes What if we want to generate a list of prime numbers less than N? Observation: if p is a prime number, then 2p, 3p, 4p, are all composite Create a boolean table of size N P[i] will be true if i is prime Can create a HashMap instead if N is large CS 491 CAP Intro to Competitive Algorithmic Programming 8

9 Sieve of Eratosthenes Set P[2.. N] to initially true for i = 2.. sqrt(n): if P[i] == true: for j = 2.. N / i: P[i * j] = false Complexity: O(N log log N) CS 491 CAP Intro to Competitive Algorithmic Programming 9

10 Greatest Common Divisor (GCD) Given two integers a, b, GCD(a, b) is defined as the largest integer that divides both a and b Examples: GCD(16, 24) = 8 GCD( 5, 15) = 5 CS 491 CAP Intro to Competitive Algorithmic Programming 10

11 Euclidean Algorithm Not going to prove it, but GCD a, b = GCD(b, a mod b) Since GCD(a, 0) = a, can recursively compute GCD Very fast CS 491 CAP Intro to Competitive Algorithmic Programming 11

12 Least Common Multiple LCM(a, b) is defined as the smallest positive integer n that both a and b divides Examples: LCM(3, 5) = 15 LCM(6, 24) = 24 LCM(6, 8) = 24 LCM a, b = a b GCD(a,b) To avoid possible intermediate overflow, compute as a GCD a, b b (in that order) in programming languages CS 491 CAP Intro to Competitive Algorithmic Programming 12

13 Questions so far? CS 491 CAP Intro to Competitive Algorithmic Programming 13

14 Combinatorics and Probability CS 491 CAP Intro to Competitive Algorithmic Programming 14

15 Outline Number theory Combinatorics & probability Basic combinatorics concepts Pascal s triangle Principle of Inclusion Exclusion Basic probability theory Exponentiation & recurring series Linear algebra & root-finding Language considerations CS 491 CAP Intro to Competitive Algorithmic Programming 15

16 Permutations P n, r is defined as the number of ways to arrange r of n objects, where order matters P n, r = n! (n r)! There are n ways to pick an object for the first slot, n - 1 ways to pick an object for the second slot, etc. CS 491 CAP Intro to Competitive Algorithmic Programming 16

17 Combinations C n, r is defined as the number of ways to pick r objects from n objects Also notated as n choose k or n C k or C n, r = P n,r r! = n! r! n r! Permutation cares about the order of the picked objects, while combination doesn t So we divide by r! n k CS 491 CAP Intro to Competitive Algorithmic Programming 17

18 Pascal s Rule Pascal s rule states: C n, r = C n 1, r + C n 1, r 1 C n, 0 = 1 for any n Using this identity, we can quickly construct a table that stores C(n,r), i.e. T[n][r] = C(n,r) Useful because the query time is constant CS 491 CAP Intro to Competitive Algorithmic Programming 18

19 Principle of Inclusion Exclusion Given two sets A, B: A B = A + B A B More generally, given n sets A 1, A 2, A 3,, A n : CS 491 CAP Intro to Competitive Algorithmic Programming 19

20 Applications of PIE Derangement problem SPOJ NOVICE62 Description: Given an integer n, determine the number of permutations of length n where no element appears in its original position Examples: 1, 3, 4, 2 (invalid, because 1 is in its original position) 4, 3, 2, 1 (valid) CS 491 CAP Intro to Competitive Algorithmic Programming 20

21 Probability theory Topics: Probability distribution/density functions (PDFs) and cumulative distribution/density functions (CDFs) Independence of probability Expectation Common distributions CS 491 CAP Intro to Competitive Algorithmic Programming 21

22 Definition of probability Consider a fair die (can roll between a 1 and a 6) with equal probability Each possible result is an outcome The set of outcomes, 1, 2, 3, 4, 5, 6, is called the sample space Each subset of possible outcomes is an event E.g., rolling an even number The probability mass function (pmf), p x, relates each outcome to its probability p(1) = 1 6, p(2) = 1 6 CS 491 CAP Intro to Competitive Algorithmic Programming 22

23 Types of distributions Discrete distributions: Sample space is a countable set of outcomes Examples: rolling dice, flipping a coin Defined by a probability mass function (pmf) Continuous distributions: Sample space is an uncountable set of outcomes Think ranges of real numbers Examples: picking a real number between 0 and 1 Defined by a probability density function (pdf) CS 491 CAP Intro to Competitive Algorithmic Programming 23

24 Expected value Suppose a random variable X can take value x 1 with probability p 1, x 2 with probability p 2, up to x k with probability p k. Then, k E[X] = σ i=1 x i p i Given a (continuous) probability density function p x, E X = x p x dx CS 491 CAP Intro to Competitive Algorithmic Programming 24

25 Linearity of expectation Given two random variables X and Y E X + Y = E X + E Y E X 1 + X X n = E X 1 + E X E X n Seemingly difficult problems can sometimes be solved easily using this property Note: E XY E X E Y except in particular cases! CS 491 CAP Intro to Competitive Algorithmic Programming 25

26 Independence & expectation Independence: Two events A and B are independent if: P A B = P A P B Two random variables X and Y are independent if: p X,Y x, y = p X x p Y y Given two independent random variables X and Y: E XY = E X E Y CS 491 CAP Intro to Competitive Algorithmic Programming 26

27 Common types of distributions Learn some properties (expectation, distribution) of the following: Uniform distribution Bernoulli distribution Binomial distribution Geometric distribution Exponential distribution CS 491 CAP Intro to Competitive Algorithmic Programming 27

28 Exponentiation & Recurring Series CS 491 CAP Intro to Competitive Algorithmic Programming 28

29 Outline Number theory Combinatorics & probability Exponentiation & recurring series Fast exponentiation Recursively-defined series Linear algebra & root-finding Language considerations CS 491 CAP Intro to Competitive Algorithmic Programming 29

30 Fast exponentiation Recursive computation of a n : a n = 1 n = 0 a n = 1 a nτ2 2 a a nτ2 2 n is even n is odd Can be used for computation of a large power of anything (integers, doubles, matrices, etc.) in logarithmic time Particularly useful with matrices and modular arithmetic CS 491 CAP Intro to Competitive Algorithmic Programming 30

31 Generating linear recurring series Consider the Fibonacci series F 0 = 0, F 1 = 1 F n = F n-1 + F n-2 Generating normally would require generation of n-1 previous values CS 491 CAP Intro to Competitive Algorithmic Programming 31

32 Generating recursively-defined series Consider another representation F n+1 F n = F n F n 1 = n F 1 F 0 Enter fast exponentiation Now, computation takes logarithmic time Can be used to generate any linear recursively defined series CS 491 CAP Intro to Competitive Algorithmic Programming 32

33 Questions so far? CS 491 CAP Intro to Competitive Algorithmic Programming 33

34 Linear Algebra & Root-Finding CS 491 CAP Intro to Competitive Algorithmic Programming 34

35 Outline Number theory Combinatorics & probability Exponentiation & recurring series Linear algebra & root-finding Solving linear equations Finding polynomial (and non-polynomial) roots Language considerations CS 491 CAP Intro to Competitive Algorithmic Programming 35

36 Linear algebra Types of problems: Solve a system of linear equations Invert a matrix Find the rank of a matrix Compute the determinant of a matrix All of the above can be computed using Gaussian elimination Check out Wikipedia for the algorithm Good to include in your reference materials CS 491 CAP Intro to Competitive Algorithmic Programming 36

37 Finding polynomial roots 1 st -order polynomial: ax + b = 0 Can solve directly 2 nd -order polynomial: ax 2 + bx + c = 0 Can solve using the quadratic formula What about 3 rd -order and up? Yes, some formulas exist, but they can get very complicated CS 491 CAP Intro to Competitive Algorithmic Programming 37

38 Bisection method Algorithm: Start with an interval [a, b] that contains only a single root Calculate c, the midpoint Examine the sign of f(c) and replace either a or b with c so the new interval contains the root Repeat until convergence Uses binary search Can be used to find roots of nonpolynomial functions as well! Image: Wikipedia CS 491 CAP Intro to Competitive Algorithmic Programming 38

39 More advanced techniques Remember your calculus? Newton s method Secant method Etc. CS 491 CAP Intro to Competitive Algorithmic Programming 39

40 Questions so far? CS 491 CAP Intro to Competitive Algorithmic Programming 40

41 Language Considerations CS 491 CAP Intro to Competitive Algorithmic Programming 41

42 Outline Number theory Combinatorics & probability Exponentiation & recurring series Linear algebra & root-finding Language considerations Double formatting BigInteger & BigDecimal considerations CS 491 CAP Intro to Competitive Algorithmic Programming 42

43 Basic functions Available in <cmath> (C++), java.lang.math (Java), or math module (Python) Functions: sin, cos, tan, asin, acos, atan, atan2 And their hyperbolic equivalents abs (and fabs in C++/Python), copysign (C++11/Python) and signum (Java) ceil, floor, round (C++/Java), trunc (Python) max, min sqrt, pow, hypot, log, log10, log1p, exp, expm1 Constants: e (call exp(1) in C++), π (call acos(-1) in C++) Complex numbers: <complex> (C++) and cmath module (Python) CS 491 CAP Intro to Competitive Algorithmic Programming 43

44 When to use float vs. double floats are 32-bit data types, with 23 bits dedicated to the significand Maximum precision: ~7 significant digits doubles are 64-bit data types, with 52 bits dedicated to the significand Maximum precision: ~15 significant digits ALWAYS USE DOUBLES! CS 491 CAP Intro to Competitive Algorithmic Programming 44

45 Output formatting Some problems may call for formatting a number to k decimal places Use printf (C++), System.out.printf (Java), or print (Python) to do formatting Example: print/printf( %.3f, d) will print d to 3 decimal places For string formatting, can also use stringstream and sprintf (C++), String.format (Java), or string.format (Python) CS 491 CAP Intro to Competitive Algorithmic Programming 45

46 Output formatting Beware the rounding! GNU C++ uses the round-half-to-even rounding mode, which rounds to the nearest even number if the last digit is halfway between numbers Java uses the round-half-up rounding mode, which rounds up if the last digit is halfway between numbers For example, in C++, printf( %.1f, ) will print 123.4, whereas in Java, it will print You can change the rounding mode in C/C++ using fesetround in <cfenv> and in Java using java.math.roundingmode CS 491 CAP Intro to Competitive Algorithmic Programming 46

47 Arbitrary precision numbers Normal numeric types have fixed limits (e.g., 32-bit or 64-bit integer/float) We want types that can support arbitrary-length numbers Python: int and decimal Note: Python decimal and Java BigDecimal differ in functionality Java: BigInteger and BigDecimal Support addition, subtraction, multiplication, division *, exponentiation, negation BigInteger also supports bitwise operations Read API for more details lots of good stuff there! Not available in standard C++ (there are external libraries, but can t use them in ICPC) CS 491 CAP Intro to Competitive Algorithmic Programming 47

48 Notes on BigInteger and BigDecimal BigInteger stores arbitrary precision integers, but it is slow Only use when you can t do the work with longs BigDecimal stores arbitrary precision decimals numbers, but it can t deal with repeating decimals! BigDecimal.ONE.divide(BigDecimal.valueOf(3)) will throw an exception! You can t divide by anything that can t be prime factorized by 2 and 5 Python s decimal can deal with repeating decimals, but it truncates CS 491 CAP Intro to Competitive Algorithmic Programming 48

49 What s left? Trigonometry and geometry were covered in the Computational Geometry lecture More advanced number theory (totient function, modulo arithmetic, etc.) will not be covered Refer to TopCoder tutorials and CP book You rarely need more complicated math for easier competitions CS 491 CAP Intro to Competitive Algorithmic Programming 49

50 Questions? CS 491 CAP Intro to Competitive Algorithmic Programming 50

51 Problem set Problem set will be released tomorrow CS 491 CAP Intro to Competitive Algorithmic Programming 51

52 Resources for this lecture Chapter 5 of Competitive Programming by Steven Halim TopCoder Tutorial Understanding Probabilities Lecture 2 from Stanford s CS 97 SI course CS 491 CAP Intro to Competitive Algorithmic Programming 52

Lecture 2 Data Structures & Libraries

Lecture 2 Data Structures & Libraries CS 491 CAP Intro to Competitive Algorithmic Programming Lecture 2 Data Structures & Libraries Victor Gao University of Illinois at Urbana-Champaign September 8, 2017 Updates ICPC tryouts start Sept. 23

More information

Mathematics. Jaehyun Park. CS 97SI Stanford University. June 29, 2015

Mathematics. Jaehyun Park. CS 97SI Stanford University. June 29, 2015 Mathematics Jaehyun Park CS 97SI Stanford University June 29, 2015 Outline Algebra Number Theory Combinatorics Geometry Algebra 2 Sum of Powers n k=1 k 3 k 2 = 1 n(n + 1)(2n + 1) 6 = ( k ) 2 = ( 1 2 n(n

More information

Lecture Notes, CSE 232, Fall 2014 Semester

Lecture Notes, CSE 232, Fall 2014 Semester Lecture Notes, CSE 232, Fall 2014 Semester Dr. Brett Olsen Week 11 - Number Theory Number theory is the study of the integers. The most basic concept in number theory is divisibility. We say that b divides

More information

CS 97SI: INTRODUCTION TO PROGRAMMING CONTESTS. Jaehyun Park

CS 97SI: INTRODUCTION TO PROGRAMMING CONTESTS. Jaehyun Park CS 97SI: INTRODUCTION TO PROGRAMMING CONTESTS Jaehyun Park Today s Lecture Algebra Number Theory Combinatorics (non-computational) Geometry Emphasis on how to compute Sum of Powers n k=1 k 2 = 1 6 n(n

More information

Built-in Types of Data

Built-in Types of Data Built-in Types of Data Types A data type is set of values and a set of operations defined on those values Python supports several built-in data types: int (for integers), float (for floating-point numbers),

More information

UCT Algorithm Circle: Number Theory

UCT Algorithm Circle: Number Theory UCT Algorithm Circle: 7 April 2011 Outline Primes and Prime Factorisation 1 Primes and Prime Factorisation 2 3 4 Some revision (hopefully) What is a prime number? An integer greater than 1 whose only factors

More information

COP 4516: Math for Programming Contest Notes

COP 4516: Math for Programming Contest Notes COP 4516: Math for Programming Contest Notes Euclid's Algorithm Euclid's Algorithm is the efficient way to determine the greatest common divisor between two integers. Given two positive integers a and

More information

1 Elementary number theory

1 Elementary number theory Math 215 - Introduction to Advanced Mathematics Spring 2019 1 Elementary number theory We assume the existence of the natural numbers and the integers N = {1, 2, 3,...} Z = {..., 3, 2, 1, 0, 1, 2, 3,...},

More information

COMPSCI 230 Discrete Math Prime Numbers January 24, / 15

COMPSCI 230 Discrete Math Prime Numbers January 24, / 15 COMPSCI 230 Discrete Math January 24, 2017 COMPSCI 230 Discrete Math Prime Numbers January 24, 2017 1 / 15 Outline 1 Prime Numbers The Sieve of Eratosthenes Python Implementations GCD and Co-Primes COMPSCI

More information

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B CS1800 Discrete Structures Fall 2017 October 25, 2017 Instructions: CS1800 Discrete Structures Midterm Version B 1. The exam is closed book and closed notes. You may not use a calculator or any other electronic

More information

Euclid's Algorithm. MA/CSSE 473 Day 06. Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm

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 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 1 Quick look at review topics in textbook REVIEW

More information

CS3233 Competitive i Programming

CS3233 Competitive i Programming This course material is now made available for public usage. Special acknowledgement to School of Computing, National University of Singapore for allowing Steven to prepare and distribute these teaching

More information

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems SCHOOL OF ENGINEERING & BUILT ENVIRONMENT Mathematics Numbers & Number Systems Introduction Numbers and Their Properties Multiples and Factors The Division Algorithm Prime and Composite Numbers Prime Factors

More information

Confidence Level Red Amber Green

Confidence Level Red Amber Green Maths Topic Foundation/ 1 Place Value 2 Ordering Integers 3 Ordering Decimals 4 Reading Scales 5 Simple Mathematical Notation 6a Interpreting Real-Life Tables Time 6b Interpreting Real-Life Tables Timetables

More information

Lecture 3 Algorithms with numbers (cont.)

Lecture 3 Algorithms with numbers (cont.) Advanced Algorithms Floriano Zini Free University of Bozen-Bolzano Faculty of Computer Science Academic Year 2013-2014 Lecture 3 Algorithms with numbers (cont.) 1 Modular arithmetic For cryptography it

More information

Discrete Mathematics Lecture 4. Harper Langston New York University

Discrete Mathematics Lecture 4. Harper Langston New York University Discrete Mathematics Lecture 4 Harper Langston New York University Sequences Sequence is a set of (usually infinite number of) ordered elements: a 1, a 2,, a n, Each individual element a k is called a

More information

Arithmetic and Logic Blocks

Arithmetic and Logic Blocks Arithmetic and Logic Blocks The Addition Block The block performs addition and subtractions on its inputs. This block can add or subtract scalar, vector, or matrix inputs. We can specify the operation

More information

Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD

Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD In this session, we will write another algorithm to solve a mathematical problem. If you

More information

Honors Precalculus: Solving equations and inequalities graphically and algebraically. Page 1

Honors Precalculus: Solving equations and inequalities graphically and algebraically. Page 1 Solving equations and inequalities graphically and algebraically 1. Plot points on the Cartesian coordinate plane. P.1 2. Represent data graphically using scatter plots, bar graphs, & line graphs. P.1

More information

r=1 The Binomial Theorem. 4 MA095/98G Revision

r=1 The Binomial Theorem. 4 MA095/98G Revision Revision Read through the whole course once Make summary sheets of important definitions and results, you can use the following pages as a start and fill in more yourself Do all assignments again Do the

More information

Discrete Math: Selected Homework Problems

Discrete Math: Selected Homework Problems Discrete Math: Selected Homework Problems 2006 2.1 Prove: if d is a common divisor of a and b and d is also a linear combination of a and b then d is a greatest common divisor of a and b. (5 3.1 Prove:

More information

Chapter 4. Number Theory. 4.1 Factors and multiples

Chapter 4. Number Theory. 4.1 Factors and multiples Chapter 4 Number Theory We ve now covered most of the basic techniques for writing proofs. So we re going to start applying them to specific topics in mathematics, starting with number theory. Number theory

More information

Savio Salesian College. Mathematics Department

Savio Salesian College. Mathematics Department Savio Salesian College Mathematics Department Get your maths revision material from the school website here. Raising achievement Foundation/Higher Tier Grades 1 9 Mathematics department Tiers Foundation

More information

About the Author. Dependency Chart. Chapter 1: Logic and Sets 1. Chapter 2: Relations and Functions, Boolean Algebra, and Circuit Design

About the Author. Dependency Chart. Chapter 1: Logic and Sets 1. Chapter 2: Relations and Functions, Boolean Algebra, and Circuit Design Preface About the Author Dependency Chart xiii xix xxi Chapter 1: Logic and Sets 1 1.1: Logical Operators: Statements and Truth Values, Negations, Conjunctions, and Disjunctions, Truth Tables, Conditional

More information

AQA GCSE Maths - Higher Self-Assessment Checklist

AQA GCSE Maths - Higher Self-Assessment Checklist AQA GCSE Maths - Higher Self-Assessment Checklist Number 1 Use place value when calculating with decimals. 1 Order positive and negative integers and decimals using the symbols =,, , and. 1 Round to

More information

Section A Arithmetic ( 5) Exercise A

Section A Arithmetic ( 5) Exercise A Section A Arithmetic In the non-calculator section of the examination there might be times when you need to work with quite awkward numbers quickly and accurately. In particular you must be very familiar

More information

Univ. of Illinois Due Wednesday, Sept 13, 2017 Prof. Allen

Univ. of Illinois Due Wednesday, Sept 13, 2017 Prof. Allen ECE 298JA NS #2 Version.28 April 22, 208 Fall 207 Univ. of Illinois Due Wednesday, Sept 3, 207 Prof. Allen Topic of this homework: Prime numbers, greatest common divisors, the continued fraction algorithm

More information

Mathematics Curriculum

Mathematics Curriculum Mathematics Curriculum Pathway A Pupils who enter St Hilda s with a scaled score of approximately 110 or above from KS2, begin working on the Year 8 curriculum (approximately GCSE grades 3 and 4). These

More information

CS Programming I: Primitives and Expressions

CS Programming I: Primitives and Expressions CS 200 - Programming I: Primitives and Expressions Marc Renault Department of Computer Sciences University of Wisconsin Madison Spring 2018 TopHat Sec 3 (AM) Join Code: 427811 TopHat Sec 4 (PM) Join Code:

More information

Object-Based Programming. Programming with Objects

Object-Based Programming. Programming with Objects ITEC1620 Object-Based Programming g Lecture 8 Programming with Objects Review Sequence, Branching, Looping Primitive datatypes Mathematical operations Four-function calculator Scientific calculator Don

More information

! Addition! Multiplication! Bigger Example - RSA cryptography

! Addition! Multiplication! Bigger Example - RSA cryptography ! Addition! Multiplication! Bigger Example - RSA cryptography Modular Arithmetic Modular Exponentiation Primality Testing (Fermat s little theorem) Probabilistic algorithm Euclid s Algorithm for gcd (greatest

More information

Department Curriculum Map (new GCSE)

Department Curriculum Map (new GCSE) Department Curriculum Map 2014-15 (new GCSE) Department Mathematics required in Year 11 Foundation 1. Structure and calculation: N1 to N9 Fractions, decimals and percentages: N10 to N12 Measure and accuracy:

More information

Applied Cryptography and Network Security

Applied Cryptography and Network Security Applied Cryptography and Network Security William Garrison bill@cs.pitt.edu 6311 Sennott Square Lecture #8: RSA Didn t we learn about RSA last time? During the last lecture, we saw what RSA does and learned

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how

More information

Chapter 1. Math review. 1.1 Some sets

Chapter 1. Math review. 1.1 Some sets Chapter 1 Math review This book assumes that you understood precalculus when you took it. So you used to know how to do things like factoring polynomials, solving high school geometry problems, using trigonometric

More information

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture) COSC 243 Data Representation 3 Lecture 3 - Data Representation 3 1 Data Representation Test Material Lectures 1, 2, and 3 Tutorials 1b, 2a, and 2b During Tutorial a Next Week 12 th and 13 th March If you

More information

Lecture 1: What is MATLAB?

Lecture 1: What is MATLAB? Lecture 1: What is MATLAB? Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1. MATLAB MATLAB (MATrix LABoratory) is a numerical

More information

1001ICT Introduction To Programming Lecture Notes

1001ICT Introduction To Programming Lecture Notes 1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 1, 2015 1 M Environment console M.1 Purpose This environment supports programming

More information

Math Introduction to Advanced Mathematics

Math Introduction to Advanced Mathematics Math 215 - Introduction to Advanced Mathematics Number Theory Fall 2017 The following introductory guide to number theory is borrowed from Drew Shulman and is used in a couple of other Math 215 classes.

More information

9-1 GCSE Maths. GCSE Mathematics has a Foundation tier (Grades 1 5) and a Higher tier (Grades 4 9).

9-1 GCSE Maths. GCSE Mathematics has a Foundation tier (Grades 1 5) and a Higher tier (Grades 4 9). 9-1 GCSE Maths GCSE Mathematics has a Foundation tier (Grades 1 5) and a Higher tier (Grades 4 9). In each tier, there are three exams taken at the end of Year 11. Any topic may be assessed on each of

More information

Introduction to C Language

Introduction to C Language Introduction to C Language Instructor: Professor I. Charles Ume ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Introduction to C Language History of C Language In 1972,

More information

Y9 Maths. Summative Assessment 1 hour written assessment based upon modules 1-5 during Autumn 2. Term Cycle 1

Y9 Maths. Summative Assessment 1 hour written assessment based upon modules 1-5 during Autumn 2. Term Cycle 1 Term Cycle 1 Whole Numbers and Decimals Powers of 10 Rounding Order of operations Multiples, factors, divisibility and prime numbers Prime factors, the HCF and the LCM Ordering decimals Estimating and

More information

MAT 090 Brian Killough s Instructor Notes Strayer University

MAT 090 Brian Killough s Instructor Notes Strayer University MAT 090 Brian Killough s Instructor Notes Strayer University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

Hegarty Maths Clip Numbers List

Hegarty Maths Clip Numbers List Hegarty Maths Clip Numbers List Strand Topic Skill Number Arithmetic with positive integers Simple addition & its meaning 1 Number Arithmetic with positive integers Simple subtraction & its meaning 2 Number

More information

Curriculum Catalog

Curriculum Catalog 2018-2019 Curriculum Catalog Table of Contents MATHEMATICS 800 COURSE OVERVIEW... 1 UNIT 1: THE REAL NUMBER SYSTEM... 1 UNIT 2: MODELING PROBLEMS IN INTEGERS... 3 UNIT 3: MODELING PROBLEMS WITH RATIONAL

More information

Counting shapes 1.4.6

Counting shapes 1.4.6 GRADE R_TERM 1 WEEK TOPIC CONTENT CAMI KEYSTROKE CAMI Program Count in ones 1.1.1.1; 1.1.1.2; 1.1.1.3 1.1.1.4 Cami Math Count pictures 1.1.3.1; 1.1.3.2; 1 & 2 Counting 1.1.3.3; 1.1.3.4; Counting in units

More information

Introduction to Programming

Introduction to Programming Introduction to Programming Department of Computer Science and Information Systems Tingting Han (afternoon), Steve Maybank (evening) tingting@dcs.bbk.ac.uk sjmaybank@dcs.bbk.ac.uk Autumn 2017 Week 4: More

More information

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Excerpt from Art of Problem Solving Volume 1: the Basics 2014 AoPS Inc. Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is

More information

Basic types and definitions. Chapter 3 of Thompson

Basic types and definitions. Chapter 3 of Thompson Basic types and definitions Chapter 3 of Thompson Booleans [named after logician George Boole] Boolean values True and False are the result of tests are two numbers equal is one smaller than the other

More information

Variables. location where in memory is the information stored type what sort of information is stored in that memory

Variables. location where in memory is the information stored type what sort of information is stored in that memory Variables Processing, like many programming languages, uses variables to store information Variables are stored in computer memory with certain attributes location where in memory is the information stored

More information

Downloaded from Chapter 2. Functions

Downloaded from   Chapter 2. Functions Chapter 2 Functions After studying this lesson, students will be able to: Understand and apply the concept of module programming Write functions Identify and invoke appropriate predefined functions Create

More information

Discrete Mathematics SECOND EDITION OXFORD UNIVERSITY PRESS. Norman L. Biggs. Professor of Mathematics London School of Economics University of London

Discrete Mathematics SECOND EDITION OXFORD UNIVERSITY PRESS. Norman L. Biggs. Professor of Mathematics London School of Economics University of London Discrete Mathematics SECOND EDITION Norman L. Biggs Professor of Mathematics London School of Economics University of London OXFORD UNIVERSITY PRESS Contents PART I FOUNDATIONS Statements and proofs. 1

More information

Summary of Course Coverage

Summary of Course Coverage CS-227, Discrete Structures I Spring 2006 Semester Summary of Course Coverage 1) Propositional Calculus a) Negation (logical NOT) b) Conjunction (logical AND) c) Disjunction (logical inclusive-or) d) Inequalities

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

Package VeryLargeIntegers

Package VeryLargeIntegers Type Package Package VeryLargeIntegers Title Store and Manage Arbitrarily Large Integers Version 0.1.5 Author December 15, 2017 Maintainer Multi-precission library that allows

More information

MAT128A: Numerical Analysis Lecture Two: Finite Precision Arithmetic

MAT128A: Numerical Analysis Lecture Two: Finite Precision Arithmetic MAT128A: Numerical Analysis Lecture Two: Finite Precision Arithmetic September 28, 2018 Lecture 1 September 28, 2018 1 / 25 Floating point arithmetic Computers use finite strings of binary digits to represent

More information

The Math Class. Using various math class methods. Formatting the values.

The Math Class. Using various math class methods. Formatting the values. The Math Class Using various math class methods. Formatting the values. The Math class is used for mathematical operations; in our case some of its functions will be used. In order to use the Math class,

More information

Odd-Numbered Answers to Exercise Set 1.1: Numbers

Odd-Numbered Answers to Exercise Set 1.1: Numbers Odd-Numbered Answers to Exercise Set.: Numbers. (a) Composite;,,, Prime Neither (d) Neither (e) Composite;,,,,,. (a) 0. 0. 0. (d) 0. (e) 0. (f) 0. (g) 0. (h) 0. (i) 0.9 = (j). (since = ) 9 9 (k). (since

More information

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B CS1800 Discrete Structures Fall 2017 October 25, 2017 Instructions: CS1800 Discrete Structures Midterm Version B 1. The exam is closed book and closed notes. You may not use a calculator or any other electronic

More information

A Survey of Mathematics with Applications 8 th Edition, 2009

A Survey of Mathematics with Applications 8 th Edition, 2009 A Correlation of A Survey of Mathematics with Applications 8 th Edition, 2009 South Carolina Discrete Mathematics Sample Course Outline including Alternate Topics and Related Objectives INTRODUCTION This

More information

X Std. Topic Content Expected Learning Outcomes Mode of Transaction

X Std. Topic Content Expected Learning Outcomes Mode of Transaction X Std COMMON SYLLABUS 2009 - MATHEMATICS I. Theory of Sets ii. Properties of operations on sets iii. De Morgan s lawsverification using example Venn diagram iv. Formula for n( AÈBÈ C) v. Functions To revise

More information

DISCRETE MATHEMATICS

DISCRETE MATHEMATICS DISCRETE MATHEMATICS WITH APPLICATIONS THIRD EDITION SUSANNA S. EPP DePaul University THOIVISON * BROOKS/COLE Australia Canada Mexico Singapore Spain United Kingdom United States CONTENTS Chapter 1 The

More information

YEAR 10- Mathematics Term 1 plan

YEAR 10- Mathematics Term 1 plan Week YEAR 10- Mathematics Term 1 plan 2016-2017 Course Objectives 1 The number system To understand and use 4 rules and order of operation. To understand and use Recurring decimals. Add subtract multiply

More information

Introduction to Modular Arithmetic

Introduction to Modular Arithmetic Randolph High School Math League 2014-2015 Page 1 1 Introduction Introduction to Modular Arithmetic Modular arithmetic is a topic residing under Number Theory, which roughly speaking is the study of integers

More information

Symbols. Anscombe s quartet, antiderivative, 200. bar charts for exercise, for expenses, Barnsley fern, drawing,

Symbols. Anscombe s quartet, antiderivative, 200. bar charts for exercise, for expenses, Barnsley fern, drawing, Index Symbols + (addition operator), 2 {} (curly brackets), to define a set, 122 δ (delta), 184 / (division operator), 2 ε (epsilon), 192, 197 199 == (equality operator), 124 e (Euler s number), 179 **

More information

Mathematics 12 Pre-Calculus WNCP

Mathematics 12 Pre-Calculus WNCP Mathematics 1 Pre-Calculus WNCP Page 1 Page Page 3-8 Page 9-1 General Information Record Chart Sample Guided Outlines Sample Unit Test Pages Textbook This course uses the textbook Pre-Calculus 1 ISBN 978007073870

More information

Function Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design

Function Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design What is a Function? C Programming Lecture 8-1 : Function (Basic) A small program(subroutine) that performs a particular task Input : parameter / argument Perform what? : function body Output t : return

More information

Conditionals !

Conditionals ! Conditionals 02-201! Computing GCD GCD Problem: Compute the greatest common divisor of two integers. Input: Two integers a and b. Output: The greatest common divisor of a and b. Exercise: Design an algorithm

More information

CS321 Introduction To Numerical Methods

CS321 Introduction To Numerical Methods CS3 Introduction To Numerical Methods Fuhua (Frank) Cheng Department of Computer Science University of Kentucky Lexington KY 456-46 - - Table of Contents Errors and Number Representations 3 Error Types

More information

CS-201 Introduction to Programming with Java

CS-201 Introduction to Programming with Java CS-201 Introduction to Programming with Java California State University, Los Angeles Computer Science Department Lecture V: Mathematical Functions, Characters, and Strings Introduction How would you estimate

More information

Mathematics Student Progress Tracker

Mathematics Student Progress Tracker Mathematics Student Progress Tracker Name : Maths Group Date Started : KS2 : MIN : ASP : Yr 7 Result : Yr 8 Result : Yr 9 Result : Yr 10 Result : R E S P O N S I B I L I T Y Your maths, your progress Statistics

More information

SECONDARY DRAFT SYLLABUS. 2. Representation of functions. 3. Types of functions. 4. Composition of functions (two and three)

SECONDARY DRAFT SYLLABUS. 2. Representation of functions. 3. Types of functions. 4. Composition of functions (two and three) et et et CLASS IX Topic :Set Language et et 1. Describing and representing sets SECONDARY DRAFT SYLLABUS Able to describe a set in Descriptive, Set- builder and roster forms and through Venn diagram. Use

More information

This image cannot currently be displayed. Course Catalog. Pre-algebra Glynlyon, Inc.

This image cannot currently be displayed. Course Catalog. Pre-algebra Glynlyon, Inc. This image cannot currently be displayed. Course Catalog Pre-algebra 2016 Glynlyon, Inc. Table of Contents COURSE OVERVIEW... 1 UNIT 1: THE REAL NUMBER SYSTEM... 1 UNIT 2: MODELING PROBLEMS IN INTEGERS...

More information

Integers and Mathematical Induction

Integers and Mathematical Induction IT Program, NTUT, Fall 07 Integers and Mathematical Induction Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology TAIWAN 1 Learning Objectives Learn about

More information

Lecture 7: Computational Geometry

Lecture 7: Computational Geometry Lecture 7: Computational Geometry CS 491 CAP Uttam Thakore Friday, October 7 th, 2016 Credit for many of the slides on solving geometry problems goes to the Stanford CS 97SI course lecture on computational

More information

Floating-point numbers. Phys 420/580 Lecture 6

Floating-point numbers. Phys 420/580 Lecture 6 Floating-point numbers Phys 420/580 Lecture 6 Random walk CA Activate a single cell at site i = 0 For all subsequent times steps, let the active site wander to i := i ± 1 with equal probability Random

More information

Maths: Phase 5 (Y12-13) Outcomes

Maths: Phase 5 (Y12-13) Outcomes Maths: Phase 5 (Y12-13) Outcomes I know numbers are beautiful. If they aren t beautiful nothing is. Paul Erdose Maths is discovered it doesn t just exist. Maths is a tool to understand, question and criticise

More information

Algebra 2 Semester 2 Final Exam Study Outline Semester 2 Final Exam Study Tips and Information

Algebra 2 Semester 2 Final Exam Study Outline Semester 2 Final Exam Study Tips and Information Algebra 2 Semester 2 Final Exam Study Outline 2013 Semester 2 Final Exam Study Tips and Information The final exam is CUMULATIVE and will include all concepts taught from Chapter 1 through Chapter 13.

More information

Advanced features of the Calculate signal tool

Advanced features of the Calculate signal tool Advanced features of the Calculate signal tool Case study: how to us the advanced features of the Calculate signal tool? 1 The calculate signal tool The calculate signal tool is one of the most useful

More information

correlated to the Michigan High School Mathematics Content Expectations

correlated to the Michigan High School Mathematics Content Expectations correlated to the Michigan High School Mathematics Content Expectations McDougal Littell Algebra 1 Geometry Algebra 2 2007 correlated to the STRAND 1: QUANTITATIVE LITERACY AND LOGIC (L) STANDARD L1: REASONING

More information

Click on the topic to go to the page

Click on the topic to go to the page Click on the topic to go to the page A B C 3D Pythagoras 3D Trigonometry and Pythagoras accuracy calculation with bounds 164 addition of decimals 389 of fractions 269 of money 457 of negative numbers of

More information

ENGI Introduction to Computer Programming M A Y 2 8, R E Z A S H A H I D I

ENGI Introduction to Computer Programming M A Y 2 8, R E Z A S H A H I D I ENGI 1020 - Introduction to Computer Programming M A Y 2 8, 2 0 1 0 R E Z A S H A H I D I Last class Last class we talked about the following topics: Constants Assignment statements Parameters and calling

More information

Primality Testing! 1

Primality Testing! 1 Primality Testing! 1 Goals of Assignment! Writing software as part of a large team" Living and breathing what COS 217 is about" Abstraction, separation of interfaces and implementations, modularity" Also,

More information

6-12 Math Course Sequence Effective

6-12 Math Course Sequence Effective 6-12 Math Course Sequence Effective 2009-2010 Regular Single Acceleration Double Acceleration Grade 6 Everyday Math Pre- Algebra Linear Algebra I Grade 7 Pre-Algebra Linear Algebra I Intermediate Algebra

More information

Curriculum Catalog

Curriculum Catalog 2017-2018 Curriculum Catalog 2017 Glynlyon, Inc. Table of Contents MATHEMATICS 800 FUNDAMENTALS COURSE OVERVIEW... 1 UNIT 1: THE REAL NUMBER SYSTEM... 1 UNIT 2: MODELING PROBLEMS IN INTEGERS... 2 UNIT

More information

The Pretest will consist of 30 different questions ranging from Geometry and Algebra and will be one hour long.

The Pretest will consist of 30 different questions ranging from Geometry and Algebra and will be one hour long. MATH OLYMPICS Procedures: 1. A limit of two (2) students from each team may register for this competition. Each student competes individually, so collaboration is not permitted. 2. This competition will

More information

CS 320: Concepts of Programming Languages

CS 320: Concepts of Programming Languages CS 320: Concepts of Programming Languages Wayne Snyder Computer Science Department Boston University Lecture 04: Basic Haskell Continued o Polymorphic Types o Type Inference with Polymorphism o Standard

More information

MAT 003 Brian Killough s Instructor Notes Saint Leo University

MAT 003 Brian Killough s Instructor Notes Saint Leo University MAT 003 Brian Killough s Instructor Notes Saint Leo University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

Algorithms (III) Yu Yu. Shanghai Jiaotong University

Algorithms (III) Yu Yu. Shanghai Jiaotong University Algorithms (III) Yu Yu Shanghai Jiaotong University Review of the Previous Lecture Factoring: Given a number N, express it as a product of its prime factors. Many security protocols are based on the assumed

More information

DEPARTMENT - Mathematics. Coding: N Number. A Algebra. G&M Geometry and Measure. S Statistics. P - Probability. R&P Ratio and Proportion

DEPARTMENT - Mathematics. Coding: N Number. A Algebra. G&M Geometry and Measure. S Statistics. P - Probability. R&P Ratio and Proportion DEPARTMENT - Mathematics Coding: N Number A Algebra G&M Geometry and Measure S Statistics P - Probability R&P Ratio and Proportion YEAR 7 YEAR 8 N1 Integers A 1 Simplifying G&M1 2D Shapes N2 Decimals S1

More information

Computing Fundamentals

Computing Fundamentals Computing Fundamentals Salvatore Filippone salvatore.filippone@uniroma2.it 2012 2013 (salvatore.filippone@uniroma2.it) Computing Fundamentals 2012 2013 1 / 18 Octave basics Octave/Matlab: f p r i n t f

More information

CURRICULUM STRUCTURE Topics Covered Term 1: Term 2: Term 3:

CURRICULUM STRUCTURE Topics Covered Term 1: Term 2: Term 3: CURRICULUM STRUCTURE Topics Covered Term 1: Term 2: Term 3: Year 7 The four operations Place value Ordering numbers Inverse operations Perimeter and area of shapes Fractions and Decimals Order of operations

More information

W4260: Modeling the Universe. Lecture 4

W4260: Modeling the Universe. Lecture 4 W4260: Modeling the Universe Lecture 4 Overview Input and output (I/O) Files Scope Global variables More on functions The art of programming Before starting Program structure/layout Comments Root finding

More information

To be a grade 1 I need to

To be a grade 1 I need to To be a grade 1 I need to Order positive and negative integers Understand addition and subtraction of whole numbers and decimals Apply the four operations in correct order to integers and proper fractions

More information

YEAR 12 Core 1 & 2 Maths Curriculum (A Level Year 1)

YEAR 12 Core 1 & 2 Maths Curriculum (A Level Year 1) YEAR 12 Core 1 & 2 Maths Curriculum (A Level Year 1) Algebra and Functions Quadratic Functions Equations & Inequalities Binomial Expansion Sketching Curves Coordinate Geometry Radian Measures Sine and

More information

36 Modular Arithmetic

36 Modular Arithmetic 36 Modular Arithmetic Tom Lewis Fall Term 2010 Tom Lewis () 36 Modular Arithmetic Fall Term 2010 1 / 10 Outline 1 The set Z n 2 Addition and multiplication 3 Modular additive inverse 4 Modular multiplicative

More information

CURRICULUM CATALOG. CCR Mathematics Grade 8 (270720) MS

CURRICULUM CATALOG. CCR Mathematics Grade 8 (270720) MS 2018-19 CURRICULUM CATALOG Table of Contents COURSE OVERVIEW... 1 UNIT 1: THE REAL NUMBER SYSTEM... 2 UNIT 2: MODELING PROBLEMS IN INTEGERS... 2 UNIT 3: MODELING PROBLEMS WITH RATIONAL NUMBERS... 2 UNIT

More information

Prime Factorization. Jane Alam Jan. 1 P a g e Document prepared by Jane Alam Jan

Prime Factorization. Jane Alam Jan. 1 P a g e Document prepared by Jane Alam Jan Prime Factorization by Jane Alam Jan 1 P a g e Prime Factorization Introduction Sometimes we need to prime factorize numbers. So, what is prime factorization? Actually prime factorization means finding

More information

Python Numbers. Learning Outcomes 9/19/2012. CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17

Python Numbers. Learning Outcomes 9/19/2012. CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17 Python Numbers CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17 1 (adapted from Meeden, Evans & Mayberry) 2 Learning Outcomes To become familiar with the basic

More information

UNIVERSITY OF ENGINEERING & MANAGEMENT, KOLKATA C ASSIGNMENTS

UNIVERSITY OF ENGINEERING & MANAGEMENT, KOLKATA C ASSIGNMENTS UNIVERSITY OF ENGINEERING & MANAGEMENT, KOLKATA C ASSIGNMENTS All programs need to be submitted on 7th Oct 206 by writing in hand written format in A4 sheet. Flowcharts, algorithms, source codes and outputs

More information