Cheat

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Theoretical Computer Science Cheat Sheet

De nitions Series
f (n) = O(g(n)) i 9 positive c n0 such that X
n X
n n + 1) X
n
0  f (n)  cg(n) 8n  n0 . i = n(n2+ 1) i2 = n(n + 1)(2
6 i 3
= n2 (n + 1)2 :
4
f (n) = (g(n)) i 9 positive c n0 such that i=1 i=1 i=1
In general:
f (n)  cg(n)  0 8n  n0 .
X
n Xn ;  
f (n) = (g(n)) i f (n) = O(g(n)) and m i = m 1+ 1 (n + 1)m+1 ; 1 ; (i + 1)m+1 ; im+1 ; (m + 1)im
f (n) = (g(n)). i=1
 
i=1
nX;1 Xm m + 1 B nm+1;k :
f (n) = o(g(n)) i limn!1 f (n)=g(n) = 0. im = m 1+ 1 k k
i=1 k=0
!1 an = a
nlim i 8 > 0, 9n0 such that
jan ; aj < , 8n  n0 . Geometric series:
Xn n+1 X
1 X1
sup S least b 2 R such that b  s, ci = c c ;;1 1 c 6= 1 ci = 1 ;1 c ci = 1 ;c c jcj < 1
8s 2 S . i=0 i=0 i=1
X
n n+2 n+1 X
1
inf S greatest b 2 R such that b  ici = nc ;((cn;+1)1)2c + c c 6= 1 ici = (1 ;c c)2 jcj < 1:
s , 8s 2 S . i=0 i=0
lim inf a lim inf fai j i  n i 2 Ng. Harmonic series:
n!1 n Xn X
n
iHi = n(n2+ 1) Hn ; n(n4; 1) :
n!1
Hn = 1i
lim sup an lim supfai j i  n i 2 Ng. i=1 i=1
n i   
n!1 n!1
;n X
n X n+1
k Combinations: Size k sub- Hi = (n + 1)Hn ; n m Hi = m + 1 Hn+1 ; m 1+ 1 :
sets of a size n set. i=1 i=1
n Stirling numbers (1st kind): n n n
X   
k
Arrangements of an n ele- 1. k = (n ;nk! )!k! 2. k =2
n 3. nk = n ;n k
ment set into k cycles.    k=0     

n Stirling numbers (2nd kind): 4. nk = nk nk ;; 11 5. nk = n ;k 1 + nk ;; 11
k
Partitions of an n element  n m n n ; k  Xn r + k  r + n + 1
set into k non-empty sets. 6. m k = k m ; k 7. k = n
n n k  n + 1
k=0    
k 1st order Eulerian numbers: X X r s
n r+s
Permutations 1 2 : : : n on 8. m = m+1 9. k n;k = n
n
f1 2 : : : ng with k ascents. 

k=0   k=0 n n
k 2nd order Eulerian numbers. 10. nk = (;1)k k ; nk ; 1 11. 1 = n =1
Cn Catalan Numbers: Binary n n n ; 1 n ; 1
trees with n + 1 vertices. 12. = 2n;1 ; 1
2 13. k = k k + k ; 1

n = (n ; 1)! n
 n
 n
 n
14. 1 15. 2 = (n ; 1)!Hn;1 16. n = 1 17. k  k
 
n = (n ; 1) n ; 1 + n ; 1   n n   n  Xn n  1
2n
18. 19. = = 2 20. = n! 21. Cn = n + 1 n
kn   n  k k;1  n  n; 1 n n; 1  n k=0 k  n ; 1  n ; 1
22. = =1 23. k = n ; 1 ; k 24. k = (k + 1) k + (n ; k) k ; 1
 00  n n ; 1 n n n + 1
25. 1 if k = 0, n
26. 1 = 2 ; n ; 1 n
27. 2 = 3 ; (n + 1)2 + 2 n
k = 0  otherwise
     n X
X n n x+k n Xm n+1 n  n  k 
28. n
x = k n 29. m = k (m + 1 ; k) (;1)
n k 30. m! m = k n;m
n X k =0
n  n n ; k 
k =0
 n   nk=0
31. n;k;m k ! 32. 0 = 1 33. n = 0 for n 6= 0
m = k=0 k m (;1)
 n   n ; 1   n ; 1  X n  n  (2n)n
34. k = (k + 1) k + (2n ; 1 ; k) k ; 1 35. k = 2n
 x X n  n x + n ; 1 ; k  n + 1 X n k X n k
k =0

36. x;n = k 2n 37. m + 1 = k m = m (m + 1)n;k


k=0 k k=0
Theoretical Computer Science Cheat Sheet
Identities Cont. Trees
n + 1
   
X n k X k n;k X
n n 1 k x
 X n  n x + k  Every tree with n
38. m + 1 = k m = k=0 m n = n! k=0 k! m 39. x ; n = vertices has n ; 1
 n X n k + 1
k
n
 X n +k=01 kk  2n edges.
40. m = k m + 1 (;1)n;k 41. m = k + 1 m (;1)m;k Kraft inequal-
 m + n +k1 Xm n + k m+n+1 X
k
m n+k
 ity: If the depths
42. = k k 43. = k(n + k) of the leaves of
m m k a binary tree are
 n  X  n +k=0
    k=0
1 k (;1)m;k 45. (n ; m)! n = X n + 1 k (;1)m;k for n  m, d1 :n: : dn :
44. m = k+1 m m X ;di
 n k X m ; nm + n m + k  k  k + 1  m  2 1
n X m ; n m + n m + k i=1
46. n ; m = 47. n ; m =
 n ` +kmm +Xk  kn 
+k k
n ; k n
 n
m + k n + k k
k` + m X k  n ; k n and equality holds
only if every in-
48. ` + m ` = ` m k 49. ` + m ` = ` m k : ternal node has 2
k k sons.
Recurrences
Master method: ;
1 T (n) ; 3T (n=2) = n
 Generating functions:
T (n) = aT (n=b) + f (n) a  1 b > 1 ;  1. Multiply both sides of the equa-
3 T (n=2) ; 3T (n=4) = n=2 tion by xi .
If 9 > 0 such that f (n) = O(nlogb a; ) 2. Sum both sides over all i for
then .. .. ..
. . . which the equation is valid.
T (n) = (nlogb a ): log2 n;1 ;  3. Choose a generatingPfunction
3 T (2) ; 3T (1) = 2
If f (n) = (nlogb a ) then G(x). Usually G(x) = 1 i
i=0 x gi .
T (n) = (nlogb a log2 n): Let m = log2 n. Summing the left side 3. Rewrite the equation in terms of
we get T (n) ; 3m T (1) = T (n) ; 3m = the generating function G(x).
If 9 > 0 such that f (n) = (nlogb a+ ), T (n) ; nk where k = log2 3  1:58496.
and 9c < 1 such that af (n=b)  cf (n) 4. Solve for G(x).
Summing the right side we get 5. The coecient of xi in G(x) is gi .
for large n, then mX
;1 n 3i = n mX
;1 ; 
3 i Example:
T (n) = (f (n)): i :
i=0 2 gi+1 = 2gi + 1 g0 = 0:
2
i=0
Substitution (example): Consider the
following recurrence Let c = 23 . Then we have Multiply
X andi sum: X X
Ti+1 = 22i  Ti2 T1 = 2: mX
;1 m  gi+1 x = 2gixi + xi :
n ci = n cc ;;11 i0 i0 i0
Note that Ti is always a power of two. i=0 P
We choose G(x) = i0 xi gi . Rewrite
Let ti = log2 Ti . Then we have = 2n(clog2 n ; 1) in terms of G(x):
ti+1 = 2i + 2ti t1 = 1: = 2n(c(k;1) logc n ; 1) G(x) ; g0 X i
Let ui = ti =2i . Dividing both sides of x = 2G(x) + x:
= 2nk ; 2n i0
the previous equation by 2i+1 we get
ti+1 = 2i + ti : and so T (n) = 3nk ; 2n. Full history re- Simplify:
2i+1 2i+1 2i currences can often be changed to limited G(x) = 2G(x) + 1 :
Substituting we nd history ones (example): Consider x 1;x
ui+1 = 21 + ui u1 = 12 X
i;1
Solve for G(x):
Ti = 1 + Tj T0 = 1: x
which is simply ui = i=2. So we nd j =0 G(x) = (1 ; x)(1 ; 2x)
:
that Ti has the closed form Ti = 2i2i;1 . Note that Expand this 
Summing factors (example): Consider Xi 2 1

using partial fractions:
the following recurrence Ti+1 = 1 + Tj : G(x) = x 1 ; 2x ; 1 ; x
T (n) = 3T (n=2) + n T (1) = 1: j =0 0 1
Subtracting we nd X X
Rewrite so that all terms involving T Xi X
i;1 = x @2 2i xi ; xi A
are on the left side Ti+1 ; Ti = 1 + Tj ; 1 ; Tj 0 i0
T (n) ; 3T (n=2) = n: j =0 j =0 X ii+1 i+1
= (2 ; 1)x :
Now expand the recurrence, and choose = Ti : i0
a factor which makes the left side \tele-
scope" And so Ti+1 = 2Ti = 2i+1 . So gi = 2i ; 1.
Theoretical Computer Science Cheat Sheet
p5 p
  3:14159, e  2:71828,   0:57721, = 1+2  1:61803, ^ = 1;2 5  ;:61803
i 2i pi General Probability
1 2 2 Bernoulli Numbers (Bi = 0, odd i 6= 1): Continuous distributions:Z If
b
2 4 3 B0 = 1, B1 = ; 21 , B2 = 16 , B4 = ; 301 , Pra < X < b] = p(x) dx
3 8 5 B6 = 421 , B8 = ; 301 , B10 = 665 . a
4 16 7 Change of base, quadratic formula: then p is the probability density function of
p X . If
5 32 11 log
logb x = log ba x ;b b2 ; 4ac
: PrX < a] = P (a)
6 64 13 a 2a then P is the distribution function of X . If
7 128 17 Euler's number e: P and p both existZthen
e = 1 + 12 + 16 + 241 + 120
 x n x +   
