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

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

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
Image of page 1

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

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
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 first 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.” First, 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 five “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 Figure 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) Figure 3.1: Plot of the Sine Function with 5 Sample Points a coarse depiction of such a smooth function. Five evenly distributed sample points means an x -spacing of π/ 2 and that is just too crude.
Image of page 3

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

4 Chapter 3. The Discrete vs. The Continuous
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.
  • Summer '07
  • FAN/VANLOAN
  • built-in function

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern