0% found this document useful (0 votes)
112 views10 pages

CDI I - Diversos - Theoretical Cheat Sheet

The document provides a theoretical computer science cheat sheet covering big O notation, series, recurrences, identities, combinatorics, and algorithms. It defines big O notation and common time and space complexities. It also covers topics like series, recurrences, master theorem, generating functions, and algorithms for solving recurrences. The cheat sheet provides formulas and examples for analyzing algorithmic complexity.

Uploaded by

Bruno Trindade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views10 pages

CDI I - Diversos - Theoretical Cheat Sheet

The document provides a theoretical computer science cheat sheet covering big O notation, series, recurrences, identities, combinatorics, and algorithms. It defines big O notation and common time and space complexities. It also covers topics like series, recurrences, master theorem, generating functions, and algorithms for solving recurrences. The cheat sheet provides formulas and examples for analyzing algorithmic complexity.

Uploaded by

Bruno Trindade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Theoretical Computer Science Cheat Sheet

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

De nitions
i 9 positive c; n such that
0  f(n)  cg(n) 8n  n .
i 9 positive c; n such that
f(n)  cg(n)  0 8n  n .
i f(n) = O(g(n)) and
f(n) =
(g(n)).
i limn!1 f(n)=g(n) = 0.
i 8 2 R, 9n such that
jan , aj < , 8n  n .
least b 2 R such that b  s,
8s 2 S.
greatest b 2 R such that b 
s, 8s 2 S.
lim inf fai j i  n; i 2 Ng.
n!1

n
X

f(n) =
(g(n))

=1

In general:

f(n) = o(g(n))
lim a = a
n!1 n
sup S
inf S
lim
inf a
n!1 n

n
X
i

=1

n
X

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

i = n (n4+ 1) :
i

n ,
X

+1

=1

=1

+1

+1

+1

=1

=0

+1

n
X

=0

ici =

ncn

+2

=0

+1

(c , 1)

=0

Harmonic series:
n
X
Hn = 1i ;

n!1

, (n + 1)cn

+ c ; c 6= 1;

1
X

=1

=0

n
X

ici = (1 ,c c) ; c < 1:

iHi = n(n2+ 1) Hn , n(n4, 1) :

=1

n i
X

=1

+1

=1

=0

=0

25.
28.

=0

=0

31.

=0

=0

=0

34.

=0

36.

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


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





 n , 1


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

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

n
k

n
1st order Eulerian numbers:
n  k  n + 1
n r  s  r + s
k
X
X
Permutations   : : :n on
8.
=
;
9.
m+1
k n,k = n ;
f1; 2; : : :; ng with k ascents.
k  m
k
n n

n
n = (,1)k k , n , 1;
10.
11.
2nd
order
Eulerian
numbers.
k
k
k
1 = n = 1;
n
n n , 1 n , 1
Cn
Catlan Numbers: Binary
n
,
trees with n + 1 vertices.
12. 2 = 2 , 1;
13. k = k k + k , 1 ;
n
n
n
n n
=
(n
,
1)!;
15.
=
(n
,
1)!H
;
16.
=
1;
17.
 k ;
n,
1
2
n
k
n
n , 1 n , 1
 n   n  n
 
n n
X
1 2n ;
=
(n
,
1)
+
;
19.
=
=
;
20.
=
n!;
21.
C
=
n n+1 n
k,1
2
kn   n  k
 n  n, 1 n n, 1
 n k k  n , 1 
n , 1
=
=
1;
23.
=
;
24.
=
(k
+
1)
+
(n
,
k)
;
0
n
,
1
k
n
,
1
,
k
k
k
k
,
1
0 n
n
 n
 
1 if k = 0,
n , n , 1;
n , (n + 1)2n + n + 1 ;
=
26.
=
2
27.
=
3
k
0 otherwise
1
2  
2
n X
n  n x + k
m n + 1
n  n  k 
X
X
n
xn =
;
29. m =
(m + 1 , k)n(,1)k ;
30. m! m =
k
n
k
k n,m ;
k
k
k
n X
 n 
 n 
n  n n , k
n
,
k
,
m
k!;
32. 0 = 1;
33. n = 0 for n 6= 0;
m =k k
m (,1)
 n 
 n , 1 
 n , 1 
n  n  (2n)n
X
=
(k
+
1)
+
(2n
,
1
,
k)
;
35.
k
k
k,1
k = 2n ;
k
 x  X
 n + 1  X n k  X
n  n x + n , 1 , k
n k
;
37. m + 1 =
=
(m + 1)n,k ;
x,n = k
k
2n
k
m
m
k
k
n
X

=0

22.



=1

=1

18.

n!1
,n
k

14.

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


m
nX
,
X m+1
Bk nm ,k :
im = m 1+ 1
k
i
k
Geometric series:
1
1
n
n
X
X
X
ci = 1 ,1 c ;
ci = 1 ,c c ; c < 1;
ci = c c ,,1 1 ; c 6= 1;

lim supfai j i  n; i 2 Ng.

lim sup an

n
X
m

f(n) = (g(n))

i = n(n2+ 1) ;

Series

=0

=0

Theoretical Computer Science Cheat Sheet

Identities Cont.
 n + 1  X  n  k  X
n k
n  
n,k = n! X 1 k ;
38. m + 1 =
=
n
k m k m
k k! m
 n  X k n

k+1
=0

=0

40. m =
(,1)n,k ;
k
m
+
1
 m + n +k1  X
m n + k
42.
=
k k ;
m

Trees
 x  X
n  n x + k
tree with n
39. x , n =
; Every
vertices
has n , 1
k
2n
 n  X  n +k 1  k 
edges.
=0

41. m =
(,1)m,k ; Kraft inequalk
+
1
m
 m + n + 1k X
 n + k  ity: If the depths
m
43.
= k(n + k) k ; of the leaves of
m

a binary tree are


 n  X  n +k 1  k 
 n  X  n + 1  k  k
:n: :; dn:
m,k ; 45. (n , m)!
m,k ; for n  m, d ;X
44. m =
(
,
1)
=
(
,
1)
k+1 m
m
2,di  1;
 n k X
m , nm + n m + k 
 n k  k +X1 mm, nm + n m + k 
i
=0

=0

46. n , m =
+k
k ;
 n ` +kmm +Xk  kn


n
,
k
n
48. ` + m
` =
`
m
k ;

47. n , m =
k ; and equality holds
 n k` + mm+ k X n k+k n , k 
 only if every inn
49. ` + m
` =
` m
k : ternal node has 2
=1

Master method:
T(n) = aT(n=b) + f(n); a  1; b > 1
If 9 > 0 such that f(n) = O(n b a, )
then
T (n) = (n b a ):
If f(n) = (n b a ) then
T(n) = (n b a log n):
If 9 > 0 such that f(n) =
(n b a  ),
and 9c < 1 such that af(n=b)  cf(n)
for large n, then
T(n) = (f(n)):
Substitution (example): Consider the
following recurrence
Ti = 2 i  Ti ; T = 2:
Note that Ti is always a power of two.
Let ti = log Ti . Then we have
ti = 2i + 2ti; t = 1:
Let ui = ti =2i. Dividing both sides of
the previous equation by 2i we get
ti = 2i + ti :
2i
2i
2i
log

log

log

log

log

+1

log

+1

+1

+1

Substituting we nd
ui = + ui ; u = 12;
which is simply ui = i=2. So we nd
that Ti has the closed form Ti = 2i i,1 .
Summing factors (example): Consider
the following recurrence
Ti = 3Tn= + n; T = n:
Rewrite so that all terms involving T
are on the left side
Ti , 3Tn= = n:
Now expand the recurrence, and choose
a factor which makes the left side \telescope"
+1

log

log

=0

Let c = andm = log n.


Then we have
m
m , 1
X
c
n ci = n c , 1
3

+1

=0

= 2n(c  c 2 n , 1)
= 2n(c  ck c n , 1)
= 2nk , 2n  2n :
log

+1

1 58496

Note that

=0

Ti = 1 +
+1

, 2n;

where k = (log ), . Full history recurrences can often be changed to limited history ones (example): Consider the following recurrence
i,
X
Ti = 1 + Tj ; T = 1:
3
2 2

Xi
j

Tj :

=0

Subtracting we nd
i,
Xi
X
Ti , Ti = 1 + Tj , 1 , Tj
1

+1

=0

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

+1

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
i
G(x). Usually G(x) = 1
i x.
3. Rewrite the equation in terms of
the generating function G(x).
4. Solve for G(x).
5. The coecient of xi in G(x) is gi .
Example:
gi = 2gi + 1; g = 0:
Multiply
X andi sum:
X
X
gi x = 2gi xi + xi:
=0

+1

i

+1

i

i

P
We choose G(x) = i xi. Rewrite
in terms of G(x):
X i
G(x) , g
0

log

+1

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

3 T(n=2) , 3T(n=4) = n=2
.. .. ..
. . .
,T(2) , 3T(1) = 2
n
,
2
3
,

3 2 n T(1) , 0 = 1
Summing the left side we get T (n). Summing the right side we get
X2 n n i
i3 :
i 2

+1

Recurrences

sons.

=0

= 2G(x) +

x:

i

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

G(x) = x 1 ,2 2x , 1 ,1 x

0
1
X
X
= x @2 2i xi , xi A
i
X ii
i
0

(2

i

So gi = 2i , 1.

+1

, 1)x :
+1

Theoretical Computer Science Cheat Sheet


p
e  2:71828,
 0:57721,
=
 1:61803,

  3:14159,
i
2i
pi
General
1
2
2
Bernoulli Numbers (Bi = 0, odd i 6= 1):
2
4
3
B = 1, B = , , B = , B = , ,
B = ,B =, ,B = .
3
8
5
Change of base, quadratic formula:
4
16
7
p
b , 4ac :
log
x
,
b

5
32
11
a
logb x = log b ;
2a
6
64
13
a
Euler's
number
e:
7
128
17
+
e
=
1
+
8
256
19
 +x n+ x +   
9
512
23
lim 1 + n = e :
n!1
,1 + n < e < ,1 + n :
10
1,024
29
n
n  
11
2,048
31
,

e
11e
n
1 + n = e , 2n + 24n , O n1 :
12
4,096
37
13
8,192
41
Harmonic numbers:
14
16,384
43
1, , , , , , , , ; : : :
15
32,768
47
16
65,536
53
lnn < Hn < ln n + 1;
17
131,072
59
Hn = ln n + + O n1 :
18
262,144
61
Factorial, Stirling's approximation:
19
524,288
67
:::
20
1,048,576
71
 1 
21
2,097,152
73
p  n n
n!
=
2n
1
+

22
4,194,304
79
e
n :
23
8,388,608
83
Ackermann's
8 jfunction and inverse:
24
16,777,216
89
i=1
<2
a(i; j) = : a(i , 1; 2)
j=1
25
33,554,432
97
a(i
,
1;
a(i;
j
,
1))
i; j  2
26
67,108,864
101
(i) = minfj j a(j; j)  ig:
27
134,217,728
103
28
268,435,456
107
Binomial distribution:
n
29
536,870,912
109
Pr[X = k] = k pk qn,k ; q = 1 , p;
30
1,073,741,824
113
n
n
X
31
2,147,483,648
127
[X]
=
k
=
1k
pk qn,k = np:
E
k
32
4,294,967,296
131
Poisson distribution:
Pascal's Triangle
, k
Pr[X = k] = e k! ; E[X] = :
1
11
Normal (Gaussian) distribution:
121
p(x) = p 1 e, x, 2 = 2 ; E[X] = :
2
1331
The
\coupon
collector": We are given a
14641
random coupon each day, and there are n
1 5 10 10 5 1
di erent types of coupons. The distribu1 6 15 20 15 6 1
tion of coupons is uniform. The expected
number of days to pass before we to col1 7 21 35 35 21 7 1
lect all n types is
1 8 28 56 70 56 28 8 1
nHn:
1 9 36 84 126 126 84 36 9 1
1 10 45 120 210 252 210 120 45 10 1
1+

30

10

30

42

66

24

120

+1

11

25

137

49

363

761

7129

12

60

20

140

280

2520

1, 2, 6, 24, 120, 720, 5040, 40320, 362880,

^ = ,  ,:61803
Probability
Continuous distributions:Z If
b
Pr[a < X < b] = p(x) dx;
a
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 existZthen
a
P(a) =
p(x) dx:
,1
Expectation: If XX
is discrete
E[g(X)] = g(x) Pr[X = x]:
1

If X continuous
Z 1 then
Z1
E[g(X)] = g(x)p(x) dx = g(x) dP(x):
,1
,1
Variance, standard deviation:
VAR[X] = E[X ] , E[X] ;
p
 = VAR[X]:
Basics:
Pr[X _ Y ] = Pr[X] + Pr[Y ] , Pr[X ^ Y ]
Pr[X ^ Y ] = Pr[X]  Pr[Y ];
i X and Y are independent.
^Y]
Pr[X jY ] = Pr[X
Pr[B]
E[X  Y ] = E[X]  E[Y ];
i X and Y are independent.
E[X + Y ] = E[X] + E[Y ];
E[cX] = c E[X]:
Bayes' theorem:
jAi] Pr[Ai ]
Pr[AijB] = PnPr[B
Pr[A ] Pr[B jA ] :
2

=1

Inclusion-exclusion:
n
h _n i X
Pr
Xi = Pr[Xi ] +
i

=1

i
n
X

=1

(,1)k

+1

=1

X
ii <<ik

Pr

h ^k
j

Moment inequalities:


Pr jX j   E[X]  1 ;

=1

h
i

Pr X , E[X]      1 :
Geometric distribution:
Pr[X = k] = pk, q; q = 1 , p;
1
X
1
E[X] = kpqk, = p :
k
2

=1

Xij :

Theoretical Computer Science Cheat Sheet

Trigonometry

Multiplication:

C = A  B; ci;j =

(0,1)

(-1,0)

B
Pythagorean theorem:
C =A
De nitions:
sin a = A=C;
csc a = C=A;
sin a = A ;
tan a = cos
a B
2

(cos ; sin )
(1,0)

det A =

=
Permanents:

cos x = sec1 x ;

sin x + cos x = 1;
2

1 + cot x = csc x;
2

, 
sin x = cos  , x ;

sin x = sin( , x);

cos x = , cos( , x);

, 
tan x = cot  , x ;

cot x = , cot( , x);

csc x = cot x , cot x;

sin(x  y) = sinx cos y  cos x siny;


cos(x  y) = cos x cos y  sin x sin y;
x  tan y ;
tan(x  y) = 1tan
 tan x tany
cot
y1
cot(x  y) = cotxxcot
 cot y ;

sin 2x = 1 +2 tanx
tan x ;

sin 2x = 2 sin x cos x;

cos 2x = cos x , sin x;

cos 2x = 2 cos x , 1;
tan x
cos 2x = 1 , 2 sin x;
cos 2x = 11 ,
+ tan x ;
2 tanx ;
x , 1;
tan 2x = 1 ,
cot 2x = cot2 cot
x
tan x
sin(x + y) sin(x , y) = sin x , sin y;
2

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


Euler's equation:
eix = cos x + i sin x; ei = ,1:
c 1994 by Steve Seiden
2

n
XY

sign()ai; i :

[email protected]
http://www.ics.uci.edu/~sseiden

perm A =


b
e

ai; i :

=1

x ,x
cosh x = e +2e ;
1 ;
csch x = sinh
x
1 :
coth x = tanh
x

Identities:
cosh x , sinh x = 1;
tanh x + sech x = 1;
coth x , csch x = 1;
sinh(,x) = , sinh x;
cosh(,x) = cosh x;
tanh(,x) = , tanh x;
sinh(x + y) = sinh x cosh y + cosh x sinh y;
cosh(x + y) = cosh x cosh y + sinh x sinh y;
sinh 2x = 2 sinh x cosh x;
cosh 2x = cosh x + sinh x;
cosh x + sinh x = ex ;
cosh x , sinh x = e,x ;
(cosh x + sinh x)n = cosh nx + sinh nx; n 2 Z;
2 sinh x = cosh x , 1; 2 cosh x = cosh x + 1:
2

 sin  cos  tan 


0 0
p1
p0




6

3
2

p
p

2
2

2
3

2
2

2
1
2

p
3
1

A = hc;
= ab sin C;
A sin B :
= c sin
2 sin C
Heron's formula:
2
1
2

A = ps  sa  sb  sc ;
s = (a + b + c);
sa = s , a;
sb = s , b;
sc = s , c:
More identities:
r
x
sin = 1 , 2cos x ;
2

Hyperbolic Functions

De nitions:
x ,x
sinh x = e ,2 e ;
x e,x
tanh x = eex ,
+ e,x ;
1 ;
sech x = cosh
x

( )

 i

A
c
B
Law of cosines:
c = a +b ,2ab cos C:
Area:
1

aei + bfg + cdh


, ceg , fha , ibd:
n
XY

b h

( )

 i

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

cos a = B=C;
sec a = C=B;
a B
cot a = cos
sin a = A :

ai;k bk;j :

=1

2  2 and 3  3 determinant:
a b
c d = ad , bc;

Area, radius of inscribed circle:


AB; A +AB
B +C:

=1

+B :

Identities:
sin x = csc1 x ;
tan x = cot1 x ;
1 + tan x = sec x;

n
X

More Trig.
C

Determinants: det A = 0 i A is non-singular.


det A  B = det A  det B;

(0,-1)

Matrices

: : : in mathematics
you don't understand things, you
just get used to
them.
{ J. von Neumann

= 1 + 2cos x ;
r 1 , cos x
x
tan = 1 + cos x ;
x;
= 1 ,sincos
x
sin
= 1 + cosx x ;
r 1 + cos x
x
cot = 1 , cos x ;
= 1 +sincosx x ;
x ;
= 1 ,sincos
x
ix , e,ix
e
sin x =
2i ;
ix ,ix
cos x = e +2 e ;
ix e,ix
tan x = ,i eeix ,
+ e,ix ;
ix 1
= ,i ee ix ,
+ 1;
sin x = sinhi ix ;
cos x = cosh ix;
tan x = tanhi ix :
cos x
2

Theoretical Computer Science Cheat Sheet

Number Theory
The Chinese remainder theorem: There exists a number C such that:
C  r mod m
.. .. ..
. . .
C  rn mod mn
if mi and mj are relatively prime for i 6= j.
Euler's function: (x) is the number of
positive integersQnless than x relatively
prime to x. If i pei i is the prime factorization of x then
n
Y
(x) = pei i , (pi , 1):
1

=1

=1

Euler's theorem: If a and b are relatively


prime then
1  a b mod b:
Fermat's theorem:
1  ap, mod p:
The Euclidean algorithm: if a > b are integers then
gcd(a; b) = gcd(a mod b; b):
Q
If ni pei i is the prime factorization of x
then
n ei
X Y
S(x) = d = pip ,,1 1 :
( )

=1

+1

djx

=1

Perfect Numbers: x is an even perfect number i x = 2n, (2n , 1) and 2n , 1 is prime.


Wilson's theorem: n is a prime i
(n , 1)!  ,1 mod n:
Mobius 8
inversion:
if i = 1.
>
< 10
square-free.
(i) = > (,1)r ifif ii isis not
the
product
of
:
r distinct primes.
If
X
G(a) = F(d);
1

then

F(a) =

X
dja

dja

a

Prime numbers:
n
pn = n ln n + n lnln n , n + n lnln
ln
n
n
+ O ln n ;
2!n
(n) = lnnn + (lnnn) + (lnn)


+ O (lnnn) :
4

(d)G d :

Graph Theory
Notation:
De nitions:
E(G) Edge set
Loop
An edge connecting a verV (G) Vertex set
tex to itself.
c(G) Number of components
Directed
Each edge has a direction.
G[S] Induced subgraph
Simple
Graph with no loops or
deg(v) Degree of v
multi-edges.
(G) Maximum degree
Walk
A sequence v e v : : :e` v` .
(G) Minimum degree
Trail
A walk with distinct edges.
(G) Chromatic number
Path
A trail with distinct
E (G) Edge chromatic number
vertices.
Gc
Complement graph
Connected A graph where there exists
K
Complete graph
n
a path between any two
K
Complete bipartite graph
n
;n
1
2
vertices.
r(k;
`)
Ramsey number
Component A maximal connected
subgraph.
Geometry
Tree
A connected acyclic graph.
Projective coordinates: triples
Free tree
A tree with no root.
(x; y; z), not all x, y and z zero.
DAG
Directed acyclic graph.
(x; y; z) = (cx; cy; cz) 8c 6= 0:
Eulerian
Graph with a trail visiting
Cartesian
Projective
each edge exactly once.
Hamiltonian Graph with a path visiting
(x; y)
(x; y; 1)
each vertex exactly once.
y = mx + b (m; ,1; b)
Cut
A set of edges whose rex=c
(1; 0; ,c)
moval increases the numDistance formula, Lp and L1
ber of components.
metric:
p
Cut-set
A minimal cut.
(x , x ) + (x , x ) ;
Cut edge
A size 1 cut.
jx , x jp + jx , x jp =p;
k-Connected A graph connected with
jx , x jp + jx , x jp =p:
the removal of any k , 1
lim
p
!1
vertices.
k-Tough
8S  V; S 6= ; we have Area of triangle (x ; y ), (x ; y )
and (x ; y ):
k  c(G , S)  jS j.


k-Regular A graph where all vertices
x
,
x
y
,
y

abs x , x y , y :
have degree k.
k-Factor
A k-regular spanning
Angle formed by three points:
subgraph.
Matching A set of edges, no two of
(x ; y )
which are adjacent.
`
Clique
A set of vertices, all of

which are adjacent.
(0; 0) ` (x ; y )
Ind. set
A set of vertices, none of
which are adjacent.
cos  = (x ; y `) `(x ; y ) :
Vertex cover A set of vertices which
cover all edges.
Line through two points (x ; y )
Planar graph A graph which can be emand (x ; y ):
beded in the plane.
x y 1
Plane graph An embedding of a planar
x y 1 = 0:
graph.
x y 1
X
Area of circle, volume of sphere:
deg(v) = 2m:
v2V
A = r ; V = r :
If G is planar then n , m + f = 2, so
If I have seen farther than others,
f  2n , 4; m  3n , 6:
it is because I have stood on the
Any planar graph has a vertex with de- shoulders of giants.
gree  5.
{ Issac Newton
1

4
3

Theoretical Computer Science Cheat Sheet

Wallis' identity:
 = 2  21  23  43  45  65  67   

Brouncker's continued fraction expansion:


1
 =1+
2
2+
52
2

2+

2+ 2+72

Gregrory's series:
 = 1, + , + , 
Newton's series:
1 + 13 + 
=1+
2 232 2452
Sharp's series:


 = p1 1 , 1 + 1 , 1 +   
3 3 3 5 3 7
3
Euler's series:
4

2

=
=
2
 =
6

+
2+

+
2+
2, 2+
2

2

12

+
2+

+
2+
2, 2+
2

1
3

1
5

1
3

+
2 +
2

1
5

1
9

,

Partial Fractions
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(x) = Q(x) + N 0(x) ;
D(x)
D(x)

where the degree of N 0 is less than that of


D. Second, factor D(x). Use the following rules: For a non-repeated factor:
N(x) = A + N 0 (x) ;
(x , a)D(x) x , a D(x)
where

 N(x) 

A = D(x)
:
x a
For a repeated factor:
mX
,
N(x)
Ak + N 0 (x) ;
=
m
(x , a) D(x)
(x , a)m,k D(x)

Calculus

Derivatives:
du
dv
d(uv)
dv du
2. d(udx+ v) = du
1. d(cu)
dx = c dx ;
dx, + dx ; ,  3. dx = u dx + v dx ;
du
dv
n)
d(ecu ) = cecu du ;
n, du ; 5. d(u=v) = v dx , u dx ;
4. d(u
=
nu
6.
dx
dx
dx
v
dx
dx
u
u) 1 du
7. d(cdx ) = (ln c)cu du
8. d(ln
dx ;
dx = u dx ;
d(cos u) = , sin u du ;
u) = cos u du ;
10.
9. d(sin
dx
dx
dx
dx
d(tan
u)
du
d(cot
u)
12. dx = csc u du
11. dx = sec u dx ;
dx ;
du
u)
du
u)
14. d(csc
13. d(sec
dx = tan u sec u dx ;
dx = , cot u csc u dx ;
u)
1 du
u) = p ,1 du ;
15. d(arcsin
16. d(arccos
dx = p1 , u dx ;
dx
1 , u dx
u) = 1 du ;
d(arccot u) = ,1 du ;
17. d(arctan
18.
dx
1 , u dx
dx
1 , u dx
1

where

=0

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

u) = p,1 du ;
20. d(arccsc
dx
u 1 , u dx
u)
du
22. d(cosh
dx = sinh u dx ;

u) = p 1 du ;
19. d(arcsec
dx
u 1 , u dx
u)
du
21. d(sinh
dx = cosh u dx ;
2

u)
du
23. d(tanh
dx = sech u dx ;

u)
du
24. d(coth
dx = , csch u dx ;

u)
du
25. d(sech
dx = , sech u tanh u dx ;
u) = p 1
27. d(arcsinh
dx

u)
du
26. d(csch
dx = , csch u coth u dx ;

du ;
1 + u dx
d(arctanh
u)
1 du ;
29.
=
dx
1 , u dx
u) = p,1 du ;
31. d(arcsech
dx
u 1 , u dx
Integrals:

u) = p 1
28. d(arccosh
dx

du ;
u , 1 dx
d(arccoth
u)
1 du ;
30.
=
dx
u , 1 dx
u) = p,1 du :
32. d(arccsch
dx
juj 1 + u dx

1.
3.

6.
8.

xn dx =

Z 1
4. x dx = ln x;
Z dv

1 n
n + 1 x ; n 6= ,1;
+1

Z dx
1 + x = arctan x;
Z

10.
12.
14.

7.

Z
Z
Z

2. (u + v) dx = u dx + v dx;

cu dx = c u dx;

5.

9.

13.

sec x dx = ln j sec x + tan xj;

arcsin xa dx = arcsin xa + a , x ; a > 0;


2

ex dx = ex ;

Z
u dx dx = uv , v du
dx dx;

sin x dx = , cos x;

tan x dx = , ln j cos xj;

11.

cos x dx = sin x;

cot x dx = ln j cos xj;

csc x dx = ln j csc x + cot xj;

Theoretical Computer Science Cheat Sheet


15.
17.
19.
21.
23.
25.
26.
29.
33.
36.

Z
Z
Z
Z
Z
Z
Z
Z
Z
Z

Calculus Cont.

arccos xa dx = arccos xa ,

16.

a , x ; a > 0;

arctan xa dx = x arctan ax , a ln(a + x ); a > 0;


2

18.

sin (ax)dx = a ax , sin(ax) cos(ax) ;


2

39.

40.

Z
Z

43.
46.
48.
50.
52.

Z
Z
Z
Z

20.

csc x dx = , cot x;
2

Z
n,
n, x sinx n , 1 Z
1 Z sinn, x dx;
n x dx = cos
sinn x dx = , sin nx cos x + n ,
22.
cos
+ n
cosn, x dx;
n
n
Z
n, x Z
n, x Z
tan
cot
n
n
,
n
24. cot x dx = , n , 1 , cotn, x dx; n 6= 1;
tan x dx = n , 1 , tan x dx; n 6= 1;
n, x n , 2 Z
n,
sec n x dx = tan xnsec
, 1 + n , 1 sec x dx; n 6= 1;
Z
Z
n, x n , 2 Z
n, x dx; n 6= 1; 27. sinh x dx = cosh x; 28. cosh x dx = sinh x;
+
csc
csc n x dx = , cot xncsc
,1
n,1
1

tanh x dx = ln j cosh xj; 30.

coth x dx = ln j sinh xj; 31.

arcsinh xa dx = x arcsinh xa ,

34.

sinh x dx = sinh(2x) , x;
2

sech x dx = arctan sinh x; 32.


1

37.

x + a ; a > 0;
2

= ln x + a + x ; a > 0;
a +x
dx
x
a + x = a arctan a ; a > 0;
2

41.

2 3 2

a4 arcsin x ;
a

a > 0;

Zp

51.

x x  a dx = (x  a ) ;
2

1
3

2 3 2

arctanh xa dx = x arctanh xa + a ln ja , x j;

sech x dx = tanh x;

a , x dx = x a , x + a2 arcsin ax ; a > 0;

dx = 1 ln x ;
ax + bx a a + bx
p
a + bx dx = 2pa + bx + a Z p 1 dx;
x a +pbx

p x
a , x dx = pa , x , a ln a + a , x ;


x
x
2

Z
1 ln a + x ;
p dx = arcsin ax ; a > 0;
44. a dx
=
, x 2a a , x
a ,x


p
p
p
a  x dx = x a  x  a2 ln x + a  x ;
47.
8

csch x dx = ln tanh x ;

35.

cosh x dx = sinh(2x) + x;
2

Z p
p
54. x a , x dx = x (2x , a ) a , x + a4 arcsin xa ; a > 0;
Z
Z x dx
p
56. pa , x = , a , x ;
57.


p
p
Z a +x
Z
a + a + x
p
58.
dx
=
a
+
x
,
a
ln
;
59.




x
Z px
=
60.

sec x dx = tan x;

42. (a , x ) = dx = x (5a , 2x ) a , x +

cos (ax)dx = a ax + sin(ax) cos(ax) ;


2

p
8
<
x arccosh xa , x + a ; if arccosh xa > 0 and a > 0,
38. arccosh xa dx = :
p
x arccosh xa + x + a ; if arccosh xa < 0 and a > 0,
Z dx

 p
Z

49.

45.

p dx
Z xp , a
2

dx
x
p
;
=
=
(a , x )
a a ,x
p

= ln x + x , a ; a > 0;
2

3 2

+ bx) ;
x a + bxdx = 2(3bx , 2a)(a
15b
3 2

pa

x
1
a
+
bx
,

; a > 0;
p
dx = p ln p
a + bx
a + bx + pa
2
Z p
53. x a , x dx = , (a , x ) = ;
2

2 3 2



55. p dx = , a ln a + ax , x ;
a ,x
p
x
dx
p
= , x a , x + a2 arcsin a;x a > 0;
pa , x
x , a dx = px , a , a arccos a ; a > 0;
jxj
x
2

61.

p dx

x x +a
2

= a ln


;
a+ a +x
px

Theoretical Computer Science Cheat Sheet

62.
64.
66.

Z
Z

Calculus Cont.

p dx = a arccos jaxj ; a > 0;


p dx
63.
=  xa x a ;
x x ,a
Z pxx  ax  a (x + a ) =
p
x
dx
p
65.
dx =  3a x ;
= x a ;
x a

8
p x
>
+ b , pb , 4ac ; if b > 4ac,
>
< pb ,1 4ac ln 2ax
dx
2ax + b + b , 4ac
=
ax + bx + c >
>
: p 2 arctan p2ax + b ;
if b < 4ac,
4ac , b
4ac , b
8 1
papax + bx + c ; if a > 0,
>
p
ln
2ax
+
b
+
2


<
a
p dx
=
ax + bx + c >
: p1,a arcsin p,b2ax, ,4acb ;
if a < 0,
Z
p
p
ax + bx + c dx = 2ax + b ax + bx + c + 4ax , b p dx
;
1

3 2

Finite Calculus
Di erence, 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

67.
68.
69.
70.
71.
72.
73.
74.

4a

8a

Z
x
dx
ax
+
bx
+
c
b
p
=
, 2a p dx
;
a
ax + bx + c
ax + bx + c
p

ax + bx + c

8 ,1 2pcpax + bx + c + bx + 2c
>
; if c > 0,
>
< pc ln

x
dx
p
=>
x ax + bx + c > 1
: p,c arcsin jxjpbxb+,2c4ac ;
if c < 0,
p
x x + a dx = ( x , a )(x + a ) = ;
Z
2

Z
Z
Z
Z

2 3 2

xn sin(ax) dx = , a xn cos(ax) + na xn, cos(ax) dx;


xneax dx =

sin(ax) dx;

+1

 ln(ax)

+1

=
=
=
=
=

x
x
x
x
x

=
x
=
x +x
=
x + 3x + 2x
=
x + 6x + 11x + 6x
= x + 10x + 35x + 50x + 24x

2
3
4
5

1
2
3
4
5

x
x +x
x + 3x + x
x + 6x + 7x + x
x + 15x + 25x + 10x + x

=
=
=
=
=

x
x
x
x
x

+1

x ,x
x , 3x + x
x , 6x + 7x , x
x , 15x + 25x , 10x + x
2

=
x
=
x ,x
=
x , 3x + 2x
=
x , 6x + 11x , 6x
= x , 10x + 35x , 50x + 24x
1

=1

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


n
X n
xn =
(,1)n,k xk ;
k
k
n n
X
n
x =
xk :
k
k
+

x
x
x
x
x

xn ln(ax) dx = xn

Di erences:
(cu) = cu;
(u + v) = u + v;
(uv) = uv + E vu;
(xn) = nxn, ;
(Hx ) = x, ;
(2x ) = 2x ;
,
 , 
(cx ) = (c , 1)cx ;
 mx = mx, :
Sums:
P cu x = c P u x;
P(u + v) x = P u x + P v x;
P uv x = uv , P E vu x;
P x, x = H ;
P xn x = xn+1 ;
x
m
P, x  x = , x :
P cx x = cx ;
c,
m
m
Falling Factorial Powers:
xn = x(x , 1)    (x , m + 1); n > 0;
x = 1;
xn = (x + 1)  1 (x + jnj) ; n < 0;
xn m = xm (x , m)n :
Rising Factorial Powers:
xn = x(x + 1)    (x + m , 1); n > 0;
x = 1;
xn = (x , 1)  1 (x , jnj) ; n < 0;

1
,
n + 1 (n + 1) ;
Z
Z
n
76. xn(ln ax)m dx = nx + 1 (ln ax)m , n m+ 1 xn(ln ax)m, dx:

75.

f(i):

n
n,
n
a x sin(ax) , a x
xn eax , n Z xn, eax dx;
a
a

xn cos(ax) dx =

i a

15

b,
X

+1

f(x)x =

=1

=1

=1

Theoretical Computer Science Cheat Sheet


Series

Taylor's series:
1
i
X
f(x) = f(a) + (x , a)f 0 (a) + (x ,2 a) f 00 (a) +    = (x ,i! a) f i (a):
i
Expansions:
1
X
1
=
1
+
x
+
x
+
x
+
x
+



=
xi ;
1,x

Ordinary power series:

A(x) =

( )

=0

=0

1
X

= 1 + cx + c x + c x +   

1 , cx
1
1 , xn
x
(1 , x)
 1 
dn
xk dx
n 1,x

ci xi ;

1
X

=0

=0

= 1 + xn + x n + x n +   
2

= x + 2x + 3x + 4x +   
2

=
=

xni;

1
X

=1

=0

ixi ;

1
X
n
=0

= x + 2n x + 3nx + 4n x +    =
2

i xi ;

= 1+x+ x + x +
1

1 xi
X
i

=0

= x, x + x , x ,

ln(1 + x)

ln 1 ,1 x

= x+ x + x + x +

sin x

= x, x + x , x +

cos x

= 1, x + x , x +

3!

5!

7!

=
=

xn , yn = (x , y)

i! ;

1
X

(,1)i

+1

xi

i;

1 xi
X
i

=1

1
X
=1

i;

2!

4!

6!

i
= (,1)i (2ix + 1)! ;
i
1
X
xi;
= (,1)i (2i)!
i1
X
xi ;
= (,1)i (2i
i   + 1)
1 n
X
=
xi ;
i
i 
1 i + n
X
=
xi ;
i
i
1
i
X
= Bi!i x ;
i
1 1 2i
X
= i + 1 i xi ;
i  
1 2i
X
=
xi ;
i
i 
1 2i + n
X
=
xi ;
i
i
2 +1

=0

tan, x

= x, x + x , x +

= 1 + nx + n n, x +   
(

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

+1

2 +1

A(x) + B(x) =
xk A(x) =

= 1, x+ x ,
1

12

720

x +
4

=0

= 1 + x + 2x + 5x +   
2

=0

= 1 + x + 2x + 6x +   
2

= 1 + (2 + n)x +

, nx +   
4+

=0

1
X
=0

= x+ x + x + x + =
3

11

25

12

Hi xi ;

1 H xi
X
i,
=1

= x + x + x +
1

11

24

1
X
=2

= x + x + 2x + 3x +   
2

1
X

Fi xi;

=0

= Fnx + F nx + F nx +    =
2

=0

xn, ,kyk :
1

=0

1
X

( ai + bi )xi ;

1
X

Fnixi :

ai,k xi;

i
P
1
k
,
i
A(x) , i aix = X
ai,k xi ;
xk
1 i
X
i i
=0

=0

=0

A(cx) =

c ai x ;

1
X
=0

A0 (x) =

(i + 1)ai xi;
+1

1
X
=0

=0

=0

1 (1 , p1 , 4x)
2x
p 1
1 , 4x
p

n
1
1
,
1
,
4x
p
2x
1 , 4x
1
1
1 , x ln 1 , x
1 ln 1 
2 1,x
x
1,x,x
Fn x
1 , (Fn, + Fn )x , (,1)n x
+1

1
(1 , x)n
x
ex , 1

1)

For ordinary power series:

=0

(1 + x)n

nX
,

=0

=0

=0

Di erence of like powers:

=0

ex

aixi :

Exponential power series:


1
i
X
A(x) = ai xi! :
i
Dirichlet power series:
1
X
A(x) = iaxi :
i
Binomial theorem: 
n n
X
n,k k
(x + y)n =
k x y:

=0

1
X

xA0 (x) =

iai xi;

1 a
X
i,
=1

A(x) dx =

i
i x;
1

1
A(x) + A(,x) = X
a ix i;
2
i
X
A(x) , A(,x) 1
i
=1

=0

= ai x :
2
i
P
Summation: If bi = ij ai then
B(x) = 1 ,1 x A(x):
Convolution: 0
1
2 +1

2 +1

=0

=0

A(x)B(x) =

1 X
i
X
@
i

=0

aj bi,j A xi:

=0

God made the natural numbers;


all the rest is the work of man.
{ Leopold Kronecker

Theoretical Computer Science Cheat Sheet


Series

Expansions:
n + i
1
X
1
1
i
(1 , x)n ln 1 , x = (Hn i , Hn) i x ;
+1

 1 ,n

1 n
X
=
xi ;
i
i  
1 i n!xi
X
=0

xn

n
1
ln 1 , x

n i! ;
1
iB ix i
X
= (,4)(2i)!
;
i
1 1
X
= ix ;
i
1
X
= (i)
ix ;
i
=

=0

=0

=0

=1

=1

(x)(x , 1)

=1

1 S(i)
X
=1

P
where S(n) = djn d;

xi
n, jB nj
= 2 (2n)!
 n; n 2 N;
1
i 2)B ix i
X
= (,1)i, (4 ,(2i)!
;
i
1
X
= n(2ii!(n+ +n ,i)!1)! xi ;
i
1 2i= sin i
X
=
xi ;
i!
i
i

=1
2

(2n)
x
sin x
 1 , p1 , 4x n
2x

Z b,

Zb
Zb

G(x) + H(x) dF(x) = G(x) dF(x) + H(x) dF (x);
a
a
Zb
Zab
,
 Zb

=0

Zb
a

1
X

p (4i)!
=
xi ;
i
16
2(2i)!(2i
+
1)!
i
1
X
4i i!
= (i + 1)(2i
x i:
+
1)!
i
Crammer's Rule
If we have equations:
a ; x + a ; x +    + a ;nxn = b
a ; x + a ; x +    + a ;nxn = b
..
..
..
.
.
.
an; x + an; x +    + an;nxn = bn
Let A = (ai;j ) and B be the column matrix (bi ). Then
there is a unique solution i det A 6= 0. Let Ai be A
with column i replaced by B. Then
Ai
xi = det
det A :
=0

Zb
a

=0

1 2

2 1

2 2

Improvement makes strait roads, but the crooked


roads without Improvement, are roads of Genius.
{ William Blake (The Marriage of Heaven and Hell)

G(x) dF(x) +

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

Z ab
a
b

G(x) dH(x);

G(x) dF(x);

G(x) dF(x) = G(b)F(b) , G(a)F (a) , F (x) dG(x):


a
If the integrals involved exist, and F possesses a derivative F 0 at every
point in [a; b] then

Zb

1 1

c  G(x) dF(x) =

Zb

1, 1,x
x
 arcsin x 
x

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

=0

=1

exists. If a  b  c then
Zc
Zb
Zc
G(x) dF(x) = G(x) dF(x) + G(x) dF (x):
a
a
b
If the integrals involved exist

ex sin x

x cot x
n i! ;
i
1
i i 1)B i x i,
X
= (,1)i, 2 (2 ,(2i)!
; (x)
i
1
X
(x , 1)
= (i)
;
x
i
(x)
i
Y
1
= 1 , p,x ;
Stieltjes Integration
p
If G is continuous in the interval [a; b] and F is nondecreasing then
1 d(i)
X
Zb
P
=
G(x) dF(x)
xi where d(n) = djn 1;
1

 (x)

=0

=1

1
(x)
(x)

=0

(ex , 1)n

tanx

1 i
X
=
xi ;
n
i  
1 i n!xi
X

Escher's Knot

G(x) dF(x) =

47

18

76

29

93

85

34

61

52

86

11

57

28

70

39

94

95

80

22

67

38

71

49

45

63

56

13

59

96

81

33

48

73

69

90

82

44

17

72

60

24

15

58

35

68

74

91

83

55

26

27

12

46

30

37

75

19

92

84

66

23

50

41

14

25

36

40

51

62

77

88

99

21

32

43

54

65

10

89

97

78

42

53

64

16

20

31

98

79

87

The Fibonacci number system:


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

Zb
a

G(x)F 0(x) dx:


Fibonacci Numbers

1; 1; 2; 3; 5;8; 13; 21; 34; 55; 89; : : :


De nitions:
Fi = Fi, +Fi, ; F = F = 1;
i,
F,i = (,
 1)i ^Fii;
Fi = p  ,  ;
Cassini's identity: for i > 0:
Fi Fi, , Fi = (,1)i :
Additive rule:
Fn k = Fk Fn + Fk, Fn;
F n = FnFn + Fn, Fn:
Calculation
 F F by matrices:
 n
n,
n, = 0 1 :
F
F
1 1
1

+1

+1

+1

n,

You might also like