COM S
chapter2

# chapter2 - 28 Chapter 2 Numerical Exploration 2.1...

• Notes
• 24

This preview shows pages 1–5. Sign up to view the full content.

28

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

Chapter 2 Numerical Exploration § 2.1 Discovering Limits The for -loop and the while -loop § 2.2 Floating Point Terrain The floating point representation, exponent, mantissa, overflow, underflow, ma- chine precision, eps , inf , realmax , roundoff error § 2.3 Confirming Conjectures Analyzing errors § 2.4 Interactive Frameworks The type char , testing All work and no play does not a computational scientist make. It is essential to be able to play with a computational idea before moving on to its formal codification and development. This is very much a comment about the role of intuition. A computational experiment can get our mind moving in a creative direction. In that sense, merely watching what a program does is no different then watching a chemistry experiment unfold: it gets us to think about concepts and relationships. It builds intuition. The chapter begins with a small example to illustrate this point. The area of a circle is computed as a limit of regular polygon areas. We “discover” π by writing and running a sequence of programs. Sometimes our understanding of an established result is solidified by experiments that confirm its correctness. In § 2.2 we check out a theorem from number theory that says 3 2 k +1 +2 k is divisible by 7 for all positive integers k . To set the stage for more involved “computational trips” into mathematics and science, we explore the landscape of floating point numbers. The terrain is finite and dangerous . Our aim is simply to build a working intuition for the limits of floating point arithmetic. Formal models are not developed. We’re quite happy just to run a few well chosen computational experiments that show the lay of the land and build an appreciation for the inexactitude of real arithmetic. 29
30 Chapter 2. Numerical Exploration Figure 2.1 Regular n -gons Figure 2.2 Inscribed n -gon The design of effective problem-solving environments for the computational scientist is a research area of immense importance. The goal is to shorten the path from concept to computer program. We have much to say about this throughout the text, In § 2.4 we develop the notion of an interactive framework that fosters the exploration of elementary computational ideas. 2.1 Limits A polygon with n equal sides is called a regular n -gon . Figure 2.1 illustrates two cases. Given n equally spaced points around a circle C , there are two ways to construct a regular n -gon. One is simply to connect the points in order. Each point is then a vertex of the n -gon which is said to be inscribed in C . See Figure 2.2 . On the other hand, the tangent lines at each point define a regular n -gon that circumscribes C . See Figure 2.3 . If C has radius one, then the areas of these two regular n -gons are given by A n = ( n/ 2) sin(2 π/n ) (Inscribed)

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

2.1. Limits 31 Figure 2.3 Circumscribed n -gon B n = n tan( π/n ) (Circumscribed) These formulas can be derived by chopping the n -gon into n equal triangles and summing their areas. Now for any value of n that satisfies n 3, the fragment % Fragment A innerA= (n/2)*sin(2*pi/n);
This is the end of the preview. Sign up to access the rest of the document.
• Spring '07
• FAN/CHEW
• Natural number, fprintf, Numerical Exploration

{[ 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