8 256 19
1 a
P (a) = p(x) dx:
9 512 23 lim 1 + n = e : ;1
n!1
10 1,024 29 ;1 + 1 n < e < ;1 + 1 n+1 : Expectation: If X is discrete
X
;1 + 1 n = e ; e + 11e ; O  1  : Eg(X )] = g(x) PrX = x]:
11 2,048 31 n n
12 4,096 37 x
n 2n 24n2 n3 If X continuous
13 8,192 41 Harmonic numbers:
Z 1 then Z1
14 16,384 43 Eg(X )] = g(x)p(x) dx = g(x) dP (x):
1, 32 , 116 , 12 , 60 , 20 , 140 , 280 ,
25 137 49 363 761 7129
2520 ::: ;1 ;1
15 32,768 47 Variance, standard deviation:
16 65,536 53 ln n < Hn < ln n + 1 VARX ] = EX 2 ] ; EX ]2
17 131,072 59 p
Hn = ln n +  + O n1 : = VARX ]:
18 262,144 61 For events A and B :
19 524,288 67 Factorial, Stirling's approximation: PrA _ B ] = PrA] + PrB ] ; PrA ^ B ]
20 1,048,576 71 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, ::: PrA ^ B ] = PrA]  PrB ]
21 2,097,152 73 p  n n  1  i A and B are independent.
n! = 2n e 1+ n : A ^ B]
22 4,194,304 79 PrAjB ] = PrPr B]
23 8,388,608 83 Ackermann's8 jfunction and inverse: For random variables X and Y :
24 16,777,216 89 <2 i=1
EX  Y ] = EX ]  EY ]
25 33,554,432 97 a(i j ) = : a(i ; 1 2) j=1
26 67,108,864 101 a(i ; 1 a(i j ; 1)) i j  2 if X and Y are independent.
27 134,217,728 103
(i) = minfj j a(j j )  ig: E  X + Y ] = EX ] + EY ]
28 268,435,456 107 Binomial distribution: EcX ] = c EX ]:
 Bayes' theorem:
29 536,870,912 109 PrX = k] = nk pk qn;k q = 1;p B jAi ] PrAi ] :
30 1,073,741,824 113 PrAi jB ] = PnPrPr
n n
X A ] PrB jA ]
j =1 j j
31 2,147,483,648 127 EX ] = k k pk qn;k = np: Inclusion-exclusion:
32 4,294,967,296 131 k=1 h _n i X n
Pascal's Triangle Poisson distribution: Pr Xi = PrXi ] +
; k
PrX = k] = e k! EX ] = :
i=1 i=1
1 X
n X h ^k i
11 Normal (Gaussian) distribution: (;1)k+1 Pr Xij :
121 k=2 ii <<ik j =1
1331 p(x) = p 1 e;(x;)2 =22 EX ] = : Moment inequalities:
2  
14641 The \coupon collector": We are given a Pr jX j  EX ]  1
1 5 10 10 5 1 random coupon each day, and there are n h  i
dierent types of coupons. The distribu- Pr X ; EX ]    12 :
1 6 15 20 15 6 1 tion of coupons is uniform. The expected
1 7 21 35 35 21 7 1 number of days to pass before we to col- Geometric distribution:
1 8 28 56 70 56 28 8 1 lect all n types is PrX = k] = qk;1 p q =1;p
nHn : X1 1
1 9 36 84 126 126 84 36 9 1 EX ] = kpqk;1 = p :
1 10 45 120 210 252 210 120 45 10 1 k=1
Theoretical Computer Science Cheat Sheet
Trigonometry Matrices More Trig.
Multiplication: C
X
n
(0,1)
C =AB cij = aik bkj : b h a
b (cos  sin ) k=1
A C  Determinants: det A 6= 0 i A is non-singular.
A c B
det A  B = det A  det B
(-1,0) (1,0)
Law of cosines:
c a X Yn
B (0,-1)
det A = sign()ai(i) : c2 = a2 +b2;2ab cos C:
Pythagorean theorem:  i=1 Area:
C 2 = A2 + B 2 : 2 2 and 3 3 determinant:
 a b  A = 12 hc
De nitions:  c d  = ad ; bc = 12 ab sin C
sin a = A=C cos a = B=C  a b c       
 d e f  = g  b c  ; h  a
c  + i  a b  = c sin A sin B
2
csc a = C=A sec a = C=B
 g h i   e f   d f  d e 2 sin C :
sin a = A cot a = cos a = B :
tan a = cos Heron's formula:
a B sin a A aei + bfg + cdh
Area, radius of inscribed circle: = ; ceg ; fha ; ibd: A = ps  sa  sb  sc
AB AB Permanents: s = 21 (a + b + c)
A+B +C:
1
2
XY
n sa = s ; a
Identities: perm A = ai(i) :
 i=1 sb = s ; b
sin x = csc1 x cos x = sec1 x Hyperbolic Functions sc = s ; c:
tan x = cot1 x sin2 x + cos2 x = 1 De nitions:
x ;x x ;x
More identities:
r
sinh x = e ;2e cosh x = e + e sin 2 = 1 ; 2cos x
x
1 + tan2 x = sec2 x 1 + cot2 x = csc2 x x e;x 2
r
; 
sin x = cos  ; x tanh x = eex ; 1
csch x = sinh x 1 + cos x
sin x = sin( ; x) + e;x cos x2 =
1 1 : r 1 ; 2cos x
2

cos x = ; cos( ; x)
; 
tan x = cot 2 ; x
sech x = cosh x coth x = tanh x tan x2 = 1 + cos x
cot x = ; cot( ; x) csc x = cot x2 ; cot x Identities:
= 1 ;sincos x
cosh2 x ; sinh2 x = 1 tanh2 x + sech2 x = 1 x
sin(x y) = sin x cos y cos x sin y x
coth2 x ; csch2 x = 1 sinh(;x) = ; sinh x = 1 +sincos
cos(x y) = cos x cos y sin x sin y
cosh(;x) = cosh x tanh(;x) = ; tanh x r 1 + cosx x
tan(x y) = 1tan x tan y cot x2 = 1 ; cos x
tan x tan y sinh(x + y) = sinh x cosh y + cosh x sinh y
x cot y 1 = 1 +sincos x
cot(x y) = cot
cot x cot y
cosh(x + y) = cosh x cosh y + sinh x sinh y x
sin x
sin 2x = 2 sin x cos x sin 2x = 2 tan x2 sinh 2x = 2 sinh x cosh x = 1 ; cos x
1 + tan x ix ; e;ix
cos 2x = cos2 x ; sin2 x cos 2x = 2 cos2 x ; 1 cosh 2x = cosh2 x + sinh2 x sin x = e
2i
cosh x + sinh x = ex cosh x ; sinh x = e;x
cos 2x = 1 ; tan2 x ix + e;ix
2
cos 2x = 1 ; 2 sin2 x cos x = e
1 + tan x (cosh x + sinh x)n = cosh nx + sinh nx n 2 Z 2
2 tan x 2x;1 ix ; e;ix
tan 2x = cot 2x = cot2 cot x 2 sinh2 x2 = cosh x ; 1 2 cosh2 x2 = cosh x + 1:
e
tan x = ;i eix + e;ix
1 ; tan x
2
2ix
sin(x + y) sin(x ; y) = sin x ; sin y = ;i ee2ix ; 1
2 2
 sin  cos  tan  : : : in mathematics +1
