You are on page 1of 10

Theoretical Computer Science Cheat Sheet

Definitions Series
f(n) = O(g(n)) iff q positive c, no such that n
0 _< f(n) _< cgCn) vn >_ no. i - - nCn2+ 1 ) ' ~ - ~ i ~ : nCn+l)(2n6 + I ) ~--~ 13 _ n~-(" + 1) ~-
i=i i=1 ' i=l 4
f(n) = f~(g(n)) iff 3 positive c, no such that
In general:
f(n) >_ co(m) >_ 0 Vn >_ no.
f(n) = O(g(n)) iff f(n) = O(g(n)) and Ei'~ rn+l (n+ -1- ((i + 11"~+' _ i,-+~ _ (-, + 1 ) i ' ) ]
fCn) = n(g(n)). i=1 =1
m
n--1 £( : )
/(n) = o(g(n)) iff lin~_.~ f(n)Ig(n) = O. i~t i,.,, _ 1 m 1 B~n,~+1_k.
"= m ~ l k=O
lim a . = a iff Ve 6 R, qn0 such that
Geometric series:
" - ' = I~- - "I < e, Vn >_ n0.
£ cn+l -- I £ I £ C
sup S least b 6 R such that b >_ s, c~ -- c--l"
c # 1, ci = 1 - c ' c'=
" 1-c' c<l,
Vs6S. /=O i=0 i=1

infS greatest b 6 R such that b _<


£icl = n c n + 2 - - ( n - I - 1)Cn+l -I-c £ - C
,=o (c--1) = , cp1, ie'-- (1-c)"' c<1.
s, Vs 6 S . i=0
Harmonic series:
liminfa, lirn_ inf{a, l i > n, i 6 N}.
Hn=£ il, £ iHi -- n(n2+ 1) H,~ n(n 4- 1)
limsupa, lim sup{al [ i >__n,i 6 N}. i=t

(~) Combinations: Size k sub- EHi


/1
= (n + 1 ) H , - n,
i=I

£(:) co+,~(
Hi = \ r n - b 1) Hr*+I
,)
-~- 1 "
sets of a size n set. i=1 i=l m
[~] Stifling numbers (lst kind):
Arrangements of an n ele- 1. (~) -
°'
(n -7=)~k~'
2.£(:):~, 3. (:): (n)
k=D D -- k
ment set into k cycles.
{ ~. } Stirling numbers (2nd kind): , (:)=~(::~),
Partitions of an n element
set into k non-empty sets. o.(:)(:):(:)(:-~), ,.~(,+~):(,÷o+1).
~ o
( ~> " 1st order Eulerian numbers:
Permutations 7r171"2_..71"r~On
{1, 2 , . . . , n} with k ascents. k=o \m + I) o. k£=(O ; ) ( o : ~ ) = ¢:I.
((~ >) 2nd order Eulerian numbers. II.
{o} {o}
1 = n =I.
C. Catlan Numbers: Binary
trees with n + 1 vertices. 12. 2 = 13. k = k k + k 1 :

1,.[~]:~n_x,,. ,o.[;]=~o_,~,~_,, 16.[:]=,, 17. [:]>{o} -- k '

k + 19. = = 20. = hi, 21. C . -


' n-I n-i ' n+l '
l;=o
,~.<o>:<o> = i , n-1
23. <:>= < ~ > n--l-k '
24. <;> = ( k + l ~<~_1>
+(n-k ,<o_1>
k k I '
<o> ~1 ~f~__o,
25. k = 0 otherwise
~6. <~>__~_o ~,
-
2, <;> ~ : - (n+ 1)2" +
(~) 2 '

k=D n ' k=D ~: _ -- '

32.

n--1 1
35.
£ <<:>> ~2o,~_ = 2" '
k=o
3°{. _-o} £ <<:>>(. +o_~)2o
1_
=
k=O
37. f n - I ' 1 1
k
n k 1)n_ k
k=o

52
Theoretical C o m p u t e r Science Cheat Sheet
Identities Cont. Trees
[n+l]__~ [;](k) £[k] ~__o~1 [k] Every tree with n
38. Lm + l J =
k=0
n '~-j: = n! ,
,,. [.: o] _-£k=o ((:)):-+
\ 2n ) vertices has n - 1
edges.
n k+l . i'" k,
40" {:}=~(k)(rn_l_a}l,- )- 41. [ : ] :~[;:~](k)(-l)m-~,
Kraft inequal-
ity: If the depths
42. {rn+n-I-l} =£k{n+k} of the leaves of
m k f----O ""
' rn . k=0 k ' a binary tree are
44. (:) = t,~{;::}[k](-l) "-k, 45. (n--m),(:) :~[;:l]{km}(-l) ""-t, forn>__m,
dl, - -., d.:
fx

E 2-a: <- 1,
46. { n 7rn}:~(:--;)(m-l-n'~[rn:
+ kn+k)
k] ' 4T. [nTrn]---- rE(:--;)(:::){
+
re+k}
k '
i=1

and equality holds


