chapter2 - 28 Chapter 2 Numerical Exploration 2.1...

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

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: 28 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) 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 ofareas....
View Full Document

{[ snackBarMessage ]}

Page1 / 24

chapter2 - 28 Chapter 2 Numerical Exploration 2.1...

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

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