You are on page 1of 10

Theoretical Computer Science Cheat Sheet

Definitions

Series

f (n) = (g(n))

iff f (n) = O(g(n)) and


f (n) = (g(n)).

f (n) = o(g(n))

iff limn f (n)/g(n) = 0.


iff  > 0, n0 such that
|an a| < , n n0 .

lim an = a

least b R such that b s,


s S.

sup S

greatest b R such that b


s, s S.

inf S

lim inf{ai | i n, i N}.

lim inf an

i=1

n(n + 1)
,
2

n
X

i2 =

i=1

n
X

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

i3 =

i=1

n2 (n + 1)2
.
4

In general:


n
n
X
X

1
(n + 1)m+1 1
(i + 1)m+1 im+1 (m + 1)im
im =
m+1
i=1
i=1


n1
m
X
1 X m+1
Bk nm+1k .
im =
k
m
+
1
i=1

om

iff positive c, n0 such that


f (n) cg(n) 0 n n0 .

i=

k=0

Geometric series:
n
X
cn+1 1
,
ci =
c1
i=0
n
X

ici =

i=0

c 6= 1,

ci =

i=0

ncn+2 (n + 1)cn+1 + c
,
(c 1)2

Harmonic series:
n
X
1
,
Hn =
i
i=1

n
X

c 6= 1

ci =

i=
i=

.c

f (n) = (g(n))

n
X

ici =

i=0

ce

iff positive c, n0 such that


0 f (n) cg(n) n n0 .

f (n) = O(g(n))

c
,
1c

c
,
(1 c)2

|c| < 1,
|c| < 1.

n
n(n
n(n 1)
n(
( + 1)
Hn
.
2
4
lim sup an
lim sup{ai | i n, i N}.
i=1
i
=1
n
n



n
n  
X
X

i
n+1
1
n
Combinations:
Size
k
subHi =
Hn+1
.
Hi = (n + 1)H
1)Hn
k
m
m+1
m+1
sets of a size n set.
i=1
i=1
n

 
  
n  
X
Stirling numbers (1st kind):
n!
n
n!
n
n
n
k
n
,
=2 ,
=
=
,
2.
1.
3.
Arrangements of an n elenk
k
k
k
((n
n k)!k!
k)!
k
)!k
k!!
k=0










ment set into k cycles.
n1
n n1
n1
n
n
n
,
+
=
=
4.
,
5.
Stirling
numbers
(2nd
kind):
k1
k
k
k
k k1
k

    

 
n 
Partitions of an n element
X
nk
n
m
n
r+n+1
r+k
,
7.
=
6
,
=
set into k non-empty sets.
mk
k
k
m
n
k

n
k=0


 

n  
n  
1st order Eulerian numbers:
X
X
k
r+s
n+1
s
k
r
,
8.
,
9.
=
=
Permutations 1 2 . . . n on
n
m+1
nk
m
k
k=0
k=0
{1, 2, . . . , n} with k asce ts.
 

   

n
n
n
kn1

n
= (1)k
= 1,
10.
=
,
11.
2nd order Eulerian n mbers.
k
k
n
1
k

 
 

 
Cn
Catalan Numbers: Binary
n
n1
n1
n
n1
=
2
,
12.
+
=
k

1,
13.
trees with n + 1 vertices.
2
k1
k
k
 
   
 
 
n
n
n
n
n
,
= (n 1)!Hn1 ,

= (n 1)!,
15.
= 1,
17.
14.
16.
k
2
k
1
n
  
 


 

 
 
n  
X
n
n
n
n1
n1
n
2n
n
1
,
20.
=
=
,
19.
+
= (n 1)
18.
,
= n!,
21. Cn =
2
n1
n1
k1
k
k
k
n+1 n
k=0





 
  

  
n1
n1
n
n
n
n
n
,
+ (n k)
= (k + 1)
,
24.
=
23.
= 11,
=
22.
k1
k
k
n1k
k
n
0
  n
 

 

0
n
n
n+1
1 if k = 0,
=
= 2n n 1,
25.
26.
= 3n (n + 1)2n +
,
27.
k
1
2
2
0 otherwise

  X


  X
n  
m 
n  
X
n
x+k
k
n
n+1
n
n
=
,
29.
,
(m + 1 k)n (1)k ,
=
28. xn =
30. m!
m
n
nm
k
k
k
m
k=0
k=0
k=0
  X

 
 
n  
n
nk
n
n
n
nkm
=
31.
(1)
= 0 for n 6= 0,
= 1,
33.
k!,
32.
m
m
n
k
0
k=0






 
 
n 
X
n1
n1
n
(2n)n
n
,
35.
+ (2n 1 k)
= (k + 1)
34.
=
,
k1
k
k
k
2n
k=0
 X    X


 X



 
n 
n 
n+1
x+n1k
k
x
n
n
k
=
,
37.
=
=
(m + 1)nk ,
36.
m+1
2n
m
xn
k
k
m
n

iH

.e

xa

ra

k=0

k=0

Theoretical Computer Science Cheat Sheet


Identities Cont.
 

 X

 

n 
n
n 
X
X
1 k
x
k nk
n
x+k
n+1
,
39.
=
=
n
,
=
= n!
k! m
xn
k m
m
k
2n
m+1
k
k=0
k=0
k=0

 
  X
  X  
k+1
k
n
n+1
n
n
nk
(1)
(1)mk ,
=
=
,
41.
m+1
k
k+1 m
m
m
k
k
 X
 X






m
m
m+n+1
m+n+1
n+k
n+k
=
=
,
43.
,
k
k(n + k)
m
m
k
k
k=0
k=0
 
 
  X
  X
