Computer Science Matrix - Summation and Induction

Introduction to Summation Notation

  • Sigma Notation (\sum): This is a compact way to represent a sum of a sequence of numbers, analogous to a for loop in computer science.

    • Components:

      • \sum: The sigma symbol, indicating summation.

      • ii: The index variable (or generator variable), which changes with each term.

      • ss: The starting index (lower limit).

      • tt: The terminal index (upper limit).

      • aia_i: The generator or general term, which defines the pattern of the terms being summed.

Evaluating Sums

  • To evaluate a sum, substitute the index variable with values from the starting index up to the terminal index, and then add the resulting terms.

  • Example 1: Evaluate i=053i2\sum_{i=0}^{5} 3i^2

    • Start index: i=0i=0

    • Terminal index: i=5i=5

    • Generator: 3i23i^2

    • Expansion: (302)+(312)+(322)+(332)+(342)+(352)(3 \cdot 0^2) + (3 \cdot 1^2) + (3 \cdot 2^2) + (3 \cdot 3^2) + (3 \cdot 4^2) + (3 \cdot 5^2)

    • Calculation: 0+3+12+27+48+75=1650 + 3 + 12 + 27 + 48 + 75 = 165

  • Example 2: Evaluate i=13(4i2+5)\sum_{i=1}^{3} (4i^2 + 5)

    • Start index: i=1i=1

    • Terminal index: i=3i=3

    • Generator: (4i2+5)(4i^2 + 5)

    • Expansion: (412+5)+(422+5)+(432+5)(4 \cdot 1^2 + 5) + (4 \cdot 2^2 + 5) + (4 \cdot 3^2 + 5)

    • Calculation: (4+5)+(16+5)+(36+5)=9+21+41=71(4 + 5) + (16 + 5) + (36 + 5) = 9 + 21 + 41 = 71

  • Example 3: Evaluate i=141i2\sum_{i=1}^{4} \frac{1}{i^2}

    • Start index: i=1i=1

    • Terminal index: i=4i=4

    • Generator: 1i2\frac{1}{i^2}

    • Expansion: 112+122+132+142\frac{1}{1^2} + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2}

    • Calculation: 11+14+19+116\frac{1}{1} + \frac{1}{4} + \frac{1}{9} + \frac{1}{16} (Note: The calculation was not completed in the transcript, but the expansion is key).

Writing Sums in Sigma Notation

  • The goal is to reverse the process of evaluation: given an expanded sum, find its compact sigma notation.

  • Rule of Thumb: If something stays the same throughout all terms, it stays the same in the generator.

  • Example A: Write the sum 2+4+6+8+102 + 4 + 6 + 8 + 10 in sigma notation.

    • Pattern Recognition: All numbers are even, multiples of 2.

    • Generator: 2i2i (or 2k2k, etc.).

    • Indices:

      • For i=1i=1, 2(1)=22(1)=2

      • For i=2i=2, 2(2)=42(2)=4

      • For i=5i=5, 2(5)=102(5)=10

    • Sigma Notation: i=152i\sum_{i=1}^{5} 2i

  • Example B: Write the sum 2+4+8+16+322 + 4 + 8 + 16 + 32 in sigma notation.

    • Pattern Recognition: All numbers are powers of 2.

    • Generator: 2i2^i

    • Indices:

      • For i=1i=1, 21=22^1=2

      • For i=2i=2, 22=42^2=4

      • For i=5i=5, 25=322^5=32

    • Sigma Notation: i=152i\sum_{i=1}^{5} 2^i

    • There can be multiple ways to represent a sum with different starting indices, but the overall sequence of terms remains the same.

  • Example C: Write the sum f(1n)+f(2n)+f(3n)++f(nn)f(\frac{1}{n}) + f(\frac{2}{n}) + f(\frac{3}{n}) + \dots + f(\frac{n}{n}) in sigma notation.

    • Pattern Recognition: The function ff and the denominator nn remain constant. The numerator increases by 1 each time.

    • Generator: f(in)f(\frac{i}{n})

    • Indices:

      • For i=1i=1, f(1n)f(\frac{1}{n})

      • For i=2i=2, f(2n)f(\frac{2}{n})

      • For i=ni=n, f(nn)f(\frac{n}{n})

    • Sigma Notation: i=1nf(in)\sum_{i=1}^{n} f(\frac{i}{n})

