4 min read
Essential Mathematics for Computer Science

A comprehensive guide to mathematical concepts every CS student should know

Discrete Mathematics

Set Theory

  • Basic Notation: Set A={1,2,3}A = \{1, 2, 3\}
  • Operations:
    • Union: ABA \cup B
    • Intersection: ABA \cap B
    • Difference: ABA \setminus B
    • Complement: AcA^c
  • Set Properties:
    • De Morgan’s Laws:
      • (AB)c=AcBc(A \cup B)^c = A^c \cap B^c
      • (AB)c=AcBc(A \cap B)^c = A^c \cup B^c

Logic

  • Logical Operators:
    • AND (\land)
    • OR (\lor)
    • NOT (¬\neg)
    • Implies (    \implies)
    • Equivalent (    \iff)
  • Truth Tables:
    • pq¬(¬p¬q)p \land q \equiv \neg(\neg p \lor \neg q)

Number Theory

  • Division Algorithm: a=bq+ra = bq + r where 0r<b0 \leq r < b
  • GCD: gcd(a,b)=gcd(b,amodb)\gcd(a,b) = \gcd(b, a \bmod b)
  • Prime Numbers: Numbers with exactly two factors
  • Modular Arithmetic: (amodn)(a \bmod n)

Linear Algebra

Vectors

  • Vector Operations:
    • Addition: a+b\vec{a} + \vec{b}
    • Scalar Multiplication: cac\vec{a}
    • Dot Product: ab=i=1naibi\vec{a} \cdot \vec{b} = \sum_{i=1}^n a_ib_i

Matrices

  • Matrix Operations:
    • Addition: (A+B)ij=Aij+Bij(A + B)_{ij} = A_{ij} + B_{ij}
    • Multiplication: (AB)ij=kAikBkj(AB)_{ij} = \sum_k A_{ik}B_{kj}
  • Special Matrices:
    • Identity Matrix: InI_n
    • Transpose: ATA^T
    • Inverse: A1A^{-1}

Calculus

Derivatives

  • Basic Rules:
    • Power Rule: ddxxn=nxn1\frac{d}{dx}x^n = nx^{n-1}
    • Product Rule: ddx(fg)=fg+fg\frac{d}{dx}(fg) = f'g + fg'
    • Chain Rule: ddxf(g(x))=f(g(x))g(x)\frac{d}{dx}f(g(x)) = f'(g(x))g'(x)

Integrals

  • Definite Integral: abf(x)dx\int_a^b f(x)dx
  • Fundamental Theorem: abf(x)dx=F(b)F(a)\int_a^b f(x)dx = F(b) - F(a)

Probability & Statistics

Probability

  • Basic Probability: P(A)=favorable outcomestotal outcomesP(A) = \frac{\text{favorable outcomes}}{\text{total outcomes}}
  • Conditional Probability: P(AB)=P(AB)P(B)P(A|B) = \frac{P(A \cap B)}{P(B)}
  • Bayes’ Theorem: P(AB)=P(BA)P(A)P(B)P(A|B) = \frac{P(B|A)P(A)}{P(B)}

Statistics

  • Mean: μ=1ni=1nxi\mu = \frac{1}{n}\sum_{i=1}^n x_i
  • Variance: σ2=1ni=1n(xiμ)2\sigma^2 = \frac{1}{n}\sum_{i=1}^n (x_i - \mu)^2
  • Standard Deviation: σ=σ2\sigma = \sqrt{\sigma^2}

Graph Theory

Basic Concepts

  • Graph: G=(V,E)G = (V, E)
  • Degree: Number of edges incident to a vertex
  • Path: Sequence of vertices connected by edges

Important Theorems

  • Handshaking Lemma: vVdeg(v)=2E\sum_{v \in V} \deg(v) = 2|E|
  • Euler’s Formula: For planar graphs: VE+F=2V - E + F = 2

Computational Complexity

Big-O Notation

  • O(1)O(1) - Constant
  • O(logn)O(\log n) - Logarithmic
  • O(n)O(n) - Linear
  • O(nlogn)O(n \log n) - Linearithmic
  • O(n2)O(n^2) - Quadratic
  • O(2n)O(2^n) - Exponential

Space Complexity

  • Stack Space: O(n)O(n) for recursive calls
  • Heap Space: Dynamic memory allocation

Boolean Algebra

Laws

  • Commutative: a+b=b+aa + b = b + a
  • Associative: (a+b)+c=a+(b+c)(a + b) + c = a + (b + c)
  • Distributive: a(b+c)=ab+aca(b + c) = ab + ac
  • Identity: a+0=aa + 0 = a, a1=aa \cdot 1 = a
  • Complement: a+aˉ=1a + \bar{a} = 1, aaˉ=0a \cdot \bar{a} = 0

Numerical Methods

Root Finding

  • Newton’s Method: xn+1=xnf(xn)f(xn)x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}
  • Bisection Method: Binary search for roots

Interpolation

  • Linear: y=y0+y1y0x1x0(xx0)y = y_0 + \frac{y_1-y_0}{x_1-x_0}(x-x_0)
  • Lagrange: P(x)=i=0nyijixxjxixjP(x) = \sum_{i=0}^n y_i \prod_{j\neq i} \frac{x-x_j}{x_i-x_j}

Note: This cheat sheet covers fundamental mathematical concepts essential for computer science. For deeper understanding, always refer to detailed resources and practice problems.