1 / 28

Addition of Integers

(. ) 2. Addition of Integers. carry. 1. 1. 1. How do we (humans) add two integers? Example: 7583 + 4932. 1. 2. 5. 1. 5. carry. 1. 1. Binary expansions: (1011) 2 + (1010) 2. 1. 0. 1. 0. 1.

Télécharger la présentation

Addition of Integers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ( )2 Addition of Integers carry 1 1 1 • How do we (humans) add two integers? • Example: 7583 + 4932 1 2 5 1 5 carry 1 1 Binary expansions: (1011)2 +(1010)2 1 0 1 0 1 Applied Discrete Mathematics Week 5: Mathematical Reasoning

  2. Addition of Integers • Let a = (an-1an-2…a1a0)2, b = (bn-1bn-2…b1b0)2. • How can we algorithmically add these two binary numbers? • First, add their rightmost bits: • a0 + b0 = c02 + s0, • where s0 is the rightmost bit in the binary expansion of a + b, and c0 is the carry. • Then, add the next pair of bits and the carry: • a1 + b1 + c0 = c12 + s1, • where s1 is the next bit in the binary expansion of a + b, and c1 is the carry. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  3. Addition of Integers • Continue this process until you obtain cn-1. • The leading bit of the sum is sn = cn-1. • The result is: • a + b = (snsn-1…s1s0)2 Applied Discrete Mathematics Week 5: Mathematical Reasoning

  4. Addition of Integers • Example: • Add a = (1110)2 and b = (1011)2. • a0 + b0 = 0 + 1 = 02 + 1, so that c0 = 0 and s0 = 1. • a1 + b1 + c0 = 1 + 1 + 0 = 12 + 0, so c1 = 1 and s1 = 0. • a2 + b2 + c1 = 1 + 0 + 1 = 12 + 0, so c2 = 1 and s2 = 0. • a3 + b3 + c2 = 1 + 1 + 1 = 12 + 1, so c3 = 1 and s3 = 1. • s4 = c3 = 1. • Therefore, s = a + b = (11001)2. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  5. Addition of Integers • procedure add(a, b: positive integers) • c := 0 • for j := 0 to n-1 • begin • d := (aj + bj + c)/2 • sj := aj + bj + c – 2d • c := d • end • sn := c • {the binary expansion of the sum is (snsn-1…s1s0)2} Applied Discrete Mathematics Week 5: Mathematical Reasoning

  6. Matrices • A matrix is a rectangular array of numbers. • A matrix with m rows and n columns is called anmn matrix. • Example: is a 32 matrix. A matrix with the same number of rows and columns is called square. Two matrices are equal if they have the same number of rows and columns and the corresponding entries in every position are equal. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  7. Matrices • A general description of an mn matrix A = [aij]: j-th column of A i-th row of A Applied Discrete Mathematics Week 5: Mathematical Reasoning

  8. Matrix Addition • Let A = [aij] and B = [bij] be mn matrices. • The sum of A and B, denoted by A+B, is the mnmatrix that has aij + bij as its (i, j)th element. • In other words, A+B = [aij + bij]. • Example: Applied Discrete Mathematics Week 5: Mathematical Reasoning

  9. Matrix Multiplication • Let A be an mk matrix and B be a kn matrix. • The product of A and B, denoted by AB, is the mnmatrix with (i, j)th entry equal to the sum of the products of the corresponding elements from the i-th row of A and the j-th column of B. • In other words, if AB = [cij], then Applied Discrete Mathematics Week 5: Mathematical Reasoning

  10. Matrix Multiplication • A more intuitive description of calculating C = AB: - Take the first column of B • Turn it counterclockwise by 90 and superimpose it on the first row of A • Multiply corresponding entries in A and B and add the products: 32 + 00 + 13 = 9 • Enter the result in the upper-left corner of C Applied Discrete Mathematics Week 5: Mathematical Reasoning

  11. Matrix Multiplication • Now superimpose the first column of B on the second, third, …, m-th row of A to obtain the entries in the first column of C (same order). • Then repeat this procedure with the second, third, …, n-th column of B, to obtain to obtain the remaining columns in C (same order). • After completing this algorithm, the new matrix C contains the product AB. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  12. Matrix Multiplication • Let us calculate the complete matrix C: 9 7 8 15 15 20 -2 -2 Applied Discrete Mathematics Week 5: Mathematical Reasoning

  13. Identity Matrices • The identity matrix of order n is the nn matrix In = [ij], where ij = 1 if i = j and ij = 0 if i  j: Multiplying an mn matrix A by an identity matrix of appropriate size does not change this matrix: AIn = ImA = A Applied Discrete Mathematics Week 5: Mathematical Reasoning

  14. Powers and Transposes of Matrices • The power function can be defined for square matrices. If A is an nn matrix, we have: • A0 = In, • Ar = AAA…A (r times the letter A) • The transpose of an mn matrix A = [aij], denoted by At, is the nm matrix obtained by interchanging the rows and columns of A. • In other words, if At = [bij], the bij = aji for i = 1, 2, …, n and j = 1, 2, …, m. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  15. Powers and Transposes of Matrices • Example: A square matrix A is called symmetric if A = At. Thus A = [aij] is symmetric if aij = aji for alli = 1, 2, …, n and j = 1, 2, …, m. A is symmetric, B is not. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  16. Zero-One Matrices • A matrix with entries that are either 0 or 1 is called a zero-one matrix. Zero-one matrices are often used like a “table” to represent discrete structures. • We can define Boolean operations on the entries in zero-one matrices: Applied Discrete Mathematics Week 5: Mathematical Reasoning

  17. Zero-One Matrices • Let A = [aij] and B = [bij] be mn zero-one matrices. • Then the join of A and B is the zero-one matrix with (i, j)th entry aij  bij. The join of A and B is denoted by A  B. • The meet of A and B is the zero-one matrix with (i, j)th entry aij  bij. The meet of A and B is denoted by A  B. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  18. Zero-One Matrices • Example: Join: Meet: Applied Discrete Mathematics Week 5: Mathematical Reasoning

  19. Zero-One Matrices • Let A = [aij] be an mk zero-one matrix and B = [bij] be a kn zero-one matrix. • Then the Boolean product of A and B, denoted by AB, is the mn matrix with (i, j)th entry [cij], where • cij = (ai1  b1j)  (ai2  b2i)  …  (aik  bkj). • Note that the actual Boolean product symbol has a dot in its center. • Basically, Boolean multiplication works like the multiplication of matrices, but with computing  instead of the product and  instead of the sum. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  20. Zero-One Matrices • Example: Applied Discrete Mathematics Week 5: Mathematical Reasoning

  21. Zero-One Matrices • Let A be a square zero-one matrix and r be a positive integer. • The r-th Boolean power of A is the Boolean product of r factors of A. The r-th Boolean power of A is denoted by A[r]. • A[0] = In, • A[r] = AA…A (r times the letter A) Applied Discrete Mathematics Week 5: Mathematical Reasoning

  22. Let’s proceed to… • Mathematical Reasoning Applied Discrete Mathematics Week 5: Mathematical Reasoning

  23. Mathematical Reasoning • We need mathematical reasoning to • determine whether a mathematical argument is correct or incorrect and • construct mathematical arguments. • Mathematical reasoning is not only important for conducting proofs and program verification, but also for artificial intelligence systems (drawing inferences). Applied Discrete Mathematics Week 5: Mathematical Reasoning

  24. Terminology • An axiom is a basic assumption about mathematical structured that needs no proof. • We can use a proof to demonstrate that a particular statement is true. A proof consists of a sequence of statements that form an argument. • The steps that connect the statements in such a sequence are the rules of inference. • Cases of incorrect reasoning are called fallacies. • A theorem is a statement that can be shown to be true. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  25. Terminology • A lemma is a simple theorem used as an intermediate result in the proof of another theorem. • A corollary is a proposition that follows directly from a theorem that has been proved. • A conjecture is a statement whose truth value is unknown. Once it is proven, it becomes a theorem. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  26. Rules of Inference • Rules of inference provide the justification of the steps used in a proof. • One important rule is called modus ponens or the law of detachment. It is based on the tautology (p(pq))  q. We write it in the following way: • p • p  q • ____ •  q The two hypotheses p and p  q are written in a column, and the conclusionbelow a bar, where  means “therefore”. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  27. Rules of Inference • The general form of a rule of inference is: • p1 • p2 • . • . • . • pn • ____ •  q The rule states that if p1and p2and … and pn are all true, then q is true as well. These rules of inference can be used in any mathematical argument and do not require any proof. Applied Discrete Mathematics Week 5: Mathematical Reasoning

  28. Rules of Inference q pq _____  p Modus tollens Addition • p • _____ •  pq pq qr _____  pr pq _____  p Hypothetical syllogism Simplification p q _____  pq pq p _____  q Conjunction Disjunctive syllogism Applied Discrete Mathematics Week 5: Mathematical Reasoning

More Related