Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [floating-point]

Mathematical questions concerning floating point numbers, a finite approximation of the real numbers used in computing.

0
votes
0answers
18 views

How can we decide the robustness of an equation in floating point system?

Is there an objective metric for deciding whether or not an equation is robust or is it subjective? Can we rely on relative error to decide the robustness of an algorithm/equation? Say, if the ...
0
votes
1answer
45 views

Why is that the same equation with different x values produces drastically different round-off errors?

(1 + 1/n)^n approximates e^1. Case 1: When n is equally spaced between 10^4 and 10^9 with 10000 different numbers, linspace(10.^4, 10.^9, 10000) (Done in Matlab). Here's the graph: Case 2: When n is ...
3
votes
1answer
142 views

Why does $\left(1 + \frac{1}{n}\right)^n$ give vastly different relative errors when $n=252257928$ and $n = 215450934$?

This expression $\left(1 + \frac{1}{n}\right)^n$ approximates $e^1$. When $n = 252257928$, the relative error, $(e - \text{result})/e$, is $1.740557727387924\mathrm{e-}12$ When $n = 215450934$, the ...
0
votes
0answers
26 views

Floating-point rounding error in numerical differentiation formula

In Numerical Analysis by Timothy Sauer (Pearson, 2nd Edition) it says that $\tilde{f'}(x+h) = f(x+h) + \epsilon_{\text{mach}}$, where $\tilde{f'}(x)$ is the floating-point representation of the given ...
1
vote
0answers
24 views

Treatment of Floating Point Rounding in Trefethen & Bau

Something I noticed in the Trefethen & Bau Numerical Linear Algebra book is that, after introducing elementary floating point arithmetic, they do not pay too much care to the initial rounding of ...
1
vote
3answers
70 views

How many Taylor series terms are needed to accurately approximate $\sqrt{a+x}-\sqrt{a}$?

Naive evaluation of $\sqrt{a + x} - \sqrt{a}$ when $|a| >> |x|$ suffers from catastrophic cancellation and loss of significance. WolframAlpha gives the Taylor series for $\sqrt{a+x}-\sqrt{a}$ ...
0
votes
0answers
13 views

Shannon Entropy of a uniform randomly generated IEEE3 single precision float in [0, 1)

There are about 1 billion (2^30) different single precision floating point values between 0 and 1, but because smaller floats have higher precision, they don't all have an equal probability in a ...
1
vote
0answers
25 views

Converting a number to IEEE 754 - Problem [closed]

I am trying to convert -12.5 to the IEEE754 single precision (32bit) format. I use this tutorial https://youtu.be/8afbTaA-gOQ?t=105. At the time stamp linked she converts the fraction part to binary. ...
3
votes
1answer
36 views

Compute component probabilities in EM-algorithm with log densities?

I coded up an implementation of the EM-algorithm for Gaussian mixtures. In the E-step I compute, for each row in the data matrix, the probability $p_i$ that it has been drawn from the component $i \in ...
0
votes
2answers
51 views

Easy example of $Ax =b$ floating point arithmetic.

Solve $Ax =b$ with two-digit floating-point arithmetic. We have $$ A= \begin{pmatrix} 1 & 1\\ 1 & 0,99\\ \end{pmatrix} $$ and $$ b = \begin{pmatrix} -1 \\ 1 \\ \...
0
votes
0answers
26 views

Division with replacement of floating-point arithmetic to integer arithmetic

The issues: Not all the hardware has an FPU => not possible to use floating-point arithmetic. Not all the hardware has an uint64_t => not possible to use ...
0
votes
0answers
39 views

24-bit Binary to single precision floating point number

I have the 24-bit binary: 0101 0011 1111 1101 0111 1101 And I need to figure out: What pair of single precision floating point (real) numbers could be represented by these 24-bits? I'm fairly ...
0
votes
1answer
40 views

What is the purpose of regime bits in posit encoding?

Why do we need regime bits in posit? posit encoding:
0
votes
0answers
18 views

Determine rating of change from floating data

For example in this set of data (in ascending order of time) [ 100, 98, 105, 91, 108, 106, 110, 109] It is clearly the trend is rising but i would like to know how to determine the rate of change, ...
0
votes
0answers
70 views

How did they simplify this floating point expression?

Assume $D_hf(x) = \frac{f(x+h) - f(x-h)}{2h}$. Suppose $f$ can be evaluated with relative error bounded by $\epsilon$. Show that floating-point arithmetic with machine epsilon $\epsilon$ gives $...
0
votes
2answers
117 views

Why is $0.0180 = 0.0180$ false in MATLAB? [closed]

