Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.

Similar documents
Complex Numbers. Now we also saw that if a and b were both positive then ab = a b. For a second let s forget that restriction and do the following.

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz

High level vs Low Level. What is a Computer Program? What does gcc do for you? Program = Instructions + Data. Basic Computer Organization

Problem Set 3 Solutions

CSE 326: Data Structures Quicksort Comparison Sorting Bound

Brave New World Pseudocode Reference

Programming in Fortran 90 : 2017/2018

CSE 326: Data Structures Quicksort Comparison Sorting Bound

Kent State University CS 4/ Design and Analysis of Algorithms. Dept. of Math & Computer Science LECT-16. Dynamic Programming

CSCI 104 Sorting Algorithms. Mark Redekopp David Kempe

A Binarization Algorithm specialized on Document Images and Photos

CE 221 Data Structures and Algorithms

Course Introduction. Algorithm 8/31/2017. COSC 320 Advanced Data Structures and Algorithms. COSC 320 Advanced Data Structures and Algorithms

CMPS 10 Introduction to Computer Science Lecture Notes

Mathematics 256 a course in differential equations for engineering students

Sequential search. Building Java Programs Chapter 13. Sequential search. Sequential search

Today s Outline. Sorting: The Big Picture. Why Sort? Selection Sort: Idea. Insertion Sort: Idea. Sorting Chapter 7 in Weiss.

Machine Learning: Algorithms and Applications

GSLM Operations Research II Fall 13/14

Array transposition in CUDA shared memory

Sorting Review. Sorting. Comparison Sorting. CSE 680 Prof. Roger Crawfis. Assumptions

S1 Note. Basis functions.

For instance, ; the five basic number-sets are increasingly more n A B & B A A = B (1)

Sorting. Sorting. Why Sort? Consistent Ordering

Parallel matrix-vector multiplication

Parallelism for Nested Loops with Non-uniform and Flow Dependences

Optimization Methods: Integer Programming Integer Linear Programming 1. Module 7 Lecture Notes 1. Integer Linear Programming

The Codesign Challenge

Algorithm To Convert A Decimal To A Fraction

CHAPTER 2 DECOMPOSITION OF GRAPHS

CS221: Algorithms and Data Structures. Priority Queues and Heaps. Alan J. Hu (Borrowing slides from Steve Wolfman)

CHAPTER 10: ALGORITHM DESIGN TECHNIQUES

Skew Angle Estimation and Correction of Hand Written, Textual and Large areas of Non-Textual Document Images: A Novel Approach

Conditional Speculative Decimal Addition*

Insertion Sort. Divide and Conquer Sorting. Divide and Conquer. Mergesort. Mergesort Example. Auxiliary Array

Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / 2003 Elsevier

Parallel Inverse Halftoning by Look-Up Table (LUT) Partitioning

News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example

Exercises (Part 4) Introduction to R UCLA/CCPR. John Fox, February 2005

6.854 Advanced Algorithms Petar Maymounkov Problem Set 11 (November 23, 2005) With: Benjamin Rossman, Oren Weimann, and Pouya Kheradpour

The Greedy Method. Outline and Reading. Change Money Problem. Greedy Algorithms. Applications of the Greedy Strategy. The Greedy Method Technique

Data Representation in Digital Design, a Single Conversion Equation and a Formal Languages Approach

Computer models of motion: Iterative calculations

ELEC 377 Operating Systems. Week 6 Class 3

Review of approximation techniques

NAG Fortran Library Chapter Introduction. G10 Smoothing in Statistics

AP PHYSICS B 2008 SCORING GUIDELINES

Virtual Memory. Background. No. 10. Virtual Memory: concept. Logical Memory Space (review) Demand Paging(1) Virtual Memory

Introduction to Geometrical Optics - a 2D ray tracing Excel model for spherical mirrors - Part 2

Intro. Iterators. 1. Access

AMath 483/583 Lecture 21 May 13, Notes: Notes: Jacobi iteration. Notes: Jacobi with OpenMP coarse grain

