Uebungen 1 (Aufg. 1-3 p. 25ff)

1

a) MatLab:

>> 0.45-0.5+0.05
ans =  1.3878e-17

>>  0.05+0.45-0.5
ans = 0

>> 0.33-0.4+0.07
ans = 0

>> 0.07+0.35-0.42
ans = 0

>> 0.42-0.5+0.08
ans =  -1.3878e-17


>> 0.42+0.08-0.5
ans = 0

a) Zum Vergleich ein anderes Programm:

0.45-0.5+0.05

0.05+0.45-0.5

0.33-0.4+0.07

0.07+0.35-0.42

0.42-0.5+0.08

0.42+0.08-0.5

b) MatLab:

>> a=1.00000000000001
a = 1.0000

>> b=a-(a-1)/1000
b = 1.0000

>> b-a
ans = 0

>> format long

>> b
b = 1.00000000000001

>> b-a
ans = 0

b) Zum Vergleichein anderes Programm:

a=1.00000000000001

b=a-(a-1)/1000

b-a

a=1.0000000000000000000000000000000000000000000000000000000000000001

b=a-(a-1)/1000

N[b+1/10^-999,1000]

$MaxPrecision

$MinPrecision

Precision[b]

?SetPrecision

?*Pre*

approx = (1. /3)

bigapprox = SetPrecision[approx, 40]

BaseForm[bigapprox, 2]

SetPrecision[bigapprox, MachinePrecision]

c) Matlab:

1+1/10e+100-1
ans = 0

>> 1+1/10e+15-1
ans = 0

>> 1+1/10-14-1
ans = -13.9000000000000

>> 1+1/10e+14-1
ans =  1.11022302462516e-15

>> 1+1/10e13-1
ans =  9.99200722162641e-15

>> 1+1/10e12-1
ans =  9.99200722162641e-14

>> 1+1/10e+12-1
ans =  9.99200722162641e-14



>> 1/0.000000000000001
ans =  1.00000000000000e+15


>> 2*1000000000000000000/(3*1000000000000000000)
ans = 0.666666666666667


>> (2/1000000000000000)/(3/1000000000000000000)
ans = 666.666666666667

>> (1/100000000000000000)/(2/100000000000000000)
ans = 0.500000000000000


>> (2*100000000000000000)*(3/10000000000000000000)
ans = 0.0600000000000000

>> (2*1000000000000000000000000)*(3/1000000000000000000000000)
ans = 6

>> (2/100000000000000000000000000)/(3/10000000000000000000000000)
ans = 0.0666666666666667

u.s.w.

c) Zum Vergleichein anderes Programm:

1000000(1+0.05)^10000000000

1000000(1+0.05)^100000000001

d) Matlab:


>> 1000000*(1+0.5)^10
ans = 57665039.0625000

>> 1000000*(1+0.5)^11
ans = 86497558.5937500

>> 1000000*(1+0.5)^12
ans = 129746337.890625

>> 100000*(1+0.5)^10000000000
ans = Inf

>> 1000000*(1+0.05)^1000
ans =  1.54631892073199e+27

>> 1000000*(1+0.5)^1000000
ans = Inf

>> 1000000*(1+0.05)^100000
ans = Inf

>> 100000*(1+0.05)^1000
ans =  1.54631892073199e+26

>> 1000000*(1+0.05)^100000
ans = Inf

>> 100000*(1+0.05)^1000
ans =  1.54631892073199e+26

e) Matlab:

>> eps
eps =  2.22044604925031e-16

>> eps/2
ans =  1.11022302462516e-16

>> eps/2+1
ans = 1

2

a) MatLab:

>> 11/3
ans = 3.66666666666667  ===> 3.6666666666666...

b)

(Subscript[11.101010101010101011, 2])

numb = 11./3.

approx = SetPrecision[numb,30]

N[numb,100]

BaseForm[numb,2]

numb = 11/3

approx = SetPrecision[N[numb,30],30]

BaseForm[approx,2]

2

Table[10.^k,{k,1,310}]

Table[10.^k,{k,1,-310,-1}]

Table[10^k,{k,1,310}]