In the mathematical subfield of numerical analysis, numerical stability is a generally desirable property of numerical algorithms. The precise definition of stability depends on the context. One is numerical linear algebra and the other is algorithms for solving ordinary and partial differential equations by discrete approximation.
Questions tagged [numerical-stability]
104 questions
4
votes
1 answer
C/C++ code with GNU Scientific Library (GSL) gives different results to GNUPlot - possible floating point instabilities?
SShort:
GNUPlot gives a much better fit to my data than my GSL code does. Why?
Short:
I am slightly confused at the moment, so my question might not be particularly well worded... I will edit this as my understanding improves.
The original title of…

FreelanceConsultant
- 13,167
- 27
- 115
- 225
4
votes
1 answer
Numerical Stability - does Multiply/Divide give a more precise value than Divide/Multiply?
Consider the following code:
$result *= $oldFactor / $newFactor; //using shorthand *= operator
which is actually this:
$result = $oldFactor / $newFactor * $result; //division done first
I can also manually write it as this:
$result = $result *…

Dennis
- 7,907
- 11
- 65
- 115
4
votes
4 answers
Converting float to UInt32 - which expression is more precise
I have a number float x which should be in <0,1> range but it undergo several numerical operations - the result may be slightly outside <0,1>.
I need to convert this result to uint y using entire range of UInt32. Of course, I need to clamp x in the…

Libor
- 3,285
- 1
- 33
- 41
4
votes
4 answers
Source code for trigonometric functions calculations
For program that needs to be deterministic and provide the same result on different platforms (compilers), the built-in trigonometric functions can't be used, since the algorithm to compute it is different on different systems. It was tested, that…

kovarex
- 1,766
- 18
- 34
3
votes
3 answers
Numerically stable approach to computing a signed angle between vectors
My first Stack Exchange question regarding numeric stability in geometry. I wrote this function (below) for computing a signed angle from one vector to the other, inspired by the idea presented here, to which I am indebted.
In the function, the…

matanster
- 15,072
- 19
- 88
- 167
3
votes
2 answers
How can I make this function more numerically stable?
The following function is supposed to work similarly to pow(x, 1/k) but to be symmetric around the line y = 1 - x as well as not having a 0 or 1 slope at either end of [0, 1]:
def sym_gamma(x, k):
if k == 1.0:
return x
a = 1.0 / k - 1.0
b…

Emil Eriksson
- 2,110
- 1
- 21
- 31
3
votes
1 answer
LSTM 'recurrent_dropout' with 'relu' yields NaNs
Any non-zero recurrent_dropout yields NaN losses and weights; latter are either 0 or NaN. Happens for stacked, shallow, stateful, return_sequences = any, with & w/o Bidirectional(), activation='relu', loss='binary_crossentropy'. NaNs occur within a…

OverLordGoldDragon
- 1
- 9
- 53
- 101
3
votes
1 answer
Numerical stability of Simplex Algorithm
Edit: Simplex the mathematical optimization algorithm, not to be confused with simplex noise or triangulation.
I'm implementing my own linear programming solver and I would like to do so using 32bit floats. I know Simplex is very sensitive to the…

Davi Doro
- 358
- 2
- 8
3
votes
1 answer
How to evaluate an alternating series when addends contain rounding errors?
I want to numerically evaluate the transition probability of a linear Birth and Death process
where is the binomial coefficient and
I am able to evaluate it with an acceptable numerical error (using logarithms and the Kahan-Neumaier summation…

Alberto Pessia
- 41
- 4
3
votes
2 answers
Numerical precision of comparison operators
Short question: is the behavior of comparison operators defined at max precision?
Meaning, if I have two numbers (x and y) that are identical up to precision, should I always expect the same answer when I do x < y?
I realize this might seem like a…

Randi
- 320
- 2
- 11
3
votes
2 answers
Changing my finite difference model from 2D to 3D causes unstable behavior
I've been writing a finite difference code for the simulation and detection of cracks using laser-induced thermography. The crack is implemented by factors a and b, which are "damping" the heat flow through the air filled crack using a…

user6539314
- 33
- 5
3
votes
4 answers
Restoring the exact angle from std::cos(angle) using std::acos
Is it guaranteed by the C++ standard that angle == std::acos(std::cos(angle)) if angle is in the range [0, Pi], or in other words is it possible to restore the exact original value of angle from the result of std::cos using std::acos given the…

plasmacel
- 8,183
- 7
- 53
- 101
3
votes
2 answers
Numerical inconsistency in .NET
I’m building a CAD-like application in C#. I’m using SlimDX as the graphics engine, and for the number-crunching part, I build custom libraries which ultimately rely on the System.Math class, naturally.
Now, the thing is that the SlimDX libraries…

WHermann
- 159
- 1
- 8
3
votes
1 answer
Testing for "double" equality in javascript
I have translated the experimental C# "float" version of Clipper library to javascript. In the newest sandbox version there is a function IsAlmostEqual which seems to be hard to translate. Double equality cannot be compared using == operator due to…

Timo Kähkönen
- 11,962
- 9
- 71
- 112
3
votes
2 answers
solve() crashes when aimed at singular matrices
I am trying to solve a system of linear equations in the least-squares-style.
Using armadillo and its solve function I want to calculate the three coefficients of a parabolic fit.
vec coeffs = solve(CtC, Ctb)
with CtC=
1.0e+009 * …

bogus
- 867
- 6
- 14
- 24