rho = x .* (x < pi) + (x - 2*pi) .* (x > pi); rho(N/2+1)=0 k = [ 0:N/2-1, -N/2:-1 ]; k(1) = 1; phi = ifft(- fft(rho) ./ k.^2); 18.336 Problem Set 1 Due Tuesday, 21 February 2006. Problem 1: (The k(1)=1 command is a hack to avoid divid- Trigonometric interpo- ing zero by zero when we divide by lation polynomials (a) f (xn ) = fn at N points 2π n , n = 0, · · · , N − 1, and you construct N the trigonometric interpolation polynomial φ00N (x) You are given a function ation of xn = mand twice to phi and scaling by f (x) = N −1 X φ00N (x) (b) e e `k = 1, term with showed for i(k+`k N )x ck ∆N if you replace any for any integer `k (we but other values follow by N = 10 many possible trigonometric interpolations with (N −1)/2 ikx ck e on a Consider the Cooley-Tukey decimation-in-time (DIT) radix-2 FFT algorithm applied to compute the DFT of length N −1 X + k=0 (b) from Problem 3: Fast Fourier Transforms `Rk 's that min2π 1 0 2 imizes the mean-square slope 2π 0 |f (x)| dx (for arbitrary fn ) is the symmetric polynomial: f (x) = ∆N for a sequence of N values N = 10000 and plot ∆N vs. N to to be odd for simplicity. Show that the unique choice of integer X φ2N (x), and compute dence (a straight line). What is the exponent? fn . N points to get log-log scale. You should get a power-law depen- the same ck coecients passing through the same Assume 2N v u N u1 X 2π 2π |φN ( n) − φ2N ( n)|2 ≡t N n=0 N N Compute induction). This means that there are actually (a) that Estimate the error by repeating the calcu- via the DFT. We showed in class that one would ikx 1/∆x2 ) the root-mean-square dierence k=0 get the same coecient (applying Matlab's di com- ≈ ρ(x). lation for ck eikx k 2 .) Show by a simple nite-dierence evalu- fn As we showed in class, this recursively decomposes the prob- i(k−N )x ck e lem into two DFTs of length k=(N +1)/2 Suppose that the N = 2m . N/2 of the even- and odd-indexed inputs, respectively. (a) values are real num- Assume that the inputs are complex num- to be bers, and that a complex addition takes 2 real Show that the additions and a general complex multiplication above symmetric polynomial satises this (i.e. takes 4 real multiplications and 2 real additions, bers. We would like the interpolated real as well for all real f (x) x ∈ [0, 2π). for arbitrary real polynomial with real fn ). f (x) and that all twiddle factors (cosine and sine val- Is it the unique ues) are precomputed. The exact count of real f (x)? adds+multiplies is of the form # · N log2 N + O(N ). Show what # is. (Count multiplications by ±1 and ±i as free, or equivalently subtraction Problem 2: Solving Poisson's equation counts as addition.) (b) Here, you will use Matlab to explore the solution of Poisson's equation boundary conditions Suppose that the inputs are purely real, in which case the outputs 00 φ (x) = ρ(x) with periodic on x ∈ [0, 2π) via spectral try cN −k = c∗k . ck have the symme- Show that, by applying radix-2 methods and FFTs. In particular, the following Cooley-Tukey directly to this data and tossing φ(x) given a sawtooth function ρ(x) = x for 0 ≤ x < π and ρ(x) = x − 2π for π < x < 2π using N = 100 points to get an approximate solution φN (x): out the redundant computations, we can com- Matlab code solves for pute the DFT in (#/2) · N log2 N + O(N ) adds+multiplies. (Numerical Recipes fans may real know that you can compute a real-input DFT for even N=100; x = linspace(0,2*pi, N+1); x = x(1:end-1); N by embedding it into a complex-input DFT of length 1 N/2. Don't use this trick here.)