# Theoretical Computer Science Cheat Sheet

Deﬁnitions Series
f(n) = O(g(n)) iﬀ ∃ positive c, n
0
such that
0 ≤ f(n) ≤ cg(n) ∀n ≥ n
0
.
n

i=1
i =
n(n + 1)
2
,
n

i=1
i
2
=
n(n + 1)(2n + 1)
6
,
n

i=1
i
3
=
n
2
(n + 1)
2
4
.
In general:
n

i=1
i
m
=
1
m+ 1
_
(n + 1)
m+1
−1 −
n

i=1
_
(i + 1)
m+1
−i
m+1
−(m+ 1)i
m
_
_
n−1

i=1
i
m
=
1
m+ 1
m

k=0
_
m+ 1
k
_
B
k
n
m+1−k
.
Geometric series:
n

i=0
c
i
=
c
n+1
−1
c −1
, c = 1,

i=0
c
i
=
1
1 −c
,

i=1
c
i
=
c
1 −c
, |c| < 1,
n

i=0
ic
i
=
nc
n+2
−(n + 1)c
n+1
+c
(c −1)
2
, c = 1,

i=0
ic
i
=
c
(1 −c)
2
, |c| < 1.
Harmonic series:
H
n
=
n

i=1
1
i
,
n

i=1
iH
i
=
n(n + 1)
2
H
n

n(n −1)
4
.
n

i=1
H
i
= (n + 1)H
n
−n,
n

i=1
_
i
m
_
H
i
=
_
n + 1
m+ 1
__
H
n+1

1
m+ 1
_
.
f(n) = Ω(g(n)) iﬀ ∃ positive c, n
0
such that
f(n) ≥ cg(n) ≥ 0 ∀n ≥ n
0
.
f(n) = Θ(g(n)) iﬀ f(n) = O(g(n)) and
f(n) = Ω(g(n)).
f(n) = o(g(n)) iﬀ lim
n→∞
f(n)/g(n) = 0.
lim
n→∞
a
n
= a iﬀ ∀ > 0, ∃n
0
such that
|a
n
−a| < , ∀n ≥ n
0
.
sup S least b ∈ R such that b ≥ s,
∀s ∈ S.
inf S greatest b ∈ R such that b ≤
s, ∀s ∈ S.
liminf
n→∞
a
n
lim
n→∞
inf{a
i
| i ≥ n, i ∈ N}.
limsup
n→∞
a
n
lim
n→∞
sup{a
i
| i ≥ n, i ∈ N}.
_
n
k
_
Combinations: Size k sub-
sets of a size n set.
_
n
k
¸
Stirling numbers (1st kind):
Arrangements of an n ele-
ment set into k cycles.
1.
_
n
k
_
=
n!
(n −k)!k!
, 2.
n

k=0
_
n
k
_
= 2
n
, 3.
_
n
k
_
=
_
n
n −k
_
,
4.
_
n
k
_
=
n
k
_
n −1
k −1
_
, 5.
_
n
k
_
=
_
n −1
k
_
+
_
n −1
k −1
_
,
6.
_
n
m
__
m
k
_
=
_
n
k
__
n −k
m−k
_
, 7.
n

k=0
_
r +k
k
_
=
_
r +n + 1
n
_
,
8.
n

k=0
_
k
m
_
=
_
n + 1
m+ 1
_
, 9.
n

k=0
_
r
k
__
s
n −k
_
=
_
r +s
n
_
,
10.
_
n
k
_
= (−1)
k
_
k −n −1
k
_
, 11.
_
n
1
_
=
_
n
n
_
= 1,
12.
_
n
2
_
= 2
n−1
−1, 13.
_
n
k
_
= k
_
n −1
k
_
+
_
n −1
k −1
_
,
_
n
k
_
Stirling numbers (2nd kind):
Partitions of an n element
set into k non-empty sets.
¸
n
k
_
1st order Eulerian numbers:
Permutations π
1
π
2
. . . π
n
on
{1, 2, . . . , n} with k ascents.
¸¸
n
k
__
2nd order Eulerian numbers.
C
n
Catalan Numbers: Binary
trees with n + 1 vertices.
14.
_
n
1
_
= (n −1)!, 15.
_
n
2
_
= (n −1)!H
n−1
, 16.
_
n
n
_
= 1, 17.
_
n
k
_

_
n
k
_
,
18.
_
n
k
_
= (n −1)
_
n −1
k
_
+
_
n −1
k −1
_
, 19.
_
n
n −1
_
=
_
n
n −1
_
=
_
n
2
_
, 20.
n

k=0
_
n
k
_
= n!, 21. C
n
=
1
n + 1
_
2n
n
_
,
22.
_
n
0
_
=
_
n
n −1
_
= 1, 23.
_
n
k
_
=
_
n
n −1 −k
_
, 24.
_
n
k
_
= (k + 1)
_
n −1
k
_
+ (n −k)
_
n −1
k −1
_
,
25.
_
0
k
_
=
_
1 if k = 0,
0 otherwise
26.
_
n
1
_
= 2
n
−n −1, 27.
_
n
2
_
= 3
n
−(n + 1)2
n
+
_
n + 1
2
_
,
28. x
n
=
n

k=0
_
n
k
__
x +k
n
_
, 29.
_
n
m
_
=
m

k=0
_
n + 1
k
_
(m+ 1 −k)
n
(−1)
k
, 30. m!
_
n
m
_
=
n

k=0
_
n
k
__
k
n −m
_
,
31.
_
n
m
_
=
n

k=0
_
n
k
__
n −k
m
_
(−1)
n−k−m
k!, 32.
__
n
0
__
= 1, 33.
__
n
n
__
= 0 for n = 0,
34.
__
n
k
__
= (k + 1)
__
n −1
k
__
+ (2n −1 −k)
__
n −1
k −1
__
, 35.
n

k=0
__
n
k
__
=
(2n)
n
2
n
,
36.
_
x
x −n
_
=
n

k=0
__
n
k
___
x +n −1 −k
2n
_
, 37.
_
n + 1
m+ 1
_
=

k
_
n
k
__
k
m
_
=
n

k=0
_
k
m
_
(m+ 1)
n−k
,
Theoretical Computer Science Cheat Sheet
Identities Cont. Trees
38.
_
n + 1
m+ 1
_
=

k
_
n
k
__
k
m
_
=
n

k=0
_
k
m
_
n
n−k
= n!
n

k=0
1
k!
_
k
m
_
, 39.
_
x
x −n
_
=
n

k=0
__
n
k
___
x +k
2n
_
,
40.
_
n
m
_
=

k
_
n
k
__
k + 1
m+ 1
_
(−1)
n−k
, 41.
_
n
m
_
=

k
_
n + 1
k + 1
__
k
m
_
(−1)
m−k
,
42.
_
m+n + 1
m
_
=
m

k=0
k
_
n +k
k
_
, 43.
_
m+n + 1
m
_
=
m

k=0
k(n +k)
_
n +k
k
_
,
44.
_
n
m
_
=

k
_
n + 1
k + 1
__
k
m
_
(−1)
m−k
, 45. (n −m)!
_
n
m
_
=

k
_
n + 1
k + 1
__
k
m
_
(−1)
m−k
, for n ≥ m,
46.
_
n
n −m
_
=

k
_
m−n
m+k
__
m+n
n +k
__
m+k
k
_
, 47.
_
n
n −m
_
=

k
_
m−n
m+k
__
m+n
n +k
__
m+k
k
_
,
48.
_
n
+m
__
+m

_
=

k
_
k

__
n −k
m
__
n
k
_
, 49.
_
n
+m
__
+m

_
=

k
_
k

__
n −k
m
__
n
k
_
.
Every tree with n
vertices has n − 1
edges.
Kraft inequal-
ity: If the depths
of the leaves of
a binary tree are
d
1
, . . . , d
n
:
n

i=1
2
−di
≤ 1,
and equality holds
only if every in-
ternal node has 2
sons.
Recurrences
Master method:
T(n) = aT(n/b) +f(n), a ≥ 1, b > 1
If ∃ > 0 such that f(n) = O(n
log
b
a−
)
then
T(n) = Θ(n
log
b
a
).
If f(n) = Θ(n
log
b
a
) then
T(n) = Θ(n
log
b
a
log
2
n).
If ∃ > 0 such that f(n) = Ω(n
log
b
a+
),
and ∃c < 1 such that af(n/b) ≤ cf(n)
for large n, then
T(n) = Θ(f(n)).
Substitution (example): Consider the
following recurrence
T
i+1
= 2
2
i
· T
2
i
, T
1
= 2.
Note that T
i
is always a power of two.
Let t
i
= log
2
T
i
. Then we have
t
i+1
= 2
i
+ 2t
i
, t
1
= 1.
Let u
i
= t
i
/2
i
. Dividing both sides of
the previous equation by 2
i+1
we get
t
i+1
2
i+1
=
2
i
2
i+1
+
t
i
2
i
.
Substituting we ﬁnd
u
i+1
=
1
2
+u
i
, u
1
=
1
2
,
which is simply u
i
= i/2. So we ﬁnd
that T
i
has the closed form T
i
= 2
i2
i−1
.
Summing factors (example): Consider
the following recurrence
T(n) = 3T(n/2) +n, T(1) = 1.
Rewrite so that all terms involving T
are on the left side
T(n) −3T(n/2) = n.
Now expand the recurrence, and choose
a factor which makes the left side “tele-
scope”
1
_
T(n) −3T(n/2) = n
_
3
_
T(n/2) −3T(n/4) = n/2
_
.
.
.
.
.
.
.
.
.
3
log
2
n−1
_
T(2) −3T(1) = 2
_
Let m = log
2
n. Summing the left side
we get T(n) − 3
m
T(1) = T(n) − 3
m
=
T(n) − n
k
where k = log
2
3 ≈ 1.58496.
Summing the right side we get
m−1

i=0
n
2
i
3
i
= n
m−1

i=0
_
3
2
_
i
.
Let c =
3
2
. Then we have
n
m−1

i=0
c
i
= n
_
c
m
−1
c −1
_
= 2n(c
log
2
n
−1)
= 2n(c
(k−1) log
c
n
−1)
= 2n
k
−2n,
and so T(n) = 3n
k
− 2n. Full history re-
currences can often be changed to limited
history ones (example): Consider
T
i
= 1 +
i−1

j=0
T
j
, T
0
= 1.
Note that
T
i+1
= 1 +
i

j=0
T
j
.
Subtracting we ﬁnd
T
i+1
−T
i
= 1 +
i

j=0
T
j
−1 −
i−1

j=0
T
j
= T
i
.
And so T
i+1
= 2T
i
= 2
i+1
.
Generating functions:
1. Multiply both sides of the equa-
tion by x
i
.
2. Sum both sides over all i for
which the equation is valid.
3. Choose a generating function
G(x). Usually G(x) =

i=0
x
i
g
i
.
3. Rewrite the equation in terms of
the generating function G(x).
4. Solve for G(x).
5. The coeﬃcient of x
i
in G(x) is g
i
.
Example:
g
i+1
= 2g
i
+ 1, g
0
= 0.
Multiply and sum:

i≥0
g
i+1
x
i
=

i≥0
2g
i
x
i
+

i≥0
x
i
.
We choose G(x) =

i≥0
x
i
g
i
. Rewrite
in terms of G(x):
G(x) −g
0
x
= 2G(x) +

i≥0
x
i
.
Simplify:
G(x)
x
= 2G(x) +
1
1 −x
.
Solve for G(x):
G(x) =
x
(1 −x)(1 −2x)
.
Expand this using partial fractions:
G(x) = x
_
2
1 −2x

1
1 −x
_
= x
_
_
2

i≥0
2
i
x
i

i≥0
x
i
_
_
=

i≥0
(2
i+1
−1)x
i+1
.
So g
i
= 2
i
−1.
Theoretical Computer Science Cheat Sheet
π ≈ 3.14159, e ≈ 2.71828, γ ≈ 0.57721, φ =
1+

5
2
≈ 1.61803,
ˆ
φ =
1−

5
2
≈ −.61803
i 2
i
p
i
General Probability
1 2 2 Bernoulli Numbers (B
i
= 0, odd i = 1):
B
0
= 1, B
1
= −
1
2
, B
2
=
1
6
, B
4
= −
1
30
,
B
6
=
1
42
, B
8
= −
1
30
, B
10
=
5
66
.
log
b
x =
log
a
x
log
a
b
,
−b ±

b
2
−4ac
2a
.
Euler’s number e:
e = 1 +
1
2
+
1
6
+
1
24
+
1
120
+· · ·
lim
n→∞
_
1 +
x
n
_
n
= e
x
.
_
1 +
1
n
_
n
< e <
_
1 +
1
n
_
n+1
.
_
1 +
1
n
_
n
= e −
e
2n
+
11e
24n
2
−O
_
1
n
3
_
.
Harmonic numbers:
1,
3
2
,
11
6
,
25
12
,
137
60
,
49
20
,
363
140
,
761
280
,
7129
2520
, . . .
ln n < H
n
< ln n + 1,
H
n
= ln n +γ +O
_
1
n
_
.
Factorial, Stirling’s approximation:
1, 2, 6, 24, 120, 720, 5040, 40320, 362880, . . .
n! =

2πn
_
n
e
_
n
_
1 + Θ
_
1
n
__
.
Ackermann’s function and inverse:
a(i, j) =
_
_
_
2
j
i = 1
a(i −1, 2) j = 1
a(i −1, a(i, j −1)) i, j ≥ 2
α(i) = min{j | a(j, j) ≥ i}.
Continuous distributions: If
Pr[a < X < b] =
_
b
a
p(x) dx,
then p is the probability density function of
X. If
Pr[X < a] = P(a),
then P is the distribution function of X. If
P and p both exist then
P(a) =
_
a
−∞
p(x) dx.
Expectation: If X is discrete
E[g(X)] =

x
g(x) Pr[X = x].
If X continuous then
E[g(X)] =
_

−∞
g(x)p(x) dx =
_

−∞
g(x) dP(x).
Variance, standard deviation:
VAR[X] = E[X
2
] −E[X]
2
,
σ =
_
VAR[X].
For events A and B:
Pr[A∨ B] = Pr[A] + Pr[B] −Pr[A∧ B]
Pr[A∧ B] = Pr[A] · Pr[B],
iﬀ A and B are independent.
Pr[A|B] =
Pr[A∧ B]
Pr[B]
For random variables X and Y :
E[X · Y ] = E[X] · E[Y ],
if X and Y are independent.
E[X +Y ] = E[X] + E[Y ],
E[cX] = c E[X].
Bayes’ theorem:
Pr[A
i
|B] =
Pr[B|A
i
] Pr[A
i
]

n
j=1
Pr[A
j
] Pr[B|A
j
]
.
Inclusion-exclusion:
Pr
_
n

i=1
X
i
_
=
n

i=1
Pr[X
i
] +
n

k=2
(−1)
k+1

ii<···<i
k
Pr
_
k

j=1
X
ij
_
.
Moment inequalities:
Pr
_
|X| ≥ λE[X]
¸

1
λ
,
Pr
_
¸
¸
X −E[X]
¸
¸
≥ λ · σ
_

1
λ
2
.
Geometric distribution:
Pr[X = k] = pq
k−1
, q = 1 −p,
E[X] =

k=1
kpq
k−1
=
1
p
.
2 4 3
3 8 5
4 16 7
5 32 11
6 64 13
7 128 17
8 256 19
9 512 23
10 1,024 29
11 2,048 31
12 4,096 37
13 8,192 41
14 16,384 43
15 32,768 47
16 65,536 53
17 131,072 59
18 262,144 61
19 524,288 67
20 1,048,576 71
21 2,097,152 73
22 4,194,304 79
23 8,388,608 83
24 16,777,216 89
25 33,554,432 97
26 67,108,864 101
27 134,217,728 103
28 268,435,456 107 Binomial distribution:
Pr[X = k] =
_
n
k
_
p
k
q
n−k
, q = 1 −p,
E[X] =
n

k=1
k
_
n
k
_
p
k
q
n−k
= np.
Poisson distribution:
Pr[X = k] =
e
−λ
λ
k
k!
, E[X] = λ.
Normal (Gaussian) distribution:
p(x) =
1

2πσ
e
−(x−µ)
2
/2σ
2
, E[X] = µ.
The “coupon collector”: We are given a
random coupon each day, and there are n
diﬀerent types of coupons. The distribu-
tion of coupons is uniform. The expected
number of days to pass before we to col-
lect all n types is
nH
n
.
29 536,870,912 109
30 1,073,741,824 113
31 2,147,483,648 127
32 4,294,967,296 131
Pascal’s Triangle
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1
1 10 45 120 210 252 210 120 45 10 1
Theoretical Computer Science Cheat Sheet
Trigonometry Matrices More Trig.
A
c
θ
B
a
b
C
(0,-1)
(0,1)
(-1,0) (1,0)
(cos θ, sin θ)
Pythagorean theorem:
C
2
= A
2
+B
2
.
Deﬁnitions:
sin a = A/C, cos a = B/C,
csc a = C/A, sec a = C/B,
tan a =
sin a
cos a
=
A
B
, cot a =
cos a
sin a
=
B
A
.
1
2
AB,
AB
A+B +C
.
Identities:
sin x =
1
csc x
, cos x =
1
sec x
,
tan x =
1
cot x
, sin
2
x + cos
2
x = 1,
1 + tan
2
x = sec
2
x, 1 + cot
2
x = csc
2
x,
sin x = cos
_
π
2
−x
_
, sin x = sin(π −x),
cos x = −cos(π −x), tan x = cot
_
π
2
−x
_
,
cot x = −cot(π −x), csc x = cot
x
2
−cot x,
sin(x ±y) = sin xcos y ±cos xsin y,
cos(x ±y) = cos xcos y ∓sin xsin y,
tan(x ±y) =
tan x ±tan y
1 ∓tan xtan y
,
cot(x ±y) =
cot xcot y ∓1
cot x ±cot y
,
sin 2x = 2 sin xcos x, sin 2x =
2 tan x
1 + tan
2
x
,
cos 2x = cos
2
x −sin
2
x, cos 2x = 2 cos
2
x −1,
cos 2x = 1 −2 sin
2
x, cos 2x =
1 −tan
2
x
1 + tan
2
x
,
tan 2x =
2 tan x
1 −tan
2
x
, cot 2x =
cot
2
x −1
2 cot x
,
sin(x +y) sin(x −y) = sin
2
x −sin
2
y,
cos(x +y) cos(x −y) = cos
2
x −sin
2
y.
Euler’s equation:
e
ix
= cos x +i sin x, e

= −1.
Multiplication:
C = A· B, c
i,j
=
n

k=1
a
i,k
b
k,j
.
Determinants: det A = 0 iﬀ A is non-singular.
det A· B = det A· det B,
det A =

π
n

i=1
sign(π)a
i,π(i)
.
2 ×2 and 3 ×3 determinant:
¸
¸
¸
¸
a b
c d
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
a b c
d e f
g h i
¸
¸
¸
¸
¸
¸
= g
¸
¸
¸
¸
b c
e f
¸
¸
¸
¸
−h
¸
¸
¸
¸
a c
d f
¸
¸
¸
¸
+i
¸
¸
¸
¸
a b
d e
¸
¸
¸
¸
=
aei +bfg +cdh
−ceg −fha −ibd.
Permanents:
permA =

π
n

i=1
a
i,π(i)
.
A
a
c
h
b
B
C
Law of cosines:
c
2
= a
2
+b
2
−2ab cos C.
Area:
A =
1
2
hc,
=
1
2
ab sin C,
=
c
2
sin Asin B
2 sin C
.
Heron’s formula:
A =

s · s
a
· s
b
· s
c
,
s =
1
2
(a +b +c),
s
a
= s −a,
s
b
= s −b,
s
c
= s −c.
More identities:
sin
x
2
=
_
1 −cos x
2
,
cos
x
2
=
_
1 + cos x
2
,
tan
x
2
=
_
1 −cos x
1 + cos x
,
=
1 −cos x
sin x
,
=
sin x
1 + cos x
,
cot
x
2
=
_
1 + cos x
1 −cos x
,
=
1 + cos x
sin x
,
=
sin x
1 −cos x
,
sin x =
e
ix
−e
−ix
2i
,
cos x =
e
ix
+e
−ix
2
,
tan x = −i
e
ix
−e
−ix
e
ix
+e
−ix
,
= −i
e
2ix
−1
e
2ix
+ 1
,
sin x =
sinh ix
i
,
cos x = cosh ix,
tan x =
tanh ix
i
.
Hyperbolic Functions
Deﬁnitions:
sinh x =
e
x
−e
−x
2
, cosh x =
e
x
+e
−x
2
,
tanh x =
e
x
−e
−x
e
x
+e
−x
, csch x =
1
sinh x
,
sech x =
1
cosh x
, coth x =
1
tanh x
.
Identities:
cosh
2
x −sinh
2
x = 1, tanh
2
x + sech
2
x = 1,
coth
2
x −csch
2
x = 1, sinh(−x) = −sinh x,
cosh(−x) = cosh x, tanh(−x) = −tanh x,
sinh(x +y) = sinh xcosh y + cosh xsinh y,
cosh(x +y) = cosh xcosh y + sinh xsinh y,
sinh 2x = 2 sinh xcosh x,
cosh 2x = cosh
2
x + sinh
2
x,
cosh x + sinh x = e
x
, cosh x −sinh x = e
−x
,
(cosh x + sinh x)
n
= cosh nx + sinh nx, n ∈ Z,
2 sinh
2 x
2
= cosh x −1, 2 cosh
2 x
2
= cosh x + 1.
θ sin θ cos θ tan θ
0 0 1 0
π
6
1
2

3
2

3
3
π
4

2
2

2
2
1
π
3

3
2
1
2

3
π
2
1 0 ∞
. . . in mathematics
you don’t under-
stand things, you
just get used to
them.
– J. von Neumann v2.02 c 1994 by Steve Seiden
sseiden@acm.org
http://www.csc.lsu.edu/~seiden
Theoretical Computer Science Cheat Sheet
Number Theory Graph Theory
The Chinese remainder theorem: There ex-
ists a number C such that:
C ≡ r
1
mod m
1
.
.
.
.
.
.
.
.
.
C ≡ r
n
mod m
n
if m
i
and m
j
are relatively prime for i = j.
Euler’s function: φ(x) is the number of
positive integers less than x relatively
prime to x. If

n
i=1
p
ei
i
is the prime fac-
torization of x then
φ(x) =
n

i=1
p
ei−1
i
(p
i
−1).
Euler’s theorem: If a and b are relatively
prime then
1 ≡ a
φ(b)
mod b.
Fermat’s theorem:
1 ≡ a
p−1
mod p.
The Euclidean algorithm: if a > b are in-
tegers then
gcd(a, b) = gcd(a mod b, b).
If

n
i=1
p
ei
i
is the prime factorization of x
then
S(x) =

d|x
d =
n

i=1
p
ei+1
i
−1
p
i
−1
.
Perfect Numbers: x is an even perfect num-
ber iﬀ x = 2
n−1
(2
n
−1) and 2
n
−1 is prime.
Wilson’s theorem: n is a prime iﬀ
(n −1)! ≡ −1 mod n.
M¨obius inversion:
µ(i) =
_
¸
_
¸
_
1 if i = 1.
0 if i is not square-free.
(−1)
r
if i is the product of
r distinct primes.
If
G(a) =

d|a
F(d),
then
F(a) =

d|a
µ(d)G
_
a
d
_
.
Prime numbers:
p
n
= nln n +nln ln n −n +n
ln ln n
ln n
+O
_
n
ln n
_
,
π(n) =
n
ln n
+
n
(ln n)
2
+
2!n
(ln n)
3
+O
_
n
(ln n)
4
_
.
Deﬁnitions:
Loop An edge connecting a ver-
tex to itself.
Directed Each edge has a direction.
Simple Graph with no loops or
multi-edges.
Walk A sequence v
0
e
1
v
1
. . . e

v

.
Trail A walk with distinct edges.
Path A trail with distinct
vertices.
Connected A graph where there exists
a path between any two
vertices.
Component A maximal connected
subgraph.
Tree A connected acyclic graph.
Free tree A tree with no root.
DAG Directed acyclic graph.
Eulerian Graph with a trail visiting
each edge exactly once.
Hamiltonian Graph with a cycle visiting
each vertex exactly once.
Cut A set of edges whose re-
moval increases the num-
ber of components.
Cut-set A minimal cut.
Cut edge A size 1 cut.
k-Connected A graph connected with
the removal of any k − 1
vertices.
k-Tough ∀S ⊆ V, S = ∅ we have
k · c(G−S) ≤ |S|.
k-Regular A graph where all vertices
have degree k.
k-Factor A k-regular spanning
subgraph.
Matching A set of edges, no two of
Clique A set of vertices, all of
Ind. set A set of vertices, none of
Vertex cover A set of vertices which
cover all edges.
Planar graph A graph which can be em-
beded in the plane.
Plane graph An embedding of a planar
graph.

v∈V
deg(v) = 2m.
If G is planar then n −m+f = 2, so
f ≤ 2n −4, m ≤ 3n −6.
Any planar graph has a vertex with de-
gree ≤ 5.
Notation:
E(G) Edge set
V (G) Vertex set
c(G) Number of components
G[S] Induced subgraph
deg(v) Degree of v
∆(G) Maximum degree
δ(G) Minimum degree
χ(G) Chromatic number
χ
E
(G) Edge chromatic number
G
c
Complement graph
K
n
Complete graph
K
n1,n2
Complete bipartite graph
r(k, ) Ramsey number
Geometry
Projective coordinates: triples
(x, y, z), not all x, y and z zero.
(x, y, z) = (cx, cy, cz) ∀c = 0.
Cartesian Projective
(x, y) (x, y, 1)
y = mx +b (m, −1, b)
x = c (1, 0, −c)
Distance formula, L
p
and L

metric:
_
(x
1
−x
0
)
2
+ (y
1
−y
0
)
2
,
_
|x
1
−x
0
|
p
+|y
1
−y
0
|
p
¸
1/p
,
lim
p→∞
_
|x
1
−x
0
|
p
+|y
1
−y
0
|
p
¸
1/p
.
Area of triangle (x
0
, y
0
), (x
1
, y
1
)
and (x
2
, y
2
):
1
2
abs
¸
¸
¸
¸
x
1
−x
0
y
1
−y
0
x
2
−x
0
y
2
−y
0
¸
¸
¸
¸
.
Angle formed by three points:
θ
(0, 0) (x
1
, y
1
)
(x
2
, y
2
)

2

1
cos θ =
(x
1
, y
1
) · (x
2
, y
2
)

1

2
.
Line through two points (x
0
, y
0
)
and (x
1
, y
1
):
¸
¸
¸
¸
¸
¸
x y 1
x
0
y
0
1
x
1
y
1
1
¸
¸
¸
¸
¸
¸
= 0.
Area of circle, volume of sphere:
A = πr
2
, V =
4
3
πr
3
.
If I have seen farther than others,
it is because I have stood on the
shoulders of giants.
– Issac Newton
Theoretical Computer Science Cheat Sheet
π Calculus
Wallis’ identity:
π = 2 ·
2 · 2 · 4 · 4 · 6 · 6 · · ·
1 · 3 · 3 · 5 · 5 · 7 · · ·
Brouncker’s continued fraction expansion:
π
4
= 1 +
1
2
2 +
3
2
2+
5
2
2+
7
2
2+···
Gregrory’s series:
π
4
= 1 −
1
3
+
1
5

1
7
+
1
9
−· · ·
Newton’s series:
π
6
=
1
2
+
1
2 · 3 · 2
3
+
1 · 3
2 · 4 · 5 · 2
5
+· · ·
Sharp’s series:
π
6
=
1

3
_
1−
1
3
1
· 3
+
1
3
2
· 5

1
3
3
· 7
+· · ·
_
Euler’s series:
π
2
6
=
1
1
2
+
1
2
2
+
1
3
2
+
1
4
2
+
1
5
2
+· · ·
π
2
8
=
1
1
2
+
1
3
2
+
1
5
2
+
1
7
2
+
1
9
2
+· · ·
π
2
12
=
1
1
2

1
2
2
+
1
3
2

1
4
2
+
1
5
2
−· · ·
Derivatives:
1.
d(cu)
dx
= c
du
dx
, 2.
d(u +v)
dx
=
du
dx
+
dv
dx
, 3.
d(uv)
dx
= u
dv
dx
+v
du
dx
,
4.
d(u
n
)
dx
= nu
n−1
du
dx
, 5.
d(u/v)
dx
=
v
_
du
dx
_
−u
_
dv
dx
_
v
2
, 6.
d(e
cu
)
dx
= ce
cu
du
dx
,
7.
d(c
u
)
dx
= (ln c)c
u
du
dx
, 8.
d(ln u)
dx
=
1
u
du
dx
,
9.
d(sin u)
dx
= cos u
du
dx
, 10.
d(cos u)
dx
= −sin u
du
dx
,
11.
d(tan u)
dx
= sec
2
u
du
dx
, 12.
d(cot u)
dx
= csc
2
u
du
dx
,
13.
d(sec u)
dx
= tan u sec u
du
dx
, 14.
d(csc u)
dx
= −cot u csc u
du
dx
,
15.
d(arcsin u)
dx
=
1

1 −u
2
du
dx
, 16.
d(arccos u)
dx
=
−1

1 −u
2
du
dx
,
17.
d(arctan u)
dx
=
1
1 +u
2
du
dx
, 18.
d(arccot u)
dx
=
−1
1 +u
2
du
dx
,
19.
d(arcsec u)
dx
=
1
u

1 −u
2
du
dx
, 20.
d(arccsc u)
dx
=
−1
u

1 −u
2
du
dx
,
21.
d(sinh u)
dx
= cosh u
du
dx
, 22.
d(cosh u)
dx
= sinh u
du
dx
,
23.
d(tanh u)
dx
= sech
2
u
du
dx
, 24.
d(coth u)
dx
= −csch
2
u
du
dx
,
25.
d(sech u)
dx
= −sech u tanh u
du
dx
, 26.
d(csch u)
dx
= −csch u coth u
du
dx
,
27.
d(arcsinh u)
dx
=
1

1 +u
2
du
dx
, 28.
d(arccosh u)
dx
=
1

u
2
−1
du
dx
,
29.
d(arctanh u)
dx
=
1
1 −u
2
du
dx
, 30.
d(arccoth u)
dx
=
1
u
2
−1
du
dx
,
31.
d(arcsech u)
dx
=
−1
u

1 −u
2
du
dx
, 32.
d(arccsch u)
dx
=
−1
|u|

1 +u
2
du
dx
.
Integrals:
1.
_
cudx = c
_
udx, 2.
_
(u +v) dx =
_
udx +
_
v dx,
3.
_
x
n
dx =
1
n + 1
x
n+1
, n = −1, 4.
_
1
x
dx = ln x, 5.
_
e
x
dx = e
x
,
6.
_
dx
1 +x
2
= arctan x, 7.
_
u
dv
dx
dx = uv −
_
v
du
dx
dx,
8.
_
sin xdx = −cos x, 9.
_
cos xdx = sin x,
10.
_
tan xdx = −ln | cos x|, 11.
_
cot xdx = ln | cos x|,
12.
_
sec xdx = ln | sec x + tan x|, 13.
_
csc xdx = ln | csc x + cot x|,
14.
_
arcsin
x
a
dx = arcsin
x
a
+
_
a
2
−x
2
, a > 0,
Partial Fractions
Let N(x) and D(x) be polynomial func-
tions of x. We can break down
N(x)/D(x) using partial fraction expan-
sion. First, if the degree of N is greater
than or equal to the degree of D, divide
N by D, obtaining
N(x)
D(x)
= Q(x) +
N

(x)
D(x)
,
where the degree of N

is less than that of
D. Second, factor D(x). Use the follow-
ing rules: For a non-repeated factor:
N(x)
(x −a)D(x)
=
A
x −a
+
N

(x)
D(x)
,
where
A =
_
N(x)
D(x)
_
x=a
.
For a repeated factor:
N(x)
(x −a)
m
D(x)
=
m−1

k=0
A
k
(x −a)
m−k
+
N

(x)
D(x)
,
where
A
k
=
1
k!
_
d
k
dx
k
_
N(x)
D(x)
__
x=a
.
The reasonable man adapts himself to the
world; the unreasonable persists in trying
to adapt the world to himself. Therefore
all progress depends on the unreasonable.
– George Bernard Shaw
Theoretical Computer Science Cheat Sheet
Calculus Cont.
15.
_
arccos
x
a
dx = arccos
x
a

_
a
2
−x
2
, a > 0, 16.
_
arctan
x
a
dx = xarctan
x
a

a
2
ln(a
2
+x
2
), a > 0,
17.
_
sin
2
(ax)dx =
1
2a
_
ax −sin(ax) cos(ax)
_
, 18.
_
cos
2
(ax)dx =
1
2a
_
ax + sin(ax) cos(ax)
_
,
19.
_
sec
2
xdx = tan x, 20.
_
csc
2
xdx = −cot x,
21.
_
sin
n
xdx = −
sin
n−1
xcos x
n
+
n −1
n
_
sin
n−2
xdx, 22.
_
cos
n
xdx =
cos
n−1
xsin x
n
+
n −1
n
_
cos
n−2
xdx,
23.
_
tan
n
xdx =
tan
n−1
x
n −1

_
tan
n−2
xdx, n = 1, 24.
_
cot
n
xdx = −
cot
n−1
x
n −1

_
cot
n−2
xdx, n = 1,
25.
_
sec
n
xdx =
tan xsec
n−1
x
n −1
+
n −2
n −1
_
sec
n−2
xdx, n = 1,
26.
_
csc
n
xdx = −
cot xcsc
n−1
x
n −1
+
n −2
n −1
_
csc
n−2
xdx, n = 1, 27.
_
sinh xdx = cosh x, 28.
_
cosh xdx = sinh x,
29.
_
tanh xdx = ln | cosh x|, 30.
_
coth xdx = ln | sinh x|, 31.
_
sech xdx = arctan sinh x, 32.
_
csch xdx = ln
¸
¸
tanh
x
2
¸
¸
,
33.
_
sinh
2
xdx =
1
4
sinh(2x) −
1
2
x, 34.
_
cosh
2
xdx =
1
4
sinh(2x) +
1
2
x, 35.
_
sech
2
xdx = tanh x,
36.
_
arcsinh
x
a
dx = xarcsinh
x
a

_
x
2
+a
2
, a > 0, 37.
_
arctanh
x
a
dx = xarctanh
x
a
+
a
2
ln |a
2
−x
2
|,
38.
_
arccosh
x
a
dx =
_
_
_
xarccosh
x
a

