• No results found

Numerical Accuracy 01/29/2009. Computational Physics. Homework Assignment. Computing Numerics. Representing Numbers. Computational.

N/A
N/A
Protected

Academic year: 2021

Share "Numerical Accuracy 01/29/2009. Computational Physics. Homework Assignment. Computing Numerics. Representing Numbers. Computational."

Copied!
21
0
0

Loading.... (view fulltext now)

Full text

(1)

Physics Homework Assignment Computing Numerics Representing Numbers

(2)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Outline

1

Homework Assignment

2

Computing Numerics

3

Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

4

Computational Errors

(3)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Homework Assignment

1

Read Chapter 6

“An Introduction to object-oriented analysis”

2

Assignments (6) and (7) of Section 5.15

See handout!

For assignment 7, do not use the DISLIN package,

instead save data for x, y, and the field to a file and

plot in 3D using Gnuplot “splot”!

(4)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Outline

1

Homework Assignment

2

Computing Numerics

3

Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

4

Computational Errors

(5)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Computing Numerics

Representing Numbers

Bits and Bytes

Fixed Points (int or long)

Floating Points (float or double)

Floating Point Arithmetic

Computational Errors

(6)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Outline

1

Homework Assignment

2

Computing Numerics

3

Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

4

Computational Errors

(7)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Representing Numbers

Binary Bits

Units of Memory

All numbers eventually are represented in

Binary Form

Finite precision:

Limits & Approximation

Word Length

Number of bits to store a number (often given in

Bytes

)

1 byte = 1 B = 8 bits = 8 b

(8)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

Computational Errors

Range Errors

Fixed Points (int or long)

Exact Representation

2

N

1 integers represented by N bits

1

st

bit gives the sign

Remaining N

1 bits give the value

32-bit integers:

2 147 483 648

≤ int

32

2 147 483 648

Integer Arithmetic is exact!

(9)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double) Computational Errors Range Errors

Bit Manipulation

1

Shift Operator

< <

2

Bitwise Logical AND

&

# include <iostream.h>

main() {

int thirdBit = (1 < < 2);

int i = 8;

if (

(i & thirdBit)

!= 0 ) {

cerr < < endl < < “ Third bit true! ”;

}

else if ( (i & thirdBit) == 0 ) {

cerr < < endl < < “ Third Bit false! ”;

}

(10)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

Computational Errors

Range Errors

Floating Points (float or double)

sign

exp + bias

mantissa

Scientific work mainly uses floating-point numbers

Floating-Point Notation

float

32

0

01111111

10000000000000000000000

x

= (−

1

)

sign

· mantissa ·

2

exponent

1

mantissa:

1.

m

1

2

1

+

m

2

2

2

+

...

2

bias = 0111 1111

2

= 127

10

Example:

true exponent = 127

127 = 0

(11)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

Computational Errors

Range Errors

Floating Points (float or double)

sign

exp + bias

mantissa

Scientific work mainly uses floating-point numbers

Floating-Point Notation

float

32

0

10000000

00000000000000000000000

x

= (−

1

)

sign

· mantissa ·

2

exponent

1

mantissa:

1.

m

1

2

1

+

m

2

2

2

+

...

2

bias = 0111 1111

2

= 127

10

Example:

true exponent = 128

127 = 1

(12)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

Computational Errors

Range Errors

Floating Points (float or double)

sign

exp + bias

mantissa

Scientific work mainly uses floating-point numbers

Floating-Point Notation

float

32

1

10000000

00000000000000000000000

x

= (−

1

)

sign

· mantissa ·

2

exponent

1

mantissa:

1.

m

1

2

1

+

m

2

2

2

+

...

2

bias = 0111 1111

2

= 127

10

Example:

true exponent = 128

127 = 1

(13)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

Computational Errors

Range Errors

Floating Points (float or double)

sign

exp + bias

mantissa

Scientific work mainly uses floating-point numbers

Floating-Point Notation

float

32

0

10000001

10000000000000000000000

x

= (−

1

)

sign

· mantissa ·

2

exponent

1

mantissa:

1.

m

1

2

1

+

m

2

2

2

+

...

2

bias = 0111 1111

2

= 127

10

Example:

true exponent = 129

127 = 2

(14)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

Computational Errors

Range Errors

Floating Points (float or double)

sign

exp + bias

mantissa

Scientific work mainly uses floating-point numbers

Floating-Point Notation

float

32

0

01111110

10000000000000000000000

x

= (−

1

)

sign

· mantissa ·

2

exponent

1

mantissa:

1.

m

1

2

1

+

m

2

2

2

+

...

2

bias = 0111 1111

2

= 127

10

Example:

true exponent = 126

127 =

1

(15)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

Computational Errors

Range Errors

Floating Points (float or double)

sign

exp + bias

mantissa

Scientific work mainly uses floating-point numbers

Floating-Point Notation

float

32

0

01111011

1001100110011001100110

1

x

= (−

1

)

sign

· mantissa ·

2

exponent

1

mantissa:

1.

m

1

2

1

+

m

2

2

2

+

...

2

bias = 0111 1111

2

= 127

10

Example:

true exponent = 123

127 =

4

(16)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

Computational Errors

Range Errors

Floating Points (float or double)

sign

exp + bias

mantissa

Scientific work mainly uses floating-point numbers

Floating-Point Notation

float

32

0

01111111

10000000000000000000000

x

= (−

1

)

sign

· mantissa ·

2

exponent

(17)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Outline

1

Homework Assignment

2

Computing Numerics

3

Representing Numbers

Fixed Points (int or long)

Floating Points (float or double)

4

Computational Errors

(18)

Physics Homework Assignment Computing Numerics Representing Numbers

(19)

Physics Homework Assignment Computing Numerics Representing Numbers

(20)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Range Errors

32 bit words

2 147 483 648

≤ int32

2 147 483 648

2

.

9

·

10

39

≤ float

32

3

.

4

·

10

38

(21)

Physics Homework Assignment Computing Numerics Representing Numbers

Fixed Points (int or long) Floating Points (float or double) Computational Errors Range Errors

Round-Off Errors

Machine Accuracy

ǫ

The largest number such that

1

.

0

+ ǫ =

1

.

0

Computer Representation x

c

:

References

Related documents

When you open the RBOScope testing tool in Web Designer, Web Designer uses the user ID and password you entered in the User Credentials window of the RedBack Object Server

Passage, 2012, video stills, duration: 4:47, HD (16:9), stereo audio vimeo.com/janszewczyk/passage (portfolio)... Workshop, 2012, video stills, duration: 8:32, HD (16:9), stereo

Questions regarding RSML -e and Nimbus shall be shall be directed to Mats Heimdahl ([email protected]) or posted on the Phorum.. Information and sample files will also be posted

• Each school age child care program shall provide program activities that are appropriate to the various age levels of the children to be served and that meet the

• Accurate use of intonation patterns and stress. The course is ideal for those who have a high intermediate to proficient level of English, no previous knowledge of pronunciation

Areas of Potential Environmental Concern (APECs) were identified on the subject site associated with the former storage of fuel/presence of fuel storage tanks on

If one uses an incremental cost-effectiveness ratio (ICER) and the growth in the consumption value of health is not accounted for elsewhere, the discount rate of health effects will

Figure 1: Regions of the complex plane in which the polynomials have different asymptotic expansions: the lens (I), the outer region (II) and the right and left disks (III and IV)..