Lecture 6 Notes

G going from m2 to m log m m versus 2m note in scien3c

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t; err_pq % best p/q found err_pq = abs(p/q - pi); pBest= p; qBest= q; end end end myPi = pBest/qBest; Ques3on Time This is an example of a “nested loop” for every q M p’s are checked. What is the run 3me? (i.e. how many itera3ons for a given M?) A) M B) 2M C) M^2 D) M^M 6 2/11/14 Remark % Rational approximation of pi •  Example of finding best thing in a set •  Version in book is ugly (but remarks and analysis are correct). –  SimpleEg_1.m and BeJerEg_1.m are cleaner implementa3ons. Improvements •  Inner loop floor(qπ) < qπ < ceil(qπ) => (dividing by q gives) floor(qπ)/q < π < ceil(qπ)/q => need to check only two numerator values p- = floor(qπ) p+ = ce...
View Full Document

This document was uploaded on 03/11/2014 for the course CSCI 004 at Brown.

Ask a homework question - tutors are online