_
x
2
+a
2
, if arccosh
x
a
> 0 and a > 0,
xarccosh
x
a
+
_
x
2
+a
2
, if arccosh
x
a
< 0 and a > 0,
39.
_
dx

a
2
+x
2
= ln
_
x +
_
a
2
+x
2
_
, a > 0,
40.
_
dx
a
2
+x
2
=
1
a
arctan
x
a
, a > 0, 41.
_
_
a
2
−x
2
dx =
x
2
_
a
2
−x
2
+
a
2
2
arcsin
x
a
, a > 0,
42.
_
(a
2
−x
2
)
3/2
dx =
x
8
(5a
2
−2x
2
)
_
a
2
−x
2
+
3a
4
8
arcsin
x
a
, a > 0,
43.
_
dx

a
2
−x
2
= arcsin
x
a
, a > 0, 44.
_
dx
a
2
−x
2
=
1
2a
ln
¸
¸
¸
¸
a +x
a −x
¸
¸
¸
¸
, 45.
_
dx
(a
2
−x
2
)
3/2
=
x
a
2

a
2
−x
2
,
46.
_
_
a
2
±x
2
dx =
x
2
_
a
2
±x
2
±
a
2
2
ln
¸
¸
¸x +
_
a
2
±x
2
¸
¸
¸ , 47.
_
dx

x
2
−a
2
= ln
¸
¸
¸x +
_
x
2
−a
2
¸
¸
¸ , a > 0,
48.
_
dx
ax
2
+bx
=
1
a
ln
¸
¸
¸
¸
x
a +bx
¸
¸
¸
¸
, 49.
_
x

a +bxdx =
2(3bx −2a)(a +bx)
3/2
15b
2
,
50.
_

a +bx
x
dx = 2

a +bx +a
_
1
x

a +bx
dx, 51.
_
x

a +bx
dx =
1

2
ln
¸
¸
¸
¸

a +bx −

a

a +bx +

a
¸
¸
¸
¸
, a > 0,
52.
_

a
2
−x
2
x
dx =
_
a
2
−x
2
−a ln
¸
¸
¸
¸
¸
a +

a
2
−x
2
x
¸
¸
¸
¸
¸
, 53.
_
x
_
a
2
−x
2
dx = −
1
3
(a
2
−x
2
)
3/2
,
54.
_
x
2
_
a
2
−x
2
dx =
x
8
(2x
2
−a
2
)
_
a
2
−x
2
+
a
4
8
arcsin
x
a
, a > 0, 55.
_
dx

a
2
−x
2
= −
1
a
ln
¸
¸
¸
¸
¸
a +

a
2
−x
2
x
¸
¸
¸
¸
¸
,
56.
_
xdx

a
2
−x
2
= −
_
a
2
−x
2
, 57.
_
x
2
dx

a
2
−x
2
= −
x
2
_
a
2
−x
2
+
a
2
2
arcsin
x
a,
a > 0,
58.
_

a
2
+x
2
x
dx =
_
a
2
+x
2
−a ln
¸
¸
¸
¸
¸
a +

a
2
+x
2
x
¸
¸
¸
¸
¸
, 59.
_

x
2
−a
2
x
dx =
_
x
2
−a
2
−a arccos
a
|x|
, a > 0,
60.
_
x
_
x
2
±a
2
dx =
1
3
(x
2
±a
2
)
3/2
, 61.
_
dx
x

x
2
+a
2
=
1
a
ln
¸
¸
¸
¸
x
a +

a
2
+x
2
¸
¸
¸
¸
,
Theoretical Computer Science Cheat Sheet
Calculus Cont. Finite Calculus
62.
_
dx
x

x
2
−a
2
=
1
a
arccos
a
|x|
, a > 0, 63.
_
dx
x
2

x
2
±a
2
= ∓

x
2
±a
2
a
2
x
,
64.
_
xdx

x
2
±a
2
=
_
x
2
±a
2
, 65.
_

x
2
±a
2
x
4
dx = ∓
(x
2
+a
2
)
3/2
3a
2
x
3
,
66.
_
dx
ax
2
+bx +c
=
_
¸
¸
¸
_
¸
¸
¸
_
1

b
2
−4ac
ln
¸
¸
¸
¸
¸
2ax +b −

b
2
−4ac
2ax +b +

b
2
−4ac
¸
¸
¸
¸
¸
, if b
2
> 4ac,
2

4ac −b
2
arctan
2ax +b

4ac −b
2
, if b
2
< 4ac,
67.
_
dx

ax
2
+bx +c
=
_
¸
¸
_
¸
¸
_
1

a
ln
¸
¸
¸2ax +b + 2

a
_
ax
2
+bx +c
¸
¸
¸ , if a > 0,
1

−a
arcsin
−2ax −b

b
2
−4ac
, if a < 0,
68.
_
_
ax
2
+bx +c dx =
2ax +b
4a
_
ax
2
+bx +c +
4ax −b
2
8a
_
dx

ax
2
+bx +c
,
69.
_
xdx

ax
2
+bx +c
=

ax
2
+bx +c
a

b
2a
_
dx

ax
2
+bx +c
,
70.
_
dx
x

ax
2
+bx +c
=
_
¸
¸
¸
_
¸
¸
¸
_
−1

c
ln
¸
¸
¸
¸
¸
2

c

ax
2
+bx +c +bx + 2c
x
¸
¸
¸
¸
¸
, if c > 0,
1

−c
arcsin
bx + 2c
|x|

b
2
−4ac
, if c < 0,
71.
_
x
3
_
x
2
+a
2
dx = (
1
3
x
2

2
15
a
2
)(x
2
+a
2
)
3/2
,
72.
_
x
n
sin(ax) dx = −
1
a
x
n
cos(ax) +
n
a
_
x
n−1
cos(ax) dx,
73.
_
x
n
cos(ax) dx =
1
a
x
n
sin(ax) −
n
a
_
x
n−1
sin(ax) dx,
74.
_
x
n
e
ax
dx =
x
n
e
ax
a

n
a
_
x
n−1
e
ax
dx,
75.
_
x
n
ln(ax) dx = x
n+1
_
ln(ax)
n + 1

1
(n + 1)
2
_
,
76.
_
x
n
(ln ax)
m
dx =
x
n+1
n + 1
(ln ax)
m

m
n + 1
_
x
n
(ln ax)
m−1
dx.
Diﬀerence, shift operators:
∆f(x) = f(x + 1) −f(x),
Ef(x) = f(x + 1).
Fundamental Theorem:
f(x) = ∆F(x) ⇔

f(x)δx = F(x) +C.
b

a
f(x)δx =
b−1

i=a
f(i).
Diﬀerences:
∆(cu) = c∆u, ∆(u +v) = ∆u + ∆v,
∆(uv) = u∆v + Ev∆u,
∆(x
n
) = nx
n−1
,
∆(H
x
) = x
−1
, ∆(2
x
) = 2
x
,
∆(c
x
) = (c −1)c
x
, ∆
_
x
m
_
=
_
x
m−1
_
.
Sums:

cuδx = c

uδx,

(u +v) δx =

uδx +

v δx,

u∆v δx = uv −

Ev∆uδx,

x
n
δx =
x
n+1
m+1
,

x
−1
δx = H
x
,

c
x
δx =
c
x
c−1
,
_
x
m
_
δx =
_
x
m+1
_
.
Falling Factorial Powers:
x
n
= x(x −1) · · · (x −n + 1), n > 0,
x
0
= 1,
x
n
=
1
(x + 1) · · · (x +|n|)
, n < 0,
x
n+m
= x
m
(x −m)
n
.
Rising Factorial Powers:
x
n
= x(x + 1) · · · (x +n −1), n > 0,
x
0
= 1,
x
n
=
1
(x −1) · · · (x −|n|)
, n < 0,
x
n+m
= x
m
(x +m)
n
.
Conversion:
x
n
= (−1)
n
(−x)
n
= (x −n + 1)
n
= 1/(x + 1)
−n
,
x
n
= (−1)
n
(−x)
n
= (x +n −1)
n
= 1/(x −1)
−n
,
x
n
=
n

k=1
_
n
k
_
x
k
=
n

k=1
_
n
k
_
(−1)
n−k
x
k
,
x
n
=
n

k=1
_
n
k
_
(−1)
n−k
x
k
,
x
n
=
n

k=1
_
n
k
_
x
k
.
x
1
= x
1
= x
1
x
2
= x
2
+x
1
= x
2
−x
1
x
3
= x
3
+ 3x
2
+x
1
= x
3
−3x
2
+x
1
x
4
= x
4
+ 6x
3
+ 7x
2
+x
1
= x
4
−6x
3
+ 7x
2
−x
1
x
5
= x
5
+ 15x
4
+ 25x
3
+ 10x
2
+x
1
= x
5
−15x
4
+ 25x
3
−10x
2
+x
1
x
1
= x
1
x
1
= x
1
x
2
= x
2
+x
1
x
2
= x
2
−x
1
x
3
= x
3
+ 3x
2
+ 2x
1
x
3
= x
3
−3x
2
+ 2x
1
x
4
= x
4
+ 6x
3
+ 11x
2
+ 6x
1
x
4
= x
4
−6x
3
+ 11x
2
−6x
1
x
5
= x
5
+ 10x
4
+ 35x
3
+ 50x
2
+ 24x
1
x
5
= x
5
−10x
4
+ 35x
3
−50x
2
+ 24x
1
Theoretical Computer Science Cheat Sheet
Series
Taylor’s series:
f(x) = f(a) + (x −a)f

(a) +
(x −a)
2
2
f

(a) +· · · =

i=0
(x −a)
i
i!
f
(i)
(a).
Expansions:
1
1 −x
= 1 +x +x
2
+x
3
+x
4
+· · · =

i=0
x
i
,
1
1 −cx
= 1 +cx +c
2
x
2
+c
3
x
3
+· · · =

i=0
c
i
x
i
,
1
1 −x
n
= 1 +x
n
+x
2n
+x
3n
+· · · =

i=0
x
ni
,
x
(1 −x)
2
= x + 2x
2
+ 3x
3
+ 4x
4
+· · · =

i=0
ix
i
,
x
k
d
n
dx
n
_
1
1 −x
_
= x + 2
n
x
2
+ 3
n
x
3
+ 4
n
x
4
+· · · =

i=0
i
n
x
i
,
e
x
= 1 +x +
1
2
x
2
+
1
6
x
3
+· · · =

i=0
x
i
i!
,
ln(1 +x) = x −
1
2
x
2
+
1
3
x
3

1
4
x
4
−· · · =

i=1
(−1)
i+1
x
i
i
,
ln
1
1 −x
= x +
1
2
x
2
+
1
3
x
3
+
1
4
x
4
+· · · =

i=1
x
i
i
,
sin x = x −
1
3!
x
3
+
1
5!
x
5

1
7!
x
7
+· · · =

i=0
(−1)
i
x
2i+1
(2i + 1)!
,
cos x = 1 −
1
2!
x
2
+
1
4!
x
4

1
6!
x
6
+· · · =

i=0
(−1)
i
x
2i
(2i)!
,
tan
−1
x = x −
1
3
x
3
+
1
5
x
5

1
7
x
7
+· · · =

i=0
(−1)
i
x
2i+1
(2i + 1)
,
(1 +x)
n
= 1 +nx +
n(n−1)
2
x
2
+· · · =

i=0
_
n
i
_
x
i
,
1
(1 −x)
n+1
= 1 + (n + 1)x +
_
n+2
2
_
x
2
+· · · =

i=0
_
i +n
i
_
x
i
,
x
e
x
−1
= 1 −
1
2
x +
1
12
x
2

1
720
x
4
+· · · =

i=0
B
i
x
i
i!
,
1
2x
(1 −

1 −4x) = 1 +x + 2x
2
+ 5x
3
+· · · =

i=0
1
i + 1
_
2i
i
_
x
i
,
1

1 −4x
= 1 +x + 2x
2
+ 6x
3
+· · · =

i=0
_
2i
i
_
x
i
,
1

1 −4x
_
1 −

1 −4x
2x
_
n
= 1 + (2 +n)x +
_
4+n
2
_
x
2
+· · · =

i=0
_
2i +n
i
_
x
i
,
1
1 −x
ln
1
1 −x
= x +
3
2
x
2
+
11
6
x
3
+
25
12
x
4
+· · · =

i=1
H
i
x
i
,
1
2
_
ln
1
1 −x
_
2
=
1
2
x
2
+
3
4
x
3
+
11
24
x
4
+· · · =

i=2
H
i−1
x
i
i
,
x
1 −x −x
2
= x +x
2
+ 2x
3
+ 3x
4
+· · · =

i=0
F
i
x
i
,
F
n
x
1 −(F
n−1
+F
n+1
)x −(−1)
n
x
2
= F
n
x +F
2n
x
2
+F
3n
x
3
+· · · =

i=0
F
ni
x
i
.
Ordinary power series:
A(x) =

i=0
a
i
x
i
.
Exponential power series:
A(x) =

i=0
a
i
x
i
i!
.
Dirichlet power series:
A(x) =

i=1
a
i
i
x
.
Binomial theorem:
(x +y)
n
=
n

k=0
_
n
k
_
x
n−k
y
k
.
Diﬀerence of like powers:
x
n
−y
n
= (x −y)
n−1

k=0
x
n−1−k
y
k
.
For ordinary power series:
αA(x) +βB(x) =

i=0
(αa
i
+βb
i
)x
i
,
x
k
A(x) =

i=k
a
i−k
x
i
,
A(x) −

k−1
i=0
a
i
x
i
x
k
=

i=0
a
i+k
x
i
,
A(cx) =

i=0
c
i
a
i
x
i
,
A

(x) =

i=0
(i + 1)a
i+1
x
i
,
xA

(x) =

i=1
ia
i
x
i
,
_
A(x) dx =

i=1
a
i−1
i
x
i
,
A(x) +A(−x)
2
=

i=0
a
2i
x
2i
,
A(x) −A(−x)
2
=

i=0
a
2i+1
x
2i+1
.
Summation: If b
i
=

i
j=0
a
i
then
B(x) =
1
1 −x
A(x).
Convolution:
A(x)B(x) =

i=0
_
_
i

j=0
a
j
b
i−j
_
_
x
i
.
all the rest is the work of man.
– Leopold Kronecker
Theoretical Computer Science Cheat Sheet
Series Escher’s Knot
Expansions:
1
(1 −x)
n+1
ln
1
1 −x
=

i=0
(H
n+i
−H
n
)
_
n +i
i
_
x
i
,
_
1
x
_
−n
=

i=0
_
i
n
_
x
i
,
x
n
=

i=0
_
n
i
_
x
i
, (e
x
−1)
n
=

i=0
_
i
n
_
n!x
i
i!
,
_
ln
1
1 −x
_
n
=

i=0
_
i
n
_
n!x
i
i!
, xcot x =

i=0
(−4)
i
B
2i
x
2i
(2i)!
,
tan x =

i=1
(−1)
i−1
2
2i
(2
2i
−1)B
2i
x
2i−1
(2i)!
, ζ(x) =

i=1
1
i
x
,
1
ζ(x)
=

i=1
µ(i)
i
x
,
ζ(x −1)
ζ(x)
=

i=1
φ(i)
i
x
,
Stieltjes Integration
ζ(x) =

p
1
1 −p
−x
,
ζ
2
(x) =

i=1
d(i)
x
i
where d(n) =

d|n
1,
ζ(x)ζ(x −1) =

i=1
S(i)
x
i
where S(n) =

d|n
d,
ζ(2n) =
2
2n−1
|B
2n
|
(2n)!
π
2n
, n ∈ N,
x
sin x
=

i=0
(−1)
i−1
(4
i
−2)B
2i
x
2i
(2i)!
,
_
1 −

1 −4x
2x
_
n
=

i=0
n(2i +n −1)!
i!(n +i)!
x
i
,
e
x
sin x =

i=1
2
i/2
sin

4
i!
x
i
,
¸
1 −

1 −x
x
=

i=0
(4i)!
16
i

2(2i)!(2i + 1)!
x
i
,
_
arcsin x
x
_
2
=

i=0
4
i
i!
2
(i + 1)(2i + 1)!
x
2i
.
If G is continuous in the interval [a, b] and F is nondecreasing then
_
b
a
G(x) dF(x)
exists. If a ≤ b ≤ c then
_
c
a
G(x) dF(x) =
_
b
a
G(x) dF(x) +
_
c
b
G(x) dF(x).
If the integrals involved exist
_
b
a
_
G(x) +H(x)
_
dF(x) =
_
b
a
G(x) dF(x) +
_
b
a
H(x) dF(x),
_
b
a
G(x) d
_
F(x) +H(x)
_
=
_
b
a
G(x) dF(x) +
_
b
a
G(x) dH(x),
_
b
a
c · G(x) dF(x) =
_
b
a
G(x) d
_
c · F(x)
_
= c
_
b
a
G(x) dF(x),
_
b
a
G(x) dF(x) = G(b)F(b) −G(a)F(a) −
_
b
a
F(x) dG(x).
If the integrals involved exist, and F possesses a derivative F

at every
point in [a, b] then
_
b
a
G(x) dF(x) =
_
b
a
G(x)F

(x) dx.
Cramer’s Rule
00 47 18 76 29 93 85 34 61 52
86 11 57 28 70 39 94 45 02 63
95 80 22 67 38 71 49 56 13 04
59 96 81 33 07 48 72 60 24 15
73 69 90 82 44 17 58 01 35 26
68 74 09 91 83 55 27 12 46 30
37 08 75 19 92 84 66 23 50 41
14 25 36 40 51 62 03 77 88 99
21 32 43 54 65 06 10 89 97 78
42 53 64 05 16 20 31 98 79 87
Fibonacci Numbers
If we have equations:
a
1,1
x
1
+a
1,2
x
2
+· · · +a
1,n
x
n
= b
1
a
2,1
x
1
+a
2,2
x
2
+· · · +a
2,n
x
n
= b
2
.
.
.
.
.
.
.
.
.
a
n,1
x
1
+a
n,2
x
2
+· · · +a
n,n
x
n
= b
n
Let A = (a
i,j
) and B be the column matrix (b
i
). Then
there is a unique solution iﬀ det A = 0. Let A
i
be A
with column i replaced by B. Then
x
i
=
det A
i
det A
.
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, . . .
Deﬁnitions:
F
i
= F
i−1
+F
i−2
, F
0
= F
1
= 1,
F
−i
= (−1)
i−1
F
i
,
F
i
=
1

5
_
φ
i

ˆ
φ
i
_
,
Cassini’s identity: for i > 0:
F
i+1
F
i−1
−F
2
i
= (−1)
i
.
F
n+k
= F
k
F
n+1
+F
k−1
F
n
,
F
2n
= F
n
F
n+1
+F
n−1
F
n
.
Calculation by matrices:
_
F
n−2
F
n−1
F
n−1
F
n
_
=
_
0 1
1 1
_
n
.
The Fibonacci number system:
Every integer n has a unique
representation
n = F
k1
+F
k2
+· · · +F
km
,
where k
i
≥ k
i+1
+ 2 for all i,
1 ≤ i < m and k
m
≥ 2.
Improvement makes strait roads, but the crooked
– William Blake (The Marriage of Heaven and Hell)

44. Note that Ti is always a power of two. 2 2i i=0 i=0 Let c = 3 . Then we have ti+1 = 2i + 2ti . dn : n n n−m n +m m−n m+k = 2−di ≤ 1. G(x) = (1 − x)(1 − 2x) Expand this using partial fractions: 1 2 − G(x) = x 1 − 2x 1 − x   Ti = 1 + j=0 Tj . t1 = 1. 2n k+1 (−1)n−k . k k (−1)m−k . T1 = 2. T0 = 1. Summing the left side we get T (n) − 3m T (1) = T (n) − 3m = T (n) − nk where k = log2 3 ≈ 1. ui+1 = 1 + ui . 38. n = n−m n +m i=1 +m n−k m k 49. a ≥ 1. g0 = 0. Rewrite so that all terms involving T are on the left side T (n) − 3T (n/2) = n. k m+n+1 m n m = k n+k k . m n+k . Choose a generating function ∞ G(x). m m−n m+k m+n n+k k k for n ≥ m. Rewrite the equation in terms of the generating function G(x). Example: gi+1 = 2gi + 1. . Recurrences Master method: T (n) = aT (n/b) + f (n). So gi = 2i − 1. 5. Then we have 2 m−1 If ∃ > 0 such that f (n) = O(nlogb a− ) then T (n) = Θ(nlogb a ). . and choose a factor which makes the left side “telescope” Generating functions: 1. i+1 2 2 2 Substituting we ﬁnd u1 = 1 . Solve for G(x). Dividing both sides of the previous equation by 2i+1 we get 2i ti ti+1 = i+1 + i . . Multiply both sides of the equation by xi . +m = and equality holds only if every internal node has 2 sons. then T (n) = Θ(f (n)). Now expand the recurrence. k 47. 2 2 which is simply ui = i/2. k n . 42. 48. . Ti+1 − Ti = 1 + j=0 Tj − 1 − j=0 = i≥0 (2 − 1)x i+1 = Ti . 41. x 1−x Solve for G(x): x . . Substitution (example): Consider the following recurrence i Ti+1 = 22 · Ti2 . So we ﬁnd i−1 that Ti has the closed form Ti = 2i2 . n+1 = m+1 n m = k Trees 39. 46. Sum both sides over all i for which the equation is valid. 3. 43. Usually G(x) = i=0 xi gi . . . j=0 Subtracting we ﬁnd i i−1 = x 2 Tj i≥0 2i xi − i≥0 i+1 xi  . k n−k m n . . Let ui = ti /2i .Theoretical Computer Science Cheat Sheet Identities Cont. And so Ti+1 = 2Ti = 2i+1 . 3log2 n−1 T (2) − 3T (1) = 2 Let m = log2 n. . and so T (n) = 3n − 2n. m+k . Note that Ti+1 = 1 + i Tj . 4. x = x−n n k=0 k n k n k = k=0 k m n = k=0 k n−k = n! n m n k=0 1 k . 2. 3. Let ti = log2 Ti . . . (n − m)! m m+k . m+1 m n = m k n+1 k+1 m k (−1)m−k . If f (n) = Θ(nlogb a ) then T (n) = Θ(nlogb a log2 n). x i≥0 Simplify: 1 G(x) = 2G(x) + . . Summing the right side we get m−1 m−1 n i 3 i 3 =n . and ∃c < 1 such that af (n/b) ≤ cf (n) for large n. m m+n n+k k k m+n+1 = m n+1 k+1 k(n + k) k=0 n+1 k+1 = k n 45. = k k (−1)m−k .58496. Multiply and sum: gi+1 xi = 2gi xi + i≥0 i≥0 i≥0 n i=0 c =n i c −1 c−1 m xi . Summing factors (example): Consider the following recurrence T (n) = 3T (n/2) + n. k Every tree with n vertices has n − 1 edges. 40. Kraft inequality: If the depths of the leaves of a binary tree are d1 . = 2n(clog2 n − 1) = 2n(c(k−1) logc n − 1) = 2nk − 2n. T (1) = 1. . k! m n k x+k . If ∃ > 0 such that f (n) = Ω(nlogb a+ ). Full history recurrences can often be changed to limited history ones (example): Consider k i−1 We choose G(x) = i≥0 xi gi . Rewrite in terms of G(x): G(x) − g0 = 2G(x) + xi . b > 1 1 T (n) − 3T (n/2) = n 3 T (n/2) − 3T (n/4) = n/2 . The coeﬃcient of xi in G(x) is gi .

