• Keine Ergebnisse gefunden

Wrong results in spite of exact computations

N/A
N/A
Protected

Academic year: 2022

Aktie "Wrong results in spite of exact computations"

Copied!
8
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

>

>

>

>

(4) (4)

>

>

>

>

(1) (1)

>

>

>

>

(2) (2)

>

>

(3) (3)

>

>

double x=0.7;

int i = 0;

while(i < 10) { i=i+1;

} }

The result of the C-program is rubbish. In the last round it is y = -1127140547773912.5

Limits of Floating-Point arithmetic in Maple

0.700000000

(2)

(4) (4) Numbers, their representations and

more and less native number representations for a digital computer

numbers can be elements from various sets. e.g. x2Z, x2;.

each number has various representations. e.g.

17 XVII

IIIII IIIII IIIII II

usually, we encode numbers with the help of base-10 digits, i.e. the alphabet

A string is then interpreted as

Example:

What happens, if we use another base, another alphabet?

E.g. with "bits", we have:

= {0, 1}

= {0, 1, 2, 3, 4, 5 , 6, 7, 8, 9, a, b, c, d, e, f}

0x11 (so called hex numbers)

integer variables of fixed length are the most natural and mostly used kind of variables

Bitstrings are interpreted as numbers in the dual number system.

bit 0 bit 1 bit 30 bit 31 (MSB) 0 1 0 0 0 1 1 0 0 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 1

The value then is .

(3)

My idealized computer

My idealized memory

How to compute with binary numbers?

(4)

(4) (4)

base-2 base-10 sum: 1 0 1 1 9 9 +

1 1 1 0 1

product: 1011

0000

1011

110111 Generalized binary fixed-point and floating-point numbers

0.75

0.75 = 1 + 0.7

0.7 = 1 + + 1 + + ...

the first 64 bits:

0.1011001100110011001100110011001100110011001100110011001100110011 0.7 is a periodic number in the binary system.

(5)

(6) (6)

(7) (7) (5) (5) -> representation errors in IEEE format is not avoidable

Wrong results in spite of exact computations

Expand

11379726889978832996251 22492823

The case

The fibonacci series is defined as follows:

fib(0) = 0, fib(1) = 1 and fib(n+1) = fib(n-1) + fib(n)

We would like to know whether f(n) might be expressible as

We would like to get some information fast and without lots of hand work.

How can we start working at the exercise? How can Maple help us?

Solution:

Relativly soon, it is clear that:

0 and

1 Additionally, it must be true that

(6)

(9) (9)

(11) (11) (4) (4)

(8) (8)

(10) (10) Some large numbers can quickly be tested, the expression may be simpified via the command simlify.

An example is 876:

The procedure becomes by far more tricky, if we want Maple to show equality for general n. Sometimes, it helps to expand the expression.

0

(7)

(21) (21)

>

>

>

>

>

>

>

>

(12) (12)

>

>

(15) (15)

(19) (19)

>

>

(16) (16)

>

>

>

>

>

>

>

>

>

>

(17) (17) (13) (13)

>

>

>

>

(14) (14)

>

>

(20) (20)

>

>

(18) (18) false

Error, out of bound assignment to a list

83621143489848422977

83621143489848422977

(8)

(21) (21) (4) (4)

>

>

83621143489848422977

Referenzen

ÄHNLICHE DOKUMENTE

After you have completed your online application and been accepted for the programme, the contact point you will have chosen in your country will help you to find a new

It is against this background that Pope Benedict XVI, in his Message for the 2010 World Day for Peace, said that the degradation of the environment is a pressing moral problem

The fidelity of the hybridization reac- tions can be improved significantly and as an example of a set of 24 words of 16-mers we show that the optimal set has unique

In this exercise we want to show that the classical “Łoś-Tarski Theorem” does not hold if we restrict to finite structures. Recall that this theorem says the following: for a

These conferences and publications and the policy visions they propagated as “The Kenya We Want” represented the changing political background and the reality

Thus, an increase in ordinary income tax rates increases the effective tax rate on capital gains and dividends for taxpayers affected by the phaseout.. (Note that, due to tax

Organizarea contabilităţii de gestiune şi calculaţiei costurilor pe baze ştiinţifice în întreprinderile din industria fierului şi oţelului asigură premisele pentru

In general, from a dyadic perspective the increasing loss of individual autonomy related to the progressing dementia results in increasing and changing needs for