1
$\begingroup$

We have that: $\epsilon$ is the smallest positive machine number that summed to $1$ resuts in $(\epsilon + 1)$: i.e. the smallest number greater than $1$:

if $p$ is precision and $\beta$ the base:

$$\begin{array}{lcl} 1 & = & 0.1\underbrace{00 \ldots 00}_{p-1 \text{ zeros}} \times \beta^1 \\ 1 + \epsilon & = & 0.1\underbrace{00 \ldots 0}_{p-2}1 \times \beta^1 \end{array}$$ we can consider $\epsilon$ as the distance between the above numbers: $$ \begin{array}{lcl} \epsilon & = & (1+\epsilon) - 1 \\ & = & 0.1\underbrace{00 \ldots 0}_{p-2}1 \times \beta^1 - 0.1\underbrace{00 \ldots 00}_{p-1} \times \beta^1 \\ & = & 0.\underbrace{000 \ldots 0}_{p-1}1 \times \beta^1 \\ & = & 1 \times \beta^{1} \times \beta^{-p} \\ & = & 1 \times \beta^{1-p} \\ & = & \beta^{1-p} \end{array} $$

so the only significant figure $1$, stays on the p-th position after the dot.
Calculating the value of that $p$, is equivalent to know the precision, i.e. the number of digits for the mantissa.

I know that the algorithm for finding Epsilon Machine is similar to this:

U = 1.0
while (1+U)>1 do
   Umem = U
   U = U/beta
end while
U = Umem

and I know that, from the given $\epsilon$, I can calculate the number $p$ of digits for the mantissa:

$$\begin{array}{lcl} \epsilon & = & \beta^{1-p} \\ \log\epsilon & = & \log\beta^{1-p} \\ \log\epsilon & = & (1-p)\log\beta \\ p & = & 1-\frac{\log \epsilon}{\log \beta} \end{array} $$

I don't know how elaborate this fact in Python, can you give me any hint? Thanks.

$\endgroup$
0
$\begingroup$

It's easier to look these things up than to try and write a program that tests these quantities. Floating point numbers used by almost all programming languages today are specified in the IEEE-754 standard, see https://en.wikipedia.org/wiki/IEEE_754

For floating point numbers, Python uses the "double precision" (binary64) format, for which you can find the specifications in the table about a page down on the page referenced. If you click on "binary64" there, you get to a page solely on double precision: https://en.wikipedia.org/wiki/Double-precision_floating-point_format

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.