{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 01a-fft - Algorithms Non-Lecture A Fast Fourier Transforms...

This preview shows pages 1–3. Sign up to view the full content.

Algorithms Non-Lecture A: Fast Fourier Transforms Calvin: Here’s another math problem I can’t figure out. What’s 9+4? Hobbes: Ooh, that’s 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. It’s a little confusing at first. Calvin: How did YOU learn all this? You’ve 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 Horse’s Letter”, Dr. Horrible’s Sing-Along Blog (2008) A Fast Fourier Transforms ? A.1 Polynomials In this lecture we’ll 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 = 0 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 0 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 ] 0 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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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 Horner’s rule : p ( x ) = a 0 + x ( a 1 + x ( a 2 + ... + xa n )) . H ORNER ( P [ 0.. n ] , x ) : y P [ n ] for i n - 1 downto 0 y x · y + P [ i ] return y The addition algorithm also runs in O ( n ) time, and this is clearly the best we can do. The multiplication algorithm, however, runs in O ( n 2 ) time. In the previous lecture, we saw a divide and conquer algorithm (due to Karatsuba) for multiplying two n -bit integers in only O ( n lg3 ) steps; precisely the same algorithm can be applied here. Even cleverer divide-and-conquer strategies
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}