1、Theoretical Computer Science Cheat SheetDe nitions Seriesf(n)=O(g(n) i 9 positive c;n0such that0 f(n) cg(n) 8n n0.nXi=1i =n(n +1)2;nXi=1i2=n(n + 1)(2n +1)6;nXi=1i3=n2(n +1)24:In general:nXi=1im=1m +1(n +1)m+11 nXi=1parenleftbig(i +1)m+1im+1(m +1)imn1Xi=1im=1m +1mXk=0m +1kBknm+1k:Geometric series:nXi
2、=0ci=cn+11c1;c6=1;1Xi=0ci=11 c;1Xi=1ci=c1 c; jcj 0, 9n0such thatjanaj 1If 9 0 such that f(n)=O(nlogba )thenT(n)= (nlogba):If f(n)= (nlogba) thenT(n)= (nlogbalog2n):If 9 0 such that f(n)=(nlogba+ ),and 9cbare in-tegers thengcd(a;b) = gcd(a mod b;b):IfQni=1peiiis the prime factorization of xthenS(x)=X
3、djxd =nYi=1pei+1i1pi1:Perfect Numbers: x is an even perfect num-ber i x =2n1(2n1) and 2n1 is prime.Wilsons theorem: n is a prime i (n 1)! 1modn:Mobius inversion:(i)=8:1ifi =1.0ifi is not square-free.(1)rif i is the product ofr distinct primes.IfG(a)=XdjaF(d);thenF(a)=Xdja(d)Gad:Prime numbers:pn= n l
4、n n + n ln lnn n + nln lnnlnn+ Onlnn;(n)=nlnn+n(lnn)2+2!n(ln n)3+ On(lnn)4:De nitions:Loop An edge connecting a ver-tex to itself.Directed Each edge has a direction.Simple Graph with no loops ormulti-edges.Walk A sequence v0e1v1:ev.Trail A walk with distinct edges.Path A trail with distinctvertices.
5、Connected A graph where there existsa path between any twovertices.Component A maximal connectedsubgraph.Tree A connected acyclic graph.Free tree A tree with no root.DAG Directed acyclic graph.Eulerian Graph with a trail visitingeach edge exactly once.Hamiltonian Graph with a cycle visitingeach vert
6、ex exactly once.Cut A set of edges whose re-moval increases the num-ber of components.Cut-set A minimal cut.Cut edge A size 1 cut.k-Connected A graph connected withthe removal of any k 1vertices.k-Tough 8S V;S 6= ; we havek c(G S) jSj.k-Regular A graph where all verticeshave degree k.k-Factor A k-re
7、gular spanningsubgraph.Matching A set of edges, no two ofwhich are adjacent.Clique A set of vertices, all ofwhich are adjacent.Ind. set A set of vertices, none ofwhich are adjacent.Vertex cover A set of vertices whichcover all edges.Planar graph A graph which can be em-beded in the plane.Plane graph
8、 An embedding of a planargraph.Xv2Vdeg(v)=2m:If G is planar then n m + f =2,sof 2n 4;m 3n 6:Any planar graph has a vertex with de-gree 5.Notation:E(G) Edge setV (G) Vertex setc(G) Number of componentsGS Induced subgraphdeg(v) Degree of v(G) Maximum degree(G) Minimum degree(G) Chromatic numberE(G) Ed
9、ge chromatic numberGcComplement graphKnComplete graphKn1;n2Complete bipartite graphr(k;) Ramsey numberGeometryProjective coordinates: triples(x;y;z), not all x, y and z zero.(x;y;z)=(cx;cy;cz) 8c 6=0:Cartesian Projective(x;y)(x;y;1)y = mx + b (m;1;b)x = c (1;0;c)Distance formula, Lpand L1metric:p(x1
10、x0)2+(y1y0)2;jx1x0jp+jy1y0jp1=p;limp!1jx1x0jp+jy1y0jp1=p:Area of triangle (x0;y0), (x1;y1)and (x2;y2):12absx1x0y1y0x2x0y2y0:Angle formed by three points:(0;0) (x1;y1)(x2;y2)21cos =(x1;y1) (x2;y2)12:Line through two points (x0;y0)and (x1;y1):xy1x0y01x1y11=0:Area of circle, volume of sphere:A = r2;V=4
11、3r3:If I have seen farther than others,it is because I have stood on theshoulders of giants. Issac NewtonTheoretical Computer Science Cheat SheetCalculusWallis identity:=2 2 2 4 4 6 6 1 3 3 5 5 7 Brounckers continued fraction expansion:4=1+122+322+522+722+ Gregrorys series:4=113+1517+19 Newtons seri
12、es:6=12+12 3 23+1 32 4 5 25+ Sharps series:6=1p311313+13251337+ Eulers series:26=112+122+132+142+152+ 28=112+132+152+172+192+ 212=112122+132142+152 Derivatives:1.d(cu)dx= cdudx; 2.d(u + v)dx=dudx+dvdx; 3.d(uv)dx= udvdx+ vdudx;4.d(un)dx= nun1dudx; 5.d(u=v)dx=vparenleftbigdudxuparenleftbigdvdxv2; 6.d(
13、ecu)dx= cecududx;7.d(cu)dx= (lnc)cududx; 8.d(ln u)dx=1ududx;9.d(sin u)dx= cos ududx; 10.d(cos u)dx= sin ududx;11.d(tan u)dx= sec2ududx; 12.d(cot u)dx= csc2ududx;13.d(sec u)dx= tan u sec ududx; 14.d(csc u)dx= cot u csc ududx;15.d(arcsin u)dx=1p1u2dudx; 16.d(arccos u)dx=1p1u2dudx;17.d(arctan u)dx=11+u
14、2dudx; 18.d(arccot u)dx=11+u2dudx;19.d(arcsec u)dx=1up1 u2dudx; 20.d(arccsc u)dx=1up1u2dudx;21.d(sinh u)dx= cosh ududx; 22.d(cosh u)dx= sinh ududx;23.d(tanh u)dx= sech2ududx; 24.d(coth u)dx= csch2ududx;25.d(sech u)dx= sech u tanhududx; 26.d(csch u)dx= csch u coth ududx;27.d(arcsinh u)dx=1p1+u2dudx;
15、28.d(arccosh u)dx=1pu21dudx;29.d(arctanh u)dx=11 u2dudx; 30.d(arccoth u)dx=1u21dudx;31.d(arcsech u)dx=1up1 u2dudx; 32.d(arccsch u)dx=1jujp1+u2dudx:Integrals:1.Zcudx = cZudx; 2.Z(u + v)dx =Zudx+Zv dx;3.Zxndx =1n +1xn+1;n6= 1; 4.Z1xdx =lnx; 5.Zexdx = ex;6.Zdx1+x2= arctan x; 7.Zudvdxdx = uv Zvdudxdx;8.
16、Zsinxdx= cos x; 9.Zcos xdx= sinx;10.Ztan xdx= lnjcos xj; 11.Zcot xdx=lnjcos xj;12.Zsec xdx=lnjsec x + tan xj; 13.Zcsc xdx=lnjcsc x + cot xj;14.Zarcsinxadx = arcsinxa+pa2x2;a0;Partial FractionsLet N(x) and D(x) be polynomial func-tions of x. We can break downN(x)=D(x) using partial fraction expan-sio
17、n. First, if the degree of N is greaterthan or equal to the degree of D, divideN by D, obtainingN(x)D(x)= Q(x)+N0(x)D(x);where the degree of N0is less than that ofD. Second, factor D(x). Use the follow-ing rules: For a non-repeated factor:N(x)(xa)D(x)=Axa+N0(x)D(x);whereA =N(x)D(x)x=a:For a repeated
18、 factor:N(x)(x a)mD(x)=m1Xk=0Ak(xa)mk+N0(x)D(x);whereAk=1k!dkdxkN(x)D(x)x=a:The reasonable man adapts himself to theworld; the unreasonable persists in tryingto adapt the world to himself. Thereforeall progress depends on the unreasonable. George Bernard ShawTheoretical Computer Science Cheat SheetC
19、alculus Cont.15.Zarccosxadx = arccosxapa2x2;a0; 16.Zarctanxadx = xarctanxaa2ln(a2+ x2);a0;17.Zsin2(ax)dx =12aparenleftbigaxsin(ax)cos(ax); 18.Zcos2(ax)dx =12aparenleftbigax + sin(ax)cos(ax);19.Zsec2xdx= tan x; 20.Zcsc2xdx= cot x;21.Zsinnxdx= sinn1xcos xn+n 1nZsinn2xdx; 22.Zcosnxdx=cosn1xsin xn+n 1nZ
20、cosn2xdx;23.Ztannxdx=tann1xn 1Ztann2xdx; n 6=1; 24.Zcotnxdx= cotn1xn 1Zcotn2xdx; n 6=1;25.Zsecnxdx=tan xsecn1xn 1+n 2n 1Zsecn2xdx; n 6=1;26.Zcscnxdx= cot xcscn1xn 1+n 2n 1Zcscn2xdx; n 6=1; 27.Zsinhxdx= cosh x; 28.Zcosh xdx= sinhx;29.Ztanh xdx=lnjcosh xj; 30.Zcoth xdx=lnjsinhxj; 31.Zsech xdx= arctan
21、sinhx; 32.Zcsch xdx=lntanhx2;33.Zsinh2xdx=14sinh(2x) 12x; 34.Zcosh2xdx=14sinh(2x)+12x; 35.Zsech2xdx= tanhx;36.Zarcsinhxadx = xarcsinhxapx2+ a2;a0; 37.Zarctanhxadx = xarctanhxa+a2lnja2x2j;38.Zarccoshxadx =80 and a0,xarccoshxa+px2+ a2; if arccoshxa0,39.Zdxpa2+ x2=lnx +pa2+ x2;a0;40.Zdxa2+ x2=1aarctanx
22、a;a0; 41.Zpa2x2dx =x2pa2x2+a22arcsinxa;a0;42.Z(a2x2)3=2dx =x8(5a22x2)pa2x2+3a48arcsinxa;a0;43.Zdxpa2x2= arcsinxa;a0; 44.Zdxa2x2=12alna + xax; 45.Zdx(a2x2)3=2=xa2pa2x2;46.Zpa2x2dx =x2pa2x2a22lnx +pa2x2; 47.Zdxpx2a2=lnx +px2a2;a0;48.Zdxax2+ bx=1alnxa + bx; 49.Zxpa + bxdx =2(3bx 2a)(a + bx)3=215b2;50.Z
23、pa + bxxdx =2pa + bx + aZ1xpa + bxdx; 51.Zxpa + bxdx =1p2lnpa + bxpapa + bx +pa;a0;52.Zpa2x2xdx =pa2x2alna +pa2x2x; 53.Zxpa2x2dx = 13(a2x2)3=2;54.Zx2pa2x2dx =x8(2x2a2)pa2x2+a48arcsinxa;a0; 55.Zdxpa2x2= 1alna +pa2x2x;56.Zxdxpa2x2= pa2x2; 57.Zx2dxpa2x2= x2pa2x2+a22arcsinxa;a0;58.Zpa2+ x2xdx =pa2+ x2al
24、na +pa2+ x2x; 59.Zpx2a2xdx =px2a2aarccosajxj;a0;60.Zxpx2a2dx =13(x2a2)3=2; 61.Zdxxpx2+ a2=1alnxa +pa2+ x2;Theoretical Computer Science Cheat SheetCalculus Cont. Finite Calculus62.Zdxxpx2a2=1aarccosajxj;a0; 63.Zdxx2px2a2= px2a2a2x;64.Zxdxpx2a2=px2a2; 65.Zpx2a2x4dx = (x2+ a2)3=23a2x3;66.Zdxax2+ bx + c
25、=8:1pb24acln2ax + b pb24ac2ax + b +pb24ac; if b2 4ac,2p4ac b2arctan2ax + bp4ac b2; if b2:1paln2ax + b +2papax2+ bx + c; if a0,1paarcsin2axbpb24ac; if a:1pcln2pcpax2+ bx + c + bx +2cx; if c0,1pcarcsinbx +2cjxjpb24ac; if c0;x0=1;xn=1(x +1) (x +jnj);n0;x0=1;xn=1(x1) (xjnj);n0:Fi+1Fi1F2i=(1)i:Additive r
26、ule:Fn+k= FkFn+1+ Fk1Fn;F2n= FnFn+1+ Fn1Fn:Calculation by matrices:Fn2Fn1Fn1Fn=0111n:The Fibonacci number system:Every integer n has a uniquerepresentationn = Fk1+ Fk2+ + Fkm;where kiki+1+ 2 for all i,1 imand km2.Improvement makes strait roads, but the crookedroads without Improvement, are roads of Genius. William Blake (The Marriage of Heaven and Hell)