Hermite Splines in Lie Groups as Products of Geodesics

R s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes

F Geometric Mean Graphs

9. BASIC programming: Control and Repetition

2x x l. Module 3: Element Properties Lecture 4: Lagrange and Serendipity Elements

An Optimal Algorithm for Prufer Codes *

Classification / Regression Support Vector Machines

ON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE

Specifications in 2001

User Authentication Based On Behavioral Mouse Dynamics Biometrics

Machine Learning 9. week

Smoothing Spline ANOVA for variable screening

On Some Entertaining Applications of the Concept of Set in Computer Science Course

Improving Low Density Parity Check Codes Over the Erasure Channel. The Nelder Mead Downhill Simplex Method. Scott Stransky

CS1100 Introduction to Programming

A Fast Visual Tracking Algorithm Based on Circle Pixels Matching

Motivation. EE 457 Unit 4. Throughput vs. Latency. Performance Depends on View Point?! Computer System Performance. An individual user wants to:

Cluster Analysis of Electrical Behavior

K-means and Hierarchical Clustering

Solving Route Planning Using Euler Path Transform

A MOVING MESH APPROACH FOR SIMULATION BUDGET ALLOCATION ON CONTINUOUS DOMAINS

Module Management Tool in Software Development Organizations

MATHEMATICS FORM ONE SCHEME OF WORK 2004

Floating-Point Division Algorithms for an x86 Microprocessor with a Rectangular Multiplier

Solutions to Programming Assignment Five Interpolation and Numerical Differentiation

Notes on Organizing Java Code: Packages, Visibility, and Scope

A SYSTOLIC APPROACH TO LOOP PARTITIONING AND MAPPING INTO FIXED SIZE DISTRIBUTED MEMORY ARCHITECTURES

Using Delayed Addition Techniques to Accelerate Integer and Floating-Point Calculations in Configurable Hardware

Wishing you all a Total Quality New Year!

Optimizing Document Scoring for Query Retrieval

Outline. Midterm Review. Declaring Variables. Main Variable Data Types. Symbolic Constants. Arithmetic Operators. Midterm Review March 24, 2014

Hierarchical clustering for gene expression data analysis

Lecture 3: Computer Arithmetic: Multiplication and Division

A Fast Content-Based Multimedia Retrieval Technique Using Compressed Data

Sorting: The Big Picture. The steps of QuickSort. QuickSort Example. QuickSort Example. QuickSort Example. Recursive Quicksort

Random Kernel Perceptron on ATTiny2313 Microcontroller

Optimal Workload-based Weighted Wavelet Synopses

Sorting and Algorithm Analysis

Priority queues and heaps Professors Clark F. Olson and Carol Zander

UNIT 2 : INEQUALITIES AND CONVEX SETS

2D Raster Graphics. Integer grid Sequential (left-right, top-down) scan. Computer Graphics

Problem Definitions and Evaluation Criteria for Computational Expensive Optimization

Solving two-person zero-sum game by Matlab

A mathematical programming approach to the analysis, design and scheduling of offshore oilfields

Accounting for the Use of Different Length Scale Factors in x, y and z Directions

Lecture 5: Multilayer Perceptrons

USING GRAPHING SKILLS

AVO Modeling of Monochromatic Spherical Waves: Comparison to Band-Limited Waves

Design and Analysis of Algorithms

Transcription:

Farrukh Jabeen Algorthms 51 Assgnment #2 Due Date: June 15, 29. Assgnment # 2 Chapter 3 Dscrete Fourer Transforms Implement the FFT for the DFT. Descrbed n sectons 3.1 and 3.2. Delverables: 1. Concse descrpton of the problem. 2. Defne all the varables, ncludng nputs and outputs. 3. Provde an FFT soluton. 4. Analyze the run tme. 5. Gve 2 eamples, wth specfc values for the varables, showng each step of the algorthm. 6. Implement a software smulaton (any programmng language). a) user nputs values for the ntal varables (or read from a fle). b) soluton s prnted out. c) dscusson of the plausblty of the solutons (are they correct?). d) graphc dsplay (etra credt). 1. Concse descrpton of the problem. Polynomal: p + 2 3 4 ( = 5 + 2 + 8 + 3 4 n general p( = a p( 1 n 1 = or = + a + a 2 a 2 + L+ a n 1 n 1 Horner s Rule: Gven coeffcents (a,a 1,a 2,,a n-1 ), defnng polynomal