48. {g:rn}(g~rn) =~t (k~.}{n~nk}(;) , 49. [,:rn]('~m) :~[~][n~k](;). only if every in-
ternal node has 2
sons.

Recurrences
Master method: Generating functions:
•T(n)=aT(n/b)+f(n), a>_ l , b > 1 l ( T ( n ) - a T ( n / 2 ) = n) I. Multiply both sides of the equa-
3 ( T ( n / 2 ) - 3 T ( n / 4 ) = n/2) tion by z i.
If Be > 0 such that f ( n ) = O ( n logb a - , )
then 2. S u m both sides over all i for
T ( n ) = O(n l°gb"). which the equation is valid_
31og, n-I (T(2)- 3T(1)= 2) 3. Choose a generating function
If 1(n) = O(n ~°~ ~) then G(~). Usually c(z) = E = o ~'.
T(n) = O(n~°g' ° 1og~ n).
3log,n (T(1) - 0 = 1)
3. l ~ w r i t e the equation in terms of
If 3e > 0 such that f ( n ) = f](n l°gb a+,), Summing the left side we get T(n). Sum- the generating function G(~').
ming the right side we get 4. Solve for G(z).
and 3c < 1 such that af(n/b) <_ cf(n) log 2 n
for large n, then n i
5. The coefficient o f x i in G ( x ) is gi.
T ( n ) = ®(f(n)). E#-
i=O
Example:
gi+z = 2gi + l, go = 0 .
Substitution (example): Consider the
following recurrence
Let c = .=~and rn = loll
2~ n. Then we have Multiply and sum:
rn (C m+l -- i'~
T~+z=22'.T~, TI=2- Egi+Zz i = E2gixi + E Z i.
n~c~=n \ 7:T / i_>o i_>o :_>o
i=O
Note t h a t T/ is always a power of two.
Let ti = log 2 T/. T h e n we have
= 2n(c. cl°g=" - i) We choose G ( z ) = ~ i > 0 zi- Rewrite
ti+l = 2 i + 2ti, t I = i. = 2n(c-C kl°g=" -- I) in terms of G(z):
C(=) - go
Let u~ = t;/2 i. Dividing both sides of = 2 n ~ + I -- 2 n ~ 2 n 1'sg4ss - 2n, - 2G(=) + ~ ~'.
i>O
the previous equation by 2 I+1 we get where k = (log 2 ~)
a - I . Full history recur-
ti+t 2i ti Simplify:
rences can often be changed to limited his-
2i+1 -- 2i+-----
[ + 2i.
tory ones (example): Consider the follow-
G(z) 1
Z
-- 2 G ( z ) + 1 x
Substituting we find ing recurrence
Ui+I = 21- + U i , U1 = 12, i--1 Solve for G(z):
T,: 1 + ~ , To=I. z
which is simply u{ = i/2. So we find j=0 G(z) = (1 - z)(1 - 2.r)
that T / h a s the closed form T~ = 2 {2~-' .
Note that Expand this using partial fractions:
Summing factors (example): Consider i
the following recurrence T,+I= 1+ ~ T j .
Ti = 3T.12 + n, Tl = n. j=0
G(z)=z '1--2z 1-z

Rewrite so t h a t M1 terms involving T


are on the left side
Subtracting we find
i i--1
__. \ i>_o - ~ xi
)
-
Ti 32',12= n. Ti+l - Ti = 1 + E T J
./=0
- 1- ET j
./=e =E(2i+l--l)z i+I.
Now expand the recurrence, and choose =T/. ~>o
a factor which makes the left side "tele-
scope" And so Ti+1 = 2T~ = 2 i+1. S o gi : 2i - 1.

53
Theoretical Con, puter Science Cheat Sheet

~ 3.14159, e ~ 2.71828, 7 ~ 0.5772i, O = 1~V~1.61803, = ~ ~ -.61803

i 2i Pi General Probability
1 2 2 Bernoulli Numbers (B~ = O, odd £ # 1): Continuous distributions: If
t b
2 4 B0 1, B 1 - - ~I, ~I , B 4 -__- - - ~ '16 ,
3 = = B2 = Pr[a < x < bl = L p(~) d~:
3 8 5 B5 ~, =
i Bs = --~-6,
i B , o - -- ~'~"
5
then p is the probability density function of
4 16 7 Change of base, quadratic formula:
X. If
5 32 ii log s z - b 4 - ~ / b 2 - - 4ac P d X < ,q = e(.),
logb z -- l o g s b ' 2a
6 64 13 then P is the distributionfunction of X. If
7 128 17 Euler's number e: P and p both exist then
8 256 19 e = 1 + ½ + ~ + 2-!~+ i-~uo+ ---
9 512 23 lira ( l + Z ) " ---- e =.
Expectation: If X is discrete
I0 1,024 29 (1 + .1-)" < e < (i + ~)"+1 -
II 2,048 31 E[g(X)] = E g ( z ) P r [ X = z].
e lle (n~)
12 4,096 37 ( 1 + ~)~ = e - - ~n + 2-~n2 - O - If X continuous then
13 8,192 41 Harmonic numbers:
.14 16,384 43 25 137 49 363 761 7129
i, 3 ' 12' 60 ' 20 I 1 4 0 ' 2SO' 2 5 2 0 1 "
15 32,768 47 Variance, standard deviation:
16 65,536 53 Inn < H , < I n n + 1, VAR[X] = E[X 2] - E[XI "~,
17 131,072 • 59
H . = Inn + 7 + O(1) .
18 262,144 61 Basics:
19 524,288 67 Factorial, Stirling's approximation: Pr[X v YI = Pr[X] + Pr[Y] - P r [ X A ]']
20 1,048,576 71 1, "
_ , 8, 24, 120, 720, 5040, 40320,3628SO, . . .
Pr[X A Y] = Pr[X] - P r ~ ' ] ,
21 2,097,152 73 iff X mad Y are independent.
22 4,194,304 79 n' : 2x/2"~-~n(-he) ~ (1 + 0 ( 1 ) ) . Pr[X A Y]
Pr[XIY] - Pr[B]
23 8,388,608 83 Ackerm~nn's function and inverse:
24 16,777,216 89 '2 j i= 1 E [ X - Y ] = e [ X ] - ELY],
25 33,554,432 97 a(i,j)= , aCi--1,2) j=l iff X and Y are independent.
26 67,108,864 I01
l a(i- l,a(i,j--1)) i,j>2 E[X + Y] = E[X] + E [ Y ] ,
27 134,217,728 103 ~(i) = min{j [ a(j, j) >_ i}. E[cX] = c E[X].

Binomial distribution: Bayes' theorem:


28 268,435,456 107
Pr[B lAd Pr[Ai]
29 536,870,912 109 Pr[X = k] = (nk)pl'q "-I', q = l -- p, Pr[Adn] = Y]~'=i Pr[Aj] Pr[BI-4/]"
30 1,073,741,824 113
31
32
2,147,483,648
4,294,967,296
127
131
EIX] = ~ k = lk (;) pkq.-~ = -v-
Inclusion-exclusion:
:
n

+
Poisson distribution: i:I i:l
Pascal's Triangle e-~Ak k
1 Pr[X=k]- ' E[XI=A.
k!
£ (-1)'+' E Pr [ A " Y ' ,
11 Normal (Gauesian) distribution: k=l i~<..-<ik ]=1

121 Moment inequalities:


I .e_C=_~F/2,~ ' E[X] = ~.
1
1331 Pr [IX I > AE[X]] _< ~,
The "coupon collector": We are given a
14641 1
random coupon each day, and there axe n
1 5 10 10 5 1 different types of coupons. The distribu-
P, [Ix- ax]l >_ _<
1 6 15 20 1 5 6 1 tion of coupons is uniform. The expected Geometric distribution:
17213535217 1 number of days to pass before we to col- P r [ X = k] = p~-lq, q = 1 - p,
lect all n types is 1
1 828567056288 1
nH,~. E[X] = kpq ~ - 1 = -
1 9 3 6 8 4 1 2 6 126 84 3 6 9 1 k----1 P
1 10 45 120 210 252 210 120 45 10 I
54
Theoretical Computer Science C h e a t Sheet
Trigonometry Matrices .More Trig.
Multiplication: C"
rl

S 0os .in0, Determinants:


C = A - B,

detA
Cid = E
k=l
a~,#.bk,i.

= 0 iff A is n o n - s i n g u l a r .
h a

A c B
det A - B = det A- det B,
n
Law of cosines:
B (0,-1)
det A = E I'l sign(r)a','(0"
c2 = a~'+b2--2abcosC
Pythagorean theorem: 7r i=1
C 2 = A 2 + B 2. 2 × 2 and 3 x 3 determinant: Area:

Definitions: [ a= a db- b c ' c A = ½he.


sina=A/C, cosa= B/C,
= ~ab s i n C .
csc a = C'/A, sec a = C / B ,
d e fi• = g -h + c2 sin A sin B
sin a A cos a B e d f d e
t~na---- - - = -- cota= 2 sin C
cos a B ' sin a A Heron's formula:
aei + bf g + cdh
Area, radius of inscribed circle: - cog - f h a - ibd.
½AB, AB Permanents: A : ~/$- 8a " 8b -$e.
A+B+C" s= ½(a + b + ~1.
Identities: perm A = E I-[ a,,=(i).
1 1 *r i=1
sin z = COS Z : s~=s-b.
CSCZ I sec 2: i Hyperbolic Functions
1 Definitions: 8c~-8--C.
tanz = sin2 z + cos 2 z = 1,
cot Z £m -- B - - z
e= + e - = More identities:
1 + tan 2 z = sec 2 z,
sinh z -- - - cosh z - - -
l+cot 2z= csc 2z, 2 ' 2 '
sin{- =,/1-c°sr
B= - - e - ~ 1
tanh z -- - - CSCh ne - - V 2 "
sin = = cos ({ - = ) , sin z = sin(r - z), e= --~e -z' sinh z'
1 1 cos-~=~/l+~ °sx_
seth z -- - - coth z =
cos = = - - cosh z '
t a n = = cot - tanh z"
Identities: tan~= ~/l~C°SZ
cot= = -- cot(= -- =), CSC= = cot ~ -- cotz,
COS ,,r "
cosh-" z - s i n h 2 z = 1, tanh 2 = + s e c h 2 z = 1,
s i n ( z + V) = s i n z c o s y + c o s = s i n y, 1 - cos
coth 2 z - csch 2 z : 1, sinh(-z) = - sinh z, sin x
cos(z + Zt) = cos z cos V q: sin z sin V, s i n z"
tan z + tanv
cosh(-z) = cosh z, tanh(-z) = - tanh z, 1 + cos x
tan(z ~V) = 1 :Ftanztany' x ~/{ + cosx
sinh(= + V) = sinh z cosh y + cosh z sinh Y,
cot~ = --cosx"
c o t ( = + y ) - - c o t z c o t y :F 1
cosh(z + Y) = cosh z cosh V + sinh z sinhv, 1 + cos x
c o t = -4- c o t y '
2tan= sin 2
sin 2z = 2 sin z cos z, sin 2z = sinh 22 = 2 sinh z cosh 2,
1 +tan2z ' sin r

cos 2 z = c o s 2 = -- sin 2 z , cosh 2z = cosh 2 z + sinh ~-z, 1 -- cos x"


cos 2~ = 2 cos 2 z - I,
Eiz __ E - i t
1 - tan 2 z cosh z + sinh z = ex , cosh z - sinh = = e-~, sin z --
cos2z = 1 - 2sin 2 z, cos 2z - 2i
1 + tan 2 =' e iz + e -i~
(cosh z + sinh z)" = cosh n z + sinh nz, n 6 Z,
2tan= cot 2 z - - I C O S .~
tan 22 - cot 2z -- 2
1 -- t a n 2 z ' 2cot z ' 2 sinh 2 ~ = cosh z - I, 2 cosh 2 ~ = cosh z + I. e L r __ E - i x
t a n . z ---- - - i
s i n ( z + Z/) s i n ( = - F) = s i n 2 z - s i n 2 F, e iz + e -iz'
0 sin0 cos/7 tan/7 ... in m a t h e m a t i c s . e 2iz 1 - -

cos(z + Y) cos(z - V) = cos2 z - s i n 2 Y. you don't under-


0 0 1 0 e 2i'r + i"
Euler's equation: stand things, you sinh ix
6 2 2 3 just get used to sin z =
e'= = c o s z + i s i n z , e i*r = - 1. i
4
~ 2- ~2 i them.
cos z = cosh iz.
(~)1994 b y S t e v e S e i d e n - J. von N e u m a n n

sseiden@ies.uci.edu g 2 g tanh iz
~- I 0 o0 tanx =
http://wee.ics.uci.edu/-sseiden 2 i

55
T h e o r e t i c a l C o m p u t e r Science Cheat S h e e t
Number Theory Graph Theory
The Chinese remainder theorem: There ex- Definitions: Notation:
ists a number C such that: Loop An edge connecting a ver- E(G) Edge set
tex to itself• V(G) Vertex set
C = rl mod ml e(G) Number of components
Directed Each edge has a direction.
Simple Graph with no loops or G[S] Induced subgraph
multi-edges. deg(v) Degree of v
C -- rn rood rnn A(G) M a x i m u m degree
Walk A sequence voel vl ezvt.
• • •

Trail A walk with distinct edges. 6(G) Minimum degree


if mi and mj are relatively prime for i ~ j.
Path A trail with distinct x(G) Chromatic number
Euler's function: ~b(z) is the number of x E ( G ) Edge chromatic n u m b e r
vertices.
positive integers less than z relatively G~ Complement graph
prime to z. If I-I~=l p~' is the prime fac- Conneeted A graph where there exists
a path between any two K . Complete graph
torization of z then K . I , . 2 Complete bipartite graph
vertices.
¢ ( z ) = Hp;'-l(p, - 1). r(k, l) R a m s e y n u m b e r
Component A maximal connected
i=1
subgraph. Geometry
Euler's theorem: If a and b are relatively Tree A connected acyclic graph. Projective coordinates: triples
prime then Free tree A tree with no root. (z, y, z), not all x, y and z zero.
1 = a ~(~) rood b. DAG Directed acyclic graph.
Eulerian Graph with a trail visiting (~, y, ~) = (ca, c y , ~ ) vc # o.
Fermat's theorem: Cartesian Projective
each edge exactly once.
1 ~_ a p-1 m o d p.
Hamiltonian Graph with a path visiting (~, y) (~, y, 1)
The Euclidean algorithm: if a > b are in- each vertex exactly once• y = m z -4- b (m, --1, b)
tegers then Cut A set of edges whose re- z = e (1, O, - c )
gcd(a, b) = $cd(a m o d b, b). moval increases the num- Distance formula, Lp and L=,:
ber of components. metric:
If l'I~=t P~' is the prime factorization of z
Cut-set A minimal cut. j(z 1 -- 2:0) 2 --1-( z 1 -- Zo) "2-"
then
n ei+l Cut edge A size 1 cut.
s(=) = d = -
k-Connected A graph connected with [1~ - =ol ~ + l~l - =ol']x/~.
the removal of any k - 1 pli_m [Ix1 - -o1" + Ix1 - ~ol'] 1/,
Perfect Numbers: z is an even perfect num- vertices.
k-Tough VS C_ V,S ~ @ we have Area of triangle (zo, yo), (Zl. yl)
ber iffz = 2"-1(2" - 1 ) and 2 = - 1 is prime.
k.c(V- S) < ISl. and (z2, y~):
Wilson's theorem: n is a prime iff
( n - 1)! -- - 1 m o d n. k-Regular A graph where all vertices l a b s l Z Z - - zo Yl--YO[
have degree k. z 2 - - x0 Y 2 - - Y0 "

M~Jbius inversion: k-Factor A k-regular spanning Angle 'formed by three points:


1 i f / = 1.
if i is not square-free• subgraph.
#(i)= 0
( - I ) " if i is the product of Matching A set of edges, no two of
r distinct primes. which are adjacent.
Clique A set of vertices, all of
If which are adjacent.
G(a) = E F(d), Ind. set A set of vertices, none of
did which are adjacent.
then Vertex cover A set of vertices which cos 0 = ( ~ ' m)" (~2, y~)
~192
cover all edges. Line through two points (xo, yo)
dla Planar graph A graph which can be em- and (~1, m):
beded in the plane.
Prime numbers:
In In n Plane graph An embedding of a planar
p. = n l n n + n l n l n n - - n + n Inn zo Y0 I = 0.
graph.
z l Yl 1
+ 0 , E deg(v) = 2m. Area of circle, volume of sphere:
-EV A ~ 71"r2, V : ~ r 4 3.
n n 2!n
If G is planar then n - m + f = 2, so
7r(n) = ~ + (inn)---~-----+ (inn)-----~---- If I have seen farther than others,
f_< 2 n - 4 , m_< 3 n - f t . it is because I have stood on the
Any planar graph has a vertex with de- shoulders of giants.
gree < 5- - Issac Newton
i
56
Theoretical Computer Science Cheat Sheet
Calculus
Wallis' identity: Derivatives:
2-2-4-4-6.6---
r=2- 1. d(cu) du d(u + ,~) d,, d~, d(,.,) d. du
1-3-3-5-5.7--- dx c-~z'
= 2. dz = "~z + "~z' 3. dz = U-~z -'k V-~z,
Brouncker's continued fraction expansion:
12 dCu") = ,,u,,_,du, 5. d ( u / v ) _ v ( ~ ) - u(~) 6 d(e'U) cee,~ du,
-1+ s~ 4. dz dz
2 + ~ d--; -J ' " d~ =
+ r~... d(cu) - u du d o n u) 1 du
7. ~ _ ( l n c ) c d'~z' 8. dz - udz'
Gregrory's series:
~=1-½+~-~+~ .... 9. d(sin u) cos u ~du
z, 10. d(cos u) .. du
-- -- -- sln u~z:
dz dz
Newton's series:
d(tanu) see 2 u ~duz , 12. d ( c o t u ) 2 du
1 1 1-3 11.
dx - T~x -csc ~xx"
~-_
s 2 + -2 . 3-- 2+ s 2-4-5. 2s +---
13. d(sec u) du 14. d(csc u) du
Sharp's series: d~ - tan u see u~-£, d~ - cot u csc u~-~,

1 (1- 1 1 1 d(arcsin u) 1 du 16. d(arccosu) _ -1 du


15.
3- .3 * 3,:5 3".7 dz = ~ d--~' dz lx/T=-~-
u2 d z '
Euler's series: d(arctan u) i
1 du 18. d ( a r c c o t u ) _ - 1 du
17.
dz 1 - u2 dz' dx 1 - u2 dz'
-~=~+~+~+~+~+... d(arcsec u) 1 du
19. i 20. d(arccsc u) _ -1 du
T- g,+~+b+r,+~+---
x ~ _ _ 1
dx ux/T'=-~- d x ' d~ ulx/i--Z~-u2 d x '
~2 I ~ 1 I 1
1--~ = 1"-~ - - ..~- 3 - - f f - - . ~ . - ~ - ~-~ . . . . 21. d(sinhu)dz -- coshu~-~, 22. d(cosh u) du
dz - sinh u ~-~,
Partial Fractions d(tanh u) du d(coth u) u du
Let N ( z ) and D(=) be polynomial func- 23. dz -- sech2 u ~ z ' 24. dx -- - csch2 ~z-z"
tions of z. We can break down
25. d(sech u) du dux-
N ( z ) / D ( x ) rising partial fraction expan- d~ -- - s e c h u tanh u ~ , 26. d(cSChdxu) _ cschu cothu~x
sion. First, if the degree of N is greater
than or equal to the degree of D, divide 27. d(arcsinhu) _ 1 du 28. d(arccoshu) _ 1 du
N by D, obtaining dz ~ dz' dz u~-x/fff=-~-
1 dz"
N(~) N'(x)
29. d(arctanhu) _ 1 du 30. d(arccoth u) 1 du
D(~) = Q(~) + n(~-----7' dz 1 - u -~ d z ' dz - u ~"- 1 dx"
where the degree of N ' is less than that of 31. d(arcsech u) _ -1 du 32. d(arccsch u) -1 du
D. Second, factor D ( z ) . Use the follow- dz u lvtT-z~-
u ~- d z ' dx lul lx/i-V-~ d x
ing rules: For a non-repeated factor:
Integrals:
N(x) A N'(z)
i .3L i
(z- a)D(x) z- a D(x)'
1. feudx = cJud,,
where
[N(=)]
A = LD(x)J:=.
3.
f zn dx = n +----'~'xr'+l'' n ~ -1,

For a repeated factor:


6. 1 + z 2 - arctan~,
IvCx) "'X-"
-' A~ N'Cz)
(z - a)'~D(=) - ~ (z - a)"~-~ + ~ ( z ) '
8. f sin z dz = - cos z, 9, i cos z dz = sin z,
where
1 r dk ( N ( z ) ~ ]
A t = ~.. [ ~ kD(z)JJx=,
,o. ftan~d~ = -lnlcos=l, 11. / cotzdx = lnlcos=l,

The reasonable m a n adapts himself to the 12. f s e c ~ d x = Inlsecx + tanzl, 13. / csc z dx = In I cscz + cot
world; the unreasonable persists in trying
to adapt the world to himself. Therefore 14. / arcsin ~dx = arcsin -~ + ~ - x2, a>O,
all progress depends on the unreasonable.
- George Bernard Shaw

57
Theoretical Computer Science Cheat Sheet

Calculus Cone

,:. fa.~cos~d-:.r~.os~-V::.'-.', °>o, ,6. fa.~,..~=:.arct.,,-~-~,.(a'-+.~-), .>0.

17. /sin2(az)dz = ~-:a(az- sin(az) cos(az)), 18. f cos2(az)dz---- -~:(az + sin(az) cos(a,)).

21. / s i n " z d z - - sin"-'zc°sz+n-I/sin"-'zdz,


n ~
22-/cos"zdz=COS"-'zsinz-i-n-l/
cosn-2 x d z .
11
- -

23. t~nnzdz-- -~-~_~ - ta~-~zdz, n =if=1, 24. c°tnzdz- n- 1 cotn-~zdz, n ~ 1.

~0/.~..~=,~.-o- ,~ .-2/
"
n--1 +
rt--1
sec n-~zdz, n~l,

,,../~.o..~.: oo,.o.o.-,.
n -- 1 +
°-_,
-

n
-

lJ
/ cscn-2~:dz, n ~- 1 27.
/ sinhzdz = coshz, 28.
/ coshzdz = sinhz.

,,/,~,.~.=,°oo.,.,,o joo,,~,. ,o .in,.,,,/..o,.~=...~.o.,°,.= /o~o,.~=,.,.°~0


:z, 34. cosh2 ~dz = ¼ sinh(2z) + :z, 35. sech2 z dx = tanhz,

Z--~+a2 ' ifarccosh~>O a n d a > O ,


38. / arccosh ~dz _

/ ~
{zarccosh
( )
a
za
z a x c c o s h - + ~ / z 2 + a 2, ifarccosh~ < 0 a n d a > O ,

39. ~4f~..~_.~=In
z + ~ , a>O,
40. / a~ dz
+ == -- ~I ~¢tan-~, a > O, 41. / ~/a= -- ~ a~ = -~/a= - ~" + :~= arcsin ~-, a ~> O.

42. f ( a ~--- ~ ) ~ n d ~ = f(S. ~ -- 2~)V/~.~ - ~ + @ a~c.i. ~, . > O,

dz - - a x c s i n ~-, a ~ 0, 44. a~ d_z z 2 1 In , 45. _ z2)_~/2 _ x ~-


43. ~ - - z2 - - -- 2a a - - ~" (a 2 a-~x/~

46.
J ~ a 2 -4- z 2 d z = ~ ~ z 2 4- ~ I n z + ~
I I, 47.
/ ~
x/z2 _ a 2 -
'nl'+ ~~-~1 °>°
48. / ~ ~ : 11~
- In , 49. / zVr~'-+bz dz : 2(3bz - 2a)(a + b~) a/~-
az 2 + bz a 15 b-~ :

5"0. ~ dz = 2Vfa"T bz + a 51. dz =


4~ + b= -~ In ¥~+
, a > O,

d==v~-~-~.-~1~ ~ + ~V~-~-~ , s3. z~/~'-='d==-}(~---~-j -,


Z z

s4. ='~- ~, d= = -~(2-2 - , , ' ) ~ / a ' - ~' + ~ ,,csi~, -~, a > O. 55. 4 " ~ - ~' : - '

.~e. f ~ .dz __~/~.~_.2, .7. f 4::_ .~d.~= - - - ~ X / a 2 -- ~ + :., ~ c s i n ~ . > 0,

58./~dz=v~a~_i_za_alna+~l , 59. f ~ - a = d~ = x / ~ ~ - a" - a ~ccos l~I' a > O,

60. ! ~v,~ ± a , d , = ~ ( ~ ' +.,2)~/~-. 6t. / ~,/::+,, "HI . , +

5 8
Theoretical C o m p u t e r Science C h e a t S h e e t
Calculus Cont. Finite Calculus
f dz 1 Difference, shift operators:
62. ZV/-~ __ a z ~ arccos ~ [ , a > 0, 63. z2%/~ a ~ -- ~ a2--------~-- ,
a f ( z ) ----f ( z -I- 1) -- f(m).
64. ~ zdz V/~z~+ a 2 , . f ~ (Z 2 -I- a2) -a/2 Z f(z) ----f ( z -I-i).
65. ~ dz=q: ~ ,
Fundamental Theorem:
In 2a2 + b - b~V"~"L-'~4ac
c- b2 fCz) = / ' F ( z ) ~ ~ J'Cz)6z = r ( z ) + C.
2az + b + ~ ' if >4at,
66. - b b-1
az 2 + bz + c 2 2as + b
axctaa ~ , if b 2 < 4ac, | a
~vq-~- b~
Differences:
dx = { -~a ln ]2az + b + 2 V ~ / a z ~ + b2 + c ' i f a > 0, ~(c,.O = ~ ' ~ , ~(~ + ~) = ± . + ~.,,,
67. A(uv) = u A v + E v A u ,
/ %lax~ Jr bz -I- c 1 . -2as - b
arcsln ~ i r a < 0, A(~"--) = n ~ -1,
x/-a %/b 2 - - 4ac
, x ( n ~ ) = ~-1 "x(2":) = 2".
68. / ~/az2 + bz + cdz - 2az + b~/az 2 4ax - ba / dz
4"------'~ Jr bz + c "l- -8; ~/az~ Jr bz Jr c' ACez) = (c - 1)e =, A(~) = (roSs)-
Sums:

z dz ~/az ~ + bz + c b f dz E CU~. = C E U ~ 2 ,
69. x/az 2 + bz + c = a 2a J "Vaz ~ + bz + c I
E ( u + v) 6~ = E u 6. + E ~ 6,.
dz ~-1 In 2v/EV'az~ + bz_z+ c + bz + 2c , uAv 6z = uv - ~_, E vAu 6z.
i f e > 0,
TO.
/ z ~ / a z 2 + bz + c 1 bz + 2c EZn6 z = z.+l
m+l,
E2~ -1 ~,Z = War.

ar~in i~l~Z=_~_~_
~ , i r e < 0,
e--l' E (z) 62 = (re+l)"
Falling Factorial Powers:
rl. /.s~ + a~ d. = (1~, _ A # ) ( . ~ + .~)s/L
• "-= z(z- 1)-.-(.- rn + 1). n>O.

rz. / . " sin(.=)d. = - ~ . ' ~ c o s ( - ~ ) + ~ f=.-1cos(.~) d., z°-= i,


I
• "--=(.+1)...(.+1.1 ), n<O,
73. /znc°s(az) dz= lZznsin(az)-ha/zn-lsin(az)d2' z " + ~ = zw_(z _ m)"-.
II "~ .n--le " dz, Kising Factorial Powers:
z" z(z+l)---Cz+rn-1), n>0,
75. f z . ln(az)dz=z.+lfln(az) 1 ) z°= i,
\n+l ( n + l ) z' '
- 1
n <0,
7s. ,"(ln,,~) ~ d, = . + l(ln"') '~ ~ . . ( l ~ a 2 ) ~ - ~ d~. (2- 1)-..(z-In[) '
~ " + " = =~-(. + . 0 ~.
Conversion:
Z1 = Z! = z[ z"-- = ( - 1 ) " ( - z ) n" = (z -- rn + i) n"
Z2 : Z~ + Z ! : z ~ _ zT = 1 / ( , + 1) - n ,
zs = z ~ + 3 z ~ + z! = z • _ 3z ~ + z T z" (-1)"(-z)"-- = (z + rn - 1)"-
z4 = z ! + 6 z ~ + 7 z ~ + z! = 24 _ 6 z ~ + 7z ~ _ z T = l l ( z - 1)="-,
zs = z~+ 15z~+ 25z~+ 10z~+ z! = z £ - 15z ~ + 25z ~ - l o s 2 + z [
n 1 " - ~ z ~- "
Z~ : Z I Z! : zI
~"=
k=l.
~= k=l "
k" ( - ) '

z~ : z2 + z I ¢~ = z 2 -- z I
~= (-) ,
z~ = z s + 3Z 2 + 2 z I z~ = zs _ 3z 2 + 2z I li--I k
zT=
z~ =
z 4 + 6 z s + 11z 2 + 6z I
z s + l O z 4 + 3 5 z s + 50z ~ + 24z*
z!=
zE =
z 4 _ 6zs + I 1 2 2 - 6zI
z s _ 1024 + 35z s - 50z 2 + 24z z
z~ = ~ °[;] zk-
I:----1

59
Theoretical C o m p u t e r Science Cheat Sheet
Series

T a y l o r ' s series: O r d i n a r y p o w e r series:

f ( z ) = S(a) + (z -- a)f'(a) + - - .... £i = O (: 7 ")' ,,,>(.). A(~) = ~ a;~'


Expansions:
E x p o n e n t i a l p o w e r series:
1 = 1 --~ Z -~- X2 + Z 3 --~ X4 --~ - - - = ~Zil
1--z i=o A(~) ~ a i ~~; -
1 i=0
= 1 + CZ + C2X 2 "~ C3Z 3 "Jr - • • £ Ci Z i
D i r i c h l e t p o w e r series:
1 ~ Cg ~=0
1 :l+z n+z 2,'+z an+-'- A(~) = 2.~ 7a i;
1 - z" i=0
I 1
Binomial theorem:
= z+2z 2+3z a+4z 4+-'" = £ izi,
(1 - z) 2 i=o
.,r_ ( 1 )
dz n
= z+2nz 2 + 3riz 3 + 4 n z 4 + ' ' "
OD
~---~ - ~ i n z i '
k=O
Difference o f like p o w e r s :
ff=O n--1

e¢ = l+z+ {z2+ ~Z'~ + . . . .


i=0 k=O
F o r o r d i n a r y p o w e r series:
In(1 + 2) =z--~z 1 2 1 3
+ ~z -- ~1 z 4 . . . . =
~,A(~) + ~B(~) = ~ ( ~ - ~ + pb,)~ ~
1
ln-- =x+~'+ +~z +-.- =
1--z i=1 z~A(z) = ~ °,'-A-xi,
sin z =z-~~+~z 5-~- + .... £( _1)i
i=o
~2i+1
(2i + 1)!' A(x) - - k-x fliXz
i----0

Ei=0
- i Z:2i Qgk = Oi--kZJ "
1 2 I 4 1 6 (-1) (~,,
C O S ~C =l-~z +T,z --~.,x +..- = i=O
i--=O " " "

1 i Z2i+I A(cz) = ~ c'aix i.


t a b l 1 - 1 ~g = x - - ~ - z1 3
+ ~ iz 5
-- 1 Z 7 + ' - " =
(-) (~7¥i1' i=0
om

A'(z) = ~(i + 1)ai+lX i


(1 + z)" = 1 + n z + ~(~2-~L~z2 + - - - =

1 £(i+ ) zA'(z) = £ iaix i.


= l+(n+l)x+ ("+")z'~ + --- = i x,
(1 - ~)n-I-1 i=1
i=O
Biz i -

= l -- l z + l z U -- ~-~z'l- t- . . . .
e~ - 1 i! ' i z',
i=O i=1
1 =£ 1 {2i'~ , A(z) + A(-z) £
~-~.(1-- qT- 4z) = l+z+2z 2+5z a+--- 2 ---- a2iz2i'
i=o
A(~) A(-~) = £
V ~ ' - 4z
= l+z+2zz+6za+...
=.: t , i ) " -

2
i=O
a21+lz2i+l"

= 1 + (2 + n ) x + ( 4 V ) ~ + " " = ! S u m m a t i o n : If bi = ~ ' ~ = 0 ai t h e n


i=0 i ~.i
1
1 1 = ~ + ~ z 2 + ~ ~ + ~ * 25 - 4 + .... B ( z ) -- 1 -- z "A(z)"
m In - -
~ Hiz i,
l--z l--z i=1 Convolution:
-1(
2
l n ~1 ) ~ = i~+~3+~. 1 1 _ 4 -~-

= z + z 2 + 2z -~ + 3 z 4 + . . . .
- . . . .
i=2
.

Fiz i,
i J A(~)B(~)= ajbi_j ) ~'.

1-z-z 2
i=O God made the natural numbers:
all t h e r e s t is t h e w o r k o f m a n .
= F . z + F~..z ~-+ F ~ . z a + . . . . £ F . i ~ i. - Leopold Kronecker
1 - (F.-1 + F.+l)x - (-1)nz 2 i=D

6O
T h e o r e t i c a l C o m p u t e r Science C h e a t Sheet
Series Escher's Knot
Expansions:

)
1 1
In m m
(1 - z ) - + l I- z

z', (e~ - 1)" = n i!


i= i=0

(ln _1 - - ~ ) " :
"----
~-~, ~cot= = 5
i=0
r, .~. , ,
!
~ ( _ 1 ) ~ _ 122i(22i - 1)B2iz 2i-1 £ 1
tan -~ = (2i)[ , ((z) = i-~,
i=1 i=1

¢(=) = . , - __ ,
i=1 ~(Z) i=1
1
¢(=1 :IIl_p-., Stieltjes Integration
P
If G is continuous in the interval [a, b] and F is nondecreasing then
¢2(z ) = £ d(i). where dCn) = ~"]~dl,',1,
i=1
b G(z) dR(z)
exists. If a < b < c then
¢'(x)¢(x - 1) = £ S(i). where S(n) = E d l . d,
Zt
i=1 G(z) dF(z) = G(z) dF(z) + G(x) dF(x).
22"-11B2.1 r2.,
((2n) -- (2n)! n • 1~, If the integrals involved exist
b b b

sin~ = (_1),_~ (4' - 2)B2,~ ~'


i=o (20! '

2x ,I = "= i[(n + ~)'l)[z~'.


/ b G(=) d ( F ( z ) + H(z)) = G(z) dF(z) + // G(z) dH(.r).

2il2
'"
sin "T zi,
c- G(z) d F ( z ) G(z) d(c- F ( z ) ) = c G(z) dF(x).
e~ sin z =
b b
i=1
/ V ( z ) dF(:r) = G(b)F(b) - G(a)F(a) - / F ( z ) dV(z).
If the integrals involved exist, and F possesses a derivative F" at every
z ~=o 16iv/'2(2i)!( 2i + 1) !x'' point in [a, b] then
(arc~n x.] -~ =~-~ 4ii[2 . b b

~=o ( i + 1)(2i + 1)[ z2'"


Crammer's Rule Fibonacci Numbers
0 4? 18 7'6 29 93 85 34 61 52
If we have equations: 86 11 57 28 7'0 39 94 45 2 63
a 1 , 1 ~ 1 -[- a l , 2 Z 2 + • . . 4- a l . , n z n - : b 1 I, i, 2, 3, 5,8, 13, 21, 34, 55, 89 . . . .
95 fl(] 22 67' 38 71 49 56 13 4
a2,1a~l 4- a 2 , 2 z 2 + -.. 4- a 2 , n z n : b2 59 96 81 33 7 4 8 72 60 24 15
Definitions:
73 69 90 S2 44 17 5g 1 35 26 Fi = Fi_ t + Fi_ 2 , Fo = FI = 1:
68 74 9 91 B3 55 27 12" 46 30 F-i = (-1)/:IF.
an,lZl 4- a n , 2 z 2 + " " " "~- a n , n Z n = b. 37 8 75 19 92 84 66 23 50 41
14 25 36 40 g l 82 3 77 88 99
Let A = (aij) and B be the column maLrix (bi). Then
there is a unique solution iff det A" # 0. Let Ai be A
21 32 43 54 65 6 10 89 97 7g Cassini's identity: for i > 0:
42 53 64 5 16 20 31 98 79 87
with column i replaced by B. Then F , + l F , - 1 - F? = ( - 1 ) ' .
det A~ Additive rule:
3: i = The Fibonacci number system:
det A " Every integer n has a unique F.+~ = FkF.+I + Fk-IF.,
representation F2. = F . F . + I + F,.-1F..
Improvement makes strait roads, but the crooked n = Fkx + F~2 + . - . + F~,~, • Calculation by matrices:
roads without Improvement, are roads of Genius. where ki > ki+l + 2 for all i,
- William Blake (The Marriage of Heaven and Hell.) 1 < i < m and km >_2. ~F._l. F. ) = 0 1

61

You might also like