# Tag Info

## Hot answers tagged numerical-analysis

• 275
Accepted

### Do formulas involving fewer repetitions of variables give higher numerical precision?

First, I want to say that it is not the case in general that an algorithm that minimizes the number of uses of the inputs is more accurate, at least for IEEE 754 floating point. For example, ...
Accepted

### Avoiding overflows while computing $e^x$ by Taylor series

Of course there are better numerical ways to compute exponential, but if you want to use Taylor expansion only, the better approach is to reformulate the expansion to avoid computing large nominators ...
• 434
Accepted

### fast and stable x * tanh(log1pexp(x)) computation

OP points to a particular implementation of the mish activation function for accuracy specifications, so I had to characterize this first. That implementation uses ...
• 520
Accepted

### How can I compute logarithm when comparison is undecidable?

Even though absolute comparisons may not converge, you should be able to narrow the argument into at least one of several partially overlapping ranges, such that you have a technique that works in ...
• 22.1k
Accepted

### How to represent zero as floating point number?

Note: In the interest of making this somewhat self-contained, I am using terminology from the most recent versions of the IEEE-754 standard. Prior to 2008, "subnormal numbers" were called &...
• 22.1k

### Alternatives to SVD for rank factorization

The proper search term in scientific journals is "Rank-Revealing Decomposition". If You want some theoretic guarantees on numeric accuracy/stability, the search term would be "Strong ...
• 991
Accepted

### Why do I get different results from two calculation methods?

For $\exp(-10)$, more terms have to be computed since the 30-th term $\dfrac{(-10)^{30}}{30!}\approx 0.00377$ is several times bigger than the partial sum so far, 0.0009703416. For $\exp(10)$, all ...
• 39k

### Proof that (x-y)(x+y) is more accurate than x²-y²

I'm not 100% sure of everything, but here are some elements that are implicit in the proof. Note that I reuse the notations and common knowledge of the paper, therefore this answer isn't self-...
• 453

### Proof that (x-y)(x+y) is more accurate than x²-y²

Suppose $y = x + \Delta$. Then $(x^2 - y^2) = x^2 - (x^2 + 2\Delta x + \Delta^2) = - (2\Delta x + \Delta^2)$ with leading term on the order of $2 \Delta x$. Multiply by $1 + \delta_1$ and that's still ...
• 2,082

### Why is computation of this function numerically unstable?

We can write it as $$f(x) = \dfrac{\sqrt{-x+a} - \sqrt{2x+a}}{ 4a}= \dfrac{\sqrt{-\frac xa+1} - \sqrt{\frac{2x}a+1}}{ 4\sqrt a}$$ If $x \ll a$ both of the square roots will be just about $1$. When ...
Accepted

### Reception of numerical infinities

So the paper's "Numerical infinities and infinitesimals: Methodology, applications, and repercussions on two Hilbert problems", Yaroslav D. Sergeyev (2017), and it's basically a discussion on the ...
• 1,351
Accepted

• 22.1k

### Robust two lines/segments intersection point in 2D

If you choose a formula with parameter $t$ you'll get the $P_x$ value as a result of a number of operations - additions, multiplications and one division: t = \frac{(x_1-x_3)(y_3-y_4)-(y_1-y_3)(x_3-...
• 3,088

### fast and stable x * tanh(log1pexp(x)) computation

My impression is that someone wanted to multiply x by a function f(x) that goes smoothly from 0 to 1, and experimented until they found an expression using elementary functions that did this, with no ...
• 30k

### fast and stable x * tanh(log1pexp(x)) computation

The context here is computer vision and the activation function for training neural nets. Chances are this code is going to be executed on a GPU. While performance is going to depend on the ...

### Validity of Algorithm for Testing Two Floating Point Numbers

There is one method to compare floating point numbers for equality, which is both very simple and correct: You use the equality (==) operator. There is another method to compare whether floating point ...
• 30k
Let me summarize what I wrote in the comments. It is not a complete answer, since the intervals on which to apply each formula still need to be investigated. It is enough to assume $x\geq0$, since \$\...