Comp 163 Week 6 notes

Week of Feb 21

mathwithbaddrawings.com/2017/02/08/how-to-tell-a-mathematician-you-love-them

Homework 4:

3a: stars-and-bars for picking six jellybeans from among five flavors. What is indistinguishable? The flavors are distinguishable.

Here's another way of looking at it: let's distribute six identical pebbles in front of the five jars of distinguishable jelly beans. This is exactly the same as distributing six identical cookies to five children, and is done with six stars and 5-1 = 4 bars.

Now just trade in each pebble for one of that flavor of jelly bean, and we've converted this to the original problem!

2bc: starting with a0 vs starting with a1

Chapter 2: Sequences

2.1.6: more summation

2.2: Arithmetic and Geometric Sequences

p 148: Investigate!

Arithmetic sequences: constant difference
Geometric sequences: constant ratio

Example 2.2.1: arithmetic sequences

Example 2.2.2: geometric sequences

Sums of arithmetic and geometric sequences

1 + 2 + 3 + ... + 100

Proof by induction: 1 + 2 + ... + N = N(N+1)/2

Example 2.2.4: reverse-and-add, often easier than reducing to triangle numbers

Example 2.2.5

Example 2.2.6 on Levin p 154

Let bk = 1+3k. Then the sum

an = 2 + 1 + 4 + 7 + 10 + · · · + (1 + 3(n−1))

can be rewritten as

an =2 + b0 + b1 + ... + bn-1.

Written this way it is clearer that there are n terms of the form bk here, ranging from 0 to (n-1).

Evaluate 1+2+4+...+512

Example 2.2.7

Example 2.2.8

Example 2.2.9

    S = 0.464646.... When we subtract from 100S, we get +46 on the right, but there is no minus term. Why?

2.3: Polynomial Fitting

Let bN = 12 + 22 + 32 + ... + N2

Is bN an arithmetic sequence? No, but look at the second differences.

Find a closed formula for bN.

What about 13 + 23 + 33 + ... + N3?

If the n-th differences are constant, then ak can be expressed as a polynomial in k of degree n, and the sums can be expressed as a polynomial of degree n+1.

2.4: Recurrence Relations

Investigate!, page 167

Start here Wednesday

def a(n):
    if n== 0: return 1
    if n==1: return 2
    return 5*a(n-1) - 6*a(n-2)
def b(n):
    if n== 0: return 1
    if n==1: return 3
    return 5*b(n-1) - 6*b(n-2)

def c(n):
    if n== 0: return 1
    if n==1: return 4
    return 5*c(n-1) - 6*c(n-2)

Example 2.4.2, p 168; proof by induction

Example 2.4.3: an = an-1 + n. This is a constant 2nd-difference sequence. Use telescoping.

Example 2.4.4: same problem, alternative approach

Example 2.4.5: introduce a factor: an = 3*an-1 + 2. Note Levin's algebra restart!

def a(n):
    if n== 0: return 1
    return 3*a(n-1) + 2

    

Characteristic roots: works when an+1 is the sum of a linear combination of the two previous terms an and an-1.

Example 2.4.6

Example at start of chapter: an = 5*an-1 - 6*an-2

Fibonacci example, Levin p 173

import math
phi=(1+math.sqrt(5))/2
pho=(1-math.sqrt(5))/2
def s(n):
    return (pow(phi,n)-pow(pho,n))/math.sqrt(5)
for i in range(20):
    print(i,'\t',s(i))

2.5: Mathematical Induction

Postage in Investigate!

Example 2.5.1: triangle numbers

Example 2.5.2: 6n-1 is divisible by 5

Example 2.5.3: n2 < 2n for n>=5

Warning: Canadians

Euclidean algorithm theorem: for integers a and b<a, we can find q and r so a=qb+r