{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 3 Notes

# The loop body n 10 number of data values total 0

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: . end 1/30/14 37 1/30/14 Mo=va=ng Problem: Compu=ng Square Roots 38 A Geometric Restatement Given a posi=ve number A, ﬁnd its square root. Given a posi=ve number A, ﬁnd a square whose area is A. 1/30/14 39 1/30/14 40 Observa=on An Ini=al Guess W=1 L=A s How can we make this rectangle “ more square”? 1/30/14 The answer is in between L and W: W<s<L 41 1/30/14 42 1/31/14 Idea: Repeat: W W1 L L1 = (L+W)/2 L1 W1 = A/L1 L2 = (L1+W1)/2 W2 = A/L2 W1 L1 1/30/14 43 1/30/14 44 A Script A Modiﬁed Script A = input(‘A:’); L0 = A; W0 = A/L0; L1 L2 L3 L4 = = = = (L0 (L1 (L2 (L3 + + + + W0)/2; W1)/2; W2)/2; W3)/2; A = input(‘A:’); L = A; W = A/L; W1 W2 W3 W4 = = = = A/L1; A/L2; A/L3; A/L4; 1/30/14 L L L L 45 = = = = (L (L (L (L W W W W = = = = A/L; A/L; A/L; A/L; 46 More General A = input(‘A:’); L = A; W = A/L; 1/30/14 W)/2; W)/2; W)/2; W)/2; 1/30/14 Square Root with I...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern