hw1_solutions - Due: September 4, 2008 CS 257 (Luke Olson):...

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

View Full Document Right Arrow Icon
Due: September 4, 2008 CS 257 (Luke Olson): Homework #1 Solutions Problem 1 Problem 1 [Timing] While developing code for a project, we notice that the implementation of our numerical method strongly depends on the size of the data with which we are working. Suppose we time ( t ) our method with n pieces of data and notice the following timing results (see timing data.m ): n t (milliseconds) 1 4.700000e+00 6 8.770584e+02 11 5.364180e+03 16 1.646625e+04 21 3.718331e+04 26 7.051535e+04 31 1.194624e+05 36 1.870244e+05 41 2.762014e+05 46 3.899935e+05 51 5.314005e+05 56 7.034225e+05 61 9.090595e+05 66 1.151312e+06 71 1.433179e+06 76 1.757661e+06 81 2.127758e+06 86 2.546470e+06 91 3.016797e+06 96 3.541739e+06 Determine the dependence on n (e.g. is the dependence O ( n α )?). Hint: look at plot , semilogy , loglog , in Matlab. Hand in your estimate and justify with either a plot or with a short script . Solution A log-log plot of t versus n gives us: 10 0 10 1 10 2 10 0 10 2 10 4 10 6 10 8 n t This is a straight line with slope about equal to 3, which would mean t ≈ O ( n 3 ). More precisely, consider t = kn α . Then for two consecutive pieces of data ( n 1 ,t 1 ) and ( n 2 ,t 2 ), we have t 1 = kn α 1 and t 2 = kn α 2 . From this, we see t 1 t 2 = ± n 1 n 2 ² α Problem 1 [Solution] continued on next page. . . Page 1 of 6
Background image of page 1

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

View Full DocumentRight Arrow Icon
Due: September 4, 2008 CS 257 (Luke Olson): Homework #1 Solutions Problem 1 so that α log ± t 1 t 2 ² log ± n 1 n 2 ² In Matlab: >> log(t(1:end-1)./t(2:end))./log(n(1:end-1)./n(2:end))
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

hw1_solutions - Due: September 4, 2008 CS 257 (Luke Olson):...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online