25
Numeric Processing Chapter 6, Exploring the Digital Domain

Numeric Processing Chapter 6, Exploring the Digital Domain

Embed Size (px)

Citation preview

Page 1: Numeric Processing Chapter 6, Exploring the Digital Domain

Numeric Processing

Chapter 6,Exploring the Digital Domain

Page 2: Numeric Processing Chapter 6, Exploring the Digital Domain

Digital Number Representations

Integers infinite discrete subset of the number

line are represented with a limited range

Decimal numbers (real numbers) infinite and continuous are represented with limited range

and limited precision

Page 3: Numeric Processing Chapter 6, Exploring the Digital Domain

Integer Storage

All integers between two values (one negative and one positive) are stored with exact precision

The specific values marking the range limits depend on the particular computer system being used

If calculations with integers give rise to numbers outside the allowable range, we say that an integer overflow error has occurred

Page 4: Numeric Processing Chapter 6, Exploring the Digital Domain

Real (Decimal) Number Storage

Real numbers are stored in floating point representation a sign an exponent a mantissa (normalized decimal fraction)

no digits to the left of the decimal first digit to the right of the decimal is

nonzero Limited precision because most real numbers have

an infinite decimal expansion (this holds no matter what number base is used in the representation)

Page 5: Numeric Processing Chapter 6, Exploring the Digital Domain

Real Number StorageLimited Range and Precision

There are three categories of numbers left out when floating point representation is used numbers out of range because their absolute

value is too large (similar to integer overflow) numbers out of range because their absolute

value is too small (numbers too near zero to be stored given the precision available

numbers whose binary representations require either an infinite number of binary digits or more binary digits than the bits available

Page 6: Numeric Processing Chapter 6, Exploring the Digital Domain

Real Number StorageLimited Range and Precision Illustrated

Page 7: Numeric Processing Chapter 6, Exploring the Digital Domain

Limited Range and PrecisionSome Consequences

Limited range will invalidate certain calculations If integers are involved, this can often be avoided by

switching to real numbers For real number calculations, this problem arises

infrequently and in those cases can sometimes be handled by special methods. It is not a common occurrence in non-scientific work.

Limited precision for real numbers is very pervasive Assume that most decimal calculations will, in fact,

be in error! Evaluate and use computer calculations with this in

mind

Page 8: Numeric Processing Chapter 6, Exploring the Digital Domain

Social Themes:Risks in Numerical Computing

Almost all computer calculations involve roundoff error (limited precision error)

If not monitored and planned for carefully, such errors can lead to unexpected and catastrophic results Arianne 5 Rocket Failure Patriot Missile Failure during Gulf War

Page 9: Numeric Processing Chapter 6, Exploring the Digital Domain

Software for Numerical Work

Software Libraries Spreadsheets Mathematical Software

symbolic manipulation data analysis data visualization

Page 10: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheets: Brief History

First spreadsheets appeared in early 1980s ran on personal computers helped popularize personal computers

Basic Organization Hasn’t Changed computations organized on a two-

dimensional worksheet both built-in and user-supplied formulas

used to facilitate computation

Page 11: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheets: Basic Features

Worksheet Organization rectangular grid of cells cells are identified by the row (indicated by an

integer) and column (indicated by a letter) in which they appear

Entering Data one cell is active at a time (called the current

cell) a separate data entry bar is associated with the

current cell text, numerical data, dates, and formulas can be

entered into the current cell through the entry bar

Page 12: Numeric Processing Chapter 6, Exploring the Digital Domain

Worksheet Organization: Illustrated

Page 13: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheets: Basic Features (cont’d)

Formatting Data variety of formats depending on the type of

data data format is associated with the cell and

can be changed later Using Formulas in a Worksheet

cell addresses (column, row) can be used like variable names in formulas

formulas begin with an = or other special symbol (like @)

Page 14: Numeric Processing Chapter 6, Exploring the Digital Domain

Using Spreadsheet FormulasAn Example

Page 15: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheets: Basic Features (cont’d)

Copying (Replicating) Formulas formulas can be copied to perform repetitive calculations especially useful when similar calculations take place on a

group (block,row, column) of contiguous data Cell Referencing

cell references will be adjusted automatically when formulas are copied if relative cell addressing is used in formulas

cell references will remain the same if absolute cell addressing is used in formulas

relative cell addressing is the default addressing scheme

Page 16: Numeric Processing Chapter 6, Exploring the Digital Domain

Copying Spreadsheet FormulasAn Example

The formula in cell B12 has been copied to cells C12 and D12. Note how the cell references are automatically adjusted.

Page 17: Numeric Processing Chapter 6, Exploring the Digital Domain

SpreadsheetsAdditional Features

Using absolute references and problem

parameters

Using built-in functions

Using logical functions

Displaying data in charts

Spreadsheets as decision support tools

Page 18: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheet ModelsUsing Problem Parameters

Most spreadsheet models will require modifications over time as underlying assumptions and important problem values change

Good spreadsheet design will minimize the danger of making errors when updating spreadsheet models

Problem parameters are important problem values that are subject to change over time

Separating problem parameters, placing them in clearly identified cells, then referring to them by absolute references in formulas within the model makes changing them relatively error-proof

Page 19: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheet ModelsDecision Support

Modeling problem parameters as clearly identified separate entities enables convenient “what if” analysis in spreadsheet models

“What if” analysis involves observing modified calculations and results when problem parameters change. In other words, the model is examined in response to questions of the form “What if … changes to … ?”

Page 20: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheet ModelsUsing Built-in Functions

Built-in functions act on arguments to produce resulting values A user of a built-in function need not know all the details of

how the function does its calculation The user needs to understand only what input arguments are

required and what type of result is produced An extensive library of financial and statistical functions adds

powerful problem-solving capabilities for the average user

Page 21: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheet ModelsUsing Built-in Logical Functions

Logical functions allow spreadsheet models to make decisions during calculations

Such processing is called conditional processing and is a fundamental property of programming languages

For example, the IF function acts on a logical (or Boolean) expression to take one of two actions, as shown here

Page 22: Numeric Processing Chapter 6, Exploring the Digital Domain

Spreadsheet ModelsDisplaying Data in Charts

Graphical display and summary of data is often easier to interpret than the raw data itself

Spreadsheets typically provide several types of charts bar charts pie charts

Page 23: Numeric Processing Chapter 6, Exploring the Digital Domain

Bar ChartAn Example

Page 24: Numeric Processing Chapter 6, Exploring the Digital Domain

Pie ChartAn Example

Page 25: Numeric Processing Chapter 6, Exploring the Digital Domain

Summary

Integers are stored with limited range: real numbers (decimals) with limited range and limited precision

Almost all decimal calculations involve roundoff errors because of limited precision

Spreadsheets provide powerful, yet easy to use, calculational environments

formulas and relative referencing provide for easy calculation extension

absolute referencing and problem parameters enable modeling built-in functions (arithmetic and logical) displaying data in charts decision support tool