Computer Mathematics and Logic

Computer Mathematics and Logic

COMPUTER MATHEMATICS AND LOGIC STEVE KOLLMANSBERGER http://www.kolls.net/cml South Puget Sound Community College Computer Mathematics and Logic Compiled on September 1, 2011. Copyright ⃝c 2011 Steven J Kollmansberger For information contact [email protected] Or visit http://www.kolls.net/ This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. Typeset in LATEX. Dedication This work is dedicated to those who shaped my academic ambitions and provided personal encouragement along the way. My Parents Denise Sumner Dr. Kent Jones, Ph.D. Dr. Susan Mabry, Ph.D. Dr. Michael Quinn, Ph.D. Dr. Martin Erwig, Ph.D. Lisa Kollmansberger And to all my students who have encouraged my efforts to provide the best educational opportunities. iii Preface The breadth of topics in computer mathematics and logic have the potential to be among the most interesting computational subjects you will study. Take out your phone. Start typing a text message. How are the characters and words represented (Chapter 12)? How does the phone calculate how many more characters you can type in the message (Chapter 10)? Attach a photo. How is an image stored inside the phone (Chapter 13)? Send the message and image across the wireless network. How is the information sent quickly (Chapter 16) and how are errors prevented (Chapter 15)? How is the phone’s software designed (Chapters 6, 19)? Even with such a small processor, how were the designers able to make sure it would perform fast enough (Chapter 20)? Imagine the insides of the phone. What are the “chips” made of (Chapter 8) and how do they make the phone perform all its tasks (Chapter 17)? This book offers to take you on a conceptual journey starting with only your knowledge of basic algebra, all the way through the techniques of designers and programmers, and to explain along the way how the miracle of modern computation is achieved. This book was borne out of frustration with existing offerings in the computer mathematics and logic arena. Many books are written for upper division undergraduates or graduate students. Many books focus on limited subsets of the topics presented herein, or stray far and wide into unrelated topics. Few books are willing to take on a broad spectrum of computer math at an introductory level. Of books that do venture into such territory, many are painfully dated, dis- cussing with gusto obsolete encodings and omitting modern standards. This book is designed for the student with little to no computer programming or college math ex- perience, but who has completed high school algebra. Each topic is presented with an emphasis on conceptual understanding; as a result, not all topics are explored in complete depth. Spe- cific advanced texts on each topic should be consulted should the student wish to delve further beyond the basics. In order to remain within the basic algebra requirement, certain subtopics requiring more advanced math have been omitted. In all cases explanations emphasize practical and down-to-earth approaches rather than highly technical mathematical definitions. iv Layout Definitions are shown with the dictionary icon. All def- Throughout this text, pages will be divided into two initions also appear in the columns: the main column contains the primary text, glossary in the back. and the sidebar contains highlights, placed into boxes. Definitions are used to give a concise meaning of a term Insights give helping hints that is likely to appear again throughout the chapter for problem solving, or or beyond. In all cases, short and practical definitions possible pitfalls to watch are preferred over detailed and precise technical math- out for. ematical definitions. Certain mathematical properties or formulas may be shown using the math box in the sidebar. These for- mulas may not be essential to being able to work with the concepts described, but understanding them (and why they are true!) is likely to be a great benefit. You If n is negative, and p is should work on discovering why these formulas are positive, then n < p true instead of simply accepting them at face value. In some chapters, computer software has been em- The author’s website is ployed to assist in the creation of figures. In other http://www.kolls.net cases, various websites or software is recommended to help work through certain types of problems. Links for recommended websites and software will appear in a box with the computer icon. The computer icon may also be used to indicate computer or programmer re- lated notes or limitations. Example 0.1 • Many concepts will be illustrated with examples. To help avoid confusion, examples of more than few sentences in length will be marked and num- bered. v CONTENTS I Sets and Counting IV Data Representation 1 Sets ................ 2 13 Images and Color . 131 2 Counting .............. 9 14 Bitwise Operations and Masking . 145 3 Venn Diagrams . 19 15 Error Correcting Codes . 155 4 Simplifying Set Expressions . 27 16 Compression . 168 II Boolean Logic V Algorithms 5 Logical Operators and Truth Tables . 37 17 Digital Logic . 170 6 Manipulating Logical Expressions . 48 18 Finite Automata . 196 7 Decision Tables . 62 19 Flowcharts . 197 8 Logic Circuits . 73 20 Analysis of Algorithms . 223 21 Expression Trees . 238 III Numbers and Letters 9 Number Systems . 90 VI Supporting Material 10 Integer Numbers . 100 A Solutions . 240 11 Floating Point Numbers . 112 B Bibliography . 373 12 Unicode and ASCII . 123 C Glossary . 377 vi PART I Sets and Counting 1 Sets ................ 2 3 Venn Diagrams . 19 1.1 Set Notation . 3 3.1 Set Operations . 20 1.2 Set Operations . 4 3.2 Other Set Operations . 22 1.3 Exercises .......... 8 3.3 Creating a Venn Diagram . 22 2 Counting .............. 9 3.4 Higher Order Venn Dia- grams . 24 2.1 Additive and Multiplica- tive Counting . 9 3.5 Exercises . 26 2.2 Preliminaries . 10 4 Simplifying Set Expressions . 27 2.3 Two Key Questions . 12 4.1 Algebra Laws of Sets . 27 2.4 Sample Applications . 12 4.2 Explanation of Laws . 28 2.5 Explanation of Formulas . 14 4.3 Applying Algebra Laws . 30 2.6 Partition Rule . 17 4.4 Exercises . 35 2.7 Exercises . 18 Chapter 1 Sets A set is an unordered collection of items without du- plicates. When we say “item”, we refer to any type of thing: a set could consist of numbers, of letters, of ani- mals, of planets, of people, of buildings, and so on. For example, all the people who have read this book form a set. All positive numbers also form a set. You could define the set of all elephants in India. How about the Set: an unordered collec- set of pink flying elephants? This is also fine, but it is tion of items without dupli- likely that this set contains no elements. A set which cates. contains no elements is referred to as the empty set. Empty set: the set contain- When referring to sets it is helpful to always keep in ing no elements. mind the universe for those sets. The universe is usu- ally the largest set of items of the same type as the sets Universe: the set contain- in question. In some cases, the universe may be im- ing all possible items under plicit. In other cases, it should be defined directly. For consideration. example, in the set of all people who have read this book, the universe is likely to be all people. With the set Finite Set: a set containing a of all elephants in India, is the universe all elephants in limited (although possibly the world? Or is it all animals in India? Or... In such a very large) number of ele- case, and in most cases, it is best to define the universe ments. explicitly so there is no possibility of confusion. Infinite Set: a set contain- Sets may be finite (meaning they have a limited num- ing an unlimited number of ber of elements) or infinite. Finite sets would include elements, usually defined all people on planet Earth. Infinite sets are usually mathematically. numerical and include sets like all positive numbers. Even sets which appear “small” could be infinite: for example, the set of all reals between 1 and 2 is infinite. 2 SECTION 1.1 j Set Notation 3 1.1 Set Notation To facilitate discussion, a standard notation is usually employed to describe sets. A set is often assigned a name, usually just a single uppercase letter. The enu- meration (list of elements) of the set itself is wrapped in curly brackets and the elements are listed out, sep- arated by commas. For example, consider the set of all whole numbers between 1 and 10, inclusive. If we called this set A, we could write it: A = f1; 2; 3; 4; 5; 6; 7; 8; 9; 10g Unlike lists, sets have no Keep in mind that sets are unordered, which means ordering. The sequence that the sequence of elements written has no meaning. that elements are written in If we define B as follows: is coincidental and has no meaning. B = f10; 1; 9; 2; 8; 3; 7; 4; 6; 5g Equivalent: two sets which Then A = B (or, A is equivalent to B) because both sets contain the same elements contain the same elements. Whenever two sets contain are equivalent. the same elements, they are said to be equivalent. The two sets defined above, A and B are both finite sets described using enumeration.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    393 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us