Upload
stephanie-fields
View
220
Download
1
Tags:
Embed Size (px)
Citation preview
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
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
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)
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
Real Number StorageLimited Range and Precision Illustrated
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
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
Software for Numerical Work
Software Libraries Spreadsheets Mathematical Software
symbolic manipulation data analysis data visualization
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
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
Worksheet Organization: Illustrated
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 @)
Using Spreadsheet FormulasAn Example
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
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.
SpreadsheetsAdditional Features
Using absolute references and problem
parameters
Using built-in functions
Using logical functions
Displaying data in charts
Spreadsheets as decision support tools
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
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 … ?”
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
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
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
Bar ChartAn Example
Pie ChartAn Example
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