DMUG-Archiv 2001

Frühere   Chronologischer Index   Spätere
Vorherige   Thematischer Index   Nächste

Re: ganz einfach, sehr eigenartig => f[h_, dh_] = Floor[N[h/dh]]

Hallo Peter,

>Aber warum kommt da 1 raus?

Man kann diese Rundungsfehler der Hardware-Fliesskommaarithmetik umgehen,
z.B. so:

neuron% math        
Mathematica 4.0 for Solaris
Copyright 1988-1999 Wolfram Research, Inc.
 -- Motif graphics initialized -- 

In[1]:= f[h_, dh_] := Floor[h/dh + $MachineEpsilon]

In[2]:= Table[f[h, h 0.5 ], {h, 0, 2, 0.01}]

                                 1
Power::infy: Infinite expression - encountered.
                                 0

Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered.

Out[2]= {Indeterminate, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 
>    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 
>    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 
>    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 
>    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 
>    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 
>    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 
>    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 
>    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}

In[3]:= ?$MachineEpsilon
$MachineEpsilon gives the smallest machine-precision number which can be added
   to 1.0 to give a result that is distinguishable from 1.0.

Gruß,

Arnd


Frühere   Chronologischer Index   Spätere
Vorherige   Thematischer Index   Nächste

DMUG DMUG-Archiv, http://www.mathematica.ch/archiv.html