Rules for Sums (Properties of Summation)

  • These rules are derived from properties of addition and multiplication.

  • Let <em>i=sta</em>i=N\sum<em>{i=s}^{t} a</em>i = N and <em>i=stb</em>i=M\sum<em>{i=s}^{t} b</em>i = M, and cc is a constant.

  • Rule 1: Constant Multiple Rule

    • If a constant cc is multiplied by the generator, it can be factored out of the summation:
      <em>i=stca</em>i=c<em>i=sta</em>i=cN\sum<em>{i=s}^{t} c \cdot a</em>i = c \cdot \sum<em>{i=s}^{t} a</em>i = c N

    • Concept: Just as you can factor out a common term from an expanded sum, you can factor out a constant from a sigma notation.

  • Rule 2: Sum/Difference Rule

    • The sum (or difference) of two generators can be split into the sum (or difference) of two separate summations:
      <em>i=st(a</em>i±b<em>i)=</em>i=sta<em>i±</em>i=stbi=N±M\sum<em>{i=s}^{t} (a</em>i \pm b<em>i) = \sum</em>{i=s}^{t} a<em>i \pm \sum</em>{i=s}^{t} b_i = N \pm M

    • Concept: This allows distributing the summation across terms being added or subtracted within the generator.

  • Rule 3: Sum of a Constant

    • If the generator is just a constant cc (i.e., it doesn't depend on the index ii):
      i=stc=c(ts+1)\sum_{i=s}^{t} c = c \cdot (t - s + 1)

    • Special Case: If the starting index is i=1i=1 (s=1s=1):
      i=1tc=ct\sum_{i=1}^{t} c = c \cdot t

    • Concept: This is equivalent to repeated addition, which is multiplication (e.g., 5+5+5=5×35+5+5 = 5 \times 3).

    • This rule holds even if the constant is negative or if subtraction is involved.

Application: Approximating Area with Rectangles (Riemann Sums)

  • Problem: Approximate the area under the curve f(x)=x2f(x) = x^2 on the interval [0,1][0, 1] using nn right-endpoint rectangles.

  • Step 1: Calculate the width of each rectangle (Δx\Delta x or base)

    • Δx=ban=10n=1n\Delta x = \frac{b-a}{n} = \frac{1-0}{n} = \frac{1}{n}

  • Step 2: Determine the heights of the rectangles

    • Using right endpoints, the x-values for the heights are rac1n,rac2n,rac3n,,racnnrac{1}{n}, rac{2}{n}, rac{3}{n}, \dots, rac{n}{n}.

    • Heights: f(1n),f(2n),f(3n),,f(nn)f(\frac{1}{n}), f(\frac{2}{n}), f(\frac{3}{n}), \dots, f(\frac{n}{n})

  • Step 3: Write the approximate area (AA) as an expanded sum

    • AΔx[f(1n)+f(2n)+f(3n)++f(nn)]A \approx \Delta x \cdot [f(\frac{1}{n}) + f(\frac{2}{n}) + f(\frac{3}{n}) + \dots + f(\frac{n}{n})]

    • A1n[f(1n)+f(2n)+f(3n)++f(nn)]A \approx \frac{1}{n} [f(\frac{1}{n}) + f(\frac{2}{n}) + f(\frac{3}{n}) + \dots + f(\frac{n}{n})]

  • Step 4: Convert the expanded sum to sigma notation

    • A1ni=1nf(in)A \approx \frac{1}{n} \sum_{i=1}^{n} f(\frac{i}{n})

  • Step 5: Substitute the function f(x)=x2f(x) = x^2 into the sum

    • A1ni=1n(in)2A \approx \frac{1}{n} \sum_{i=1}^{n} (\frac{i}{n})^2

  • Step 6: Simplify the expression using summation rules

    • A1ni=1ni2n2A \approx \frac{1}{n} \sum_{i=1}^{n} \frac{i^2}{n^2}

    • Since nn is a constant with respect to the index ii, n2n^2 can be factored out:
      A1n1n2i=1ni2A \approx \frac{1}{n} \cdot \frac{1}{n^2} \sum_{i=1}^{n} i^2

    • A1n3i=1ni2A \approx \frac{1}{n^3} \sum_{i=1}^{n} i^2

  • This result shows that to find the exact area, a formula for the sum of squares (i2\sum i^2) is needed.

Special Summation Formulas

  • These formulas provide immediate values for common sums, eliminating the need for manual expansion and calculation.

  • 1. Sum of the First nn Integers (Gauss's Formula)

    • Formula: i=1ni=1+2+3++n=n(n+1)2\sum_{i=1}^{n} i = 1 + 2 + 3 + \dots + n = \frac{n(n+1)}{2}

    • Origin: Attributed to Carl Friedrich Gauss. He observed that pairing the first and last numbers (1 and nn), second and second-to-last (2 and n1n-1), etc., always yields the sum (n+1)(n+1). There are racn2rac{n}{2} such pairs.

    • Example: For n=100n=100, the sum is rac100(100+1)2=50101=5050rac{100(100+1)}{2} = 50 \cdot 101 = 5050.

  • 2. Sum of the First nn Squares

    • Formula: i=1ni2=12+22+32++n2=n(n+1)(2n+1)6\sum_{i=1}^{n} i^2 = 1^2 + 2^2 + 3^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6}

    • This formula is more complex and relates to geometric principles involving hexagons in 2D space.

  • 3. Sum of the First nn Cubes

    • Formula: <em>i=1ni3=13+23+33++n3=(n(n+1)2)2=(</em>i=1ni)2\sum<em>{i=1}^{n} i^3 = 1^3 + 2^3 + 3^3 + \dots + n^3 = \left(\frac{n(n+1)}{2}\right)^2 = (\sum</em>{i=1}^{n} i)^2

    • This formula relates to 3D principles, such as tetrahedrons.

  • These formulas are essential for simplifying expressions derived from applications like Riemann sums and should be memorized.

Mathematical Induction

  • Purpose: To rigorously prove that a mathematical statement (or formula) is true for all natural numbers.

  • Motivation: While we can test a formula with a few numbers, we cannot test it for infinitely many. Induction provides a formal proof method.

  • Analogy: The