I am trying to do a small script in MatLab. What it does is load .txt data in to memory. The data comes in a few columns, and I need it to figure out in how many. The data in the .txt will look like ...
1
vote
1answer
82 views

Double-precision algorithm for inverse log gamma or log factorial?

Question in a nutshell: Can anyone point me to an algorithm for computing to double-precision floating-point (roughly 16 digits) the inverse of either log gamma or log factorial? In other words, if ...
0
votes
0answers
35 views

Two's complement addition issue

In a two's complement system, 16-bit binary numbers $0010010010010010$ and $1111110011111100$ can be represented in the decimal system as $9362$ and $-772$, correspondingly. Now, from what I've read ...
0
votes
1answer
31 views

46- and 64-bit integers

Some Cray supercomputers used to support 46-bit and 64-bit integer data types. What are the maximum and minimum values that we could express in a 46-bit integer? in a 64-bit integer? Is my ...
0
votes
0answers
39 views

23-bit mantissa and 9-bit exponent range and precision

I have the following problem which I would like to make sure that I understand correctly. So I would appreciate your help in this matter. Some computers (such as IBM mainframes) used to implement ...
0
votes
2answers
43 views

Numerical Accuracy: How many digits are correct?

I'm really not too sure how to go on about this: Problem. Julia (or take MatLab etc. (I guess.)) computes ...
1
vote
1answer
61 views

Why do harmonic series converge in a finite precision number system?

I'm new to numerical analysis. I'm still unclear as to why the harmonic series $\sum 1/k $, where k = 1, ... , infinity converges. I would appreciate any help! I can show that the sum does indeed ...
0
votes
1answer
54 views

How do we do arithmetic with negative floating point numbers?

I'm studying floating point arithmetic and understand everything in the positive domain but can't seem to wrap my head around how negative floating point numbers are dealt with. I understand that the ...
1
vote
1answer
51 views

How to compute amount of floating point operations for LU-decomposition of banded matrix?

