# app2 - APPENDIX 2 MATHEMATICAL BACKGROUND A2 1 INTRODUCTION...

This preview shows pages 1–4. Sign up to view the full content.

APPENDIX 2 MATHEMATICAL BACKGROUND A2. 1 INTRODUCTION Mathematics is one of the outstanding accomplishments of the human mind. Its abstract models of real-life phenomena have fostered advances in every field of science and engineering. Most of computer science is based on mathematics, and this book is no exception. This appendix provides an introduction to those mathematical concepts referred to in the chapters. Some exercises are given at the end of the appendix, so that you can practice the skills while you are learning them. A2.2 FUNCTIONS AND SEQUENCES An amazing aspect of mathematics, first revealed by Whitehead and Russell [1910], is that only two basic concepts are required. Every other mathematical term can be built up from the primitives set and element . For example, an ordered pair < a , b > can be defined as a set with two elements: <a, b> = {a, {a, b}} The element a is called the first component of the ordered pair, and b is called the second component . Given two sets A and B , we can define a function f from A to B , written f: A B as a set of ordered pairs < a , b >, where a is an element of A , b is an element of B , and each element in A is the first component of exactly one ordered pair in f . Thus no two ordered pairs in a function have the same first element. The sets A and B are called the domain and co-domain , respectively. 175

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
For example, f = { < -2, 4>, <-1, 1>, <0, 0>, <1, 1>, <2, 4> } defines the "square" function with domain { -2, -1, 0, 1, 2 } and co-domain { 0, 1, 2, 4 }. No two ordered pairs in the function have the same first component, but it is legal for two ordered pairs to have the same second component. For example, the pairs <-1, 1> and <1, 1> have the same second component, namely, 1. If < a , b > is an element of f , we write f(a) = b . This gives us a more familiar description of the above function: the function f is defined by f(i) = i 2 , for i in -2...2. Another name for a function is a map . This is the term used in Chapters 12, 14 and 15 to describe a collection of elements in which each element has a unique key part and a value part. There is, in effect, a function from the keys to the values, and that is why the keys must be unique. A finite sequence t is a function such that for some positive integer k , called the length of the sequence, the domain of t is the set { 0, 1, 2, ..., k-1 } . For example, the following defines a finite sequence of length 4: t(0) = "Karen" t(1) = "Don" t(2) = "Mark" t(3) = "Courtney" Because the domain of each finite sequence starts at 0, the domain is often left implicit, and we write 176
t = "Karen", "Don", "Mark", "Courtney" A2.3 SUMS AND PRODUCTS Mathematics entails quite a bit of symbol manipulation. For this reason, brevity is an important consideration. An example of abbreviated notation can be found in the way that sums are represented. Instead of writing x 0 + x 1 + x 2 + ... + x n-1 we can write n-1 Σ x i i=0 This expression is read as "the sum, as i goes from 0 to n-1 , of x sub i ." We say that i is the count index . A count index corresponds to a loop-control variable in a for statement. For example, the following code will store in sum the sum of components 0 through n-1 in the array x : double sum = 0.0;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern