Docstoc

Theoretical Computer Science Cheatsheet

Document Sample
Theoretical Computer Science Cheatsheet Powered By Docstoc
					CS161: Data Structures and Algorithms                            Handout # 6
Stanford University                                  Tuesday, 18 January 2000

   The following is a copy of the Theoretical Computer Science Cheat Sheet by
Seiden, from the December 1996 issue of ACM Sigact News.
                                                   Theoretical Computer Science Cheat Sheet
                          De nitions                                                                                   Series
f(n) = O(g(n))             i 9 positive c n such that                X
                                                                     n                           X
                                                                                                 n                                     X
                                                                                                                                       n
                                                                                    +
                                                                             i = n(n2 1)               i = n(n + 1)(2n + 1)                 i = n (n4+ 1) :
                                               0

                           0 f(n) cg(n) 8n n .
                                                                                                                                                         2       2
                                                                                                         2                                      3
                                                           0

                                                                     i                           i                6                       i
f(n) = (g(n))              i 9 positive c n such that
                                               0
                                                                      =1

                                                                    In general:
                                                                                                  =1                                       =1



                           f(n) cg(n) 0 8n n .                      Xm
                                                                    n                                                      X;
                                                                                                                           n
                                                                            i = m 1 1 (n + 1)m ; 1 ;
                                                           0



f(n) = (g(n))              i f(n) = O(g(n)) and                                   +
                                                                                                         +1
                                                                                                               (i + 1)m ; im ; (m + 1)im
                                                                                                                                     +1         +1



                           f(n) = (g(n)).                            i
                                                                     =1                                  i                 =1



f(n) = o(g(n))             i limn!1 f(n)=g(n) = 0.
                                                                    Xm 1 X
                                                                    n;   1            m m+1
                                                                                                        m ;k :
                                                                            i = m+1            k Bk n
                                                                                                                           +1



  lim a = a                i 8 2 R, 9n such that                     i               k
 n!1 n
                                                                     =1                     =0
                                           0

                           jan ; aj < , 8n n .                      Geometric series:
                                                       0
                                                                       X i cn ; 1
                                                                         n         +1                Xi 1 Xi c
                                                                                                      1                 1
       sup S               least b 2 R such that b s,                        c = c;1        c 6= 1      c = 1;c            c = 1;c c < 1
                           8s 2 S.                                     i                             i                 i
                                                                    X i ncn ; (n + 1)cn + c                          X i
                                                                      =0                                              =0             =1

                                                                      n                                               1          c
       inf S               greatest b 2 R such that b                                                      c 6= 1
                                                                                   +2                        +1

                                                                           ic =        (c ; 1)                           ic = (1 ; c) c < 1:
                           s, 8s 2 S.                               i
                                                                    =0
                                                                                                     2
                                                                                                                     i           =0
                                                                                                                                                             2




  lim inf an                lim inf fai j i n i 2 Ng.               Harmonic series:
                                                                                     Xn            X
                                                                                                   n
                                                                                                     iHi = n(n2 1) Hn ; n(n4; 1) :
   n!1                     n!1
                                                                                Hn = 1    i
                                                                                                                 +
  lim sup an                  lim supfai j i n i 2 Ng.
                              n!1                                                       i                    i
      n!1
        ;n                                                          X                     X i
                                                                                         =1                  =1

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




        n              Stirling numbers (1st kind):                                           X n n
                                                                                                n
        k
                       Arrangements of an n ele-                    1. n = (n ;n!
                                                                       k          k)!k!   2.       k =2      3. n = n ; k
                                                                                                                k
                                                                                                                       n
                       ment set into k cycles.                                                k
                                                                              ;1                        5. n = n ; 1 + n ; 1          ;1
                                                                                                                      =0



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


        n
        k              2nd order Eulerian numbers.                    k                k                            11. n = n = 1
                                                                                                                           1      n
       Cn              Catlan Numbers: Binary
                       trees with n + 1 vertices.            12. n = 2n; ; 1
                                                                      2
                                                                                        1
                                                                                                     13. n = k n ; 1 + n ; 1
                                                                                                           k             k         k
                                                                                                                                      ;1

14.    n = (n ; 1)!                     15. n = (n ; 1)!Hn;                           16. n = 1                        17. n         n
       1                                         2                            1
                                                                                             n                               k       k
       n = (n ; 1) n ; 1 + n ; 1                                                              X n
                                                                                                n
18.    k                 k         k;1
                                                          n
                                                  19. n ; 1 = n ; 1 = n n
                                                                                 2       20.        k = n! 21. Cn = n + 1 n
                                                                                                                               1 2n
                                                                                              k
        n = n =1                                   n =          n                         n = (k + 1) n ; 1 + (n ; k) n ; 1
                                                                                                                  =0


22.     0       n;1                       23. k             n;1;k                   24. k                     k                  k;1
25.     0 = n 1 if k = 0,                           26. 1 n = 2n ; n ; 1                      27. 2   n = 3n ; (n + 1)2n + n + 1
        k       0 otherwise                                                                                                       2
            X n x+k
              n                                   n = X n + 1 (m + 1 ; k)n(;1)k
                                                         m                                                  n =X n     n          k
28.   xn =        k      n              29. m                   k                                  30. m! m                k n;m
            k                                           k                                                            k
                X n n;k
                n
               =0                                              =0                                                                          =0



31.     n                               n;k;m k!                        32. n = 1                          33. n = 0 for n 6= 0
        m =k k               m (;1)                                           0                                     n
                                                                                                                    X n (2n)n
                                                                                                                      n
                    =0



34.     n = (k + 1) n ; 1 + (2n ; 1 ; k) n ; 1                                                                 35.
         k                   k                          k;1                                                         k      k = 2n
           x = X n x+n;1;k
                     n                                                                         X n k X k           n
                                                                                                                                          =0



36.     x;n               k           2n
                                                                                   n
                                                                           37. m + 1 =
                                                                                     +1              k m       =         m (m + 1)
                                                                                                                                    n;k
                   k     =0                                                                      k               k                    =0
                                                             Theoretical Computer Science Cheat Sheet
                                                                Identities Cont.                                                                                                        Trees
            X n k X k n;k X 1 k
                       n            n                                                                                                    X n
                                                                                                                                         n                                       Every tree with n
    n
38. m + 1 =
      +1       k m   =   m  n = n! k! m                                                                                 x
                                                                                                                  39. x ; nk
                                                                                                                                x+k
                                                                                                                                 2n    =                                         vertices has n ; 1
    n     X k n k + 1 k n;k       k                 =0                        =0

                                                                                                           n
                                                                                                                      k
                                                                                                                 X n+1 k           m;k
                                                                                                                                           =0
                                                                                                                                                                                 edges.
40. m =                (;1)                                                                           41. m =       k + 1 m (;1)                                                 Kraft inequal-
            k k m+1                                                                                               k                                                              ity: If the depths
                 X
                 m                                                                                       m + n + 1 = X k(n + k) n + k
                                                                                                                     m
         n
42. m +m + 1 = k n + kk                                                                             43.     m                     k
                                                                                                                                                                                 of the leaves of
                                                                                                                                                                                 a binary tree are
    n =    X n +k 1 k                                          k
                           m;k 45. (n ; m)! n = X n + 1 k (;1)m;k for n m,
                               =0                                                                                                      =0
                                                                                                                                                                                 d :n: : dn:
44. m                 (;1)
                                                                                                                                                                                  1
                                                                                                                                                                                    X ;di
           k k+1 m                          m      k k+1 m                                                                                                                              2      1
       n      X m;n m+n m+k                      n     X m;n m+n m+k            i
46. n ; m =       m+k n+k       k         47. n ; m =       m+k n+k     k
                                                                                                                                                                                      =1



               k                                       k                     and equality holds
      n
48. ` + m    `+m = X k n;k n                        n
                                             49. ` + m ` + m = X k n ; k n : only if every in-
              `         `    m    k                       `      ` m      k  ternal node has 2
                                         k                                                                                             k                                         sons.
                                                                                           Recurrences
 Master method:                                                                        ;
                                                                           1 T(n) ; 3T(n=2) = n
                                                                                                                                                Generating functions:
 T (n) = aT(n=b) + f(n) a 1 b > 1                                           ;                                                                     1. Multiply both sides of the equa-
 If 9 > 0 such that f(n) = O(n b a; )             log                      3 T(n=2) ; 3T (n=4) = n=2                                                 tion by xi .
 then                                                                       .. .. ..                                                              2. Sum both sides over all i for
            T (n) = (n b a ):                                                . . .                                                                   which the equation is valid.
                                   log


                                                                   3    log
                                                                             ;
                                                                       2 n; T(2) ; 3T(1) = 2
                                                                                   1                                                              3. Choose a generatingPfunction
 If f(n) = (n b a ) then
                   log
                                                                             ;
                                                                      3 2 n T(1) ; 0 = 1                                                             G(x). Usually G(x) = 1 xi.
                                                                                                                                                                              i
         T(n) = (n b a log n):
                                                                          log                                                                                                                              =0
                             log
                                             2                                                                                                    3. Rewrite the equation in terms of
 If 9 > 0 such that f(n) = (n b a ),              log    +       Summing the left side we get T(n). Sum-                                             the generating function G(x).
 and 9c < 1 such that af(n=b) cf(n)                              ming the right side we get                                                       4. Solve for G(x).
 for large n, then                                                                Xn n i
                                                                                   2         log
                                                                                                                                                  5. The coe cient of xi in G(x) is gi .
             T(n) = (f(n)):                                                            i3 :                                                     Example:
                                                                                  i 2           =0                                                     gi = 2gi + 1 g = 0:
                                                                                                                                                           +1                              0

 Substitution (example): Consider the                            Let c = and m = log n. Then we have                                            Multiply and sum:
                                                                                                                                                   X i X i X i
                                                                              3

 following recurrence                                               Xm        2
                                                                              m
                                                                                                             2

                   i
                                                                  n ci = n c c ; ; 1                                                                   gi x = 2gi x + x :
                                                                                                 +1

         Ti = 2 Ti T = 2:
          +1
                       2      2
                                         1
                                                                                  1                                                                i
                                                                                                                                                           +1

                                                                                                                                                                             i                     i
                                                                    i
                                                                                                                                                                  P
                                                                                                                                                       0                         0                         0

 Note that Ti is always a power of two.
                                                                     =0



 Let ti = log Ti . Then we have                                                = 2n(c c 2 n ; 1)    log
                                                                                                                                                We choose G(x) = i xi. Rewrite
                                                                                                                                                in terms of G(x):
                                                                                                                                                                                           0


         ti = 2i + 2ti t = 1:                                                  = 2n(c ck c n ; 1)
               2

          +1                             1
                                                                                                     log

                                                                                                                                                     G(x) ; g       X i
 Let ui = ti =2i. Dividing both sides of                                       = 2nk ; 2n 2n :
                                                                                            +1                          1 58496
                                                                                                                                   ; 2n                    x
                                                                                                                                                                    0
                                                                                                                                                                         = 2G(x) +                         x:
                                                                                                                                                                                               i
 the previous equation by 2i we get          +1
                                                                 where k = (log ); . Full history recur-
                                                                                              3          1
                                                                                                                                                                                                       0



            ti = 2i + ti :                                                                  2 2

                                                                 rences can often be changed to limited his-                                    Simplify:
                                                                                                                                                        G(x) = 2G(x) + 1 :
               +1

            2i +1
                     2i    2i +1
                                                                 tory ones (example): Consider the follow-
 Substituting we nd                                              ing recurrence                                                                           x             1;x
       ui = + ui   1
                           u = 12                                                  X
                                                                                   i;                1
                                                                                                                                                Solve for G(x):
                                                                                                                                                                     x
                                                                         Ti = 1 + Tj T = 1:
        +1         2                     1



 which is simply ui = i=2. So we i;1   nd                                                       j   =0
                                                                                                                        0
                                                                                                                                                       G(x) = (1 ; x)(1 ; 2x) :
 that Ti has the closed form Ti = 2 i .
                                                                 Note that                                                                      Expand this using partial fractions:
                                                        2


 Summing factors (example): Consider                                                                          X
                                                                                                              i                                                  2        1
 the following recurrence                                                              Ti = 1 +                        Tj :                        G(x) = x 1 ; 2x ; 1 ; x
                                                                                                                                                               0           1
                                                                                           +1

        Ti = 3Tn= + n T = n:                                                                                  j
                                                                                                                                                                 X i i X iA
                         2               1                                                                        =0



 Rewrite so that all terms involving T                           Subtracting we nd                                                                         = x @2 2 x ; x
 are on the left side                                                             Xi      X
                                                                                          i;
                                                                                                                                                             X ii        i
                                                                                                                                   1


             Ti ; 3Tn= = n:                                         Ti ; Ti = 1 + Tj ; 1 ; Tj                                                                                    0                     0


                                                                                                                                                                       i
                                                                         +1
                               2
                                                                                                     j   =0                   j   =0                       =            (2   +1
                                                                                                                                                                                     ; 1)x :   +1


 Now expand the recurrence, and choose                                     = Ti :                                                                               i   0

 a factor which makes the left side \tele-
 scope"                                                          And so Ti = 2Ti = 2i .
                                                                                   +1
                                                                                                              +1                                So gi = 2i ; 1.
                                           Theoretical Computer Science Cheat Sheet
                                                                                  p                                                                   p
                 3:14159,      e 2:71828,               0:57721,            =        1:61803,           ^= ;        1+
                                                                                                                          ;:61803
                                                                                                                          2
                                                                                                                               5                  1
                                                                                                                                                      2
                                                                                                                                                           5




   i               2i           pi                        General                                          Probability
  1                2            2     Bernoulli Numbers (Bi = 0, odd i 6= 1):           Continuous distributions: If   Zb
  2                4            3        B = 1, B = ; , B = , B = ; ,
                                             0             1
                                                                            1
                                                                            2            2
                                                                                                 Pr a < X < b] = p(x) dx
                                                                                                 1
                                                                                                 6         4
                                                                                                                          1
                                                                                                                          30

  3                8            5            B = ,B =; ,B = .
                                                           1                             1                      5
                                                                                                                         a
                                                                                        then p is the probability density function of
                                                  6       42        8                    30          10        66

  4               16            7     Change of base, quadratic formula:
                                                                       p                X. If
  5               32           11                  loga x
                                         logb x = log b          ;b b ; 4ac :                         Pr X < a] = P(a)
                                                                                                           2



  6               64           13                      a                2a              then P is the distribution function of X. If
  7              128           17     Euler's number e:                                 P and p both existZthen
  8              256           19            e = 1+ + + + +    1            1            1           1
                                                                                                                   a
                                                              x
                                                               2
                                                                  n
                                                                            6            24      120
                                                                                                     P (a) =          p(x) dx:
  9              512           23                  lim 1 + n = ex :                                               ;1
 10             1,024          29             ;1 +n!1 < e < ;1 + n :
                                                       n   1
                                                                                        Expectation: If XX discrete
                                                                                                     1
                                                                                                           +1
                                                                                                                is
 11             2,048          31                    n                n                         E g(X)] = g(x) Pr X = x]:
 12             4,096          37
                                       ;1 + n = e ; e + 11e ; O 1 :
                                                  1                                                             x
                                              n            2n 24n             n         If X continuous then
 13             8,192          41
                                                                                                 2
                                                                                                     Z1               3
                                                                                                                            Z1
                                      Harmonic numbers:                                 E g(X)] = g(x)p(x) dx = g(x) dP (x):
 14            16,384          43       1, , , , , , , ,
                                              3   11      25   137
                                                                                 :::
                                                                                49       363      761
                                                                                                      ;1       7129
                                                                                                                              ;1
 15            32,768          47             2       6   12       60           20
                                                                                        Variance, standard deviation:
                                                                                         140         280       2520



 16            65,536          53                 lnn < Hn < ln n + 1                             VAR X] = E X ] ; E X]                                        2       2



 17            131,072         59                                       1 :                                       p
                                                Hn = ln n + + O n                                             = VAR X]:
 18            262,144         61                                                       Basics:
 19            524,288         67     Factorial, Stirling's approximation:                Pr X _ Y ] = Pr X] + Pr Y ] ; Pr X ^ Y ]
 20           1,048,576        71                                               :::
                                            1, 2, 6, 24, 120, 720, 5040, 40320, 362880,   Pr X ^ Y ] = Pr X] Pr Y ]
 21           2,097,152        73                p            n                                      i X and Y are independent.
                                            n! = 2 n n 1 + n :            1
                                                                                                              X^
 22           4,194,304        79                          e                                Pr X jY ] = PrPr B]Y ]
 23           8,388,608        83     Ackermann's function and inverse:
                                                  8j                                        E X Y ] = E X] E Y ]
 24          16,777,216        89                 <2                        i=1
 25          33,554,432        97      a(i j) = : a(i ; 1 2)                j=1                      i X and Y are independent.
 26          67,108,864        101                   a(i ; 1 a(i j ; 1)) i j 2             E X + Y ] = E X] + E Y ]
 27         134,217,728        103         (i) = minfj j a(j j) ig:                            E cX] = c E X]:
 28         268,435,456        107    Binomial distribution:                            Bayes' theorem:
 29         536,870,912        109     Pr X = k] = n pk qn;k             q = 1;p             Pr AijB] = PnPr PrjAi]]Pr Aij]A ] :
                                                                                                                     B
                                                                                                                         Aj Pr B j
 30        1,073,741,824       113                       k                                                      j
                                                       X
                                                                                                                                                      =1

                                                        n           n                   Inclusion-exclusion:
 31        2,147,483,648       127           E X] = k = 1k k pk qn;k = np:                  h_ i X
                                                                                               n            n
 32        4,294,967,296       131                                                      Pr       Xi = Pr Xi ] +
           Pascal's Triangle          Poisson distribution:                                  i            i
                                                           e; k                                       X k X h^ i
                                                                                                                                   =1        =1


                                           Pr X = k] = k!                                               n                           k
                      1                                               E X] = :                             (;1)                Pr     Xij :               +1


                     11               Normal (Gaussian) distribution:                                 k               ii < <ik    j     =1                                     =1


                   121                 p(x) = p 1 e; x; =                               Moment inequalities:
                                                                2 2     (
                                                                         E X] = :    )       2


                  1331                             2                                                Pr jX j E X] 1
                 14641                The \coupon collector": We are given a                       h                        i 1
                                      random coupon each day, and there are n                   Pr X ; E X]                       :
              1 5 10 10 5 1           di erent types of coupons. The distribu-                                                                                             2


            1 6 15 20 15 6 1          tion of coupons is uniform. The expected Geometric distribution:
          1 7 21 35 35 21 7 1         number of days to pass before we to col-               Pr X = k] = pk; q              q = 1;p                       1



        1 8 28 56 70 56 28 8 1        lect all n types is                                                     X k; 1
                                                                                                               1
     1 9 36 84 126 126 84 36 9 1                            nHn:                                   E X] = kpq = p :                                                1


                                                                                                              k                                   =1

1 10 45 120 210 252 210 120 45 10 1
                                                                   Theoretical Computer Science Cheat Sheet
                             Trigonometry                                                                       Matrices                                          More Trig.
                                                                                    Multiplication:                                                                C
                                                                                                                                  X
                                                                                                                                  n
                                                           (0,1)
                                                                                                     C=A B           ci j =                ai k bk j :            b h                 a
         b                                                          (cos sin )                                                    k
                         C
                                                                                                                                      =1


     A                                                                              Determinants: det A = 0 i A is non-singular.
                                                                                                                                                               A       c     B
                                         (-1,0)                         (1,0)
                                                                                               det A B = det A det B
             c                       a                                                                         XY
                                                                                                                n                                            Law of cosines:
               B                                           (0,-1)
                                                                                                     det A =                 sign( )ai i :        ( )
                                                                                                                                                             c = a +b ;2ab cos C:
                                                                                                                                                              2       2       2

Pythagorean theorem:                                                                                                 i=1
                                                                                                                                                             Area:
                  C = A +B :     2        2        2                                2 2 and 3 3 determinant:
                                                                                                 a b = ad ; bc
De nitions:                                                                                      c d                                                          A = hc  1


          sin a = A=C cos a = B=C
                                                                                                                                                                      2


                                                                                       a b c                                                                    = ab sin C
                                                                                                                                                                      1


          csc a = C=A sec a = C=B                                                                    b c
                                                                                       d e f = g e f ;h a f +i a e  c        b
                                                                                                                                                                      2

                                                                                                                                                                        A sin
                                                                                                                                                                = c sinsinC B :
                                                                                                                                                                          2

                                                                                                                 d         d
            sin     A             a
    tan a = cos a = B cot a = cos a = B :
                a             sin     A
                                                                                       g h i                                                                          2
                                                                                                       aei + bfg + cdh                                       Heron's formula:
Area, radius of inscribed circle:                                                                =      ; ceg ; fha ; ibd:                                            p
                 AB A +AB+ C :
                     1
                                                                                    Permanents:                                                              A = s sa sb sc
                     2
                             B                                                                           XY   n                                                s = (a + b + c)
                                                                                                                                                                      1



Identities:                                                                                     perm A =         ai i :                     ( )
                                                                                                                                                                      2

                                                                                                                                                             sa = s ; a
          1                                                           1                                                       i
                                                                                                                                                             sb = s ; b
                                                                                                                               =1

sin x = csc x                                               cos x = sec x                               Hyperbolic Functions
            1                                                                       De nitions:                                                              sc = s ; c:
tan x = cot x                                       sin x + cos x = 1
                                                       2                2
                                                                                              x ;x                                 x ;x
                                                                                    sinh x = e ; e                       cosh x = e + e                      More identities:
                                                                                                                                                                      r
1 + tan x = sec x                                  1 + cot x = csc x                              2                                    2                          x = 1 ; cos x
         2               2                                     2                2

                                                                                             ex ; e;x                                1                        sin
           ;
sin x = cos ; x                                     sin x = sin( ; x)               tanh x = ex + e;x                    csch x = sinh x                          2

                                                                                                                                                                      r 2
                                                                    ; ;x                        1                                    1                       cos x = 1 + 2 x   cos
                 2



cos x = ; cos( ; x)                               tan x = cot                       sech x = cosh x                      coth x = tanh x :
                                                                                                                                                                      r
                                                                                                                                                                  2



                                                                                                                                                                  x = 1 ; cos x
                                                                        2



cot x = ; cot( ; x)                               csc x = cot x ; cot x             Identities:                                                              tan  2
                                                                                                                                                                         1 + cos x
                                                                                    cosh x ; sinh x = 1         tanh x + sech x = 1
                                                                    2



sin(x y) = sin x cos y cos x siny
                                                                                         2              2                              2                 2
                                                                                                                                                                      1 ; cos x
                                                                                                                                                                    = sin x
                                                                                    coth x ; csch x = 1
                                                                                         2              2
                                                                                                                 sinh(;x) = ; sinh x                                    sin x
cos(x y) = cos x cos y sin x sin y                                                                                                                                  = 1 + cos x
                                                                                    cosh(;x) = cosh x           tanh(;x) = ; tanh x                                   r
                x
tan(x y) = 1tantan xtan y
                      tany                                                          sinh(x + y) = sinh x cosh y + cosh x sinh y                                   x = 1 + cos x
                                                                                                                                                             cot         1 ; cos x
           cot x cot y 1
                                                                                                                                                                  2


cot(x y) = cot x cot y                                                              cosh(x + y) = cosh x cosh y + sinh x sinh y                                       1 + cos x
                                                                                                                                                                    = sin x
sin 2x = 2 sin x cos x        sin 2x = 2 tanx                                       sinh 2x = 2 sinh x cosh x                                                           sin x
                                       1 + tan x                                2
                                                                                                                                                                    = 1 ; cos x
cos 2x = cos x ; sin x       cos 2x = 2 cos x ; 1                                   cosh 2x = cosh x + sinh x
                                                                                                           2             2

                                                                                                                                                                       ix ;ix
                                                                                                                                                              sin x = e ; e
                 2                   2                                  2




cos 2x = 1 ; 2 sin x         2
                              cos 2x = 1 ; tan x
                                                                                2
                                                                                    cosh x + sinh x = ex        cosh x ; sinh x = e;x                                       2i
                                       1 + tan x                                2

                                                                                    (cosh x + sinh x)n = cosh nx + sinh nx n 2 Z                                      eix + e;ix
                                                                                                                                                              cos x =
tan 2x = 1 ;tanx x
            2                 cot 2x = cot cot; 1
                                            x                                                                                                                               2
                                                                        2



              tan                        2 x                                        2 sinh x = cosh x ; 1 2 cosh x = cosh x + 1:
                                                                                             2                                         2
                                                                                                                                                                         eix ; e;ix
                                                                                                                                                             tan x = ;i eix + e;ix
                         2
                                                                                                 2                                          2


sin(x + y) sin(x ; y) = sin x ; sin y         2        2


                                                                                       sin            cos      tan                : : : in mathematics                      ix
                                                                                                                                                                    = ;i e ix ; 1
                                                                                                                                                                                  2


cos(x + y) cos(x ; y) = cos x ; sin y:        2            2

                                                                                     0 0                1        0                you don't under-                       e +1     2

                                                                                                       p        p                 stand things, you                   sinh ix
Euler's equation:                                                                                1         3     3
                                                                                                                                  just get used to            sin x = i
        eix = cos x + i sin x   ei = ;1:
                                                                                     6
                                                                                             p   2
                                                                                                       p
                                                                                                       2        3

                                                                                                 2         2
                                                                                                                1                 them.                       cos x = cosh ix
              c 1994 by Steve Seiden
                                                                                     4
                                                                                             p   2     2
                                                                                                               p                  { J. von Neumann
                                                                                                                 3
                                                                                                                                                             tan x = tanh ix :
                                                                                                 3     1

            sseiden@ics.uci.edu                                                      3           2     2


      http://www.ics.uci.edu/~sseiden                                                2
                                                                                                 1     0       1                                                          i
                                                       Theoretical Computer Science Cheat Sheet
              Number Theory                                                                    Graph Theory
The Chinese remainder theorem: There ex-                      De nitions:                                  Notation:
ists a number C such that:                                    Loop          An edge connecting a ver-      E(G) Edge set
                                                                            tex to itself.                 V (G) Vertex set
              C r mod m 1                     1
                                                              Directed      Each edge has a direction.     c(G) Number of components
                .. .. ..                                      Simple        Graph with no loops or         G S] Induced subgraph
                 . . .                                                                                     deg(v) Degree of v
              C rn mod mn                                                   multi-edges.
                                                              Walk          A sequence v e v : : :e` v` .     (G) Maximum degree
                                                                                                             (G) Minimum degree
                                                                                        0   1   1

