Definition 2.56 Algorithm)
2.6 Chapter at a Glance
Booleans, Numbers, and Arithmetic
ABoolean valueis True or False. TheintegersZare{. . . ,−3,−2,−1, 0, 1, 2, 3, . . .}. The realnumbersRare the integers and all numbers in between. Theclosed interval[a,b]
consists of all real numbersxwherea≤ x ≤b; theopen interval(a,b) excludesaandb.
TherationalnumbersQare those numbers that can be represented asa/bfor integersa andb6= 0. Here is some useful notation involving numbers:
• exponentiation:bkisb·b· · · · ·b, wherebis multipliedktimes;
• logarithms: logbxis the numberysuch thatby=x;
• absolute value:|x|isxforx≥0, and|x|=−xforx<0;
• floorandceiling:⌊x⌋is the largest integern≤x;⌈x⌉is the smallest integern≥x;
• modulus:nmodkis the remainder whennis divided byk.
Ifnmodd= 0, thendis afactorofnorevenly divides n, writtend|n. If 2|nfor a positive integern, thenniseven(“has evenparity”); otherwisenisodd. An integern ≥ 2 is primeif it has no positive integer factors other than 1 andn; otherwiseniscomposite.
(Note that 0 and 1 are neither prime nor composite.)
For a collection of numbersx1,x2, . . . ,xn, their sumx1+x2+· · ·+xnis written formally as∑ni=1xi, and their productx1·x2· · · · ·xnis written∏ni=1xi.
Sets: Unordered Collections
Asetis an unordered collection of objects calledelements. A set can be specified by listing its elements inside braces, as{x1,x2, . . . ,xn}. A set can also be denoted by {x:P(x)}, which contains all objectsxsuch thatP(x) is true. The set of possible val- uesxthat are considered is theuniverse U, which is sometimes left implicit.
Standard sets include theempty set{}(also written∅), which contains no elements;
theintegersZ; thereal numbersR; and thebooleans{True, False}. We writeZ≥0 = {0, 1, 2, . . .}andZ<0 = {−1,−2, . . .}, etc. For a setAand an objectx, the expression x ∈ A(“xis inA”) is true wheneverxis in the setA. (Soy ∈ {x:P(x)}whenever P(y) = True, andy ∈ {x1,x2. . . ,xn}wheneverxi =yfor somei.) Thecardinalityof a set A, written|A|, is the number of distinct elements inA.
Given two setsAandB, theunionofAandBisA∪B = {x:x∈Aorx∈B}. The intersectionofAandBisA∩B = {x:x ∈Aandx∈B}. Theset differenceofAand BisA−B = {x:x∈Aandx∈/B}. Thecomplementof a setAis∼A = U−A = {x:x∈Uandx6∈A}, whereUis the universe.
Asubsetof a setBis a setAsuch that every element ofAis also an element ofB;
this relationship is denoted byA ⊆ B. IfAis a subset ofB, thenBis asupersetofA, writtenB ⊇ A. Aproper subsetofBis a setAthat is a subset ofBbutA 6= B, written A ⊂ B. Such a setBis aproper supersetofA, writtenB ⊃ A. Two setsAandBare disjointifA∩B = ∅. Apartitionof a setSis a collection of setsA1,A2, . . . ,Ak, where A1∪A2∪ · · · ∪Ak=Sand, for any distinctiandj, the setsAiandAjare disjoint.
Thepower setof a setA, writtenP(A), is the set of all subsets ofA.
Sequences, Vectors, and Matrices: Ordered Collections
Asequence(ortuple,(ordered) pair,triple,quadruple, ...,n-tuple, ...) is an ordered col- lection of objects calledcomponentsorentries, written inside angle brackets. The set A×B={ha,bi:a∈Aandb∈B}is theCartesian productof setsAandB; the setA×B contains all pairs where the first component comes fromAand the second fromB. For a setSand a numbern ≥ 0, the setSndenotes then-fold Cartesian product ofSwith itself:Sn=S×S×. . .×S, whereSoccursntimes in this product.
Avector(orn-vector) is an element ofRn, for some positive integern ≥ 2. (An element ofR1 = Ris called ascalar.) Abit vectoris an element of{0, 1}n. Vectors are sometimes written in square brackets:x = [x1,x2, . . . ,xn]. For a vectorx, writexito denote theith component ofx. (Butxiis meaningless unlessi ∈ {1, 2, . . . ,n}.) Thesize ordimensionalityofx∈Rnisn.
For a vectorx∈ Rnand a real numberα∈R, thescalar productαxis a vector where (αx)i = αxi. For two vectorsx,y ∈ Rn, the sum ofxandyis a vectorx+y, where (x+y)i =xi+yi. Thedot productof two vectorsx,y ∈ Rnisx•y = ∑ni=1xiyi. Bothx+y andx•yare meaningless unlessxandyhave the same dimensionality.
M=
M1,1 M1,2 . . . M1,m
M2,1 M2,2 . . . M2,m
... ... ... ... Mn,1 Mn,2 . . . Mn,m
Figure 2.61: A matrix.
Ann-by-m matrix Mis an element of (Rn)m, which is also sometimes writtenRn×m. Such a matrixMhasn rowsandm columns, as in Fig- ure 2.61. A matrixM ∈ Rn×missquareifn =m. For a sizen, theidentity matrixisI ∈Rn×nhas ones on the main diagonal (the entriesIi,i = 1) and zeros everywhere else.
Given a matrixM∈ Rn×mand a real numberα∈ R, the matrixαMis specified by (αM)i,j =αMi,j. Given two matricesM,M′ ∈Rn×m, the matrixM+M′is specified by (M+M′)i,j = Mi,j+Mi,j′ . (The sumM+M′is meaningless ifMandM′have different dimensions.) The product of two matricesA ∈ Rn×mandB ∈ Rm×pis a matrix AB ∈ Rn×pwhose components are given by (AB)i,j = ∑mk=1Ai,kBk,j. (More compactly, (AB)i,j = Ai,(1...m)•B(1...m),j.) If the number of rows inAis different from the number of columns inBthenABis meaningless. TheinverseofMis a matrixM−1such that MM−1=I(if any such matrixM−1exists).
Functions
Afunction f : A → Bmaps every elementa ∈ Ato some elementf(a) ∈ B. The domainoff isAand thecodomainisB. Theimageorrangeoff is{f(x) :x∈A}, the set of elements of the codomain “hit” by some element ofAaccording tof.
Thecompositionof a functionf :A→Bandg :B→Cis writteng◦f :A→C, and (g◦f)(x) = g(f(x)). A functionf :A→ Bisone-to-oneorinjectiveiff(x) =f(y) implies thatx = y. The functionf isontoorsurjectiveif the image is equal to the codomain. If f :A→Bis one-to-one and onto, it isbijective. For a bijectionf :A→B, the function f−1:B→Ais theinverseoff, wheref−1(b) =awhenf(a) =b.
Apolynomial p:R→Ris a functionp(x) =a0+a1x+· · ·+akxk, where eachai ∈Ris acoefficient. Thedegreeofpisk. Therootsofpare{x:p(x) = 0}. A polynomial of degree kthat is not always zero has at mostkdifferent roots.
Analgorithmis a step-by-step procedure that transforms an input into an output.
Key Terms and Results
Key TermsBooleans, Numbers, Arithmetic
• booleans, integers, reals, rationals
• open intervals, closed intervals
• absolute value|x|, floor⌊x⌋, ceiling⌈x⌉
• exponentiation, logarithms
• modulus, remainder, divides
• even, odd, prime, parity
• summation∑, product∏
• nested summations, nested products Sets
• set, element, membership, cardinality
• exhaustive enumeration
• set abstraction, universe
• the empty set∅={}
• Venn diagram
• complement∼, union∪, intersection∩
• set difference−
• (proper) subset, (proper) superset
• disjoint sets
• partitions
• power set
Sequences, Vectors, Matrices
• sequence, list, ordered pair,n-tuple
• Cartesian product
• vector, dot product
• matrix, identity matrix
• matrix multiplication
• matrix inverse Functions
• domain, codomain, image/range
• function composition
• one-to-one, onto functions
• bijection, inverse
• polynomial, degree, roots
• algorithm
Key Results
Booleans, Numbers, and Arithmetic
1. The value ofbnisb·b· · ·b, multiplied togetherntimes. If n<0, thenbn= 1/(b−n). For rational exponents,b1/mis the numberxsuch thatxm=b, andbn/m= (b1/m)n. 2. For a positive real numberb6= 1 and a real numberx>0,
the quantity logbx(the log basebofx) is the real number ysuch thatby=x.
3. Consider integersk>0 andn. Thenk|n(“kdividesn”) if
nk is an integer—or, equivalently, ifnmodk= 0.
4. As long as the terms being added remain unchanged, we can reindex a summation (for example, shifting the variable over which the sum is taken, or reversing the order of nested sums) without affecting the total value of the sum. The same is true for products.
Sets: Unordered Collections
1. A set can be specified using exhaustive enumeration (a list of its elements), or by abstraction (a condition describing when an object is an element of the set).
2. Two setsSandTare equal if every element ofSis an element ofTand every element ofTis an element ofS.
Sequences, Vectors, and Matrices
1. For vectorsx,y∈Rn, thedot productofxandyis x•y=∑ni=1xiyi.
2. The productABof two matricesA∈Rn×mandB∈Rm×p is ann-by-pmatrixM∈Rn×pwhose components are given byMi,j=∑mk=1Ai,kBk,j.
Functions
1. A one-to-one and onto functionf :A→Bhas an inverse functionf−1:B→A, wheref(a) =bprecisely when f−1(b) =a.
2. A polynomial of degreekthat is not always zero has at mostkdifferent roots.