Foundation Chap 3

Foundation Chap 3 - Chapter 3 The Discrete vs The...

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

View Full Document Right Arrow Icon
Chapter 3 The Discrete vs. The Continuous § 3.1 Plotting Continuous Functions Connecting Dots § 3.2 Simulating Real Arithmetic Finite Calculation It easy to forget that there is actually a boundary between continuous mathematics and digital computing: Display monitors are an array of dots. However, the dots are so tiny that the depiction of a continuous function like sin( x ) actually looks continuous on the screen. Computer arithmetic is inexact. However, the hardware can support so many digits of numerical precision that there is the appearance of perfect computation. We begin to think that one-third is .333333333333333. In this chapter we build a respect for these illusions and an appreciation for what they hide. Visualization is central to computational science and engineering. In many applications, the volume of numerical data that makes up “the answer” is too much for the human mind to assimilate in tabular form. On the other hand, the visual display of results enables the computational scientist to spot patterns that would otherwise be hidden. To illustrate these points we consider in § 3.1 the practical exercise of plotting a simple function across an interval. Screen granularity and human perception affect how we think about the underlying table of function evaluations. What does it take to make a smooth function look smooth? Similar issues attend the boundary between exact arithmetic and computer arithmetic which we discuss in § 3.2. Thinking of the computer as a kind of telescopic instrument, rounding errors affect its resolution. Just as dish vibrations are taken into account by radio astronomers, so should the aberrations of computer arithmetic be taken into consideration by the computational scientist. 1
Background image of page 1

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

View Full Document Right Arrow Icon
Example 3.1 A Function Plot % Script Eg3_1 % Plots the function f(x) = sin(5x) * exp(x/2) / (1 + x^2) % on the interval [-2,3]. L = -2; % Left endpoint R = 3; % Right endpoint N = 100; % Number of sample points x = linspace(L,R,N); % Array of f-evaluations. .. y = sin(5*x) .* exp(-x/2) ./ (1 + x.^2); plot(x,y,[L R],[0 0],’:’) title(’The function f(x) = sin(5x) * exp(x/2) / (1 + x^2)’) ylabel(’y = f(x)’) xlabel(’x’,) Output -2 -1 0 1 2 3 -1.5 -1 -0.5 0 0.5 1 The function f(x) = sin(5x) * exp(x/2) / (1 + x 2 ) y = f(x) x 2
Background image of page 2
3.1. Plotting Continuous Functions 3 3.1 Plotting Continuous Functions Problem Write a script that displays a plot of the function f ( x )= sin(5 x ) exp( - x/ 2) 1+ x 2 across the interval [ - 2 , 3]. Program Development Let us Frst consider a much simpler problem: the plotting of the sine function across the interval [0 , 2 π ]. Even more, let us consider how we would approach such a problem “by hand.” ±irst, we would produce a table of values, e.g., x 0.0000 1.5708 3.1416 4.7124 6.2832 sin( x ) 0.0000 1.0000 0.0000 -1.0000 0.0000 We would then connect the Fve “dots” (0 . 0000 , 0 . 0000) , (1 . 5706 , 1 . 0000) , (3 . 1416 , 0 . 0000) , (4 . 7124 , - 1 . 0000) , (6 . 2832 , 0 . 0000) obtaining the simple plot that is illustrated in ±igure 3.1. It is hard to be happy with such -1 0 1 2 3 4 5 6 7 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 sin(x) ±igure 3.1: Plot of the Sine ±unction with 5 Sample Points a coarse depiction of such a smooth function. ±ive evenly distributed sample points means an x -spacing of π/ 2 and that is just too crude.
Background image of page 3

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

View Full Document Right Arrow Icon
4 Chapter 3. The Discrete vs. The Continuous
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 13

Foundation Chap 3 - Chapter 3 The Discrete vs The...

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