Theoretical Computer Science Cheat Sheet
Theoretical Computer Science Cheat Sheet
De nitions Series
f(n) = O(g(n)) i 9 positive c n0 such that X
n X
n + 1) X
n
i = n(n2+ 1) i2 = n(n + 1)(2n 3 = n (n + 1) :
2 2
0 f(n) cg(n) 8n n0. i
i=1 i=1 6 i=14
f(n) =
(g(n)) i 9 positive c n0 such that In general:
f(n) cg(n) 0 8n n0.
X
n X
n ;
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 X m+1
m
f(n) = o(g(n)) i limn!1 f(n)=g(n) = 0. im = m 1+ 1 k Bk nm+1;k :
lim a = a i 8 2 R, 9n0 such that i=1 k=0
n!1 n Geometric series:
jan ; aj < , 8n n0.
Xn n+1 X
1 X
1
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 c < 1
8s 2 S. i=0 i=0 i=1
X
n n n
nc ; (n + 1)c + c X
1
ici = (1 ;c c)2
+2 +1
inf S greatest b 2 R such that b ici = c 6= 1 c < 1:
s, 8s 2 S. i=0 (c ; 1)2 i=0
lim inf a lim inf fai j i n i 2 Ng. Harmonic series:
n!1 n n!1 X
n X
n
Hn = 1i iHi = n(n2+ 1) Hn ; n(n4; 1) :
lim sup an lim supfai j i n i 2 Ng.
n!1 i=1 i=1
n!1
;n X
n Xn i 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): X n n n n
k n
1. k = (n ; k)!k! n! 2. n 3. k = n ; k
Arrangements of an n ele- k =2
ment set into k cycles. n n
n ;1
k =0 n n ;1
n ; 1
n Stirling numbers (2nd kind): 4. k = k k ; 1 5. k = k + k ; 1
k
Partitions of an n element X r + k r + n + 1
set into k non-empty sets. 6. mn mk = nk mn ;; kk 7. k = n
n
1st order Eulerian numbers: k n
k X k
n n+1 X r s
n r+s
Permutations 12 : : :n on 8. = 9. =
n
f1 2 : : : ng with k ascents. nm
k=0 m+1
k ; n ; 1 k=0 k n; k n
k 2nd order Eulerian numbers. 10. k = (;1)k k 11. n1 = nn = 1
Cn Catlan Numbers: Binary n n n ; 1 n ; 1
trees with n + 1 vertices. 12. 2 = 2 ; 1 n ;1
13. k = k k + k ; 1
n = (n ; 1)!
n = (n ; 1)!H
n =1 n n
14. 1 15. 2 n;1 16. n 17. k k
n = (n ; 1) n ; 1 + n ; 1
Xn
18. k k k;1 19. n ;n 1 = n ;n 1 = n2 20. n = n! 21. C = 1 2n
n n+1 n
n n n n n k=0 k n ; 1 n ; 1
22. = = 1 23. = 24. = (k + 1) + (n ; k)
00 n n ; 1 k n; 1 ; k
n
k n k kn ;+ 11
25. 1 if k = 0, 26. 1 = 2n ; n ; 1 27. 2 = 3n ; (n + 1)2n + 2
k = 0 otherwise n X
X n n x+k m n + 1 n X n n k
28. xn = k n 29. m = k (m + 1 ; k)n(;1)k 30. m! m = k n;m
n k=0X 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
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 1 n+1 Z 1 Z
A = N(x)
D(x) x=a :
3. xn dx = n + 1x n 6= ;1 4. x dx = ln x 5. ex dx = ex
Z dx Z dv Z du
For a repeated factor: 6. 7.
N(x) mX;1 Ak + N 0 (x) 1 + x2 = arctan x u dx dx = uv ; v dx dx
= Z Z
m
(x ; a) D(x) (x ; a)m;k D(x)
k=0 8. sin x dx = ; cos x 9. cos x dx = sinx
where Z Z
dk N(x)
Ak = k!1 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 ax dx = arccos xa ; a2 ;x 2 a>0 16. arctan xa dx = x arctan ax ; a2 ln(a2 + x2) a > 0
Z ; Z ;
17. sin2 (ax)dx = 21a ax ; sin(ax) cos(ax) 18. cos2(ax)dx = 21a ax + sin(ax) cos(ax)
Z Z
19. sec 2 x dx = tan x 20. csc2 x dx = ; cot x
Z n;1 1 Z sinn;2 x dx Z n;1 x sinx n ; 1 Z
21. sinn x dx = ; sin nx cos x + n ; n 22. cos n x dx = cos
n + n cosn;2 x dx
Z tan n;1 x Z Z cot n;1 x Z
23. n n
tan x dx = n ; 1 ; tan x dx n 6= 1; 2 24. cot x dx = ; n ; 1 ; cotn;2 x dx n 6= 1
n
Z n;1 x n ; 2 Z
25. sec n x dx = tan xnsec
;1
+ n ; 1 sec n;2 x dx n 6= 1
Z n;1 x n ; 2 Z Z Z
26. csc n x dx = ; cot xncsc
;1
+ n;1 csc n;2 x dx n 6= 1 27. sinh x dx = cosh x 28. cosh x dx = sinh x
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. sinh x dx = sinh(2x) ; x
2 1
4
1
2 34. cosh x dx = sinh(2x) + x
2 1
4
1
2 35. sech 2 x dx = tanh x
Z p Z
36. arcsinh ax dx = x arcsinh ax ; x +a2 2 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 ax 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 Zp p
40. x
a2 + x2 = a arctan a a > 0
1
41. a2 ; x2 dx = x2 a2 ; x2 + a22 arcsin ax a>0
Z p
42. (a2 ; x2)3=2dx = x8 (5a2 ; 2x2) a2 ; x2 + 3a84 arcsin xa a > 0
Z dx Z dx
1 ln a + x
Z dx x
43. p = arcsin ax a>0 44. =
a ; x 2a a ; x 45. (a ; x ) = = p 2
Z pa ; x a a ; x2
2 2 2 2 2 2 3 2 2
p p Z p 2 2
46. a2 x2 dx = x2 a2 x2 a2 ln x + a2 x2
2
47. px2dx; a2 = ln x + x ; a a > 0
Z Z p + bx)3=2
48. ax2dx+ bx = a1 ln a +x bx 49. x a + bxdx = 2(3bx ; 2a)(a 15b2
Z pa + bx p Z 1 Z x 1
p
a + bx
p
; a
50. dx = 2 a + bx + a p dx
51. pa + bx dx = p ln pa + bx + pa a > 0
Z pa2x; x2 p2 2
x a +pbx
a + a2 ; x2 Z p2
52. x dx = a ; x ; a ln x 53. x a2 ; x2 dx = ; 13 (a2 ; x2)3=2
p 2 2
Z p p Z dx
54. x2 a2 ; x2 dx = x8 (2x2 ; a2) a2 ; x2 + a8 arcsin xa a > 0 4
55. p 2 2 = ; a1 ln a + ax ; x
Z x dx Z x2 dx a ;x
p2 2 p
56. pa2 ; x2 = ; a ; x 57. pa2 ; x2 = ; x2 a2 ; x2 + a2 arcsin ax a > 0 2
Z pa2 + x2 p2 2 p 2 2 Z px2 ; a2 p2 2
58. dx = a + x ; a ln
a + a + x
59. dx = x ; a ; a arccos jaxj a > 0
x x x
Z p Z
60. x x2 a2 dx = 13 (x2 a2)3=2 61. xpxdx 2 + a2
= 1 ln x
a a + a2 + x2
p
Theoretical Computer Science Cheat Sheet
Calculus Cont. Finite Calculus
Z dx = 1 arccos a a > 0 Z p
Dierence, shift operators:
63. 2 p dx2 2 = xa2 x a
2 2
62. p a jx j f(x) = f(x + 1) ; f(x)
Z x x ;a
2 2
Z px2x ax2 a (x2 + a2)3=2
x dx p2 2 E f(x) = f(x + 1):
64. p 2 = x a 65. x4 dx = 3a2x3 Fundamental Theorem:
x a2 8 X
2ax + b ; pb2 ; 4ac if b2 > 4ac,
p
Z >
> 1 f(x) = F (x) , f(x)x = F (x) + C:
dx < p2 ln
b ; 4ac 2ax + b + b2 ; 4ac
66. =
ax + bx + c >
X
b X
b;1
2
: p 2 2 arctan p2ax + b 2 f(x)x = f(i):
if b2 < 4ac, a i=a
4ac ; b 4ac ; b Dierences:
8 1 p p
Z >
< p ln 2ax + b + 2 a ax2 + bx + c if a > 0, (cu) = c u (u + v) = u + v
dx a (uv) = u v + E v u
67. p 2 =
ax + bx + c > : p1;a arcsin p;b2ax ;b
2 ; 4ac
if a < 0, (xn) = nxn;1
Z p 2 p 2Z
(Hx ) = x;1 (2x ) = 2x
68. ax + bx + c dx = 2ax4a+ b ax2 + bx + c + 4ax8a; b p 2 dx (cx ) = (c ; 1)cx
; x ;x
ax + bx + c m = m;1 :
Sums:
Z x dx ax
p
2 + bx + c b Z dx P cu x = c P u x
69. p 2
ax + bx + c
= a ;
2a p
ax + bx + c
2 P(u + v) x = P u x + P v x
8 ;1 2pcpax2 + bx + c + bx + 2c P u v x = uv ; P v u x
>
Z dx < pc ln
> x
if c > 0,
P xn x = xn+1
E
P x;1 x = H
70. p => m+1 x
x ax + bx + c > 1
: p;c arcsin jxjpbxb2+;2c4ac P; x x = ; x :
2
if c < 0, P cx x = cx
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 ; m + 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 = n n n;1
a x sin(ax) ; a x sin(ax) dx
1
xn+m = xm (x ; m)n :
Z xn eax ; n Z xn;1eax dx Rising Factorial Powers:
74. xneax dx = a a xn = x(x + 1) (x + m ; 1) n > 0
Z
75. xn ln(ax) dx = xn+1 ln(ax) ;
1
n + 1 (n + 1)2
x0 = 1
Z n+1 Z xn = (x ; 1) 1 (x ; jnj) n < 0
76. xn(ln ax)m dx = nx + 1 (ln ax)m ; n m n m;1
+ 1 x (ln ax) dx: xn+m = xm (x + m)n :
Conversion:
x1 = x1 = x1 xn = (;1)n (;x)n = (x ; m + 1)n
x2 = x2 + x1 = x2 ; x1 = 1=(x + 1);n
x3 = x3 + 3x2 + x1 = x3 ; 3x2 + x1 xn = (;1)n (;x)n = (x + m ; 1)n
x4 = x + 6x3 + 7x2 + x1
4 = x ; 6x3 + 7x2 ; x1
4 = 1=(x ; 1);n
Xn n n
x5 = x5 + 15x4 + 25x3 + 10x2 + x1 = x5 ; 15x4 + 25x3 ; 10x2 + x1
xn = x k = X n (;1)n;k xk
x1 = x1 x1 = x1 k=1 k k=1 k
X n
n
x =
2 x + x1
2 x =
2 x ; x1
2
xn = (;1)n;k xk
x3 = x3 + 3x2 + 2x1 x3 = x3 ; 3x2 + 2x1 k=1 k
x4 = x4 + 6x3 + 11x2 + 6x1 x4 = x4 ; 6x3 + 11x2 ; 6x1 Xn n
n
x = xk :
x5 = x5 + 10x4 + 35x3 + 50x2 + 24x1 x5 = x5 ; 10x4 + 35x3 ; 50x2 + 24x1 k=1 k
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) = aixi :
i=0 i=0
Expansions:
1 X
1 Exponential power series:
= 1 + x + x2 + x3 + x4 + = xi X1 i
1;x i=0 A(x) = ai xi! :
1 X
1 i=0
1 ; cx = 1 + cx + c2x2 + c3 x3 + = ci xi Dirichlet power series:
i=0 X1
1 X
1
A(x) = iaxi :
1 ; xn = 1 + xn + x2n + x3n + = xni
i=0 i=1
x X
1 Binomial theorem:
(1 ; x)2 = x + 2x2 + 3x3 + 4x4 + = ixi X n n
n;k k
1 i=0 (x + y)n = k x y:
dn X
1 k=0
xk dx n 1;x = x + 2n x2 + 3nx3 + 4n x4 + = n i xi Dierence of like powers:
i=0 nX
;1
X
1 xi
xn ; yn = (x ; y) xn;1;kyk :
ex = 1+x+ x + x +
1 2
2
1 3
6 = i!
i=0 k=0
X
1 xi For ordinary power series:
ln(1 + x) = x ; 12 x2 + 31 x3 ; 14 x4 ; = (;1)i+1 i X
1
i=1
A(x) + B(x) = (
ai + bi )xi
X1 i
ln 1 ;1 x = x + 12 x2 + 31 x3 + 14 x4 + = xi i=0
X
1
i=1 xk A(x) = ai;k xi
X1 2i+1
sin x = x ; 3!1 x3 + 5!1 x5 ; 7!1 x7 + = (;1)i (2ix + 1)! P i=0
i=0 A(x) ; k ;1
ax X
i=0 i
i 1
X1 x2i xk = ai;k xi
cos x = 1; x + x
1 2 1 4
; 1 6
x + = (;1)i (2i)! i=0
2! 4! 6!
i1
=0 X
1
X x2i+1 A(cx) = ci aixi
tan;1 x = x ; 13 x3 + 51 x5 ; 17 x7 + = (;1)i (2i i=0
i=0 + 1) X
1
X1 n A0 (x) = (i + 1)ai+1 xi
(1 + x)n = 1 + nx + n(n2;1) x2 + = i xi i=0
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 ; 12 x + 121 x2 ; 720
1 x4 + = Bi!i x A(x) dx = i;1
i x
i
1 1 2i
i=0 i=1
1 (1 ; p1 ; 4x) X A(x) + A(;x) = X1
2x = 1 + x + 2x2 + 5x3 + = i + 1 i xi a2ix2i
i=0 2 i=0
1 X1 2i
A(x) ; A(;x) 1 X
p = 1 + x + 2x2 + 6x3 + = i xi = a2i+1x : 2i+1
1 ; 4x 2
1
1 ; p1 ; 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 1 X
1 B(x) = 1 ;1 x A(x):
1 ; x ln 1 ; x = x + 32 x2 + 116 x3 + 25
12 x + =
4 Hi xi
Convolution: 0 1
1 ln 1 2
i=1
X
1 H xi
i;1 X
1 X i
2 1;x = 12 x2 + 34 x3 + 11
24 x +
4 = i A(x)B(x) = @ aj bi;j A xi:
i=2
x X
1 i=0 j =0
1 ; x ; x2 = x + x + 2x + 3x +
2 3 4 = Fi xi
i=0 God made the natural numbers!
Fn x X
1 all the rest is the work of man.
1 ; (Fn;1 + Fn+1)x ; (;1)n x2 = Fnx + F2nx + F3nx + =
2 3 Fnixi : { Leopold Kronecker
i=0
Theoretical Computer Science Cheat Sheet
Series Escher's Knot
Expansions:
1 1 X
1 n + i 1 ;n X1 i
i xi
(1 ; x)n+1 ln 1 ; x = (Hn+i ; Hn) i x
i=0 x = n
i=0
X1 n X1 i n!xi
xn = i xi (ex ; 1)n = n i!
1 n i=0
X1 i n!xi i=0
X
1 (;4)i B x2i
2i
ln 1 ; x = n i! x cot x = (2i)!
i=0 i=0
X
1 2i 2i 2i;1 X
1 1
tanx = (;1)i;1 2 (2 ;(2i)!
1)B2i x (x) = ix
i=1 i=1
1 X1 X1
(x) =
(i) x
(x ; 1) = (i)x
i=1 i (x) i=1 i
Y
(x) = 1 ;1p;x Stieltjes Integration
p
X
1 d(i) If G is continuous in the interval a b] and F is nondecreasing then
(x) =
P Zb
i where d(n) = djn 1
2
i=1 x G(x) dF (x)
a
X1 P d exists. If a b c then
(x)(x ; 1) = S(i) i where S(n) = djn Zc Zb Zc
i=1 x G(x) dF(x) = G(x) dF(x) + G(x) dF (x):
2n;1jB j
= 2 (2n)! 2n 2n a a b
(2n) n2N If the integrals involved exist
Z b; Zb Zb
x X1 i 2)B2ix2i
= (;1)i;1 (4 ;(2i)! a
G(x) + H(x) dF(x) = G(x) dF(x) + H(x) dF(x)
a
sin x i=0 Zb ; Zb Za b
1 ; p1 ; 4x n X1 G(x) d F (x) + H(x) = G(x) dF(x) + G(x) dH(x)
2x = n(2i + n ; 1)! xi
i!(n + i)!
a
Zb Zb a
Z ab
i=0
c G(x) dF(x) =
;
G(x) d c F(x) = c
G(x) dF (x)
X1 2i=2 sin i
a a a
ex sin x = i!
4 xi
Zb Z b
s i=1 G(x) dF(x) = G(b)F (b) ; G(a)F (a) ; F(x) dG(x):
1; 1;x
p X
1 (4i)! a a
If the integrals involved exist, and F possesses a derivative F 0 at every
x = i p xi
i=0 16 2(2i)!(2i + 1)! point in a b] then
arcsin x 2 X 1 4i i!2 Zb Zb
x = (i + 1)(2i + 1)! x2i: G(x) dF (x) = G(x)F 0(x) dx:
i=0 a a
Crammer's Rule 0 47 18 76 29 93 85 34 61 52
Fibonacci Numbers
If we have equations:
a11x1 + a12x2 + + a1nxn = b1
86 11 57 28 70 39 94 45 2 63
1 1 2 3 5 8 13 21 34 55 89 : : :
95 80 22 67 38 71 49 56 13 4
a21x1 + a22x2 + + a2nxn = b2 59 96 81 33 7 48 72 60 24 15
De nitions:
.. .. .. 73 69 90 82 44 17 58 1 35 26 Fi = Fi;1+Fi;2 F0 = F1 = 1
. . . F;i = (; 1)i;1 Fi
an1x1 + an2x2 + + annxn = bn
68 74 9 91 83 55 27 12 46 30
Fi = p15 i ; ^i
37 8 75 19 92 84 66 23 50 41
14 25 36 40 51 62 3 77 88 99
Let A = (aij ) and B be the column matrix (bi ). Then 21 32 43 54 65 6 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 5 16 20 31 98 79 87 Fi+1 Fi;1 ; Fi2 = (;1)i :
xi = det Ai
det A :
The Fibonacci number system: Additive rule:
Every integer n has a unique Fn+k = Fk Fn+1 + Fk;1Fn
representation F2n = FnFn+1 + Fn;1Fn:
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. F n;1 F n 1 1