This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 28 Chapter 2 Numerical Exploration § 2.1 Discovering Limits The forloop and the whileloop § 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 ngons Figure 2.2 Inscribed ngon The design of effective problemsolving 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 ngon . Figure 2.1 illustrates two cases. Given n equally spaced points around a circle C , there are two ways to construct a regular ngon. One is simply to connect the points in order. Each point is then a vertex of the ngon 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 ngon that circumscribes C . See Figure 2.3 . If C has radius one, then the areas of these two regular ngons are given by A n = ( n/ 2) sin(2 π/n ) (Inscribed) 2.1. Limits 31 Figure 2.3 Circumscribed ngon B n = n tan( π/n ) (Circumscribed) These formulas can be derived by chopping the ngon into n equal triangles and summing their areas. Now for any value ofareas....
View
Full
Document
 Spring '07
 FAN/CHEW
 Natural number, fprintf, Numerical Exploration

Click to edit the document details