This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Algorithms Non-Lecture A: Fast Fourier Transforms Calvin: Heres another math problem I cant figure out. Whats 9+4? Hobbes: Ooh, thats a tricky one. You have to use calculus and imaginary numbers for this. Calvin: IMAGINARY NUMBERS?! Hobbes: You know, eleventeen, thirty-twelve, and all those. Its a little confusing at first. Calvin: How did YOU learn all this? Youve never even gone to school! Hobbes: Instinct. Tigers are born with it. Calvin and Hobbes (January 6, 1998) It needs evaluation So let the games begin A heinous crime, a show of force A murder would be nice, of course Bad Horses Letter, Dr. Horribles Sing-Along Blog (2008) A Fast Fourier Transforms ? A.1 Polynomials In this lecture well talk about algorithms for manipulating polynomials : functions of one variable built from additions subtractions, and multiplications (but no divisions). The most common representation for a polynomial p ( x ) is as a sum of weighted powers of a variable x : p ( x ) = n X j = a j x j . The numbers a j are called coefficients . The degree of the polynomial is the largest power of x ; in the example above, the degree is n . Any polynomial of degree n can be specified by a sequence of n + 1 coefficients. Some of these coefficients may be zero, but not the n th coefficient, because otherwise the degree would be less than n . Here are three of the most common operations that are performed with polynomials: Evaluate: Give a polynomial p and a number x , compute the number p ( x ) . Add: Give two polynomials p and q , compute a polynomial r = p + q , so that r ( x ) = p ( x ) + q ( x ) for all x . If p and q both have degree n , then their sum p + q also has degree n . Multiply: Give two polynomials p and q , compute a polynomial r = p q , so that r ( x ) = p ( x ) q ( x ) for all x . If p and q both have degree n , then their product p q has degree 2 n . Suppose we represent a polynomial of degree n as an array of n + 1 coefficients P [ 0 .. n ] , where P [ j ] is the coefficient of the x j term. We learned simple algorithms for all three of these operations in high-school algebra: E VALUATE ( P [ 0.. n ] , x ) : X 1 X = x j y for j 0 to n y y + P [ j ] X X X x return y A DD ( P [ 0.. n ] , Q [ 0.. n ]) : for j 0 to n R [ j ] P [ j ]+ Q [ j ] return R [ 0.. n ] M ULTIPLY ( P [ 0.. n ] , Q [ 0.. m ]) : for j 0 to n + m R [ j ] for j 0 to n for k 0 to m R [ j + k ] R [ j + k ]+ P [ j ] Q [ k ] return R [ 0.. n + m ] 1 Algorithms Non-Lecture A: Fast Fourier Transforms E VALUATE uses O ( n ) arithmetic operations. 1 This is the best we can hope for, but we can cut the number of multiplications in half using Horners rule : p ( x ) = a + x ( a 1 + x ( a 2 + ... + xa n )) ....
View Full Document
This note was uploaded on 12/15/2009 for the course 942 cs taught by Professor A during the Spring '09 term at University of Illinois at Urbana–Champaign.
- Spring '09