cos(x + y) cos(x ; y) = cos2 x ; sin2 y: 0 0 you don't under- sinh ix
 p13 p03 stand things, you sin x = i
Euler's equation: 1
just get used to
eix = cos x + i sin x ei = ;1:
6
 p22 p22 3
cos x = cosh ix
1 them.
p23
tan x = tanh ix :
4 2
c 1994 by Steve Seiden  p { J. von Neumann
3 2
1
2 3 i
[email protected] 
http://www.mpi-sb.mpg.de/~seiden 2 1 0 1
Theoretical Computer Science Cheat Sheet
Number Theory Graph Theory
The Chinese remainder theorem: There ex- De nitions: 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  r1 mod m1 Directed Each edge has a direction. c(G) Number of components
.. .. .. Simple Graph with no loops or GS ] Induced subgraph
. . . deg(v) Degree of v
multi-edges.
C  rn mod mn Walk A sequence v0 e1v1 : : : e`v` . (G) Maximum degree
if mi and mj are relatively prime for i 6= j . Trail A walk with distinct edges.  ( G) Minimum degree
Euler's function: (x) is the number of Path A trail with distinct  ( G) Chromatic number
positive integersQ less than x relatively vertices.  E (G) Edge chromatic number
G c Complement graph
prime to x. If ni=1 pei i is the prime fac- Connected A graph where there exists
K n Complete graph
torization of x then a path between any two
Yn vertices. K n1 n2 Complete bipartite graph
(x) = pei i ;1 (pi ; 1): Component A maximal connected r( k `) Ramsey number
i=1 subgraph. Geometry
Euler's theorem: If a and b are relatively Tree A connected acyclic graph.
prime then Free tree A tree with no root. Projective coordinates: triples
1  a(b) mod b: DAG Directed acyclic graph. (x y z ), not all x, y and z zero.
Eulerian Graph with a trail visiting (x y z ) = (cx cy cz ) 8c 6= 0:
Fermat's theorem: Cartesian Projective
1  ap;1 mod p: each edge exactly once.
Hamiltonian Graph with a cycle visiting (x y) (x y 1)
The Euclidean algorithm: if a > b are in- each vertex exactly once. y = mx + b (m ;1 b)
tegers then Cut A set of edges whose re- x=c (1 0 ;c)
gcd(a b) = gcd(a mod b b): moval increases the num- Distance formula, Lp and L1
Q n
If i=1 pei i is the prime factorization of x ber of components. metric:
Cut-set A minimal cut. p
then (x ; x )2 + (y ; y )2
X Y n ei +1 Cut edge A size 1 cut. jx ;1 x jp0+ jy ;1y jp01=p
S (x) = d = pip ;;1 1 : k-Connected A graph connected with 1 0 1 0
djx i=1 i
the removal of any k ; 1 lim
 jx1 ; x0 j + jy1 ; y0 jp
p 1=p :
Perfect Numbers: x is an even perfect num- vertices. p!1
ber i x = 2n;1(2n ; 1) and 2n ; 1 is prime. k-Tough 8S  V S 6=  we have Area of triangle (x0 y0 ), (x1 y1 )
Wilson's theorem: n is a prime i k  c(G ; S )  jS j. and (x 2 y2 ):
 
(n ; 1)!  ;1 mod n: k-Regular A graph where all vertices 1 abs  x1 ; x0 y1 ; y0  :
have degree k. 2  x2 ; x0 y2 ; y0 
Mobius 8inversion: k-Factor A k-regular spanning Angle formed by three points:
>
< 10 if i = 1.
subgraph.
(i) = > (;1)r ifif ii isis the
not square-free.
Matching A set of edges, no two of (x2 y2 )
: product of
r distinct primes. which are adjacent.
Clique A set of vertices, all of `2
If X which are adjacent. 
G(a) = F (d) Ind. set A set of vertices, none of (0 0) `1 (x1 y1 )
dja
which are adjacent. cos  = (x1 y1`) `(x2 y2 ) :
then X   Vertex cover A set of vertices which
(d)G da :
1 2
F (a) = cover all edges. Line through two points (x0 y0 )
dja Planar graph A graph which can be em- and (x1 y1 ):
Prime numbers: beded in the plane.  x y 1 
pn = n ln n + n ln ln n ; n + n lnlnlnnn Plane graph An embedding of a planar  x0 y0 1  = 0:
  graph.  x1 y1 1 
+ O lnnn X Area of circle, volume of sphere:
deg(v) = 2m:
v2V A = r2 V = 43 r3 :
(n) = lnnn + (lnnn)2 + (ln2!nn)3 If G is planar then n ; m + f = 2, so If I have seen farther than others,
 n  f  2n ; 4 m  3n ; 6: it is because I have stood on the
+ O (ln n)4 : Any planar graph has a vertex with de- shoulders of giants.
gree  5. { Issac Newton
Theoretical Computer Science Cheat Sheet
 Calculus
Wallis' identity: Derivatives:
 = 2  12  23  34  54  65  67    1. d(cu) = c du 2. d(u + v) = du + dv 3. d(uv) = u dv + v du
dx dx dx dx; dx ;  dx dx dx
Brouncker's continued fraction expansion: n) v du ; u dv cu )
 =1+ 12 d (u du d ( u=v )
4. dx = nun;1 dx 5. dx = dx v2 dx 6. dx = cecu du
d ( e
4
2 + 2+ 3252 dx
u
72
2+ 2+  7. d(dxc ) = (ln c)cu du
dx 8. d(ln u) 1 du
dx = u dx
Gregrory's series:
9. d(sin u) du 10. d(cos u) du
 = 1; 1 + 1 ; 1 + 1 ;
dx = cos u dx dx = ; sin u dx
4 3 5 7 9
Newton's series:
=1+ 1 13 11. d(tan u) 2 du
dx = sec u dx 12. d(cot u) 2 du
dx = csc u dx
6 2 2  3  23 + 2  4  5  25 +   
Sharp's series: 13. d(sec
dx
u) = tan u sec u du
dx 14. d(csc
dx
u) = ; cot u csc u du
dx
 
 = p1 1 ; 1 + 1 ; 1 +    15. d(arcsin
dx
u) = p 1 du
1 ; u2 dx
d(arccos u )
16. dx = p1 ; u2 dx ;1 du
6
3 31  3 32  5 33  7
Euler's series: 17. d(arctan
dx
u) = 1 du
1 ; u2 dx 18. d(arccot
dx
u) = ;1 du
1 ; u2 dx
2 = + 212 + 312 + 412 + 512 +   
19. d(arcsec u) 1 du 20. d(arccsc u) du
1
12 ;1
dx = up1 ; u2 dx dx = up1 ; u2 dx
6
2 = 1 + 312 + 512 + 712 + 912 +   
8 12
2 =
12
1
12 ; 212 + 312 ; 412 + 512 ;    21. d(sinh u) du
dx = cosh u dx 22. d(cosh u)
dx = sinh u dx
du
Partial Fractions
Let N (x) and D(x) be polynomial func-
23. d(tanh
dx
u) = sech2 u du
dx 24. d(coth
dx
u) = ; csch2 u du
dx
tions of x. We can break down
N (x)=D(x) using partial fraction expan- 25. d(sech u) du
dx = ; sech u tanh u dx 26. d(csch u) du
dx = ; csch u coth u dx
sion. First, if the degree of N is greater
than or equal to the degree of D, divide 27. d(arcsinh
dx
u) = p 1 du
1 + u2 dx
28. d(arccosh
dx
u) = p 1 du
u2 ; 1 dx
N by D, obtaining
N (x) = Q(x) + N 0 (x)
D(x) D(x) 29. d(arctanh
dx
u) = 1 du
1 ; u2 dx 30. d(arccoth
dx
u) = 1 du
u2 ; 1 dx
where the degree of N 0 is less than that of 31. d(arcsech u) = p;1 du 32. d(arccsch u) = p;1 du :
D. Second, factor D(x). Use the follow- dx u 1 ; u2 dx dx juj 1 + u2 dx
ing rules: For a non-repeated factor: Integrals:
N (x) = A + N 0 (x) Z Z Z Z Z
(x ; a)D(x) x ; a D(x) 1. cu dx = c u dx 2. (u + v) dx = u dx + v dx
where  Z Z Z
A= N (x) xn dx = n +1 1 xn+1
3. n 6= ;1 4. 1 dx = ln x 5. ex dx = ex
D(x) x=a : x
Z dx Z dv Z
For a repeated factor:
mX;1 6. 1 + x2 = arctan x 7. u dx dx = uv ; v du
dx dx
N (x) = Ak + N 0 (x) Z Z
(x ; a)m D(x) k=0 (x ; a)m;k D(x) 8. sin x dx = ; cos x 9. cos x dx = sin x
where   Z Z
dk N (x)
Ak = k1! dx : 10. tan x dx = ; ln j cos xj 11. cot x dx = ln j cos xj
k D(x)
x=a Z Z
The reasonable man adapts himself to the 12. sec x dx = ln j sec x + tan xj 13. csc x dx = ln j csc x + cot xj
world! the unreasonable persists in trying Z p
to adapt the world to himself. Therefore 14. arcsin xa dx = arcsin xa + a2 ; x2 a>0
all progress depends on the unreasonable.
{ George Bernard Shaw
Theoretical Computer Science Cheat Sheet
Z Calculus Cont. Z
p
15. arccos xa dx = arccos xa ; a2 ; x2 a>0 16. arctan xa dx = x arctan xa ; a2 ln(a2 + x2 ) a>0
Z ;ax ; sin(ax) cos(ax) Z ; 
17. sin (ax)dx =
2 1
2a 18. cos2 (ax)dx = 21a ax + sin(ax) cos(ax)
Z Z
19. sec x dx = tan x
2
20. csc2 x dx = ; cot x
Z n;1 1 Z sinn;2 x dx Z n;1 Z
21. sinn x dx = ; sin nx cos x + n ; n 22. cosn x dx = cos x sin x + n ; 1 cosn;2 x dx
n n
Z n ; x Z Z n ; Z
tann x dx = tan 24. cotn x dx = ; cotn ; 1 x ; cotn;2 x dx n 6= 1
1 1
23. n; 2
n ; 1 ; tan x dx n 6= 1
Z n;1 x n ; 2 Z
25. secn x dx = tan xnsec
;1
+ n ; 1 secn;2 x dx n 6= 1
Z cot x csc n;1 x n ; 2 Z Z Z
26. n
csc x dx = ; n ; 1 n ;
+ n ; 1 csc x dx n 6= 1 27. sinh x dx = cosh x 28. cosh x dx = sinh x
2

Z Z Z Z  
29. tanh x dx = ln j cosh xj 30. coth x dx = ln j sinh xj 31. sech x dx = arctan sinh x 32. csch x dx = ln tanh x2 
Z Z Z
33. sinh2 x dx = 14 sinh(2x) ; 12 x 34. cosh2 x dx = 41 sinh(2x) + 12 x 35. sech2 x dx = tanh x
Z p Z
36. arcsinh xa dx = x arcsinh xa ; x2 + a2 a>0 37. arctanh xa dx = x arctanh xa + a2 ln ja2 ; x2 j
8 p
Z < x arccosh xa ; x2 + a2 if arccosh xa > 0 and a > 0,
38. arccosh xa dx = : p
x arccosh xa + x2 + a2 if arccosh xa < 0 and a > 0,
Z dx  p 2 2
39. p
a2 + x2
= ln x + a + x a>0
Z dx = 1 arctan x a > 0 Zp p
40. a + x2 a
2 a 41. a2 ; x2 dx = x2 a2 ; x2 + a22 arcsin xa a>0
Z p
42. (a2 ; x2)3=2 dx = x8 (5a2 ; 2x2 ) a2 ; x2 + 3a84 arcsin xa a > 0
Z dx Z dx

1 ln  a + x 
 Z dx
43. p = arcsin xa
a>0 44. a ; x 2a  a ; x 
= 45. = 2 p x2
a2 ; x2 2 2 (a2 ; x2 )3=2 a a ; x2
Z p2 2 p  p  Z dx = ln x + px2 ; a2  a > 0
46. a x dx = x2 a2 x2 a22 ln x + a2 x2  47. p 2
 x  x ; a2
Z dx Z 3=2
1
48. ax2 + bx = a ln  a + bx  x a + bx dx = 2(3bx ; 215
a)(a + bx)
p
49. b2
Z pa + bx Z Z x  p  p 
1 dx dx = p1 ln  pa + bx ; pa 
p
50. x dx = 2 a + bx + a p
x a +pbx
51. p
a + bx a + bx + a
a>0
Z  2
Z p
a ; x dx = a2 ; x2 ; a ln  a + a2 ; x2 
p
p 2 2
52. x  x  53. x a2 ; x2 dx = ; 13 (a2 ; x2 )3=2
Z p p2 2 a Z dx  p 2 2 
54. x a ; x dx = 8 (2x ; a ) a ; x + 8 arcsin a a > 0
2 2 2 x 2 2 x 4
55. pa2 ; x2 = ; a ln  a + ax ; x 
1

Z p2 2 Z x2 dx
56. pax2 dx = ; a ; x 57. p = ; x pa2 ; x2 + a arcsin x a > 0 2
a
Z pa2 ;+ xx2   a2 ; x2
2 2 2
p2 2  a + a2 + x2 
p Z p
x2 ; a2 dx = px2 ; a2 ; a arccos a a > 0
58. dx = a + x ; a ln   59.
  jxj
Z px x x
Z dx  x

60. x x a dx = 3 (x a )
2 2 1 2 2 3=2
61. xpx2 + a2 = a ln  a + pa2 + x2 
1 
Theoretical Computer Science Cheat Sheet
Calculus Cont. Finite Calculus
Z dx = 1 arccos a dx Z p
Dierence, shift operators:
= xa2 x a
2 2
62. p
x x2 ; a2 a jxj a>0 63. p
f (x) = f (x + 1) ; f (x)
Z px2x ax2 a (x2 + a2)3=2
2 2 2
Z x dx = px2 a2 E f (x) = f (x + 1):
64. p 2 65. x4  dx = 3a2 x3
x a2 8  Fundamental Theorem:
X
2ax + b ; pb ; 4ac  if b2 > 4ac,
p2
Z >
> 1  f (x) = F (x) , f (x)x = F (x) + C:
dx < b2 ; 4ac  2ax + b + b2 ; 4ac 
p ln 
66. ax2 + bx + c = >
X
b X
b;1
>
: p 2 2 arctan p2ax + b 2 f (x)x = f (i):
if b2 < 4ac, a i=a
4ac ; b 4ac ; b
8 1   Dierences:
> p p 2 (cu) = c u (u + v ) = u + v
Z dx < a
p ln 2 ax + b + 2 a ax + bx + c  if a > 0,
67. pax2 + bx + c = > 1 (uv) = u v + E v u
: p;a arcsin p;b22ax; ;4acb if a < 0, (xn ) = nxn;1
Zp (Hx ) = x;1 (2x) = 2x
68. 2ax + b p 2 4ax ; b2 Z dx ; x  ;x
2 ax + bx + c dx = 4a ax + bx + c + 8a
p (cx ) = (c ; 1)cx m = m;1 :
ax + bx + c
2
Sums:
Z x dx ax2 + bx + c ; b Z
p
dx P cu x = c P u x
69. p
ax2 + bx + c
= a 2a
p
ax2 + bx + c P(u + v) x = P u x + P v x
8 ;1  2pcpax2 + bx + c + bx + 2c  P u v x = uv ; P E v u x
Z >
> p ln  
dx < c  x  if c > 0,
P xn x = xn+1 P x;1 x = H
70. p 2 =>
x ax + bx + c > 1 m+1 x
: p;c arcsin jxjpbxb2+;2c4ac if c < 0, P cx x = cx P ; x  x = ; x :
c;1 m m+1
Z p Falling Factorial Powers:
71. x3 x2 + a2 dx = ( 13 x2 ; 152 a2 )(x2 + a2 )3=2 xn = x(x ; 1)    (x ; n + 1) n > 0
Z Z x0 = 1
72. xn sin(ax) dx = ; a1 xn cos(ax) + na xn;1 cos(ax) dx
Z Z xn = (x + 1)  1 (x + jnj) n < 0
73. xn cos(ax) dx = a1 xn sin(ax) ; na xn;1 sin(ax) dx xn+m = xm (x ; m)n :
Z n ax Z Rising Factorial Powers:
74. xn eax dx = x ae ; na xn;1 eax dx xn = x(x + 1)    (x + n ; 1) n > 0
Z  
75. xn ln(ax) dx = xn+1 ln(ax) ; n+1
1
(n + 1)2
x0 = 1
Z xn+1 m Z xn = (x ; 1)  1 (x ; jnj) n < 0
76. xn (ln ax)m dx = (ln ax)m ; n m;1
n+1 n + 1 x (ln ax) dx: xn+m = xm (x + m)n :
Conversion:
x1 = x1 = x1 xn = (;1)n (;x)n = (x ; n + 1)n
x2 = x +x
2 1 = x
2 ; x1 = 1=(x + 1);n
x3 = x + 3x2 + x1
3 = x3 ; 3x2 + x1 xn = (;1)n (;x)n = (x + n ; 1)n
x4 = x4 + 6x3 + 7x2 + x1 = x4 ; 6x3 + 7x2 ; x1 = 1=(x ; 1);n
x5 = x5 + 15x4 + 25x3 + 10x2 + x1 = x5 ; 15x4 + 25x3 ; 10x2 + x1 Xn n Xn n
n
x = k
k
x = k (;1)n;k xk
x1 = x1 x1 = x1 k=1 k=1
Xn n
x2 = x2 + x1 x2 = x2 ; x 1 xn = (;1)n;k xk
x3 = x3 + 3x2 + 2x1 x3 = x3 ; 3x2 + 2x1 k=1 k
x =
4 x + 6x3 + 11x2 + 6x1
4 x =
4 x ; 6x3 + 11x2 ; 6x1
4 Xn n
x5 = x5 + 10x4 + 35x3 + 50x2 + 24x1 x5 = x5 ; 10x4 + 35x3 ; 50x2 + 24x1 xn = k xk :
k=1
Theoretical Computer Science Cheat Sheet
Series
Taylor's series: Ordinary power series:
X1 i X
1
f (x) = f (a) + (x ; a)f 0 (a) + (x ;2 a) f 00 (a) +    = (x ;i! a) f (i) (a):
2
A(x) = ai xi :
i=0 i=0
Expansions:
1 X
1 Exponential power series:
1;x = 1 + x + x 2 + x3 + x4 +    = xi X
1 xi
i=0 A(x) = ai i! :
1 X
1 i=0
1 ; cx = 1 + cx + c2 x2 + c3 x3 +    = ci xi Dirichlet power series:
i=0 X
1 a
1 X
1
A(x) = i
1 ; xn = 1 + xn + x2n + x3n +    = xni
i=1 ix :
i=0
x X
1 Binomial theorem: 
(1 ; x) = x + 2x2 + 3x3 + 4x4 +    = ixi X
n n
n;k k

2
 i=0 (x + y )n = k x y:
dn 1 X
1 k=0
xk dx n 1;x = x + 2nx2 + 3nx3 + 4n x4 +    = n i xi Dierence of like powers:
i=0 nX
;1
X
1 xi
xn ; yn = (x ; y) xn;1;k yk :
ex = 1+x + x + x +
1 2
2
1 3
6 = i!
i=0 k=0
X
1 i For ordinary power series:
ln(1 + x) = x ; 12 x2 + 13 x3 ; 14 x4 ;    = (;1)i+1 xi X
1
i=1
A(x) + B (x) = (
ai + bi )xi
X1 xi
ln 1 ;1 x = x + 12 x2 + 13 x3 + 14 x4 +    = X
1
i=0
i=1 i xk A(x) = ai;k xi
X1 2i+1
sin x = x ; 3!1 x3 + 5!1 x5 ; 7!1 x7 +    = (;1)i (2xi + 1)! P i=k
i=0
X1 2i
A(x) ; k ; 1
a xi X
i=0 i
1
= ai+k xi
cos x = 1; x + x ; x +
1 2 1 4 1 6 = (;1)i (2xi)! xk i=0
2! 4! 6!
i=0 X
1
X1 2i+1 A(cx) = ci ai xi
tan;1 x = x ; 31 x3 + 15 x5 ; 17 x7 +    = (;1)i (2xi + 1) i=0
i=0  
X1 n X
1
(1 + x)n = 1 + nx + n(n2;1) x2 +    = xi A0 (x) = (i + 1)ai+1 xi
i=0  i i=0
1 ; x2 +    X1 i + n X
1
= 1 + (n + 1)x + n+2 = xi xA0 (x) = iai xi
(1 ; x)n+1 2 i i=1
x
i=0
X1 i Z X
1 a
ex ; 1 = 1 ; 21 x + 121 x2 ; 720
1 x4 +    = Bii!x A(x) dx = i;1
i x
i
i=0
X1   i=1
1 (1 ; p1 ; 4x) = 1 + x + 2x + 5x +   
2 3 = i +1 1 2ii xi A(x) + A(;x) = X
1
a2i x2i
2x i=0   2 i=0
1 X1 2i
A(x) ; A(;x) = X
1
p = 1 + x + 2x + 6x +   
2 3 = i xi a2i+1 x : 2i+1
1 ; 4x 2
1
 p 
1 ; 1 ; 4x n ;4+nx2 +   
i=0 
X1 2i + n i=0
P
p
2x = 1 + (2 + n)x + = i xi Summation: If bi = ij=0 ai then
1 ; 4x 2
i=0
1 ln 1 X
1 B (x) = 1 ;1 x A(x):
1;x 1;x = x + 32 x2 + 116 x3 + 25
12 x +    =
4 Hi xi
  i=1 Convolution: 0 1
1 ln 1 2 X
1 H xi
i;1 X
1 X i
2 1;x = 12 x2 + 34 x3 + 24
11 x4 +    = i A(x)B (x) = @ aj bi;j A xi :
i=2
x X1 i=0 j =0
1 ; x ; x2 = x + x 2 + 2x3 + 3x4 +    = Fi xi
i=0 God made the natural numbers!
Fn x X1 all the rest is the work of man.
1 ; (Fn;1 + Fn+1 )x ; (;1)n x2 = F n x + F2 n x 2 + F x3 +   
3 n = Fni xi : { Leopold Kronecker
i=0
Theoretical Computer Science Cheat Sheet
Series Escher's Knot
Expansions:
X
1    1 ;n X1 i
1 1
(1 ; x)n+1 ln 1 ; x = (Hn+i ; Hn ) n +i i xi x = n xi
1 n
X
i=0 i=0 
X1 i n!xi
xn = ixi (ex ; 1)n = n i!
 n i1
X
=0

i n!xi
i=0
X
1 (;4)i B x2i
ln 1 ;1 x = x cot x = 2i

i=0 n i! i=0 (2i)!


X
1 2i 2i 2i;1 X
1 1
tan x = (;1)i;1 2 (2 ;(21)i)!B2i x  (x) = ix
i=1 i=1
1 X1 (i)  (x ; 1) X
1 (i)
 (x) = ix  (x) = ix
i=1 i=1
Y 1
 (x) = 1 ; p;x Stieltjes Integration
p
X
1 If G is continuous in the interval a b] and F is nondecreasing then
 2 (x)
P
= dx(ii ) where d(n) = djn 1
Zb
i=1 G(x) dF (x)
a
X
1 S (i) P exists. If a  b  c then
 (x) (x ; 1) = xi where S (n) = djn d Zc Zb Zc
i=1 G(x) dF (x) = G(x) dF (x) + G(x) dF (x):
 (2n) = 22n;1 jB2n j  2n
n2N
a a b
(2n)! If the integrals involved exist
Z b;  Zb Zb
x X
1 i 2i

sin x = (;1)i;1 (4 ;(22)iB 2i x


a
G(x) + H (x) dF (x) =
a
G(x) dF (x) +
a
H (x) dF (x)
i=0 )! Zb ;  Zb Zb
 1 ; p1 ; 4x n X1 G(x) d F (x) + H (x) = G(x) dF (x) + G(x) dH (x)
= n(2i!(i + n ; 1)! xi
Za b Zb a; a
2x i=0 n + i)!
c  G(x) dF (x) =
 ZbG(x) d c  F (x) = c G(x) dF (x)
X 2i=2 sin i4 i
1
a a a
ex sin x = i! x Zb Z b
s i=1 G(x) dF (x) = G(b)F (b) ; G(a)F (a) ; F (x) dG(x):
p
1; 1;x X
1 (4i)! i
a a
If the integrals involved exist, and F possesses a derivative F 0 at every
x = p x
i=0 16i 2(2i)!(2i + 1)! point in a b] then
 arcsin x 2 X
1 4i i!2
Zb Zb
x = ( i + 1)(2 i + 1)! x2i : G(x) dF (x) = G(x)F 0 (x) dx:
i=0 a a
Cramer's Rule Fibonacci Numbers
00 47 18 76 29 93 85 34 61 52
If we have equations:
a11 x1 + a12 x2 +    + a1n xn = b1
86 11 57 28 70 39 94 45 02 63
1 1 2 3 5 8 13 21 34 55 89 : : :
95 80 22 67 38 71 49 56 13 04
a21 x1 + a22 x2 +    + a2n xn = b2 59 96 81 33 07 48 72 60 24 15
De nitions:
.. .. .. 73 69 90 82 44 17 58 01 35 26 Fi = Fi;1 +Fi;2 F0 = F1 = 1
. . . F;i = (; 1)i;1 Fi
an1 x1 + an2 x2 +    + ann xn = bn
68 74 09 91 83 55 27 12 46 30

Fi = p15 i ; ^i
37 08 75 19 92 84 66 23 50 41
14 25 36 40 51 62 03 77 88 99
Let A = (aij ) and B be the column matrix (bi ). Then 21 32 43 54 65 06 10 89 97 78 Cassini's identity: for i > 0:
there is a unique solution i det A 6= 0. Let Ai be A
with column i replaced by B . Then
42 53 64 05 16 20 31 98 79 87 Fi+1 Fi;1 ; Fi2 = (;1)i :
xi = det Ai : The Fibonacci number system: Additive rule:
det A Every integer n has a unique Fn+k = Fk Fn+1 + Fk;1 Fn
representation F2n = Fn Fn+1 + Fn;1 Fn :
Improvement makes strait roads, but the crooked n = Fk1 + Fk2 +    + Fkm Calculation
roads without Improvement, are roads of Genius. where ki  ki+1 + 2 for all i,  F F by matrices:  n
{ William Blake (The Marriage of Heaven and Hell) n;2 n;1 = 0 1 :
1  i < m and km  2. Fn;1 Fn 1 1

You might also like