CSC 340 Final Test 14 April 2014 Name _______________________ Due: Your response is due by 6:00 PM, Wednesday, 7 May 2014. General Instructions: This is a take home test and you must do your work independently. For this test you must employ your own implementation of matrix and vector tools implemented for Tests 1 and 2, your own implementation of complex number operations, your own implementation of fast Fourier transforms (Algorithms 10.3.1 and 10.7.1) and associated tools, to generate correlation, convolution, and spectra. You may use algorithms implemented in a software tool such as Excel, MatLab, Maple or Mathematica only to construct data displays or to verify the correctness of your personal implementation of the required algorithms. A significant component of this exercise requires the interpretation of findings as well as implementations of related algorithms (e.g., PSD, convolution, and correlation) based upon one- or twodimensional FFTs. Give careful attention to your written responses. Give complete responses, including supporting findings and written explanations. While you must provide documentation containing evidence of your coding and your computational results, YOU MUST ASSEMBLE YOUR RESPONSE INTO A SINGLE WORD DOCUMENT. DO NOT EXPECT credit for evidence that is not included in your written response to the test questions. Problems: 1. Curve fitting and root finding (26 points total): Given the four points in the set P = {(-2, -4), (-1, 1), (0, -6), (1,-1)}. a. Use your matrix tools to find and report the coefficients of the lowest degree polynomial that passes through the points in P. i. Report the augmented coefficient matrix for the system (5 points). ii. Report the coefficients for the polynomial and the polynomial itself (5 points). iii. Find and report the Lagrange polynomials for the four points. (4 points) b. Implement and test a root-finding method and then use it to find, estimate, and report the roots of the polynomial. i. How many roots does the polynomial have (3 points)? ii. What method did you implement (2 points)? iii. What are the estimates to the roots (3 points)? iv. Report the estimate precision you chose and the number of iterations necessary for the method to converge (4 points). 2. Signals and basic DSP: a. Common signals (24 points total) i. Using S terms, with S=5, 10 and 1000, from each of the series below and at least 1024 samples of x, where x ε [0, 1), generate plots of graphs of the following functions: 1. 𝑓𝑆 (𝑥) = ∑𝑆𝑘=1 sin(2𝜋(2𝑘−1)𝑥) (2𝑘−1) (3 points; 1 point for each function, with all three on a single chart) 2. 𝑔𝑆 (𝑥) = ∑𝑆𝑘=1 sin(2𝜋(2𝑘)𝑥) (2𝑘) (3 points; 1 point for each function, with all three on a single chart) Create and plot (using the positive frequencies only) power spectral density (PSD) estimates for the functions f1000 and g1000. (6 points) iii. Observe that, when more terms are used for approximating the functions, the graphs appear to be approaching limit functions fL and gL. 1. Provide a verbal description of the graphs of the two limit functions (3 points). 2. Generate your own data to estimate the limit functions fL and gL at 1024 points, and then overlay plots of their graphs onto your plot of the graphs of f and g (6 points)? iv. Create and plot PSD estimates for the functions fL and gL (3 points). b. Several in-class examples employed sums of signals of the form x(t) = a sin( 2π f (t-c)), where a is the amplitude, f is the frequency, c is the phase shift of the signal, and t ε [0, 1). Compare and contrast the PSD estimates for two signals: x(t) = the sum of two sine functions and y(t) = the product of the same two sine functions. Assume that all sine functions have the same amplitude and the same phase shift. Also assume that f1 = 10 for the first sine function and f2 = 43 for the second, in order to generate 1024 samples for x and y. (6 points total) i. How are the PSDs similar (3 points)? ii. How do the PSDs differ (3 points)? c. Phase (6 points total) i. Suppose that a collection of 1024 samples of a signal contains single 1 and 1023 zeroes. Describe how the PSD estimate is affected by varying the specific time at which the pulse occurs (2 points)? ii. Suppose that another signal consists of a pure sinusoidal tone, h(x) = sin( 38x) on the interval [0, 1]. 1. How is the discrete Fourier transform affected by introducing phase shift 1>c>0, so that h(x) = sin( 38x-c)) (2 points)? 2. How is the PSD estimate affected by the phase shift (2 points)? ii. d. For this problem, use either f1000 or g1000 (but not both) from problem 2a. Thus, this problem description assumes that exactly 1000 terms were used in forming the function. Construct ideal filters and apply them to the signal to as follows (12 points total): i. Use a low-pass (LP) filter to generate a filtered signal that passes only the lowest five frequencies. ii. Use a high-pass (HP) filter to generate a filtered signal that suppresses the lowest five frequencies. iii. Use a band-pass (BP) filter to generate a filtered signal that passes only the 5th through the 8th frequencies. iv. Use a notch filter to generate a filtered signal that suppresses only the 5th through the 8th frequencies. v. Plot the original signal with each of the four filtered signals (8 points). vi. Provide a verbal description of how the original signal is affected by each of the four filtering processes (4 points): 1. LP? 2. HP? 3. BP? 4. Notch? e. Correlation and convolution (12 points total) i. Assume that an acoustic pulse is transmitted in sea water. Estimate the range to the primary reflector for the pulse and return signals given in “rangeTest2014.txt” file. Assume that the receiver is turned off for 0.04 seconds after the pulse is transmitted, 100 kHz sampling rate, and the return signal measurements were taken from the first 1024-sample window after the receiver begins listening again. How far away is the primary reflector (6 points)? ii. Use FFT convolution to smooth the signal with a 20-point filter (p=20). On a single chart, centered on the pulse, plot 256 consecutive samples of the original signal and the smoothed signal (6 points). f. Two-dimensional FFT (14 points total) You may use the Picture class, linked to the course web site, to render images for this problem. i. Set-up (4 points) 1. Generate a test signal corresponding to a monochrome image, a 512x512 array pixel values as follows: a. Set all values to zero; b. Beginning at row 230 and column 206, change the entries to create a rectangular sub-region in the array having 150 rows and 75 columns whose values are 255 2. Generate a 50 x 25 test pulse using pixel intensity values = 255, and pad the remainder of a 512x512 array with zeros. ii. Find and display the two-dimensional correlation of the signal and the test pulse (5 points). iii. Create and render a display of the correlation magnitude, painting those locations whose correlation is within 10% of maximum with red (5 points).