k
k
n
n+1
n+1
n
(1)mk , 45. (n m)!
(1)mk , for n m,
=
=
m
m
m
k+1
k+1
m
k 




k X 

X m nm + n m + k 
n
mn m+n m+k
n
=
,
,
47.
=
nm
k
k
n+k
n+k
m+k
m+k
nm
 X  
k
 k  X  


 
 
`+m
`+m
n
n
n
nk
k
k nk n
=
=
.
,
49.
`
`
`+m
`+m
k
k
m
m
`
`

40.
42.
44.
46.
48.

Trees

X  n  k 

Every tree with n


vertices has n 1
edges.
Kraft
inequality: If the depths
of the leaves of
a bi ry tree are
d1 . . , dn :
n
X
d
di
2
1,

om

38.

aand
nd equality holds
only if every internal node has 2
sons.

Recurrences

logb a


4) = n/2
n/2
3 T (n/2) 3T (n/4)
..
..
..
.
.
.

log2 n1
3
T (2) 3T
T (1 = 2

ra

If  > 0 such that f (n) = O(n


then
T (n) = (nlogb a ).


1 T (n) 3T (n/2) = n

ce

a 1, b > 1

If f (n) = (nlogb a ) then


T (n) = (nlogb a log2 n).

xa

If  > 0 such that f (n) = (nlogb a+ ),


and c < 1 such that af (n/b) cf (n)
for large n, then
T (n) = (f (n)).

Let m = log2 n.. Summing the left side


we get T (n) 3 T (1)
T (n) 3m =
k
T (n) n where k = log2 3 1.58496.
Summing the right side we get
m
m

m1
X
X i
n i
3
3 =n
.
2
2
=0
i=0

Master method:
T (n) = aT (n/b) + f (n),

ii=1
=1

.c

Note that Ti is always a power of two.


Let ti = log2 Ti . Then we have
ti+1 = 2i + 2ti , t1 = 1

Let ui = ti /2i . Dividing both s des of


+1
we get
the previous equation by 2ii+1
2i
ti
ti+1
= ii+1
+ i
2i+1
2 +1
2
Substituting we find
u1 = 12 ,
ui+1
+1 = 2 + u
which is simply ui = i/2. So we find
i1
that Ti has the closed form Ti = 2i2 .
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 telescope

3
2 Then
m1
m
X
i

Let c =

.e

Substitution (example): Consider the


following recurrence
i
Ti+1 = 22 Ti2 , T1 = 2.

i=0

Multiply
X
X
X and sum:
gi+1 xi =
2gi xi +
xi .

we have

 m
c 1
c =n
c1

i0

= 2n(clog2 n 1)
= 2n(c(k1) logc n 1)
= 2nk 2n,

and so T (n) = 3n 2n. Full history recurrences can often be changed to limited
history ones (example): Consider
i1
X
Tj , T0 = 1.
Ti = 1 +
j=0

Ti+1 = 1 +

i
X

Tj .

j=0

Subtracting we find
i
i1
X
X
Tj 1
Tj
Ti+1 Ti = 1 +
j=0

= Ti .
And so Ti+1 = 2Ti = 2i+1 .

i0

i0

We choose G(x) = i0 xi gi . Rewrite


in terms of G(x):
X
G(x) g0
= 2G(x) +
xi .
x
i0

Note that

Generating functions:
1. Multiply both sides of the equation by xi .
2. Sum both sides over all i for
which the equation is valid.
3. Choose a generatingPfunction

G(x). Usually G(x) = i=0 xi gi .


3. Rewrite the equation in terms of
the generating function G(x).
4. Solve for G(x).
5. The coefficient of xi in G(x) is gi .
Example:
gi+1 = 2gi + 1, g0 = 0.

j=0

Simplify:
1
G(x)
= 2G(x) +
.
x
1x
Solve for G(x):
x
.
G(x) =
(1 x)(1 2x)
Expand this 
using partial fractions:

2
1
G(x) = x

1 2x 1 x

X
X
2i xi
xi
= x 2
=

i0
i+1

(2

i0

So gi = 2i 1.

i0

1)x

i+1

Theoretical Computer Science Cheat Sheet


e 2.71828,

0.57721,

1+ 5
2

2i

pi

General

1
2

2
4

2
3

3
4

8
16

5
7

5
6

32
64

11
13

7
8
9

128
256
512

17
19
23

Bernoulli Numbers (Bi = 0, odd i 6= 1):


1
B0 = 1, B1 = 21 , B2 = 16 , B4 = 30
,
1
1
5
B6 = 42 , B8 = 30 , B10 = 66 .
Change of base, quadratic formula:

b b2 4ac
loga x
,
.
logb x =
loga b
2a
Eulers number e:
1
1
e = 1 + 12 + 16 + 24
+ 120
+


n
x
= ex .
lim 1 +
n
n
n
n+1
1 + n1 < e < 1 + n1
.
 

11e
e
1
n
1 + n1 = e
+
.
O
2
2n 24n
n3
Harmonic numbers:
25 137 49 363 761 7129
1, 32 , 11
6 , 12 , 60 , 20 , 140 , 280 , 2520 , . . .

14
15

16,384
32,768

43
47

16
17
18

65,536
131,072
262,144

53
59
61

19
20

524,288
1,048,576

67
71

21
22

2,097,152
4,194,304

73
79

23
24

8,388,608
16,777,216

83
89

25
26
27

33,554,432
67,108,864
134,217,728

97
101
103

28
29
30

268,435,456
536,870,912
1,073,741,824

31
32

2,147,483,648
4,294,967 296

then p is the probability density function of


X. If
Pr[X < a]] = P ((a
(a),
a)),,
then P is the distribu ion fun tion of X. If
P and p both exist then
Z a
p(x)
p
( dx.
(a)
P ((a
a)) =

Expectation: If X is discrete
X
g(x) Pr[X = x].
[g(X)]
[g((X
X)]
)]
E[g

.c

37
41

.61803

Continuous distributions: If
Z b
Pr[a < X < b] =
p(x) dx,

I X continuous
Z
Z then
g(x)p(x)
dx
=
[g
[
g(
(X
X)]
)]
[g(X)]
=
E

ce

4,096
8,192

ln n < Hn < ln n + 1,
 
1
.
Hn = ln n + + O
n
Factorial, Stirlings approximation

ra

12
13

29
31

1, 2, 6, 24, 120, 720, 5040, 40 20, 362880,

...

 
 n 
1
n
.
1+
e
n
Ackermann
s fun tion and inverse:
i=1
2j
a( , j)
j) = a
a(
a(
(ii 1, 2)
a(i
j=1

a(i 1, a(i, j 1)) i, j 2


a
n! =

2n
2
n

xa

1,024
2,048

1 5
2

Probability

.e

10
11

1.61803,

om

3.14159,

107
109
113

27
131

Pasca 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

(i)
((ii)) = min{j

min | a(j, j) i}.

Binomial distribution:
 
n k nk
p q
Pr[X
Pr[ = k] =
,
q = 1 p,
k
 
n
X
n k nk
p q
k
= np.
[X]
=
E
k
k=1

Poisson distribution:
e k
, E[X] = .
Pr[X = k] =
k!
Normal (Gaussian) distribution:
2
2
1
e(x) /2 , E[X] = .
p(x) =
2
The coupon collector: We are given a
random coupon each day, and there are n
different types of coupons. The distribution of coupons is uniform. The expected
number of days to pass before we to collect all n types is
nHn .

g(x) dP (x).

Variance, standard deviation:


VAR[X] = E[X 2 ] E[X]2 ,
p
= VAR[X].
For events A and B:
Pr[A B] = Pr[A] + Pr[B] Pr[A B]
Pr[A B] = Pr[A] Pr[B],
iff 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[B|Ai ] Pr[Ai ]
.
Pr[Ai |B] = Pn
j=1 Pr[Aj ] Pr[B|Aj ]
Inclusion-exclusion:
n
n
i X
h_
Xi =
Pr[Xi ] +
Pr
i=1

i=1
n
X

(1)k+1

k=2

ii <<ik

Pr

k
h^

i
Xij .

j=1

Moment inequalities:

 1
Pr |X| E[X] ,

h
i

1
Pr X E[X] 2 .

Geometric distribution:
Pr[X = k] = pq k1 ,
q = 1 p,

X
1
kpq k1 = .
E[X] =
p
k=1

Theoretical Computer Science Cheat Sheet


Trigonometry

Matrices

More Trig.
C

Multiplication:
(0,1)

(-1,0)
(0,-1)

i=1

2 2 and 3 3 determinant:


a b


c d = ad bc,


a b c














d e f = g b c h a c + i a b


e f
d f
d e
g h i

Definitions:
sin a = A/C,
csc a = C/A,
A
sin a
= ,
tan a =
cos a
B
Area, radius of inscribed

cos a = B/C,
sec a = C/B,
cos a
B
cot a =
= .
sin a
A
circle:
AB
.
A+B+C

ce

Permanents:

sin2 x + cos2 x = 1,

cot x = cot( x),

csc x = cot x2 cot x

.e

sin(x y) = sin x cos y cos x sin y,

cos(x y) = cos x cos y sin x sin y,


tan x tan y
,
1 tan x tan y
cot x cot y 1
,
cot(x y) =
cot x cot y

tan(x y) =

Hyp rbolic Functions

Definitions:
e e x
sinh x =
2
x
e x
tanh x = x
,
e + ex
1
,
sec x =
cosh x

e +e
,
2
1
,
csch x =
sinh x
1
coth x =
.
tanh x

cos 2x = cos2 x sin2 x,


2 s n2 x,

2 =
sin 2x

cos 2x =

1 tan2 x
,
1 + tan2 x

2 tan x
cot2 x 1
,
tan 2x =
cot 2x =
2 ,
2 cot x
1 tan x
sin(x + y) sin(x y) = sin2 x sin2 y,
cos(x + y) cos(x y) = cos2 x sin2 y.
Eulers equation:
eix = cos x + i sin x,

dentities:

cosh2 x sinh2 x = 1,

tanh2 x + sech2 x = 1,

coth2 x csch2 x = 1,

sinh(x) = sinh x,
tanh(x) = tanh x,

cosh(x) = cosh x,

sinh(x + y) = sinh x cosh y + cosh x sinh y,


cosh(x + y) = cosh x cosh y + sinh x sinh y,

2 tan x
,
1 + tan2 x
cos 2x = 2 cos2 x 1,

sin 2x = 2 sin x cos x,

cosh x =

xa

cos x = cos( x),

sin x = sin( x),



tan x = cot 2 x ,

a ,
,(i) .

ii=1
=1

1 + cot2 x = csc2 x,

n
XY

ra

1
cos x =
,
sec x

1 + tan2 x = sec2 x,

sin x = cos 2 x ,

cos 2x = 1

aei + bf g + cdh
ceg f ha ibd.

perm A =

Identities:
1
,
sin x =
csc x
1
,
tan x =
cot x

det A B = det A det B,


n
XY
sign()ai,(i) .
det A =

1
2 AB,

ai,k bk,j .

k=1

Determinants: det A 6= 0 iff A is non-singular.

(1,0)

a
B
Pythagorean theorem:
C 2 = A2 + B 2 .

ci,j =

.c

C = A B,
(cos , sin )

= 1.

c
v2.02 1994
by Steve Seiden
sseiden@acm.org
http://www.csc.lsu.edu/~seiden

sinh 2x = 2 sinh x cosh x,


cosh 2x = cosh2 x + sinh2 x,
cosh x + sinh x = ex ,

cosh x sinh x = ex ,

(cosh x + sinh x)n = cosh nx + sinh nx,


2 sinh2 x2

= cosh x 1,

sin

1
2

2
2

3
2

cos
1

tan
0

3
2

2
2
1
2

3
3

A
c
B
Law of cosines:
c2 = 2 b2 2ab cos C.
Ae

om

n
X

2 cosh2 x2

n Z,

= cosh x + 1.

. . . in mathematics
you dont understand things, you
just get used to
them.
J. von Neumann

A = 12 hc,
= 12 ab sin C,

c2 sin A sin B
.
2 sin C
Herons formula:
=

A = s sa sb sc ,
s = 12 (a + b + c),
sa = s a,
sb = s b,
sc = s c.
More identities:
r
1 cos x
x
,
sin 2 =
2
r
1 + cos x
cos x2 =
,
2
r
1 cos x
,
tan x2 =
1 + cos x
1 cos x
=
,
sin x
sin x
,
=
1 + cos x
r
1 + cos x
,
cot x2 =
1 cos x
1 + cos x
=
,
sin x
sin x
,
=
1 cos x
eix eix
sin x =
,
2i
eix + eix
cos x =
,
2
eix eix
tan x = i ix
,
e + eix
e2ix 1
,
= i 2ix
e +1
sinh ix
sin x =
,
i
cos x = cosh ix,
tanh ix
.
tan x =
i

Theoretical Computer Science Cheat Sheet


Number Theory

Graph Theory

i=1

Eulers theorem: If a and b are relatively


prime then
1 a(b) mod b.
Fermats theorem:
1 ap1 mod p.
The Euclidean algorithm: if a > b are integers then
gcd(a, b) = gcd(a mod b, b).
Qn
If i=1 pei i is the prime factorization of x
then
n
Y
X
piei +1 1
.
d=
S(x) =
pi 1
i=1

om

xa

d|x

.c

if mi and mj are relatively prime for i 6= j.


Eulers function: (x) is the number of
positive integers
Qnless than x relatively
prime to x. If i=1 pei i is the prime factorization of x then
n
Y
piei 1 (pi 1).
(x) =

.e

Perfect Numbers: x is an even perfect number iff x = 2n1 (2n 1) and 2n 11 is prime.
Wilsons theorem: n is a prime iff
(n 1)! 1 mod n.

If

Mobius
inversion:
1
if i = 1.

0
if i is not squ re-free.
(i) =
r
if i is th product f
(1)

r distin t prim s.
a)) =
a
G(a)

F (d),
((d
d))

d|a
d|
d
|a
a

then

F (a)
((a
a)) =

X
d|a

a
.
(d)G
d

Prime numbers:
ln ln n
pn = n ln n + n ln ln n n + n
ln n


n
,
+O
ln n
n
n
2!n
+
(n) =
+
ln n (ln n)2
(ln n)3


n
.
+O
(ln n)4

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 degr e
(G)) Chromatic number
E (G)) Edge hroma ic number
Complement graph
Gc
Comp ete graph
Kn
K 1 ,n2 Complete bipartite graph
r k, `)
`) Ramsey number
Geometry

Pr jective coordinates: triples


((x,
x, y, zz), not all x, y and z zero.
(x, y, z) = (cx, cy, cz) c 6= 0.
Cartesian
Projective

ce

mod m1
..
.
C rn mod mn

An edge connecting a vertex to itself.


Directed
Each edge has a direction.
Simple
Graph with no loops or
multi-edges.
Walk
A sequence v0 e1 v1 . . . 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 tra l visiting
each edge exactly once.
Hamiltonian Graph with a cy le visiting
each vertex exact y once.
Cut
A set of edg s whose rem l in reases the number of omponents.
Cut-set
A minimal cut.
Cut edge
A size 1 cut.
k-Connec ed A graph connected with
the removal of any k 1
vertices.
S V, S 6= we have
k T ugh
k c(G S) |S|.
A graph where all vertices
k-Regular
have degree k.
k-Factor
A k-regular spanning
subgraph.
Matching
A set of edges, no two of
which are adjacent.
Clique
A set of vertices, all of
which are adjacent.
Ind. set
A set of vertices, none of
which are adjacent.
Vertex cover A set of vertices which
cover all edges.
Planar graph A graph which can be embeded in the plane.
Plane graph An embedding of a planar
graph.
X
deg(v) = 2m.

ra

C r1
.. ..
. .

Definitions:
Loop

The Chinese remainder theorem: There exists a number C such that:

vV

If G is planar then n m + f = 2, so
f 2n 4, m 3n 6.
Any planar graph has a vertex with degree 5.

(x, y)
(x, y, 1)
y = mx + b (m, 1, b)
x=c
(1, 0, c)
Distance formula, Lp and L
metric:
p
(x1 x0 )2 + (y1 y0 )2 ,
1/p

|x1 x0 |p + |y1 y0 |p
,


1/p
lim |x1 x0 |p + |y1 y0 |p
.
p

Area of triangle (x0 , y0 ), (x1 , y1 )


and (x2 , y2 ):


x1 x0 y1 y0
1

.
2 abs x x

2
0 y2 y0
Angle formed by three points:
(x2 , y2 )
`2

(x1 , y1 )
`1
(0, 0)
(x1 , y1 ) (x2 , y2 )
cos =
.
`1 `2
Line through two points (x0 , y0 )
and (x1 , y1 ):


x y 1


x0 y0 1 = 0.


x1 y1 1
Area of circle, volume of sphere:
V = 43 r3 .
A = r2 ,
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

1
7

1
9

4.

d(un )
du
= nun1 ,
dx
dx

7.

d(cu )
du
= (ln c)cu ,
dx
dx

9.

du
d(sin u)
= cos u ,
dx
dx

Newtons series:


1
1
1
1 
+ 2
3
+
= 1 1
3 3 3 5 3 7
3

Eulers series:
2
6
2
8
2
12

=
=
=

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

+
+

Partial Fractions

d(tan u)
du
= sec2 u ,
dx
dx

13.

du
d(sec u)
= tan u sec u ,
dx
dx

14.

1
d(arcsec u)
du
=
,
2
dx
u 1 u dx
du
d(sinh u)
= c sh u ,
21.
dx
dx
23.

(tanh u)
u)
d(tanh
du
= s ch2 u ,
dx
dx

N ((x
(x)
x))
A=
D(x)
D(
D
(x
x))

25.

du
d(sec u)
u)
d(sec
= sech u tanh u ,
dx
dx

1
d(arcsinh u)
d(arcsinh
du
=
,
2
dx
1 + u dx
1 du
d
d(arctanh
u)
=
,
9.
dx
1 u2 dx

k=0

where

3.

x=a

For a repea ed factor:


m1
m
X
N 0 (x)
N (x)
Ak
=
,
+
m
mk
(x a) D(x)
(x a)
D(x)



1 dk N (x)
Ak =
.
k! dxk 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

1
xn+1 ,
x dx =
n+1

Z
Z
8.

20.

d(arccsc u)
1
du
=
,
2
dx
u 1 u dx
d(cosh u)
du
22.
= sinh u ,
dx
dx

Z
n 6= 1,

d(coth u)
du
= csch2 u ,
dx
dx

d(csch u)
du
= csch u coth u ,
dx
dx

d(arccsch u)
1
du

=
.
dx
|u| 1 + u2 dx

4.

Z
(u + v) dx =

v dx,

Z
tan x dx = ln | cos x|,

11.

cot x dx = ln | cos x|,

Z
sec x dx = ln | sec x + tan x|,

Z
14.

Z
u dx +

Z
1
dx = ln x,
5.
ex dx = ex ,
x
Z
Z
du
dv
7.
u dx = uv v dx,
dx
dx
Z
9.
cos x dx = sin x,

12.

d(cot
d(cot u)
du
= csc2 u ,
dx
dx

Z
2.

sin x dx = cos x,

10.

d cos u
u))
du
= sin u ,
dx
dx

d(arccos u)
1 du
=
,
dx
1 u2 dx
d(arccot u)
1 du
18.
=
,
dx
1 + u2 dx

32.

dx
= arctan x,
1 + x2

6.

1 du
d(ln u)
d(ln
=
,
dx
u dx

d(arccosh u)
1
du
=
,
2
dx
u 1 dx
d(arccoth u)
1 du
30.
= 2
,
dx
u 1 dx

1
d(arcsech u)
du
=
,
dx
u 1 u2 dx
Integrals:
Z
Z
1.
cu dx = c u dx,
n

d(ecu )
du
= cecu ,
dx
dx

28.

31.

6.

16.

26.

27

d(uv)
dv
du
=u
+v ,
dx
dx
dx

du
d csc u)
= cot u csc u ,
dx
dx

24.

.e

where

where the degree of N 0 is less than that of


). Use the f llowD. Second, factor D(x).
ing rules: For a non-repeated facto :
A
N 0 ((x
(x)
x))
N (x)
=
+
,
(x a)D(x)
xa
D(x)
D(
D
(x
x))

12.

1
d(arcsin u)
du
=
,
2
dx
1 u dx
1 du
d(arctan u)
=
,
17.
dx
1 + u2 dx
19.

dv
dx

10.

11.

15.

3.

8.

xa

Let N (x) and D(x) be polynomial functions of x.


We can break down
N (x)/D(x) using partial fraction expansion. First, if the degree of N is greater
than or equal to the degree of D, divide
N by D, obtaining
N 0 (x)
N (x)
= Q(x) +
,
D(x)
D(x)

d(u + v)
du dv
=
+
,
dx
dx dx

v du
d(u/v)
dx u
5.
=
dx
v2

1
1
13

6 = 2 + 2 3 23 + 2 4 5 25 +
Sharps series:

2.

om

1
5

72
2+

du
d(cu)
=c ,
dx
dx

.c

Gregrorys series:

1
4 =1 3 +

2+

1.

ce

2+

Derivatives:

ra

Wallis identity:
2 2 4 4 6 6
=2
1 3 3 5 5 7
Brounckers continued fraction expansion:
12

4 =1+
32
2+
52

arcsin xa dx = arcsin xa +

p
a2 x2 ,

13.
a > 0,

csc x dx = ln | csc x + cot x|,

Theoretical Computer Science Cheat Sheet


Z
15.

arccos
Z

17.
Z
19.
Z

x
a dx

= arccos

sin2 (ax)dx =

1
2a

x
a

Calculus Cont.
a2

x2 ,

16.

a > 0,

arctan xa dx = x arctan xa
Z


ax sin(ax) cos(ax) ,

18.

20.

Z
29.
Z
33.

om

Z
26.

sinh x dx =

1
4

sinh(2x)

arcsinh

x
a dx

= x arcsinh

x
a

1
2 x,

Z
36.

csc2 x dx = cot x,

.c

Z
25.

34.

ce

23.

a > 0,

Z
Z
Z
sinn1 x cos x n 1
cosn1 x sin x n 1
2
+
sinn2 x dx,
+
cos
22.
cosn x dx =
x dx,
n
n
n
n
Z
Z
Z
tann1 x
cotn1 x
n
n2
n
tan
otn 2 x dx, n 6= 1,

x dx, n 6= 1,
24.
cot x dx =
tan x dx =
n1
n1
Z
tan x secn1 x n 2
+
secn2 x dx, n 6= 1,
secn x dx =
n1
n1
Z
Z
Z
cot x cscn1 x n 2
+
cscn2 x dx, n 6= 1,
27.
sinh x dx = cosh x,
28.
cosh x dx = sinh x,
cscn x dx =
n1
n1
Z
Z
Z


tanh x dx = ln | cosh x|, 30.
coth x dx = ln | sinh x|, 31.
sech x dx = arct n sinh x, 32.
csch x dx = ln tanh x2 ,
cosh x dx =

1
4

sinh(2x)
sinh(2x
sinh(2
x)) +

1
2x

Z
35.

sech2 x dx = tanh x,

x2

a2 ,

a > 0,

ra

ln(a2 + x2 ),


ax + sin(ax) cos(ax) ,

1
2a

sec2 x dx = tan x,
sinn x dx =

21.

cos2 (ax)dx =

a
2

37

arctanh xa dx = x arctanh xa +

a
2

ln |a2 x2 |,

x p
x arccosh x2 + a2 , if arccosh xa > 0 nd > 0,
a
38.
arccosh xa dx =
p
x arccosh x + x2 + a2 , if arcc h x < 0 and a > 0,
a
a
Z


p
dx

= ln x + a2 + x2 , a > 0,
39.
a2 + x2
Z p
Z
p
2
dx
1
x
=
arctan
,
a
>
0,
41.
a2 x2 dx = x2 a2 x2 + a2 arcsin xa , a > 0,
40.
a
a
2
2
a +x
Z
p
4
2
x2 + 33aa8 arcsin xa , a > 0,
42.
(a2 x2 )3/2 dx = x8 (5a2 2x2 )


Z
Z
Z
a + x
1
x
dx
dx
dx
x

,

ln
= arcsin a , a > 0
0,,
44.
=
=
,
43.
45.


2
2
2
2
3/2
2
2
2
a x
2a
ax
(a x )
a x
a a2 x2
Z
Z p




p
p
p
2
dx



a2 x2 dx = x2 a2 x2 a2 ln x + a2 x2 ,
= ln x + x2 a2 , a > 0,
47.
46.
x2 a2


Z
Z

1 x
2(3bx 2a)(a + bx)3/2
dx
=
,
49.
x a + bx dx =
ln
,
48.


2
ax + bx
a + bx
15b2


Z
Z
Z

a + bx a
a+ x
1
1
x

dx = 2 a + bx + a
50.
dx,
51.
dx = ln
, a > 0,
x
x a + bx
a + bx
a + bx + a
2

Z p
Z 2
a + a2 x2
p
a x2


2
2
dx = a x a ln
53.
x a2 x2 dx = 13 (a2 x2 )3/2 ,
52.
,


x
x


Z
Z
a + a2 x2
p
p
4
dx

54.
x2 a2 x2 dx = x8 (2x2 a2 ) a2 x2 + a8 arcsin xa , a > 0,
55.
= a1 ln
,
2
2


x
a x
Z
Z
2
p
p
2
x dx
x dx
x

= a2 x2 ,
57.
= x2 a2 x2 + a2 arcsin a,
a > 0,
56.
2
2
2
2
a x
a

Z
Z
a + a2 + x2
p
p
a2 + x2
x2 a2


a
dx = a2 + x2 a ln
dx = x2 a2 a arccos |x|
, a > 0,
58.
59.
,


x
x
x


Z
Z p


dx
x
,

61.
= a1 ln
60.
x x2 a2 dx = 13 (x2 a2 )3/2 ,
x x2 + a2
a + a2 + x2

.e

xa

Theoretical Computer Science Cheat Sheet

64.
Z
66.

Z
67.
Z
68.

Z
b
ax2 + bx + c
dx

,
69.
2
a
2a
ax + bx + c

1 2 c ax2 + bx + c + bx + 2c

,
Z
c ln

x
dx

=
70.
x ax2 + bx + c
bx + 2c
1

arcsin
,
c
|x| b2 4ac
Z
p
2 2
a )(x2 + a2 )3/2 ,
71.
x3 x2 + a2 dx = ( 13 x2 15
x dx

=
2
ax + bx + c

Z
73.

xn sin(ax) dx = a1 xn cos(ax) +
n

74.

xn eax dx =
Z

75.

n
a

n
a

xn11 os(
os(ax)
os(ax
ax)) dx,

n
a

Difference, shift operators:


f (x) = f (x + 1) f (x),
E f (x) = f (x + 1).
Fundamental Theorem:
X
f (x) = F (x)
f (x)x = F (x) + C.
b
X

f (x)x =

b1
1
X

1
ln ax
ax))

n+1
((n + 1)2

m
x
ax)m
(ln ax
n+1
n+1

xn (ln ax)m dx =

n+1
n
+1

sin ax)
ax) dx,

Differences:
(cu) = cu,
u,

(u
(u

u + v,
v) =
v)

u
u
vv + E v
v u,
u,
(uv) = uv
vu,
1

1
(xn ) = nxnn1

1
1
(H
(
Hx ) = x

(2x ) = 2x ,


x
x
= m1
.
m

(c ) = ( 1)cx ,
(c
Sums:
P
P
cu x = c u x,
P
P
P
(u + v) x =
u x + v x,
P
P
uv x = uv E vu x,
n+1
P 1
P n
x x = Hx ,
x x = xm+1 ,


P x
P
x
x
x
c
c x = c1
,
m x = m+1 .
Falling Factorial Powers:
xn = x(x 1) (x n + 1), n > 0,
x0 = 1,
1
,
(x + 1) (x + |n|)

n < 0,

xn+m = xm (x m)n .
Rising Factorial Powers:
xn = x(x + 1) (x + n 1),

n > 0,

x0 = 1,

xn =
xn (ln ax)m1 dx.

x1
x2 + x1

=
=

x1
x2 x1

x3 =
x4 =

x3 + 3x2 + x1
4
x + 6x3 + 7x2 + x1

=
=

x3 3x2 + x1
4
x 6x3 + 7x2 x1

x5 =

x5 + 15x4 + 25x3 + 10x2 + x1

x5 15x4 + 25x3 10x2 + x1

x1 =
x2 =

x1
x + x1

x1 =
x2 =

x1
x x1

x3 =
x4 =

x3 + 3x2 + 2x1
x4 + 6x3 + 11x2 + 6x1

x3 =
x4 =

x3 3x2 + 2x1
x4 6x3 + 11x2 6x1

x5 =

x5 + 10x4 + 35x3 + 50x2 + 24x1

x5 =

x5 10x4 + 35x3 50x2 + 24x1

f ((i
(i)
i))

i=a
ii=
=a
a

xn =

n1
1
1 ax
xnn
e dx,

x1 =
x2 =

xn eax

xn ln(ax) dx = xn+1
Z

76.

sin(ax)
Z

if c < 0,

.e

x cos(ax) dx =
Z

1 n
ax

i c>0

xa

Z
72.

ra

Finite Calculus

om

x2 a2
dx
dx
1
a

,
= a arccos |x| , a > 0,
63.
=
a2 x
x x2 a2
x2 x2 a2

Z
p
(x2 + a2 )3/2
x2 a2
x dx

= x2 a2 ,
65.
dx
=

,
x4
3a2 x3
x2 a2

2ax + b b2 4ac

ln
, if b2 > 4ac,

2
2

dx
b 4ac
2ax + b + b 4ac
=
ax2 + bx + c

2ax + b
2

arctan
,
if b2 < 4ac,
4ac b2
4ac b2



p
1

ln 2ax + b + 2 a ax2 + bx + c , if a > 0,

a
dx

=
2ax b
1
ax2 + bx + c

arcsin
,
if a < 0,
a
b2 4ac
Z
p
2ax + b p 2
4ax b2
dx

ax2 + bx + c dx =
ax + bx + c +
,
2
4a
8a
ax + bx + c
Z

.c

62.

Calculus Cont.

ce

1
,
(x 1) (x |n|)

n < 0,

xn+m = xm (x + m)n .
Conversion:
xn = (1)n (x)n = (x n + 1)n
= 1/(x + 1)n ,
xn = (1)n (x)n = (x + n 1)n
= 1/(x 1)n ,
n  
n  
X
n k X n
x =
(1)nk xk ,
xn =
k
k
k=1
k=1
n  
X
n
(1)nk xk ,
xn =
k
k=1
n  
X
n k
n
x .
x =
k
k=1

Theoretical Computer Science Cheat Sheet


Series
Taylors series:

X (x a)i
(x a)2 00
f (a) + =
f (i) (a).
f (x) = f (a) + (x a)f (a) +
2
i!
i=0
Expansions:

X
1
= 1 + x + x2 + x3 + x4 +
=
xi ,
1x
i=0

X
1
= 1 + cx + c2 x2 + c3 x3 +
=
ci xi ,
1 cx
i=0

X
1
n
2n
3n
=
1
+
x
+
x
+
x
+

=
xni ,
1 xn
i=0

X
x
2
3
4
= x + 2x + 3x + 4x +
=
ixi ,
(1 x)2
i=0



X
1
dn
= x + 2n x2 + 3n x3 + 4n x4 + =
in xi ,
xk n
dx
1x
i=0

X
xi
,
= 1 + x + 12 x2 + 16 x3 +
=
ex
i!
i=0

i
X
+ x
=
(1)
((
1)
1)ii+
ln(1 + x)
= x 12 x2 + 13 x3 14 x4
i
i=1
=1

i
Xx
1
= x + 12 x2 + 13 x3 + 14 x4 +
ln
=
1x
i
i 1

X
x2i+1
1 3
1 5
1 7
,
sin x
= x 3!
x + 5!
x 7!
x + =
((1)i
(2i + 1)!
ii=0
=0

2i
X
i x
1 2
1 4
6
,
cos x
= 1 2!
x + 4!
x
x
+

=
(1)
6!
(2i)!
i=0

X
x2i+1
,
tan1 x
= x 13 x3 + 15 x5 7 7 +
=
(1)i
(2i + 1)
i=0
 
X
n i
n(n1)
(n
n
1)
1) 2
x,
(1 + x)n
= 1 + nx + nn(
x
+

=
2
i
i=0


X

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

X
x
Bi xi
1
1 2
1
4
=
1

,
x
+
x

x
+

=
2
12
720
x
e 1
i!
i=0
 

2i i
1
1
2
3
x,
(1 1 44x
4x)
x))
= 1 + x + 2x + 5x +
=
2x
i+1 i
i=0
 
X
2i i
1

x,
=
= 1 + x + 2x2 + 6x3 +
i
1 44x
x
i=0


n


X

2i + n i
1
1
1 4x
4+n 2

x,
= 1 + (2 + n)x + 2 x + =
i
2x
1 4x
i=0

X
1
1
25 4
3
ln
= x + 32 x2 + 11
x
+
x
+

=
Hi xi ,
6
12
1x 1x
i=1

2

X
1
Hi1 xi
1
4
,
ln
= 12 x2 + 34 x3 + 11
x
+

=
24
2
1x
i
i=2

X
x
2
3
4
= x + x + 2x + 3x +
=
Fi xi ,
1 x x2
i=0

X
Fn x
2
3
=
F
x
+
F
x
+
F
x
+

=
Fni xi .
n
2n
3n
1 (Fn1 + Fn+1 )x (1)n x2
i=0

Ordinary power series:

X
ai xi .
A(x) =
i=0

Exponential power series:

X
xi
ai .
A(x) =
ii!
ii=0
=0
Dirichlet power s ies:

X
i
A
((x
x))
A(x)
.
x
i
=1
=
1

om

.c

Binomia theor m:
n  
X
n nk k
x
y .
(x
(x + yy))n =
k
k=0

k=0

For ordinary power series:

X
(ai + bi )xi ,
A(x) + B(x) =
i=0

xk A(x) =
A(x)

.e

xa

ra

ce

Difference of like powers:


n1
X
xn1k y k .
xn y n = (x y)

Pk1
i=0
xk

aik xi ,

i=k
i

ai x

A(cx) =

ai+k xi ,

i=0

ci ai xi ,

i=0

X
(i + 1)ai+1 xi ,
A0 (x) =
i=0

xA0 (x) =

iai xi ,

i=1

Z
A(x) dx =

X
ai1
i=1

A(x) + A(x)
=
2
A(x) A(x)
=
2

xi ,

a2i x2i ,

i=0

a2i+1 x2i+1 .

i=0

Pi
Summation: If bi = j=0 ai then
1
A(x).
B(x) =
1x
Convolution:

i
X
X

aj bij xi .
A(x)B(x) =
i=0

j=0

God made the natural numbers;


all the rest is the work of man.
Leopold Kronecker

Theoretical Computer Science Cheat Sheet


Series

n

tan x
1
(x)
(x)
2

(x)

(x)(x 1)

X
d(i)
i=1

where d(n) =

xi
S(i)
xi

where S(n) =

d|n

1,

P
d|n

d,

i=1
2n1

|B2n | 2n
, n N,
=
(2n)!

X
(4i 2)B2i x2i
=
,
(1)i1
(2i)!
i=0

x
sin x


n
1 1 4x
2x

e sin x

X
n(2i + n 1)!
i=0

i!(n + i)!
i/2

i=1

1x
x

2
arcsin x
x
1

X
i=0

x,

(4i)!
ii)!
)!

x,
i
16 2(2
2(2i)!(2i
2(2i
i)!(2
)!(2ii + 1)!

4i i 2
x2i .
((ii + 1)(2i
1)(2i + 1)!

sin
i!

i
4

.e

xi ,

i=0
=0

x cot x

i=0

X
i=0

Cram rs R

If we have equations:
a1,1 x1 + a 2 x2 + + a1,n xn = b1
a2,1
,,1
1 x1 + a2
2,2
2,
,2
2 x2 + + a2,n xn = b2
..
..
..
.
.
.
an,11 x1 + an,2 x2 + + an,n xn = bn

Let A = (ai,j ) and B be the column matrix (bi ). Then


there is a unique solution iff det A 6= 0. Let Ai be A
with column i replaced by B. Then
det Ai
.
xi =
det A
Improvement makes strait roads, but the crooked
roads without Improvement, are roads of Genius.
William Blake (The Marriage of Heaven and Hell)

i!

(4)i B2i x2i


,
(2i)!

X
1
=
,
x
i
i=1

X
(i)
=
,
ix
i=1

(x)
(x 1)
(x)

Stieltjes Integrat on

If G is continuous in the interval [a


[a b]
b] and F is nondecreasing then
Z b
G(x)
G(
G
( dF (x)
exists. If a b c then
Z
Z c
G(x)
G(
G
(x
x)) dF ((x
(x)
x)) =
a

Z
c G(x) dF (x) =

G(x) dF (x) +


G(x) d F (x) + H(x) =
G

G(x) dF (x).
b

If the i egral involved exist


Z
Z b

G(
G
(x
x)) + H(x) dF (x) =
G(x)

xa

(2n)

 
X
i n!xi
i=0

xi ,

(e 1)
x

om

1
1x

 
X
i

.c


ln

 n
1
x

ra


n+i i
x,
=
(Hn+i Hn )
i
i=0
 
X
n i
x,
=
i
i=0
 
X
i n!xi
,
=
n i!
i=0

X
22i (22i 1)B2i x2i1
,
=
(1)i1
(2i)!
i=1

X
(i)
=
,
ix
i=1
Y
1
=
,
1 px
p


ce

Expansions:
1
1
ln
n+1
(1 x)
1x

Eschers Knot


G(x) d c F (x) = c

G(x) dF (x) +
a

H(x) dF (x),

G(x) dF (x) +

G(x) dH(x),
a
Z b

G(x) dF (x),

G(x) dF (x) = G(b)F (b) G(a)F (a)

a
b

F (x) dG(x).
a

If the integrals involved exist, and F possesses a derivative F 0 at every


point in [a, b] then
Z b
Z b
G(x) dF (x) =
G(x)F 0 (x) dx.
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

The Fibonacci number system:


Every integer n has a unique
representation
n = Fk1 + Fk2 + + Fkm ,
where ki ki+1 + 2 for all i,
1 i < m and km 2.

Fibonacci Numbers
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, . . .
Definitions:
Fi = Fi1 +Fi2 ,

F0
i1

= F1 = 1,

Fi = (1) Fi ,


Fi = 15 i i ,
Cassinis identity: for i > 0:
Fi+1 Fi1 Fi2 = (1)i .
Additive rule:
Fn+k = Fk Fn+1 + Fk1 Fn ,
F2n = Fn Fn+1 + Fn1 Fn .
Calculation by matrices:

 
n
Fn2 Fn1
0 1
=
.
Fn1
Fn
1 1

You might also like