if mi and mj are relatively prime for i 6= j.                 Trail         A walk with distinct edges.
Euler's function: (x) is the number of                        Path          A trail with distinct            (G) Chromatic number
positive integers nless than x relatively                                   vertices.                        E (G) Edge chromatic number
                  Q
prime to x. If i pei is the prime fac-                        Connected A graph where there exists         Gc        Complement graph
torization of x then
                         i
                        =1
                                                                            a path between any two         Kn        Complete graph
                  Yn                                                        vertices.                      Kn1 n2 Complete bipartite graph
           (x) = pei ; (pi ; 1):
                       i
                                          1

                                                              Component A maximal connected                r(k `) Ramsey number
                   i                                                        subgraph.                                    Geometry
                       =1


Euler's theorem: If a and b are relatively                    Tree          A connected acyclic graph.
prime then                                                    Free tree     A tree with no root.           Projective coordinates: triples
             1 a b mod b:   ( )
                                                              DAG           Directed acyclic graph.        (x y z), not all x, y and z zero.
                                                              Eulerian      Graph with a trail visiting      (x y z) = (cx cy cz) 8c 6= 0:
Fermat's theorem:                                                           each edge exactly once.        Cartesian        Projective
             1 ap; mod p:    1

                                                              Hamiltonian Graph with a path visiting       (x y)           (x y 1)
The Euclidean algorithm: if a > b are in-                                   each vertex exactly once.      y = mx + b (m ;1 b)
tegers then                                                   Cut           A set of edges whose re-       x=c             (1 0 ;c)
        gcd(a b) = gcd(a mod b b):                                          moval increases the num-       Distance formula, Lp and L1
  Qn pei is the prime factorization of x                                    ber of components.             metric:
If i i
                                                              Cut-set       A minimal cut.                     p
then                                                                                                               (x ; x ) + (x ; x )
       =1


              X Y ei
                                                                                                                                           2                                       2
                       n                                      Cut edge      A size 1 cut.
       S(x) = d = pip ;; 1 :
                                                                                                                           1           0                   1               0


                                                                                                                jx ; x jp + jx ; x jp =p
                                              +1


                                                              k-Connected A graph connected with
                                                                                                                                                                               1


                               1              i
                                                                                                                   1           0                   1               0

               djx                i
                                  =1
                                                                            the removal of any k ; 1        lim jx ; x jp + jx ; x jp =p :                                             1



Perfect Numbers: x is an even perfect num-                                  vertices.                      p!1             1           0                   1               0




ber i x = 2n; (2n ; 1) and 2n ; 1 is prime.
               1                                              k-Tough       8S V S 6= we have Area of triangle (x y ), (x y )                          0       0                   1       1


Wilson's theorem: n is a prime i                                            k c(G ; S) jS j.               and (x y ): 2       2

                                                              k-Regular A graph where all vertices
           (n ; 1)! ;1 mod n:
                                                                            have degree k.
                                                                                                               1
                                                                                                               2
                                                                                                                  abs x ; x y ; y :
                                                                                                                        x ;x y ;y
                                                                                                                                   1           0           1               0



Mobius 8 inversion:                                           k-Factor      A k-regular spanning
                                                                                                                                   2


                                                                                                           Angle formed by three points:
                                                                                                                                               0           2               0



         >1
         <0         if i = 1.
                                                                            subgraph.
                                square-free.
   (i) = > (;1)r if i is not product of
                    if i is the                               Matching A set of edges, no two of                                  (x y )
         :          r distinct primes.                                      which are adjacent.
                                                                                                                                                                   2       2



                                                              Clique        A set of vertices, all of                        `                 2

If                     X                                                    which are adjacent.
              G(a) = F(d)                                     Ind. set      A set of vertices, none of               (0 0) ` (x y )                1                   1       1

                             dja
                                                                            which are adjacent.
then                   X                                      Vertex cover A set of vertices which
                                                                                                                               )
                                                                                                                 cos = (x y ` `(x y ) :    1   1               2           2



         F(a) =         (d)G a :
                              d                                             cover all edges.               Line through two points (x y )
                                                                                                                                                       1   2


                  dja                                         Planar graph A graph which can be em-                                                                                0       0

                                                                                                           and (x y ):
Prime numbers:                                                              beded in the plane.                        1       1


                                                                                                                       x y 1
    pn = n ln n + n lnln n ; n + n ln ln n
                                    ln n
                                                              Plane graph An embedding of a planar
                                                                            graph.                                    x y 1 = 0:
                                                                                                                               0           0


                   n                                                      X                                           x y 1    1           1

           + O ln n                                                           deg(v) = 2m:                 Area of circle, volume of sphere:
                                                                          v2V                                    A= r          V= r:
          n
   (n) = ln n + (lnn + (lnn) 2!n
                                                                                                                                   2                               4           3



                     n)           2                3
                                                              If G is planar then n ; m + f = 2, so       If I have seen farther than others,
                                                                                                                                                                   3




                                                                     f 2n ; 4 m 3n ; 6:                   it is because I have stood on the
           + O (lnn : n)              4                       Any planar graph has a vertex with de- shoulders of giants.
                                                              gree 5.                                     { Issac Newton
                                                                    Theoretical Computer Science Cheat Sheet
                                                                                                                                      Calculus
Wallis' identity:                                                         Derivatives:
          =2 2 2 4 4 6 6
                1 3 3 5 5 7                                               1. d(cu) = c du                 +      du dv
                                                                                                   2. d(udx v) = dx + dx                         dv
                                                                                                                                 3. d(uv) = u dx + v du
                                                                               dx      dx                         ; du ; u; dv        dx              dx
Brouncker's continued fraction expansion:                                        n)                                                         cu )
            =1+         1
                           2
                                               2
                                                                          4. d(u = nun; du 5. d(u=v) = v dx v dx
                                                                               dx            dx
                                                                                                     1

                                                                                                          dx                        6. d(e = cecu du
                                                                                                                                          dx          dx
                  2+
                                                                                                                                                   2
                 4
                           52
                                                   3

                                                                                 u)
                                               2+ 2+2
                                                   7
                                                                          7. d(c = (ln c)cu du                                                      1
                                                                                                                                      8. d(ln u) = u du
                                       2+




Gregrory's series:                                                            dx              dx                                             dx       dx
          = 1; + ; + ;                                                                        du
                                                                          9. d(sin u) = cos u dx                               10. d(cos u) = ; sin u du
                      1        1           1           1


                                                                                dx                                                    dx              dx
             4        3        5           7           9


Newton's series:
                                                                              d(tan u) = sec u du
                                                                          11. dx                                                     d(cot u) = csc u du
                                                                                                                                12. dx
        1       1
    = 2 + 2 3 2 + 2 41 53 2 +
                                                                                                         2                                                                                2

                                                                                                 dx                                                   dx
                                                                          13. d(sec u) = tan u sec u du                  14. d(csc u) = ; cot u csc u du
    6                      3                                    5



Sharp's series:                                                                   dx                 dx                          dx                   dx
      1
  = p 1; 3 1 3 + 3 1 5 ; 3 1 7 +                                          15. d(arcsin u) = p1 1 u du
                                                                                    dx           ;    dx                 16. d(arccos u) = p1;1 u du
                                                                                                                                   dx              ; dx
6
       3              1                2                   3                                                          2                                                                       2



Euler's series:                                                           17. d(arctan u) = 1 ; u du
                                                                                    dx
                                                                                                 1
                                                                                                     dx           2
                                                                                                                           18. d(arccot u) = 1 ;1u du
                                                                                                                                     dx            ; dx                                       2

         2
             =    +  +              +  +                     +                                                                                                         ;1
                 2     2           2            2           2
                                                                          19. d(arcsec u) = up11; u du                                             20. d(arccsc u) = up1 ; u du
                 1    1         1              1           1
        6        1    2        3               4           5
         2                                                                        dx                dx                                                     dx                  dx
        8
             =   2+
                 1
                 1
                    2+
                      1
                      3        5
                                1
                                   2+ 2+
                                               1
                                               7
                                                           1
                                                           9
                                                            2+                                                            2                                                                   2




                                                                          21. d(sinh u) = cosh u du                                                     22. d(cosh u) = sinh u du
         2
             =   2; 2+             2; 2+                        ;
                 1    1         1              1           1
                                                            2
        12       1    2        3               4           5
                                                                                 dx              dx                                                              dx            dx
             Partial Fractions
Let N(x) and D(x) be polynomial func-                                     23. d(tanh u) = sech u du
                                                                                 dx              dx
                                                                                                             2
                                                                                                                                                        24. d(coth u) = ; csch u du
                                                                                                                                                               dx                dx
                                                                                                                                                                                          2




tions of x. We can break down
N(x)=D(x) using partial fraction expan-                                   25. d(sech u) = ; sech u tanh u du
                                                                                 dx                       dx                                     26. d(csch u) = ; csch u coth u du
                                                                                                                                                        dx                       dx
sion. First, if the degree of N is greater
than or equal to the degree of D, divide                                  27. d(arcsinh u) = p 1
                                                                                  dx
                                                                                                     du                                            28. d(arccosh u) = p 1     du
N by D, obtaining                                                                              1 + u dx                   2                                 dx          u ; 1 dx      2


         N(x) = Q(x) + N 0(x)                                                  d(arctanh u) = 1 du                                                       d(arccoth u) = 1 du
         D(x)              D(x)                                           29.        dx      1 ; u dx                 2
                                                                                                                                                     30.      dx        u ; 1 dx      2



where the degree of N 0 is less than that of                                                     ;1
                                                                          31. d(arcsech u) = up1 ; u du                                          32. d(arccsch u) = jujp;1+ u du :
D. Second, factor D(x). Use the follow-                                              dx               dx                      2                           dx            1     dx              2

ing rules: For a non-repeated factor:                                     Integrals:
         N(x) = A + N 0 (x)                                                    Z                 Z                                                 Z                       Z              Z
     (x ; a)D(x) x ; a D(x)                                               1.           cu dx = c u dx                                            2. (u + v) dx = u dx + v dx
where                                                                          Z                   1 n                                          Z 1                             Z
            A = N(x)
                  D(x) x a :
                                                                          3.           xn dx =   n + 1x
                                                                                                                 +1
                                                                                                                              n 6= ;1         4. x dx = ln x               5.       ex dx = ex
                                               =
                                                                               Z dx                                                                   Z dv                  Z du
For a repeated factor:                                                    6.                                                                           7.     u dx dx = uv ; v dx dx
    N(x)          X Ak
                 m;                 N 0 (x)                                      1 + x = arctan x
                                                                               Z                                                                                       Z
                                1                                                           2



(x ; a) m D(x) =       (x ; a) m;k + D(x)
                           k   =0                                         8.           sin x dx = ; cos x                                                         9.        cos x dx = sinx
where                                                                              Z                                                                              Z
             1 dk
       Ak = k! dxk N(x)                                                   10.           tan x dx = ; ln j cos xj                                            11.       cot x dx = ln j cos xj
                      D(x) x a :                               =                   Z                                                                    Z
The reasonable man adapts himself to the                                  12.           sec x dx = ln j sec x + tan xj                           13.        csc x dx = ln j csc x + cot xj
world the unreasonable persists in trying                                          Z                                              p
to adapt the world to himself. Therefore                                  14.           arcsin x dx = arcsin x + a ; x
                                                                                               a             a
                                                                                                                                      2   2
                                                                                                                                                 a>0
all progress depends on the unreasonable.
{ George Bernard Shaw
                                                                                                Theoretical Computer Science Cheat Sheet
      Z                                                                                                                                  Calculus Cont.         Z
                                                                            p
15.              x
          arccos a dx = arccos x ;
                               a                                                    a ;x
                                                                                    2               2
                                                                                                            a>0                                           16.       arctan x dx = x arctan a ; a ln(a + x ) a > 0
                                                                                                                                                                           a
                                                                                                                                                                                           x                                                        2           2



      Z                                                                                                                                                                               Z
                                                                                                                                                                                                                                    2




17.       sin (ax)dx = a ax ; sin(ax) cos(ax)
               2                            1
                                                ;                                                                                                                         18.             cos (ax)dx = a ax + sin(ax) cos(ax)
                                                                                                                                                                                              2                             1
                                                                                                                                                                                                                                    ;
      Z                                                                                                                                                                                                                                 Z
                                            2                                                                                                                                                                               2




19.       sec x dx = tan x
               2
                                                                                                                                                                                                                        20.                     csc x dx = ; cot x
                                                                                                                                                                                                                                                    2



      Z                     n;                 Z                      Z                n;             Z
21.       sinn x dx = ; sin nx cos x + n ; 1 sinn; x dx            22. cosn x dx = cos nx sinx + n ; 1 cosn; x dx
                                                            1                                                                                                                                           1
                                                                                                                             2                                                                                                                                              2

                                           n                                                       n
      Z                    n; x Z                                     Z                   n; x Z
23.       tann x dx = tan ; 1 ; tann; x dx n 6= 1                  24. cotn x dx = ; cot ; 1 ; cotn; x dx n 6= 1
                                                        1                                                                                                                                                   1
                                                                                                2                                                                                                                                                       2

                         n                                                              n
      Z                         n; x n ; 2 Z
25.       sec n x dx = tan x sec1 + n ; 1 sec n; x dx n 6= 1
                                                                        1
                                                                                                                         2

                           n;
      Z                  cot x cscn; x + n ; 2 Z cscn; x dx n 6= 1 27. Z sinh x dx = cosh x 28. Z cosh x dx = sinh x
26.       csc n x dx = ; n ; 1
                                                                            1
                                                                                                                             2

                                         n;1
      Z                                                                              Z                                                                Z                                                                 Z
29.       tanh x dx = ln j cosh xj 30.                                                      coth x dx = ln j sinh xj 31.                                  sech x dx = arctan sinh x 32.                                         csch x dx = ln tanh x
      Z                                                                                                                              Z                                                                                              Z
                                                                                                                                                                                                                                                                                  2




33.       sinh x dx = sinh(2x) ; x
                   2                    1                                       1
                                                                                                                        34.                  cosh x dx = sinh(2x) + x
                                                                                                                                                  2       1                       1
                                                                                                                                                                                                                        35.                 sech x dx = tanh x
                                                                                                                                                                                                                                                        2



      Z                                                                                                                                                                   Z
                                        4                                       2                                                                         4                       2


                                                                                    p
36.               x                x
          arcsinh a dx = x arcsinh a ;                                                      x +a2           2
                                                                                                                        a>0                                         37.           arctanh x dx = x arctanh x + a ln ja ; x j
                                                                                                                                                                                          a                a
                                                                                                                                                                                                                                                                        2          2



                                   p
                                                                                                                                                                                                                                                            2

                   8
      Z            < x arccosh x ; x + a if arccosh x > 0 and a > 0,
                               a                     a
                                                                                                        2           2


38. arccosh a dx = :           x + px + a if arccosh x < 0 and a > 0,
            x
                     x arccosh a                     a
                                                                                                        2           2


   Z dx                  p
39. pa + x = ln x + a + x            a>0                                    2           2



   Z dx                                                         Zp
               2            2


                                                                                                                                                                                                       p
40.                        x
          a + x = a arctan a
                                    1
                                                                            a>0                                                                           41.           a ; x dx = x a ; x + a2 arcsin a
                                                                                                                                                                          2           2                x        2               2
                                                                                                                                                                                                                                                                                a>0
      Z
           2            2                                                                                                                                                                          2                                            2


                                                                                         p                                a4 arcsin x
42. (a ; x ) = dx = x (5a ; 2x ) a ; x +
           2               2 3 2                                    2               2               2           2       3
                                                                                                                                    a                 a>0
      Z                                                                                                                       Z                                                                         Z
                                                    8                                                                     8




43.    p dx = arcsin a
                     x                                                      a>0                                     44.                  a ;x
                                                                                                                                             dx  1 a+x
                                                                                                                                              = 2a ln a ; x                                       45.             dx
                                                                                                                                                                                                             (a ; x )
                                                                                                                                                                                                                              x
                                                                                                                                                                                                                      = = a pa ; x
      Zpa ;x   2            2                                                                                                            2        2

                                                                                                                                                                                  Z
                                                                                                                                                                                                                        2               2 3 2                   2           2         2


                   p                                                                                                p                                                                                                p
46.            a2
                           x dx = x a
                            2                                   2
                                                                            x   2        a2 ln          x+ a             2
                                                                                                                                     x   2
                                                                                                                                                                        47.            p dx                 = ln x + x ; a     a>0                  2           2



      Z                                                                                                                                                                               Z x ;a
                                                2                                           2                                                                                                 2         2


                                                                                                                                                                                        p                                                                                         =
48.          dx       1     x                                                                                                                                             49.             x a + bxdx = 2(3bx ; 2a)(a + bx)
                                                                                                                                                                                                                                                                                 3 2


          ax + bx = a ln a + bx                                                                                                                                                                                 15b
      Z   p
            a + bx dx = 2pa + bx + a Z p 1 dx                                                                                                                       Z                                                       p
               2                                                                                                                                                                                                                                                2




50.                                                                                                                                                           51.       p   x dx = p ln pa + bx ; pa a > 0
                                                                                                                                                                                    1
          p x                          x a + bx                                                                                                                           a + bx     2    a + bx + pa
      Z                                    p
            a ; x dx = pa ; x ; a ln a + a ; x                                                                                                                                    Z p
52.                                                                                                                                                                            53. x a ; x dx = ; (a ; x ) =
               2            2                                                                                       2            2
                                                            2               2                                                                                                                                       2               2                       1       2           2 3 2

              x                               x                                                                                                                                                                                                             3


    Z p                                                                Z dx                   p
54. x a ; x dx =
           2       x (2x ; a )pa ; x + a4 arcsin x a > 0           55.
                                                                    2
                                                                          p      = ; a ln
                                                                                    2
                                                                                          a+ a ;x                                                                                                                                           1
                                                                                                                                                                                                                                                                        2         2


                                                 a
                       2            2                                                               2           2

                                                                            a ;x                 x
    Z x dx                                                   Z x dx
                                                        8                                                                8                                                                              2               2


                 p                                                           p
56. pa ; x = ; a ; x                                     57. pa ; x = ; x a ; x + a2 arcsin a a > 0
                                                                                                x
                                                                                                                                                                              2
                                                        2               2                                                                                                                                       2               2



    Z pa + x                                                 Z px ; a
                                                                                                                                                                                                    2                                           2

                                   p
               2            2                                                                                                                                                 2           2


                 p              a+ a +x                                     p
58.          dx = a + x ; a ln                           59.           dx = x ; a ; a arccos jaj a > 0
               2            2                                                                                       2            2                                            2           2


                                                                                              x
                                                            2               2                                                                                                                                   2               2



    Z px                             x                           x
                                                                        Z dx                     x
60.       x x       2
                            a dx = (x
                                2                   1           2
                                                                            a)= 2 3 2
                                                                                                                                                                                      61.           p                           = a ln      1
                                                                                                                                                                                                                                                                p
                                                    3
                                                                                                                                                                                                  x x +a    2               2
                                                                                                                                                                                                                                                        a+ a +x         2         2
                                                                                                               Theoretical Computer Science Cheat Sheet
                                                                                               Calculus Cont.                                                                                                                          Finite Calculus
            Z                                                                                                                        Z                                                           p                         Di erence, shift operators:
62.  p dx = a arccos jxj
                      a                                                      x a                                               63.                   p dx
                                                                                                                                                                                                     2            2
                                                             1
                                                                                                   a>0                                                                           =                                                  f(x) = f(x + 1) ; f(x)
    x x ;a
   Z x dx p                                           Z pxx ax a (x +a x =
                             2               2                                                                                                   2           2               2                           2




64. p      = x a                                 65.            dx =
                                                                 2
                                                                               a)2
                                                                                                                                             2           2                                   2           2       3 2
                                                                                                                                                                                                                                  E f(x) = f(x + 1):
                  x a          8                           x                3a x                                                                                                                                           Fundamental Theorem:
                                                                                                                                                                                                                                             X
                               > p 1 ln 2ax + b ; pb ; 4ac if b > 4ac,
                         2               2                                                                                                       4                                                   2       3




            Z                  >                       p                                                                                                                                                                   f(x) = F (x) , f(x) x = F (x) + C:
                               <
                                                                                                                                     2
                                                                                                                                                                                 2


66.                 dx      = > b ; 4ac 2ax + b + b ; 4ac
                                                                                 2                                                   2
                                                                                                                                                                                                                                          X
                                                                                                                                                                                                                                          b              X
                                                                                                                                                                                                                                                         b;    1

                ax + bx + c >                                                                                                                                                                                                                 f(x) x =             f(i):
                               : p 2 arctan p2ax + b
                     2

                                                                  if b < 4ac,                                                                                                    2
                                                                                                                                                                                                                                          a              i a
                                   4ac ; b        4ac ; b                                          2                                 2

                                                                                                                                                                                                                           Di erences:
                                                                                                                                                                                                                                                           =



                                8 1
            Z                   > p ln 2ax + b + 2papax + bx + c if a > 0,
                                < a                                                                                                      2
                                                                                                                                                                                                                             (cu) = c u         (u + v) = u + v
67.             p dx          =                                                                                                                                                                                              (uv) = u v + E v u
                                             ;
                  ax + bx + c > p1 arcsin p 2ax ; b
                             2
                                : ;a                                  if a < 0,                                                                                                                                              (xn) = nxn;
                                              b ; 4ac
                                                                                                                                                                                                                                                  1
                                                                                                                   2


            Z                                                                                                                                                                                                                (Hx ) = x;                   (2x ) = 2x
                p                          p                 ; Z
                                                                                                                                                                                                                                              1



68.               ax + bx + c dx = 2ax + b ax + bx + c + 4ax8a b p dx
                                                                                                                                                             2

                                                                                                                                                                                                                             (cx ) = (c ; 1)cx
                                                                                                                                                                                                                                                       ;x = ; x :
                                                                                                                                                                                                                                                                m;
                             2                                                                                 2

                                      4a                              ax + bx + c                                                                                                        2                                                              m                   1

                                                                                                                                                                                                                           Sums:
            Z       x dx        ax + bx + c ; b Z p dx
                                                                         p                                                                                                                                                 P cu x = c P u x
69.             p
                                                                                     2

                              =    a          2a                                                                                                                                                                           P(u + v) x = P u x + P v x
                  ax + bx + c2
                                                   ax + bx + c                                                                       2



                              8 ;1 2pcpax + bx + c + bx + 2c                                                                                                                                                               P u v x = uv ; P v u x
            Z                 > p ln
                              > c                                                                                                                                                                                                               E
                              <
                                                                                                                       2

                                                                                                                                                                                     if c > 0,
70.              p   dx      =>
                                                  x                                                                                                                                                                        P xn x = xn+1             P x; x = H
                x ax + bx + c > 1                                                                                                                                                                                                        m                         x   1

                                              bx 2c
                              : p;c arcsin jxjpb+; 4ac                                                                                                                                                                     P cx x = cx           P; x x = ; x :
                                 2                                                                                                                                                                                                            +1

                                                                                                                                                                                     if c < 0,
                                                                                                                                                                                                                                        c;           m          m
            Z
                                                                                                                           2


                 p
                                                                                                                                                                                                                                              1                            +1

                                                                                                                                                                                                                           Falling Factorial Powers:
71.             x x + a dx = ( x ; a )(x + a ) =
                 3               2               2                       1       2            2        2       2       2 3 2

                                                                                                                                                                                                                               xn = x(x ; 1) (x ; m + 1) n > 0
            Z                               Z
                                                                         3                    15



                                                                                                                                                                                                                               x =1
                xn sin(ax) dx = ; a xn cos(ax) + n xn; cos(ax) dx
                                                                                                                                                                                                                                 0

72.                                                                  1                                                         1


                                                                                                                                                                                                                               xn = (x + 1) 1 (x + jnj) n < 0
                                                 a
            Z                                                                                                  Z
73.             xn cos(ax) dx =                              n          n    n;
                                                          a x sin(ax) ; a x                                                    sin(ax) dx                                                                                  xn m = xm (x ; m)n :
                                                                 1                                                         1
                                                                                                                                                                                                                             +


            Z                                        xn eax ; n Z xn; eax dx                                                                                                                                               Rising Factorial Powers:
74.             xneax dx =                             a       a
                                                                                                       1

                                                                                                                                                                                                                              xn = x(x + 1) (x + m ; 1) n > 0
            Z                        ln(ax) ; 1
75.             xn ln(ax) dx = xn                                    +1                                                                                                                                                        x =1
                                                                                                                                                                                                                                 0


                                      n + 1 (n + 1)
            Z                                         Z                                                                                                                                                                       xn = (x ; 1) 1 (x ; jnj) n < 0
                                                                                                                           2


                                  n
76.             xn(ln ax)m dx = n + 1 (ln ax)m ; n m 1 xn(ln ax)m; dx:
                                x                                            +1
                                                                                                                                                                 1

                                                   +                                                                                                                                                                       xn m = xm (x + m)n :
                                                                                                                                                                                                                             +



                                                                                                                                                                                                                           Conversion:
x   1
        =                  x                                     1
                                                                                                                   =                                                         x   1                                         xn = (;1)n (;x)n = (x ; m + 1)n
x
2
        =               x +x                             2               1
                                                                                                                   =                          x ;x                       2               1
                                                                                                                                                                                                                              = 1=(x + 1);n
x
3
        =             x + 3x + x             3                   2               1
                                                                                                                   =                       x ; 3x + x        3                   2               1
                                                                                                                                                                                                                           xn = (;1)n (;x)n = (x + m ; 1)n
x   4
        =          x + 6x + 7x + x   4                   3                   2            1
                                                                                                                   =                     x ; 6x + 7x ; x
                                                                                                                                                     4                   3                   2           1
                                                                                                                                                                                                                              = 1=(x ; 1);n
x
5
        =       x + 15x + 25x + 10x + x
                     5                       4                       3                    2            1
                                                                                                                   =                 x ; 15x + 25x ; 10x + x
                                                                                                                                         5                   4                       3                   2         1
                                                                                                                                                                                                                                X n k X n
                                                                                                                                                                                                                                  n            n
                                                                                                                                                                                                                                                           n;k k
                                                                                                                                                                                                                           xn =        k x =       k (;1) x
x   1
        =             x                                          1
                                                                                                                   x   1
                                                                                                                           =             x                                       1
                                                                                                                                                                                                                                k            k
                                                                                                                                                                                                                                X n
                                                                                                                                                                                                                                     =1               =1

                                                                                                                                                                                                                                  n
x       =           x +x                                                                                           x       =           x ;x                                                                                xn =             n;k k
                                                                                                                                                                                                                                     k (;1) x
    2                                                    2               1                                             2                                                 2               1



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

x   4
        =    x + 6x + 11x + 6x   4                   3                       2                1
                                                                                                                   x   4
                                                                                                                           =    x ; 6x + 11x ; 6x4                   3                       2               1                    n
x   5
        = x + 10x + 35x + 50x + 24x
                 5                       4                       3                    2                    1
                                                                                                                   x   5
                                                                                                                           = x ; 10x + 35x ; 50x + 24x
                                                                                                                                     5                   4                       3                   2                 1
                                                                                                                                                                                                                           xn =      k x:
                                                                                                                                                                                                                                k    =1
                                               Theoretical Computer Science Cheat Sheet
                                                                                                                    Series
Taylor's series:                                                                                                                                                Ordinary power series:
                                                          X1      i                                                                                                                    X
                                                                                                                                                                                       1
       f(x) = f(a) + (x ; a)f 0 (a) + (x ; a) f 00 (a) + = (x ; a) f i (a):
                                                               2


                                         2                    i!
                                                                                                                                          ( )
                                                                                                                                                                         A(x) =                aixi :
                                                          i                                                                                                                            i
Expansions:                                                                                                     =0
                                                                                                                                                                                        =0


                 1                                               X
                                                                 1                                                                                              Exponential power series:
                                   = 1+x+x +x +x +            = xi                                                                                                               X i
                                                                                                                                                                                  1
              1;x                                                                                                                                                        A(x) = ai x :
                                                                   2                3               4


                                                                                                                                 i
                1                                                                                                                X
                                                                                                                                 1=0

                                                                                                                                                                                 i      i!
                                         = 1 + cx + c x + c x +                                                              =            ci xi
                                                                                                                                                                                       =0


             1 ; cx                                                                                                                                             Dirichlet power series:
                                                                   2        2               3       3


                                                                                                                                 i                                                 Xa
                                                                                                                                                                                    1
                                                                                                                                 X
                                                                                                                                 1=0

                1                        = 1 + xn + x n + x n +        2                    3
                                                                                                                             =            xni                             A(x) = ixi :
             1 ; xn                                                                                                              i                                                 i
                                                                                                                                 X
                                                                                                                                                                                           =1


                x                                                                                                                1   =0
                                                                                                                                                                Binomial theorem:
            (1 ; x)                      = x + 2x + 3x + 4x +
                                                           2                   3                    4
                                                                                                                             =            ixi                                 X n n;k k
                                                                                                                                                                                n
                         2
                                                                                                                                 i                                 (x + y)n =        k x y:
                                                                                                                                 Xn
                                                                                                                                 1=0

           dn
       xk dxn 1 ; x 1                    = x + 2n x + 3nx + 4n x +                                                           =            i xi
                                                                                                                                                                                  k   =0

                                                                                                                                                                Di erence of like powers:
                                                               2                        3                       4


                                                                                                                                 i
                                                                                                                                 X xi
                                                                                                                                 1=0
                                                                                                                                                                                           X
                                                                                                                                                                                           n;   1


                ex                       = 1+x+ x + x +        1       2            1       3
                                                                                                                             =                                   xn ; yn = (x ; y)                   xn; ;kyk :
                                                                                                                                                                                                              1

                                                               2                    6
                                                                                                                                 i        i!                                               k
                                                                                                                                 X
                                                                                                                                                                                               =0
                                                                                                                                 1   =0

                                                                                                                                                         xi     For ordinary power series:
            ln(1 + x)                    = x; x + x ; x ;
                                                   1       2           1        3           1           4
                                                                                                                             =            (;1)i     +1

                                                                                                                                                          i                                X
                                                                                                                                                                                           1
                                                                                                                                                                                                    ( ai + bi )xi
                                                   2                   3                    4
                                                                                                                                 i                               A(x) + B(x) =
                                                                                                                                 X xi
                                                                                                                                 1
                                                                                                                                     =1

                  1
             ln 1 ; x                    = x+ x + x + x +                                                                    =                                                             i
                                                                                                                                                                                           X
                                                                                                                                                                                               =0

                                                                                                                                                                                           1
                                                   1       2           1        3           1           4
                                                   2                   3                    4
                                                                                                                                 i         i
                                                                                                                                 X
                                                                                                                                 1   =1
                                                                                                                                                                         xk A(x) =                  ai;k xi
              sin x                      = x; x + x ; x +                                                                              xi
                                                                                                                             = (;1)i (2i + 1)!
                                                                                                                                                         2 +1


                                                                                                                                                                       Pk; a xii X
                                                   1       3               1        5           1           7                                                                                  =0


                                                                                                                                                                 A(x) ; i i = 1 a xi
                                                   3!                      5!                   7!
                                                                                                                               i                                                  1

                                                                                                                               X ixi
                                                                                                                                1    =0
                                                                                                                                                         2
                                                                                                                                                                       xk
                                                                                                                                                                             =0
                                                                                                                                                                                    i;k
              cos x                      = 1; x + x ; x +
                                                   1       2               1        4           1           6
                                                                                                                             = (;1) (2i)!                                         i
                                                                                                                                                                              Xi i
                                                                                                                                                                                1
                                                   2!                  4!                       6!                                                                                                   =0

                                                                                                                               i1
                                                                                                                               X i xi                                     A(cx) =                   c ai x
                                                                                                                                     =0



             tan; x                      = x; x + x ; x +                                                                    = (;1) (2i + 1)
                                                                                                                                                         2 +1

                                                                                                                                                                                           i
                     1                             1       3           1        5           1           7



                                                                                                                                                                                           X
                                                                                                                                                                                               =0

                                                                                                                                                                                           1
                                                   3                   5                    7
                                                                                                                               i
                                                                                                                               X n i
                                                                                                                                1                                          A0 (x) =
                                                                                                                                     =0



             (1 + x)n                    = 1 + nx + n n; x +                                                                 =                                                                      (i + 1)ai xi
                                                                                                                                  i x
                                                                       (            1)      2                                                                                                                      +1

                                                                            2                                                                                                              i
                                                                                                                                                                                           X
                                                                                                                                                                                               =0
                                                                                                                               i                                                           1
                                                         ;                                                                     X i+n i
                                                                                                                                1    =0

                 1                       = 1 + (n + 1)x + n x +                                                              =                                           xA0 (x) =                  iai xi
                                                                                                                                    i x
                                                                                            +2

            (1 ; x)n
                                                                                                            2

                                                                                                                                                                                           i
                                                                                                                                                                     Z
                         +1                                                                 2
                                                                                                                               i
                                                                                                                                                                                           X ai;
                                                                                                                                                                                               =1


                                                                                                                               X ii
                                                                                                                                1                                                          1
                                                                                                                                     =0

                 x                                                                                                           = Bi!x                                      A(x) dx =                        i
                                         = 1; x+ x ;                                                    x +                                                                                           i x
                                                                                                                                                                                                          1
                                                   1               1                            1

              ex ; 1
                                                                                2                           4
                                                   2               12                       720
                                                                                                                               i                                                           i
                                                                                                                               X 1 2i i
                                                                                                                                1
                                                                                                                                                                 A(x) + A(;x) = X a x i
                                                                                                                                                                                               =1

          1 (1 ; p1 ; 4x)
                                                                                                                                     =0
                                                                                                                                                                                 1
         2x                              = 1 + x + 2x + 5x +           2                    3
                                                                                                                             = i+1 i x                                              i                     2


                                                                                                                               i                                       2        i
                                                                                                                                                                                                     2


                                                                                                                               X 2i i
                                                                                                                                1 =0


                                                                                                                                                                 A(x) ; A(;x) X
                                                                                                                                                                                               =0


              p 1                        = 1 + x + 2x + 6x +           2                    3
                                                                                                                             =    i x
                                                                                                                                                                                 1
                                                                                                                                                                               = ai xi :
                1 ; 4x                                                                                                         i                                       2
                                                                                                                                                                                                                  2 +1


                    p
                                                                                                                                                                                                     2 +1


                1 ; 1 ; 4x n                                                         ;                                         X 2i + n i
                                                                                                                                1                                                 i
                                                                                                                                                                                    P
                                                                                                                                  =0

       1                                                                                        n
                                                                                                                                                                                               =0


  p
     1 ; 4x          2x                  = 1 + (2 + n)x +                                4+
                                                                                            2
                                                                                                        x + 2
                                                                                                                             =       i x                        Summation: If bi = ij ai then        =0
                                                                                                                               i                                                 1
                                                                                                                                 X
                                                                                                                                 1   =0

             1        1                                                                                                                                                B(x) = 1 ; x A(x):
           1 ; x ln 1 ; x                = x+ x + x + x +
                                                   3       2           11           3           25          4
                                                                                                                             =            Hi xi
                                                                                                                                                                Convolution: 0            1
                                                   2                   6                        12
                                                                                                                                 i
                                                                                                                                 X Hi; xi
                                                                                                                                 1   =1

           1 ln 1                2

                                         = x + x + x +                                                                       =                                                X @X
                                                                                                                                                                              1  i
                                                                                                                                                                                                    aj bi;j A xi:
                                                                                                                                                    1

                                                                                                                                                                A(x)B(x) =
                                           1   2           3       3            11          4

           2 1;x                           2               4                    24
                                                                                                                                 i              i
                                                                                                                                 X
                                                                                                                                 1                                            i            j
                                                                                                                                     =2

                  x                      = x + x + 2x + 3x +                                                                 =            Fi xi
                                                                                                                                                                                  =0           =0



             1;x;x
                                                       2                   3                    4


                                                                                                                                                                God made the natural numbers
                             2
                                                                                                                                 i
                                                                                                                                 X
                                                                                                                                 1
                                                                                                                                 =0

                Fn x                     = Fnx + F nx + F nx +                                                               =            Fnixi :               all the rest is the work of man.
1 ; (Fn; + Fn )x ; (;1)n x                                                                                                                                      { Leopold Kronecker
                                                                           2                            3
                                                               2                            3
                                     2
        1       +1
                                                                                                                                 i=0
                                                                 Theoretical Computer Science Cheat Sheet
                                                                      Series                                                                                                          Escher's Knot
Expansions:
     1                 X1                                                                    1 ;n                    X i i
                                                                                                                      1
(1 ; x)n+1
            ln 1 ; x = (Hn i ; Hn) n + i xi
                 1
                                     i           +
                                                                                             x                   =      n x
                       i                                                                                             i
                       X n i
                        1                                                                                            X i n!xi
                                                                                                                      1
                                    =0                                                                                   =0



         xn          =     i x                                                             (ex ; 1)n             =                n             i!
                       i                                                                                             i
          1 n          X i n!xi
                        1                                                                                            X (;4)iB ix i
                                                                                                                     1
                                    =0                                                                                   =0
                                                                                                                                                         2

     ln 1 ; x        =    n i!                                                              x cot x              =                        (2i)!
                                                                                                                                                2


                       i                                                                                             i
                       X i; 2 i(2 i ; 1)B ix i;
                        1                                                                                            X1
                                                                                                                     1
                                    =0                                                                                =0



                     = (;1)
                                                             2    2                2   1

       tanx                         (2i)!
                                                     1                         2
                                                                                              (x)                =    ix
                       i                                                                                             i
                       X1 (i)                                                                                      X (i)
                                                                                                                    1
                                    =1                                                                                =1

          1          =                                                                      (x ; 1)              =
         (x)           i  ix                                                                  (x)                  i   ix
                      Y
                     = 1 ;1p;x
                                    =1                                                                                   =1


         (x)                                                                                                        Stieltjes Integration
                                p
                                X d(i)
                                1                                                           If G is continuous in the interval a b] and F is nondecreasing then
            (x)            =
                                                                           P                                                                             Zb
                                  i where d(n) = djn 1
        2


                             i x                                                                                                                                 G(x) dF (x)
                                                                                                                                                             a
                             X
                                =1

                              1                   P                                         exists. If a b c then
    (x) (x ; 1)            = S(i) where S(n) = djn d
                                 x i                                                                  Zc                Zb        Zc
                             i  =1

                               n; jB nj
                                                                                                         G(x) dF(x) = G(x) dF(x) + G(x) dF (x):
                           = 2 (2n)!
                                    2    1
                                           n n2N                                                       a                  a        b
        (2n)                                     2       2
                                                                                            If the integrals involved exist
                                                                                                  Z b;                                                            Zb                              Zb
                             X1            i 2)B i
       x                   = (;1)i; (4 ;(2i)! ix                                                               G(x) + H(x) dF(x) =                                     G(x) dF(x) +                    H(x) dF(x)
                                                                           2
                                                     1                 2

     sin x                                                                                         a                                                               a                              a
     p                       i                                                                    Zb                     ;                                        Zb                              Zb
                             X n(2i + n ; 1)! i
                                =0


  1 ; 1 ; 4x n                1                                                                            G(x) d F (x) + H(x) =                                       G(x) dF(x) +                    G(x) dH(x)
      2x                   =       i!(n + i)! x
                                                                                                   a
                                                                                                  Zb                                                 Zb            a
                                                                                                                                                                                              Z ab
                             i
                                                                                                               c G(x) dF(x) =
                                                                                                                                                                       ;
                                                                                                                                                             G(x) d c F(x) = c                         G(x) dF (x)
                             X 2i= sin i i
                                =0

                              1
                                                                                                       a                                             a                                            a
                                             2

      ex sin x             =         i! x
                                                         4
                                                                                                       Zb                                                                                 Z       b
  s                          i  =1
                                                                                                       G(x) dF(x) = G(b)F (b) ; G(a)F (a) ; F(x) dG(x):
            p                   X
                                1                                                                          a                                    a
      1; 1;x                         (4i)!           i                                      If the integrals involved exist, and F possesses a derivative F 0 at every
           x          =
                             16 i p2(2i)!(2i + 1)! x                                        point in a b] then
                         i
      arcsin x           X 4ii!
                           1
                                =0
                                                                                                                              Zb                                       Zb
                                                                                                                                                                            G(x)F 0(x) dx:
                      2

                      = (i + 1)(2i + 1)! x i:
                                                         2


         x
                                                                       2
                                                                                                                                      G(x) dF (x) =
                         i      =0
                                                                                                                                  a                                    a
                     Crammer's Rule                                                                                                                                              Fibonacci Numbers
 If we have equations:
                                                                                             0    47   18       76   29      93   85       34    61      52



           a x + a x + + a nxn = b
                1 1   1   1 2   2                    1                1
                                                                                             86   11   57       28   70      39   94       45        2   63
                                                                                                                                                                       1 1 2 3 5 8 13 21 34 55 89 : : :
                                                                                                                                                                       De nitions:
                                                                                             95   80   22       67   38      71   49       56    13          4

           a x + a x + + a nxn = b
                2 1   1   2 2   2                    2                2                      59   96   81       33   7       48   72       60    24      15


               ..       ..               ..                                                                                                                            Fi = Fi; +Fi; F = F = 1
                .        .                .
                                                                                             73   69   90       82   44      17   58        1    35      26                           1           2         0       1

                                                                                             68   74       9    91   83      55   27       12    46      30                  F;i = (;1)i; Fi               1


           an x + an x + + an nxn = bn
                                                                                                                                                                            Fi = p i ; ^i
                  1   1     2   2                                                            37   8    75       19   92      84   66       23    50      41
                                                                                                                                                                                          1


 Let A = (ai j ) and B be the column matrix (bi ). Then
                                                                                             14   25   36       40   51      62       3    77    88      99                                   5



 there is a unique solution i det A 6= 0. Let Ai be A
                                                                                             21   32   43       54   65       6   10       89    97      78            Cassini's identity: for i > 0:
 with column i replaced by B. Then
                                                                                             42   53   64        5   16      20   31       98    79      87
                                                                                                                                                                          Fi Fi; ; Fi = (;1)i :
                                                                                                                                                                                 +1       1
                                                                                                                                                                                                       2




                      xi = det Ai :
                             det A
                                                                                            The Fibonacci number system:                                               Additive rule:
                                                                                            Every integer n has a unique                                                 Fn k = Fk Fn + Fk; Fn
                                                                                                                                                                             +                    +1            1

                                                                                            representation                                                               F n = FnFn + Fn; Fn:
                                                                                                                                                                             2                    +1            1

 Improvement makes strait roads, but the crooked                                              n = Fk1 + Fk2 + + Fkm                                                    Calculation by matrices:
 roads without Improvement, are roads of Genius.                                            where ki ki + 2 for all i,                                                   Fn; Fn; = 0 1 n :
 { William Blake (The Marriage of Heaven and Hell)                                          1 i < m and km 2.
                                                                                                                         +1

                                                                                                                                                                         F  n;
                                                                                                                                                                                 2

                                                                                                                                                                                 1F       n
                                                                                                                                                                                              1

                                                                                                                                                                                              1 1

				
DOCUMENT INFO
Shared By:
Tags:
Stats:
views:233
posted:3/9/2008
language:English
pages:11
Philip Chen Philip Chen www.idealedge.com
About I'm a professional.