p( n = 1 = a Gven, we can evaluate p( n O(n) tme usng the equaton p( = a + ( a + 1 ( a + 2 L + ( a + n 2 an 1) L)) Gven coeffcents (a,a 1,a 2,,a n-1 ) and (b,b 1,b 2,,b n-1 ) defnng two polynomals, p() and q(), and number, compute p(q(. Horner s rule doesn t help, snce p( q( n = 1 = c Where c = j= a b j j A straghtforward evaluaton would take O(n 2 ) tme. The magcal FFT wll do t n O(n log n) tme Gven a set of n ponts n the plane wth dstnct -coordnates, there s eactly one (n-1)-degree polynomal gong through all these ponts. Alternate approach to computng p(q(: Calculate p() on 2n -values,, 1,, 2n-1. Calculate q() on the same 2n values. Fnd the (2n-1)-degree polynomal that goes through the ponts {(,p( )q( )), ( 1,p( 1 )q( 1 )),, ( 2n-1,p( 2n-1 )q( 2n-1 ))}. Unfortunately, a straghtforward evaluaton would stll take O(n 2 ) tme, as we would need to apply an O(n)-tme Horner s Rule evaluaton to 2n dfferent ponts. The magcal FFT wll do t n O(n log n) tme, by pckng 2n ponts that are easy to evaluate. Cooley-Tukey FFT algorthm The Cooley-Tukey algorthm, named after J.W. Cooley and John Tukey, s the most common fast Fourer transform (FFT) algorthm. It re-epresses the dscrete Fourer transform (DFT) of an arbtrary composte sze N = N1N2 n terms of smaller DFTs of szes N1 and N2, recursvely, n order to reduce the computaton tme to O(N log N) for hghly-composte N (smooth numbers). Because the Cooley-Tukey algorthm breaks the DFT nto smaller DFTs, t can be combned arbtrarly wth any other algorthm for the DFT. The rad-2 DIT case A rad-2 decmaton-n-tme (DIT) FFT s the smplest and most common form of the Cooley-Tukey algorthm. Rad-2 DIT dvdes a DFT of sze N nto two nterleaved DFTs (hence the name "rad-2") of sze N/2 wth each recursve stage.

The DFT s defned by the formula: where k s an nteger rangng from to N 1. Rad-2 DIT frst computes the Fourer transforms of the even-ndeed numbers ( ) and of the odd-ndeed numbers ( ), and then combnes those two results to produce the Fourer transform of the whole sequence. Ths dea can then be performed recursvely to reducee the overall runtme to O(N log N). Ths smplfed form assumes that N s a power of two; snce the number of sample ponts N can usually be chosen freely by the applcaton, ths s often not an mportant restrcton. More eplctly, let us wrte M = N / 2 and denote the DFT of the even-ndeed numbers 2m by E j and the DFT of the odd-ndeed numbers 2m + 1 by O j (m =,...,M 1, j =,...,M 1). Then t follows: Here we have used the crtcal fact that E k + M = E k and O k + M = O k, so that these DFTs, n addton to havng only M sample ponts, need only be evaluated for M values of k. The orgnal DFT has thus been dvded nto two DFTs of sze N/2. Ths process s an eample of the general technque of dvde and conquer algorthms; n many tradtonal mplementatons, however, the eplct recurson s avoded, and nstead one traverses the computatonal tree n breadth-frst fashon. The above re-epresson of a sze-nn DFT as two sze-n/2 DFTs s sometmes called the Danelson-Lanczos lemma, snce the dentty was noted by those two. They appled ther lemma n a "backwards" recursve fashon, repeatedly doublng the DFT sze untl the transform spectrum converged. The Danelson- (possbly Lanczos work predated wdespreadd avalablty of computers and requred hand calculaton wth mechancal ads such as addng machnes); they reported a computaton tme of 14 mnutes for a sze-64 DFT operatng on real nputs to 3-5 sgnfcant dgts. Cooley and Tukey's 1965 paper reported a runnng tme of.2 mnutes for a sze-248 comple DFT on an IBM 794 (probably n 36-bt sngle precson, ~8 dgts). Rescalng the tme by the number of operatons, ths corresponds roughly to a speedup factor of around 8,. (14 mnutes for sze 64 may sound lke a long tme, but t corresponds to an average of at most 16 seconds per floatng-pont operaton, around 2% of whch are multplcatons...ths s a farly mpressve rate for a human beng to sustan for over two hours.

More generally, Cooley-Tukey algorthms recursvely re-epress a DFT of a composte sze N = N 1 N 2 as: 1. Perform N 1 DFTs of sze N 2. Multply by comple roots of unty called twddle factors. 2. Perform N 2 DFTs of sze N 1. Typcally, ether N 1 or N 2 s a small factor (not necessarly prme), called the rad (whch can dffer between stages of the recurson). If N 1 s the rad, t s called a decmaton n tme (DIT) algorthm, whereas f N 2 s the rad, t s decmaton n frequency (DIF, also called the Sande-Tukey algorthm). The verson presented above was a rad-2 DIT algorthm; n the fnal epresson, the phase multplyng the odd transform s the twddle factor, and the +/- combnaton (butterfly) of the even and odd transforms s a sze-2 DFT. (The rad's small DFT s sometmes known as a butterfly, so-called because of the shape of the dataflow dagram for the rad-2 case.) 2.Defne all the varables, ncludng nputs and outputs.3. Provde an FFT soluton.4. Analyze the run tme.5. Gve 2 eamples, wth specfc values for the varables, showng each step of the algorthm. Inputs: length N comple sequence. Or we can say compute the FFT of [], assumng ts length s a power of 2 outputs : y = fft( the followng mplementaton runs n O(N log N) tme Eample 1: N=4 fft of even terms Comple[] even = new Comple[N/2]; for (nt k = ; k < N/2; k++) { even[k] = [2*k]; } Comple[] q = fft(even);

fft of odd terms Comple[] odd = even; // reuse the array for (nt k = ; k < N/2; k++) { odd[k] = [2*k + 1]; } Comple[] r = fft(odd); combne Comple[] y = new Comple[N]; for (nt k = ; k < N/2; k++) { double kth = -2 * k * Math.PI / N; Comple wk = new Comple(Math.cos(kth), Math.sn(kth)); y[k] = q[k].plus(wk.tmes(r[k])); y[k + N/2] = q[k].mnus(wk.tmes(r[k])); Eample 2: For second eample we can take N=8 because ths algorthm works only for N s a power of two. 6. Implement a software smulaton (any programmng language).a) user nputs values for the ntal varables (or read from a fle).b) soluton s prnted out.c) dscusson of the plausblty of the solutons (are they correct?).d) graphc dsplay (etra credt). Please see java fles n the folder FFT on my web page. For N=4 ------------------- Absoulte Mnmum = 1.E-12.964925473156612.834229714597234.36455598316777.1915951989722586 y = fft( ------------------- Absoulte Mnmum = 1.E-12 1.432639475182664.6369491399835 -.6426345156247726 1.226898964844113.6369491399835 +.6426345156247726 We can check our soluton by takng fft

z = fft(y) ------------------- Absoulte Mnmum = 1.E-12.964925473156611.83422971459724.364555983167765.1915951989722514 References: webhome.csc.uvc.ca/~ruskey/classes/326/sldes/chpt1fft.ppt http://www.jmloy.com/algebra/roots.htm http://www.cs.ptt.edu/~krk/cs151/anmatons/fft.html http://en.wkpeda.org/wk/cooley-tukey_fft_algorthm http://www.cs.prnceton.edu/ntrocs/97data/fft.java.html