{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 6 Notes

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

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

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 ﬁnding 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 ﬂoor(qπ) < qπ < ceil(qπ) => (dividing by q gives) ﬂoor(qπ)/q < π < ceil(qπ)/q => need to check only two numerator values p- = ﬂoor(qπ) p+ = ce...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online