CSCE 222 Lecture 22

From Notes
Jump to navigation Jump to search

« previous | Wednesday, March 30, 2011 | next »


Recurrence Relations

A recurrence relation for the sequence of integers is an equation that expresses as a function of some of the previous terms to starting from an integer

A linear homogeneous recurrence relation of degree with constant coefficients is of the form:

linear
is a linear function of the terms before it (no exponents).
EX: is not linear.
homogeneous
every term is a multiple of
degree
the number of terms added to get the current .

This function can be rewritten as a series:

where is a constant.


Theorem

Let and be real numbers. Suppose that has 2 distinct roots and . Then has a solution iff is of the form: for constants and .


Example 1: Fibonacci Numbers

Given and ,

The Fibonacci sequence is a linear homogeneous function of degree 2

From here, we can get .

Using the theorem, we can rewrite as a degree 2 polynomial: has roots (the golden ratio).

More complicated math can solve for the constants Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \alpha_1} and Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \alpha_2} . Now we can solve the Fibonacci sequence in a single formula that runs in Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(1)} time:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle f_n = \alpha_1\left(\frac{1+\sqrt{5}}{2}\right)^n + \alpha_2\left(\frac{1-\sqrt{5}}{2}\right)^n}

The sequence grows asymptotically according to Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \Theta\left(\left(\frac{1+\sqrt{5}}{2}\right)^n\right)} .

Example 2: Towers of Hanoi

Moving one disk at a time, move all Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} disks from peg 1 to peg 3. A larger disk cannot be placed on top of a smaller one.

In order to do this, the top Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n-1} disks have to be moved to peg 2, the largest disk is moved to peg 3, then the top Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n-1} disks are moved to peg 3.

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle H_n = H_{n-1} + 1 + H_{n-1} = 2H_{n-1}+1 = 2^n-1}

The towers of hanoi function is linear, but not homogeneous since we add 1.

Given Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle H_1 = 1} , we can find Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle H_2 = 3} , Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle H_3 = 7} .