2 2n 24n n3 Harmonic numbers: 1.864 134. Pr[X = k] = k! Normal (Gaussian) distribution: 2 2 1 e−(x−µ) /2σ . ∞ q = 1 − p.304 8.608 16. 24. E[cX] = c E[X]. 11 . Pr i=1 Xi = i=1 n Pr[Xi ] + k (−1)k+1 k=2 ii <···<ik Pr j=1 Xij . 137 .554. φ= √ 1+ 5 2 ≈ 1.483.777. If Pr[X < a] = P (a). σ = VAR[X]. 2. Pr[A ∧ B] Pr[A|B] = Pr[B] For random variables X and Y : E[X · Y ] = E[X] · E[Y ].048 4. logb x = loga b 2a Euler’s number e: e=1+ 1 1 + 24 + 120 + · · · x n = ex . 1 Hn = ln n + γ + O . 7129 . n Factorial.097. Moment inequalities: Pr |X| ≥ λ E[X] ≤ 1 . E[X + Y ] = E[X] + E[Y ]. 761 . If P and p both exist then a P (a) = −∞ p(x) dx. k Poisson distribution: e−λ λk . . iﬀ A and B are independent. j) = a(i − 1.296 Pascal’s Triangle 1 11 121 1331 14641 1 5 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1 1 8 28 56 70 56 28 8 1 1 9 36 84 126 126 84 36 9 1 1 10 45 120 210 252 210 120 45 10 1 e ≈ 2. 6. .388.073. j ≥ 2 n! = 2πn α(i) = min{j | a(j. ∞ 1 11e e + =e− −O 1+ . Change of base.384 32. j − 1)) i. 1 . a(i.. then P is the distribution function of X.456 536. .217. For events A and B: Pr[A ∨ B] = Pr[A] + Pr[B] − Pr[A ∧ B] Pr[A ∧ B] = Pr[A] · Pr[B]. and there are n diﬀerent types of coupons.048. B8 = − 30 . n 1 . Bayes’ theorem: Pr[B|Ai ] Pr[Ai ] . Pr[Ai |B] = n j=1 Pr[Aj ] Pr[B|Aj ] Inclusion-exclusion: n n .288 1.194. i 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 2i 2 4 8 16 32 64 128 256 512 1. The distribution of coupons is uniform.536 131.61803.144 524.Theoretical Computer Science Cheat Sheet π ≈ 3. 120.024 2. 363 . . The expected number of days to pass before we to collect all n types is nHn .57721. 1 − 30 . standard deviation: VAR[X] = E[X 2 ] − E[X]2 .61803 Probability Continuous distributions: If b Pr[a < X < b] = a p(x) dx. ˆ φ= √ 1− 5 2 ≈ −. E[X] = λ. E[X] = k=1 k n k n−k p q = np. 2 6 12 60 20 140 280 2520 1 n n If X continuous then ∞ E[g(X)] = g(x)p(x) dx = −∞ g(x) dP (x). 720.768 65. 1+Θ e n Ackermann’s function and inverse:  i=1  2j a(i. lim 1 + n→∞ n 1 n 1 n+1 . 362880. 5040.14159. 2) j=1  a(i − 1. B10 = 66 . General Bernoulli Numbers (Bi = 0.912 1. p E[X] = k=1 kpq k−1 = . Binomial distribution: n k n−k .967. Stirling’s approximation: 1. B1 = 1 1 5 B6 = 42 . quadratic formula: √ −b ± b2 − 4ac loga x . −∞ ln n < Hn < ln n + 1. Variance.432 67.870.. j) ≥ i}. λ2 Pr X − E[X] ≥ λ · σ ≤ Geometric distribution: Pr[X = k] = pq k−1 .648 4. + 1 6 then p is the probability density function of X. odd i = 1): B2 = B4 = B0 = 1. p(x) = √ 2πσ The “coupon collector”: We are given a random coupon each day.147. 3 .71828. 1+ n <e< 1+ n 1 2 1 −2. 40320. λ 1 .435.824 2.741. 25 .576 2. Expectation: If X is discrete E[g(X)] = x g(x) Pr[X = x]. if X and Y are independent. Pr[X = k] = p q k n √ n q = 1 − p. 1 6.108.096 8. E[X] = µ.728 268.072 262. pi 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 γ ≈ 0.152 4.294. 49 .192 16.216 33.

tanh x cosh x = x −x sin2 x + cos2 x = 1. sin 2x = 2 sin x cos x. = 1 − cos x eix − e−ix . cos(x ± y) = cos x cos y tan(x ± y) = sin x sin y. sin 2x = sinh 2x = 2 sinh x cosh x. cosh x − sinh x = e−x . sech x = cosh x Identities: cosh2 x − sinh2 x = 1. tan x ± tan y .edu/~seiden 3 2 √ 2 2 1 2 1 0 1 √ 3 ∞ . Euler’s equation: eix = cos x + i sin x. Deﬁnitions: sin a = A/C. tanh2 x + sech2 x = 1. sin x = i cos x = cosh ix. Determinants: det A = 0 iﬀ A is non-singular. c d a b d e g h c b f =g e i = Permanents: n = 1 ab sin C. (cos θ. Area: A = 1 hc. e + e−x 1 . det A · B = det A · det B. cot 2x = tan 2x = 2 .0) ci. sin θ) (1. csc x = cot x − cot x. . e iπ (cosh x + sinh x)n = cosh nx + sinh nx. tan x = 2 1 + cos x 1 − cos x . cosh(−x) = cosh x.02 c 1994 by Steve Seiden sseiden@acm. radius of inscribed 1 2 AB. 2 tan x . sin a A circle: AB . cos x = − cos(π − x). csc a = C/A. cot x = 2 1 − cos x 1 + cos x . b h a B θ a B Pythagorean theorem: C 2 = A2 + B 2 . coth2 x − csch2 x = 1. tan x = cot π 2 −x . sin x = sin(π − x). C b A c C (-1. = −i 2ix e +1 sinh ix . sin x = 2i eix + e−ix . s = 1 (a + b + c). sb = s − b. 2 sa = s − a.k bk. A sin a = .lsu.π(i) . sinh(−x) = − sinh x. 1 + tan2 x cot2 x − 1 2 tan x . sinh x = 2 x −x e −e tanh x = x . – J. tan x = −i ix e + e−ix e2ix − 1 . tan a = cos a B Area. csch x = sinh x 1 coth x = . sin x = csc x 1 . c2 = a2 +b2 −2ab cos C. cos 2x = cos2 x − sin2 x.j . 2 = c a c a b −h +i f d f d e aei + bf g + cdh − ceg − f ha − ibd. cos 2x = 1 − 2 sin2 x. cos 2x = 1 − tan2 x . cos a B cot a = = . 2 sin C Heron’s formula: √ A = s · sa · sb · sc . 2 cos a = B/C. cos x = 2 2 1 − cos x . sin x = cos π 2 perm A = Hyperbolic Functions Deﬁnitions: ex − e−x . sin x = 2 2 1 + cos x . cos θ √ 2 cosh2 x 2 = cosh x + 1. e +e . in mathematics you don’t understand things. n ∈ Z. tan x = i . cot(x ± y) = cot x ± cot y sinh(x + y) = sinh x cosh y + cosh x sinh y. 2 sin(x ± y) = sin x cos y ± cos x sin y.csc. π i=1 c2 sin A sin B . cos(x + y) cos(x − y) = cos2 x − sin2 y. cosh x + sinh x = ex . v2. = sin x sin x . 1 + tan2 x cos 2x = 2 cos2 x − 1. 2 sinh2 x 2 θ 0 π 6 π 4 π 3 π 2 = cosh x − 1. 1 + cot2 x = csc2 x. A+B+C cos x = 1 . ai. tanh ix . cos x = 2 eix − e−ix .0) (0.-1) C = A · B. you just get used to them.Theoretical Computer Science Cheat Sheet Trigonometry Multiplication: (0.org http://www.1) n Matrices More Trig. cot x = − cot(π − x). cosh 2x = cosh2 x + sinh2 x. sin θ 0 1 2 √ 2 2 √ 3 2 tan θ √ 1 0 3 3 = −1. 1 tan x tan y cot x cot y 1 . sc = s − c. . = sin x sin x . n A c Law of cosines: det A = π i=1 sign(π)ai. tanh(−x) = − tanh x. sec x 2 × 2 and 3 × 3 determinant: a b = ad − bc. 2 1 . 2 cot x 1 − tan x sin(x + y) sin(x − y) = sin2 x − sin2 y. sec a = C/B. −x . cosh(x + y) = cosh x cosh y + sinh x sinh y.π(i) . = 1 + cos x 1 + cos x . Identities: 1 . tan x = cot x 1 + tan2 x = sec2 x.j = k=1 ai. von Neumann More identities: 1 − cos x .

y1 ) (0. – Issac Newton . 1 2 µ(d)G a . If G(a) = d|a k-Tough k-Regular k-Factor Matching Clique Area of triangle (x0 . d= S(x) = pi − 1 i=1 d|x n Cut-set Cut edge k-Connected . Euler’s function: φ(x) is the number of positive integers less than x relatively n prime to x. A graph which can be embeded in the plane. S = ∅ we have k · c(G − S) ≤ |S|. cy. none of which are adjacent. If i=1 pei is the prime factorization of x i then n e pi i +1 − 1 . 2 abs x − x 2 0 y2 − y0 Angle formed by three points: (x2 . A tree with no root. A maximal connected subgraph. b). y1 ) and (x2 . deg(v) = 2m. m ≤ 3n − 6. volume of sphere: A = πr2 . . (ln n)4 If G is planar then n − m + f = 2. b) x=c (1. Directed acyclic graph. A sequence v0 e1 v1 . z). A set of edges. y1 ): x y 1 x0 y0 1 = 0. A minimal cut. (x1 . 1) y = mx + b (m. C ≡ rn mod mn if mi and mj are relatively prime for i = j. . A connected acyclic graph. it is because I have stood on the shoulders of giants. A trail with distinct vertices. Graph with a cycle visiting each vertex exactly once. y2 ): x1 − x0 y1 − y0 1 . 0) 1 (x1 . y. φ(x) = i=1 e pi i −1 (pi − 1). A graph where there exists a path between any two vertices. Lp and L∞ metric: (x1 − x0 )2 + (y1 − y0 )2 . The Euclidean algorithm: if a > b are integers then gcd(a. 1  0 if i is not square-free. .Theoretical Computer Science Cheat Sheet Number Theory The Chinese remainder theorem: There exists a number C such that: mod m1 . A graph connected with the removal of any k − 1 vertices. A k-regular spanning subgraph.n2 Complete bipartite graph r(k. x1 y1 1 Area of circle. Component Tree Free tree DAG Eulerian Hamiltonian Cut Notation: E(G) Edge set V (G) Vertex set c(G) Number of components G[S] Induced subgraph deg(v) Degree of v ∆(G) Maximum degree δ(G) Minimum degree χ(G) Chromatic number χE (G) Edge chromatic number Complement graph Gc Complete graph Kn Kn1 . not all x. v∈V C ≡ r1 . set Vertex cover Planar graph Plane graph then F (a) = d|a θ (x1 . If I have seen farther than others. . A set of vertices which cover all edges. A set of vertices. e v . so f ≤ 2n − 4. b) = gcd(a mod b. 3 Prime numbers: ln ln n pn = n ln n + n ln ln n − n + n ln n n . Ind. Fermat’s theorem: 1 ≡ ap−1 mod p. If i=1 pei is the prime faci torization of x then n Graph Theory Deﬁnitions: Loop Directed Simple Walk Trail Path Connected An edge connecting a vertex to itself. A set of vertices. . M¨bius  o inversion: if i = 1. y. z) = (cx. d Line through two points (x0 . . Wilson’s theorem: n is a prime iﬀ (n − 1)! ≡ −1 mod n. y2 ) 2 F (d). y1 ) · (x2 . no two of which are adjacent. . A graph where all vertices have degree k. . V = 4 πr3 . all of which are adjacent. y. A walk with distinct edges. y0 ). lim |x1 − x0 |p + |y1 − y0 | p 1/p Perfect Numbers: x is an even perfect number iﬀ x = 2n−1 (2n −1) and 2n −1 is prime. Graph with no loops or multi-edges. 0. Cartesian Projective (x. y and z zero. µ(i) = (−1)r if i is the product of   r distinct primes. −1. An embedding of a planar graph. ∀S ⊆ V. y) (x. ) Ramsey number Geometry Projective coordinates: triples (x. +O ln n n 2!n n + + π(n) = ln n (ln n)2 (ln n)3 n +O . Each edge has a direction. . −c) Distance formula. Graph with a trail visiting each edge exactly once. |x1 − x0 |p + |y1 − y0 |p p→∞ 1/p Euler’s theorem: If a and b are relatively prime then 1 ≡ aφ(b) mod b. A set of edges whose removal increases the number of components. (x. y2 ) cos θ = . . Any planar graph has a vertex with degree ≤ 5. y0 ) and (x1 . A size 1 cut. cz) ∀c = 0.

dx dx d(ln u) 1 du = . 2. dx dx du d(cu ) = (ln c)cu . = dx v2 3. u 5. 8. 1 xn+1 . 7. 28. x=a 11. dx dx d(arccosh u) 1 du =√ . 13. We can break down N (x)/D(x) using partial fraction expansion. 10. dx 1 + u2 dx d(arccsc u) −1 du = √ . dx dx d(cot u) du = csc2 u . dx dx du d(sin u) = cos u . 15. dx u 1 − u2 dx Integrals: 31. Use the following rules: For a non-repeated factor: A N (x) N (x) = + . cot x dx = ln | cos x|. dx dx du d(un ) = nun−1 . 10. Therefore all progress depends on the unreasonable. 2 dx dx 1+u 1 du d(arctanh u) = . dv dx d(uv) dv du =u +v . du d(cu) =c . obtaining N (x) N (x) = Q(x) + . 2 dx dx u 1−u d(cosh u) du 22. n+1 ex dx = ex . dx dx du d(sech u) = − sech u tanh u . d(csch u) du = − csch u coth u . dx dx du d(tan u) = sec2 u . dv dx = uv − dx 9. x 7. 8. 25. tan x dx = − ln | cos x|. cu dx = c xn dx = u dx. 1 + x2 sin x dx = − cos x. Second. dx dx 26. = . 27. D(x) D(x) where the degree of N is less than that of D. dx dx 1 1 1 1 + 2 − 3 +··· = √ 1− 1 3 ·3 3 ·5 3 ·7 3 Euler’s series: π2 6 π2 8 π2 12 1 du d(arcsin u) =√ . 12. dx dx 19. dx dx dx v du − u d(u/v) dx 5. 6. dx dx du d(sec u) = tan u sec u . 2 − 1 dx dx u d(arccoth u) 1 du 30. 2 dx dx u 1−u du d(sinh u) = cosh u . 13. sec x dx = ln | sec x + tan x|. = sinh u . dx u − 1 dx d(arccsch u) −1 du √ = . 3. dx dx d(coth u) du = − csch2 u . du d(tanh u) = sech2 u . 2 dx dx 1−u 1 du d(arctan u) = . if the degree of N is greater than or equal to the degree of D. = 2 . u dx + v dx. 11. 21. dx dx 14. n = −1. Partial Fractions Let N (x) and D(x) be polynomial functions of x. dx 1 − u2 dx d(arccot u) −1 du 18. + (x − a)m D(x) (x − a)m−k D(x) k=0 dx = arctan x. where Ak = 1 dk k! dxk N (x) D(x) . Gregrory’s series: π 1 4 =1− 3 + Newton’s series: 1 5 − 1 7 + 1 9 − ··· d(cos u) du = − sin u . dx 1 + u2 dx 1 du d(arcsec u) = √ . dx dx dx 6. 1. v du dx. factor D(x). 14. (u + v) dx = 1 dx = ln x. (x − a)D(x) x−a D(x) where A= N (x) D(x) . First. dx 1 − u2 dx −1 du d(arcsech u) = √ . 2. dx For a repeated factor: m−1 Ak N (x) N (x) = . dx u dx . a > 0. dx |u| 1 + u2 dx 1 du d(arcsinh u) =√ . 29.Theoretical Computer Science Cheat Sheet π Wallis’ identity: 2 · 2 · 4 · 4 · 6 · 6··· π =2· 1 · 3 · 3 · 5 · 5 · 7··· Brouncker’s continued fraction expansion: 12 π 4 =1+ 32 2+ 52 2+ 2+ 72 2+··· Calculus Derivatives: 1. 9. cos x dx = sin x. 12. – George Bernard Shaw csc x dx = ln | csc x + cot x|. 23. arcsin x dx = arcsin x + a a a2 − x2 . the unreasonable persists in trying to adapt the world to himself. x=a 24. 16. The reasonable man adapts himself to the world. d(arccos u) −1 du =√ . dx dx 1 1 1·3 π 6 = 2 + 2 · 3 · 23 + 2 · 4 · 5 · 25 + · · · Sharp’s series: π 6 d(csc u) du = − cot u csc u . du d(ecu ) = cecu . dx dx = = = 1 12 1 12 1 12 + + − 1 22 1 32 1 22 + + + 1 32 1 52 1 32 + + − 1 42 1 72 1 42 + + + 1 52 1 92 1 52 + ··· + ··· − ··· 20. 4. d(u + v) du dv = + . 4. divide N by D. . 32. 17.

42. a + bx a + bx + a 2 53. x a + bx dx = . a a > 0. a > 0. 41. cos2 (ax)dx = 1 2a a 2 ln(a2 + x2 ). if arccosh x > 0 and a > 0. a > 0. 21. n = 1. 2 −x 2a a−x 47. 15. sec2 x dx = tan x. 2 37. csc2 x dx = − cot x. 26. a > 0. 32. a > 0. 2 sinh(2x) + 1 x. cscn−2 x dx. a > 0. x 1 dx . 19. 59. a2 − x2 dx = a a2 + x2 (a2 − x2 )3/2 dx = x (5a2 − 2x2 ) a2 − x2 + 8 √ a2 dx = arcsin x . x a2 − x2 dx = − 1 (a2 − x2 )3/2 . n = 1. 15b2 √ √ x 1 a + bx − a √ dx = √ ln √ √ . 22. dx √ = x x2 + a2 1 a ln a+ √ x . 2 )3/2 2 a2 − x2 −x a a > 0. 52. 3 2 x2 dx x √ = − x a2 − x2 + a arcsin a. dx √ = ln x + x2 − a2 . 50. a2 2 44. arcsin x . a − x2 x 2 3a4 8 x 2 a2 − x2 + a2 2 arcsin x . 39. dx = a2 − x2 − a ln x x x 2 51. x x a + bx √ √ a + a2 − x2 a2 − x2 . sinn−2 x dx. cscn x dx = − 28. a > 0. arccos x dx = arccos x − a a sin2 (ax)dx = 1 2a a2 − x2 . 58. 40. 1 4 csch x dx = ln tanh x . 48. = ln ax2 + bx a a + bx √ √ a + bx 1 √ dx = 2 a + bx + a dx. 25. 55. cosh x dx = sinh x. a a dx √ = ln x + a2 + x2 . cosh2 x dx = sech x dx = arctan sinh x. 2 35. 54. 29. if arccosh x < 0 and a > 0. 45. tanh x dx = ln | cosh x|. a2 + x2 . ax − sin(ax) cos(ax) . 36. ax + sin(ax) cos(ax) . sinh x dx = cosh x. 38. 2 2 2 − x2 a √ x2 − a2 a dx = x2 − a2 − a arccos |x| . 23. 34. n = 1. a2 + x2 dx 1 = a arctan x . a > 0. (a2 x dx = √ . 2 − a2 x √ 2(3bx − 2a)(a + bx)3/2 49. sinh2 x dx = 1 4 coth x dx = ln | sinh x|. arcsinh x dx = x arcsinh x − a a arctanh x dx = x arctanh x + a a ln |a2 − x2 |. x a > 0. 17. a > 0. a2 ± x2 dx = a2 ± x2 ± a2 ± x2 . 43. 56. a 2 sinh(2x) − 1 x. a2 − x2 dx = 2 x 8 (2x −a ) 2 a2 − x2 + a4 8 arcsin x a. 60.Theoretical Computer Science Cheat Sheet Calculus Cont. dx = a x x x x2 ± a2 dx = 1 (x2 ± a2 )3/2 . 3 √ a+ dx 1 = − a ln 2 − x2 a √ a2 − x2 . a a x arccosh a dx = x  x arccosh + x2 + a2 . 24. x 61. a2 − x2 √ √ a + a2 + x2 a2 + x2 2 + x2 − a ln . a > 0. 46. 30. cosn−2 x dx. 57. cosn x dx = 20. tan x secn−1 x n − 2 + n−1 n−1 cot x cscn−1 x n − 2 + n−1 n−1 secn−2 x dx. a a2 a > 0. cosn−1 x sin x n − 1 + n n cotn−1 x − n−1 tann−1 x − n−1 cotn x dx = − cotn−2 x dx. sech2 x dx = tanh x. x2 + a2 . x dx √ = − a2 − x2 .  x  x arccosh − x2 + a2 . 31. n = 1. 33. ln x + 1 dx a+x ln = . sinn x dx = − tann x dx = secn x dx = sinn−1 x cos x n − 1 + n n tann−2 x dx. arctan x dx = x arctan x − a a 18. 27. 16.

n > 0. xn+m = xm (x − m)n . 67. Fundamental Theorem: f (x) = ∆F (x) ⇔ b f (x)δx = F (x) + C. Conversion: xn = (−1)n (−x)n = (x − n + 1)n = 1/(x + 1)−n . if b2 < 4ac. 76. Sums: cu δx = c (u + v) δx = u∆v δx = uv − xn δx = x m+1 . k n k x . 65. Falling Factorial Powers: xn = x(x − 1) · · · (x − n + 1). Diﬀerences: ∆(cu) = c∆u. xn = 1 . if c < 0. if a < 0. E f (x) = f (x + 1). dx = . 63. dx √ . 64. f (x)δx = a i=a f (i). 72. m δx = m+1 . ∆(cx ) = (c − 1)cx . ∆ x m 68. k x − 10x + 35x − 50x + 24x 4 3 2 xn = k=1 .   a dx √ = −2ax − b ax2 + bx + c  √1 arcsin √   .   c x dx √ = 2 + bx + c  1 x ax bx   √ arcsin √ + 2c . 1 xn sin(ax) dx = − a xn cos(ax) + x0 = 1. ∆(xn ) = nxn−1 .  √ √ 2  −1  √ ln 2 c ax + bx + c + bx + 2c . xn−1 cos(ax) dx. ln  dx b2 − 4ac 2ax + b + b2 − 4ac =  ax2 + bx + c  2ax + b √ 2  arctan √ . ∆(2x ) = 2x . n > 0. if b2 > 4ac. 71. 70. b−1 66. = x m−1 . xn (ln ax)m−1 dx. x4 3a2 x3 x2 ± a2  √  2ax + b − b2 − 4ac 1  √ √ . if a > 0. 74. (x − 1) · · · (x − |n|) n < 0. a > 0.Theoretical Computer Science Cheat Sheet Calculus Cont. shift operators: ∆f (x) = f (x + 1) − f (x). x n−1 x x c cx δx = c−1 . = 2 − a2 2 x2 ± a2 x x x √ x2 ± a2 (x2 + a2 )3/2 x dx √ = x2 ± a2 . b ax2 + bx + c − a 2a u δx. 73. 2 + bx + c ax √ x2 ± a2 . n xn = k=1 n n k x = k n k=1 n (−1)n−k xk . ∆(uv) = u∆v + E v∆u. 69. a2 x Finite Calculus Diﬀerence. 1 ln(ax) − n+1 (n + 1)2 .  −c |x| b2 − 4ac x3 x2 + a2 dx = ( 1 x2 − 3 2 2 2 15 a )(x n a E v∆u δx. x cos(ax) dx = xn eax dx = n 1 n ax sin(ax) − n a n a sin(ax) dx. dx dx 1 a √ √ = a arccos |x| . xn = 1 . 75. 2 + bx + c ax if c > 0. x n+1 ∆(u + v) = ∆u + ∆v. Rising Factorial Powers: xn = x(x + 1) · · · (x + n − 1). (x + 1) · · · (x + |n|) n < 0. −a b2 − 4ac 2ax + b ax2 + bx + c dx = 4a x dx √ = 2 + bx + c ax √ 4ax − b2 ax2 + bx + c + 8a dx √ . + a2 )3/2 . x0 = 1. k x + 3x + 2x x + 6x3 + 11x2 + 6x1 x + 10x + 35x + 50x + 24x 4 3 2 1 2 x = x4 = x = 5 5 3 x − 3x + 2x x − 6x3 + 11x2 − 6x1 4 3 2 1 xn = k=1 n 1 n (−1)n−k xk . u δx + v δx. 62. xn = (−1)n (−x)n = (x + n − 1)n = 1/(x − 1)−n . xn ln(ax) dx = xn+1 xn (ln ax)m dx = n+1 x m (ln ax)m − n+1 n+1 x1 = x2 = x3 = x4 = x5 = x1 = x2 = x = x4 = x = 5 5 3 3 4 x1 x2 + x1 x3 + 3x2 + x1 4 x + 6x3 + 7x2 + x1 x5 + 15x4 + 25x3 + 10x2 + x1 x1 x + x1 2 = = = = = x1 = x2 = 1 x1 x2 − x1 x3 − 3x2 + x1 4 x − 6x3 + 7x2 − x1 x5 − 15x4 + 25x3 − 10x2 + x1 x1 x − x1 2 xn+m = xm (x + m)n . 4ac − b2 4ac − b2  1  √ ln 2ax + b + 2√a ax2 + bx + c . xn eax − a xn−1 eax dx. ∆(Hx ) = x−1 . x−1 δx = Hx .

ix = x + 2x2 + 3x3 + 4x4 + · · · ixi . = (−1) (2i + 1) i=0 i ∞ x2i . B(x) = 1−x Convolution:   ∞ A(x)B(x) = i=0  i aj bi−j  xi . i Bi x . a2i+1 x2i+1 . in xi . x k n−1 = x + 2n x2 + 3n x3 + 4n x4 + · · · = =1+x+ 1 2 2x Diﬀerence of like powers: xn − y n = (x − y) k=0 ∞ + 1 3 6x + ··· = i=0 ∞ xi . j=0 = x + x + 2x + 3x + · · · = Fn x + F2n x + F3n x + · · · 2 3 = i=0 ∞ = i=0 Fni x . (−1)i = x − 3! x3 + 5! x5 − 7! x7 + · · · = (2i + 1)! i=0 =1− x =x− 1 2 2! x 1 3 3x xk A(x) = A(x) − k−1 i=0 xk + + 1 4 4! x 1 5 5x − 1 6 6! x + ··· − 1 7 7x + ··· x2i+1 . i 2i + n i x. i (αai + βbi )xi . i! 2i i 1 x. i Summation: If bi = j=0 ai then 1 A(x). i God made the natural numbers.Theoretical Computer Science Cheat Sheet Series Taylor’s series: (x − a)i (i) (x − a)2 f (a) + · · · = f (a). i Fi x . i=1 ∞ = 1 + (n + 1)x + = 1 − 1x + 2 1 2 12 x n+2 2 x2 + · · · = + ··· = xA (x) = A(x) dx = A(x) + A(−x) = 2 A(x) − A(−x) = 2 i=1 ∞ i=0 ∞ i=0 − 1 4 720 x √ 1 (1 − 1 − 4x) 2x 1 √ 1 − 4x √ 1 − 1 − 4x 1 √ 2x 1 − 4x 1 1 ln 1−x 1−x 1 2 1 ln 1−x x 1 − x − x2 Fn x 1 − (Fn−1 + Fn+1 )x − (−1)n x2 2 = 1 + x + 2x2 + 5x3 + · · · = 1 + x + 2x + 6x + · · · n 2 3 i=0 ∞ ai−1 i x. i Hi xi . i i+n i x. ai−k xi . – Leopold Kronecker . i! xn−1−k y k . i = i=0 ∞ = i=0 ∞ i=0 ∞ = 1 + (2 + n)x + =x+ 3 2 2x 4+n 2 x2 + · · · = + ··· = + 11 3 6 x + 25 4 12 x = 1 x2 + 3 x3 + 2 4 2 3 11 4 24 x i=1 ∞ + ··· 4 = i=2 ∞ Hi−1 xi . ci ai xi . i+1 i 2i i x. i A (x) = i=0 ∞ (i + 1)ai+1 xi . iai xi . A(cx) = i=0 ∞ (1 + x)n 1 (1 − x)n+1 ex x −1 = 1 + nx + n(n−1) 2 x 2 + ··· = i=0 ∞ i=0 ∞ n i x. ln(1 + x) 1 ln 1−x sin x cos x tan −1 = x − 1 x2 + 1 x3 − 1 x4 − · · · 2 3 4 = x + 1 x2 + 1 x3 + 1 x4 + · · · 2 3 4 xi = (−1)i+1 . i! = i=0 ∞ ci xi . i a2i x2i . f (x) = f (a) + (x − a)f (a) + 2 i! i=0 Expansions: ∞ 1 = 1 + x + x2 + x3 + x4 + · · · = xi . i=0 ∞ ni Dirichlet power series: A(x) = i=1 +x 3n + ··· = = i=0 ∞ ai . x . i=0 ∞ Binomial theorem: n (x + y)n = k=0 n n−k k y . i i=1 ∞ For ordinary power series: αA(x) + βB(x) = i=0 ∞ = i=1 ∞ xi . all the rest is the work of man. i=k i ∞ x2i+1 1 1 1 . Exponential power series: A(x) = i=0 ∞ = 1 + cx + c2 x2 + c3 x3 + · · · =1+x +x n 2n ∞ ai xi . 1−x i=0 1 1 − cx 1 1 − xn x (1 − x)2 xk dn dxn e 1 1−x x ∞ Ordinary power series: ∞ A(x) = i=0 ∞ ai xi . = (−1)i (2i)! i=0 ∞ ∞ ai x = ∞ i=0 ai+k xi .

. If a ≤ b ≤ c then c a b G(x) dF (x) b c = = = n i=0 ∞ d|n i=1 2n−1 2 |B2n | 2n π . 2. Additive rule: Fn+k = Fk Fn+1 + Fk−1 Fn . 1 − p−x p ∞ ζ(x − 1) ζ(x) = i=1 If G is continuous in the interval [a. 89.1 x1 + an. ix Stieltjes Integration = i=0 ∞ (e − 1) x cot x − 1)B2i x2i−1 . 13. 8. (2i)! 1 .1 x1 + a1.n xn = bn Let A = (ai. Fi = 1 √ 5 Cramer’s Rule If we have equations: a1.1 x1 + a2. ix φ(i) . – William Blake (The Marriage of Heaven and Hell) ˆ φi − φi . b] and F is nondecreasing then d|n ζ (x) ζ(x)ζ(x − 1) ζ(2n) x sin x √ 1 − 1 − 4x 2x e sin x 1− √ 1−x x 2 x = i=1 ∞ d(i) xi S(i) xi where d(n) = where S(n) = n ∈ N. a b x.Theoretical Computer Science Cheat Sheet Series Expansions: 1 1 ln n+1 (1 − x) 1−x x n n ∞ Escher’s Knot 1 x x −n ∞ = i=0 ∞ (Hn+i − Hn ) n i x. 3. . d. a b = i=0 ∞ n(2i + n − 1)! i x. F−i = (−1)i−1 Fi . . (2i)! ζ(x) = i=0 ∞ 1 ln 1−x tan x 1 ζ(x) ζ(x) 2 = i=0 ∞ = i=0 ∞ = = i=1 ∞ µ(i) = . i 2(2i)!(2i + 1)! 16 4i i!2 x2i . 34. . . 1. i G(x) dF (x) = G(b)F (b) − G(a)F (a) − a F (x) dG(x). F2n = Fn Fn+1 + Fn−1 Fn .2 x2 + · · · + a1. . 1. n i! (−1) i=1 ∞ 2i 2i i−1 2 (2 n+i i x.n xn = b2 . are roads of Genius. and F possesses a derivative F at every point in [a. Deﬁnitions: Fi = Fi−1 +Fi−2 .n xn = b1 a2. . Calculation by matrices: 0 1 Fn−2 Fn−1 = Fn−1 Fn 1 1 n The Fibonacci number system: Every integer n has a unique representation n = Fk1 + Fk2 + · · · + Fkm . 5. i!(n + i)! 2 i/2 G(x) d F (x) + H(x) = a b a b a a G(x) dF (x) + = i=1 ∞ sin i! iπ 4 c · G(x) dF (x) = a b G(x) d c · F (x) = c G(x) dF (x).j ) and B be the column matrix (bi ). . but the crooked roads without Improvement. ix i=1 1 = . i i n!xi . (2n)! (−1) i i−1 (4 G(x) dF (x) = a b a G(x) dF (x) + b b G(x) dF (x). i = i=0 ∞ n i xi . Cassini’s identity: for i > 0: Fi+1 Fi−1 − Fi2 = (−1)i . where ki ≥ ki+1 + 2 for all i. xi = det A Improvement makes strait roads. 21. 55. b] then b b arcsin x x = i=0 G(x) dF (x) = a 00 47 18 76 29 93 85 34 61 52 86 11 57 28 70 39 94 45 02 63 95 80 22 67 38 71 49 56 13 04 59 96 81 33 07 48 72 60 24 15 73 69 90 82 44 17 58 01 35 26 68 74 09 91 83 55 27 12 46 30 37 08 75 19 92 84 66 23 50 41 14 25 36 40 51 62 03 77 88 99 21 32 43 54 65 06 10 89 97 78 42 53 64 05 16 20 31 98 79 87 a G(x)F (x) dx. . Let Ai be A with column i replaced by B. n i n!xi . (i + 1)(2i + 1)! If the integrals involved exist.2 x2 + · · · + an. Fibonacci Numbers 1. G(x) dH(x). .2 x2 + · · · + a2. exists. i! n (−4)i B2i x2i . . . = i=0 ∞ (4i)! √ xi . an. (2i)! G(x) dF (x) + a b H(x) dF (x). Then det Ai . b If the integrals involved exist G(x) + H(x) dF (x) = a b a b ∞ − 2)B2i x2i . F0 = F1 = 1. 1 ≤ i < m and km ≥ 2. Then there is a unique solution iﬀ det A = 0. .