I want to compute the amount of floating point operations, flops, needed for the LU-decomposition/factorization of a banded matrix A consisting of 5 nonzero diagonals. Matrix $A\in\mathbb{R}^{n \...
0
votes
1answer
30 views

Transform parabola to be tangent to line in point and through other point

Sorry for stupid question, but I give up. I've spent whole weekend to solve that and no results. Please help. I think I know the solution, but it doesn't work form me. So now I am not sure. I am not ...
2
votes
0answers
39 views

Removable singularities for rational functions with floating point coefficients

Suppose I have given a rational function $r(x)=p(x)/q(x)$ where $p$ is a degree $m$ polynomial and $q$ is a degree $n$ polynomial, both over the real numbers, and the coefficients of $p$ and $q$ are ...
0
votes
1answer
44 views

Adding two IEEE754 floating-point representations and interpreting the result.

This isn't for any class or homework. As part of my personal study, I'm trying to better understand the IEEE754 representation of decimal floating-point numbers in binary. I'd like to add two numbers: ...
0
votes
1answer
33 views

Prove that in a floating point system with truncation the number of significant digits is $n$.

I was requested to prove that in a floating point system $\text{F}(\beta, n, m, M)$ with truncation the number of significant digits is $n$. (where $n$ is the number of digits and $m < \text{...
0
votes
0answers
87 views

Why Cardinality not the same for rounded floats?

I need to solve a question: Two float values are equivalent if they return same integer with Math.round(). Why the equivalence classes arising from this ...
2
votes
1answer
118 views

Detect (catastrophic) cancellation in sums

In finite precision arithmetic, what are ways to detect (catastrophic) cancellation when adding $N\in\mathbb{N}$ numbers? Example ($N=2$): When adding two numbers $a$ and $b$ the result $a+b$ might ...
1
vote
0answers
143 views

How to prove the bound for Relative Round Off error

Machine precision is defined as the smallest machine number ε. Anything smaller when added to 1 will be lost at roundoff. Prove that ε is the bound for relative round-off error. ...
0
votes
0answers
233 views

How to prove fl(x^k) definition

How would I show that fl(x^k)= (x^k)(1 + δ)^(k−1), where |δ| ≤ ,ε if x is a floating-point machine number in a computer that has machine precision . Edit: I was thinking I can use induction to ...
1
vote
0answers
106 views

How to find smallest and largest representable number possible given a Normalized Floating Point System

Let's say you are given the normalized floating-point system: $R_3(3, 1)$ with exponent range $−1 ≤ e ≤ 1$ The base is $3$, mantissa length is $3$ and exponent length is $1$. How would you go about to ...
0
votes
0answers
101 views

Error bound of chopping and rounding for floating-point

The floating point representation for a binary number $x$ is written as $$x =\sigma \cdot \bar{x}\cdot 2^e$$ where $\sigma$ denotes the sign of $x$, $e$ is an integer denotes the exponent and $\bar{x}...
1
vote
1answer
91 views

Floating Point Numbers - Machine numbers

Consider the set of machine numbers $M(10, 2, 0)$. (The "zero-length" for the exponent is to be understood such that there is only the sign ± and 0 available for the exponent. We interpret "+" as "+1" ...
2
votes
2answers
54 views

How many bits to represent these numbers precisely?

Consider the following numbers: $$19=10011_b, 12.75=1100.11_b, 7.125=111.001_b$$ What is the minimum number of bits necessary to represent the above three numbers precisely? A system like the IEEE ...
0
votes
2answers
31 views

How to get the fractional part of a product of large numbers with machine precision?

Let us have about 100 or so random (exact) floats such as: $$ A_1 = 1234123.428\\ A_2 = 13713.4193\\ A_3 = 0.1332\\ A_4 = 123.13213\\ ...$$ Now I want to find an efficient way to get the fractional ...
1
vote
0answers
51 views

Numerical Analysis- Finding two closest machine numbers in single precision.

There is a question that is similar to this that was asked already, but the answer did not really make too much sense to me. Let's say I have a number 4096.000244 and I want to find the two closest ...
0
votes
2answers
165 views

Integer part of natural logarithm

Please, does anyone know of a algorithm to compute the integer part $n$ of natural logarithm of an integer $x$? $$n = \lfloor \ln(x) \rfloor$$ Preferably using integer arithmetic only (akin to ...
0
votes
0answers
49 views

Standards for representing real numbers in computers (other than floating point)?

Some year ago I made a small discourse and investigated some representations for real number approximation, for example quotient between integers, satisfying this equation $$ax - b = 0 \...
1
vote
1answer
76 views

Can differentiation be defined for floating point numbers? [closed]

Can differentiation be defined for floating point numbers (e.g. 32 bit floats or 64 bits doubles)? I think one can have limit points in floating point numbers, I read somewhere that they have a ...
0
votes
1answer
86 views

How to compute rounding error bound?

I am using the IEEE754 half-precision floating point format, which has 11 significand bits. My input is drawn randomly with values between 1.0 and 2.0. I would like to approximate the maximum ...
2
votes
1answer
69 views

Verification: Machine number immediately to right and left of $2^m$

The question I'm given is what are the machine numbers immediately to the right and left of $2^m$? How far is each from $2^m$? I'm given the machine epsilon, $\epsilon$ is $2^{-23}$. (I believe we ...
1
vote
1answer
153 views

Between an adjacent pair of nonzero IEEE single precision real numbers, how many IEEE doubles are there?

My calculation: consider an adjacent pair of IEEE single precision floating point numbers (known as "floats" in C++ for example). Then the gap between those numbers is the corresponding machine ...
3
votes
1answer
57 views

Numerically-robust methods of calculating $1-(1-x)^n$ for $n >> 1$ and a wide dynamic range of $x$

I am trying to calculate $y = 1-(1-x)^n$ for $n$ in the 50-500 range, where $x$ ranges widely between, say, $10^{-20}$ and 1. The straightforward way is not numerically robust, and loses precision ...
1
vote
1answer
819 views

Machine Epsilon meaning

Say we have the floating-point system $(2,3,-1,2)$ and we want to find machine epsilon. According to my textbook, this can be found as $\epsilon_m=\beta^{1-t} = 2^{1-3}=0.25$. However, my textbook ...
0
votes
0answers
137 views

General way to quantize floating point numbers into arbitrary number of bins?

I want to quantize a series of numbers which have a maximum and minimum value of X and Y respectively into arbitrary number of ...
1
vote
1answer
71 views

Numerically approximating limit with large numbers, bumping up against machine precision

Consider $\lim_{x\rightarrow\infty}(1+\frac1x)^{x}=e$. Using standard calculus techniques, this limit can be evaluated, however, approximating it directly with numerical code can be difficult ...
1
vote
0answers
45 views

Hardware implementations of floating-point numbers have uses for “negative zero”; is there any use for “imaginary negative zero”?

I've been studying low-level hardware implementations of floating point numbers and doing an exercise to design a custom floating point implementation. I know that being able to represent negative ...
0
votes
1answer
62 views

Floating point arithmetic ( IEEE-754 standard ) commutative law (*,+)

How can I prove that: $ fl(a \ op \ b) = fl(b \ op \ a), \: op = +,*.$. I have been reading and searching the big majority say that its true. like here. However, I can not find a mathematical proof ...