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
1
vote
1 answer
Pytorch torch.linalg.svd returning U and V^T, which are not orthogonal
Using U,S, VT = torch.linalg.svd(M), the matrix 'M' is large, so I am getting the matrices U and VT as non orthogonal. When I compute torch.norm(torch.mm(matrix, matrix.t()) - identity_matrix)) its 0.004 and also when I print M.M^T, the diagonal…

Bhartendu Kumar
- 15
- 7
1
vote
0 answers
Why does changing the boundary conditions cause the finite difference algorithm to diverge?
I wrote a finite difference algorithm to solve the wave equation which is derived here.
When I ran my code, the plotted graphs of the numerical and analytical solution deviated, which is the problem I am trying to solve. The finite difference…

Nikola Ristic
- 133
- 4
1
vote
1 answer
Function diverging at boundaries: Schrödinger 2D, explicit method
I'm trying to simulate the 2D Schrödinger equation using the explicit algorithm proposed by Askar and Cakmak (1977). I define a 100x100 grid with a complex function u+iv, null at the boundaries. The problem is, after just a few iterations the…

Rob Tan
- 159
- 9
1
vote
0 answers
Why are my two methods of calculating image standard deviation returning different results?
I have a dataset consisting of some 17,000 images, each of size 3000x1700.
I have two methods for computing the mean and standard deviation of my dataset: a pixel-wise approach and an image-wise approach. The pixel-wise approach simply computes the…

Mate de Vita
- 1,102
- 12
- 32
1
vote
1 answer
Tensorflow: Add small number before division for numerical stability
In order to prevent divisions by zero in TensorFlow, I want to add a tiny number to my dividend. A quick search did not yield any results. In particular, I am interested in using the scientific notation, e.g.
a = b/(c+1e-05)
How can this be…

whiletrue
- 10,500
- 6
- 27
- 47
1
vote
0 answers
How to evaluate e^x in a numerically stable way?
Background: I am simulating data from a Cox proportional hazards model. There is a method provided by Bender et. al (2005). It is explained and implemented in R very well in this post. The intricacies of Cox models are not important to this…

Eli
- 280
- 1
- 3
- 13
1
vote
2 answers
Numeric instability
I'm doing some Linear programming exercises for the course of Algorithms, and in doing this I'm solving manually many operations with fractions. In doing this I realized that a human being don't suffer from numeric instability: we just keep values…

Dacav
- 13,590
- 11
- 60
- 87
1
vote
2 answers
square root of square of x equals x
Given a double precision floating-point (non-negative) number x, does square root of its square always equals to itself?
In other words, is there any loss of precision if doing the following:
x =
y = x^2
z = sqrt(y)
so that:
x…

Ecir Hana
- 10,864
- 13
- 67
- 117
1
vote
0 answers
Numerical strategy to calculate a fraction sometimes very close to zero
In the R function chisq.test() there is the following line:
PVAL <- (1 + sum(ss >= almost.1 * STATISTIC))/(B + 1) with
almost.1 <- 1 - 64 * .Machine$double.eps
This is clearly a computational adjustment to avoid getting round outputs for PVAL.
It…

Antoni Parellada
- 4,253
- 6
- 49
- 114
1
vote
2 answers
Python Calculate log(1+x)/x for x near 0
Is there a way to correctly calculate the value of log(1+x)/x in python for values of x close to 0? When I do it normally using np.log1p(x)/x, I get 1. I somehow seem to get the correct values when I use np.log(x). Isn't log1p supposed to be more…

Aditya369
- 834
- 8
- 20
1
vote
1 answer
How do I evaluate xe^x/(e^x-1) with numerical stability in Python?
How do I evaluate xe^x/(e^x-1) with numerical stability around zero and when x is very positive or negative? I have access to all the usual mathematical functions in numpy and scipy.

Neil G
- 32,138
- 39
- 156
- 257
1
vote
2 answers
Rotation matrix, normalization, determinant -1
I'm currently implementing an algorithm for 3D pointcloud filtering following a scientific paper.
I run in some problems when computing the rotation matrix for specific values. The goal is to rotate points into the coordinatesystem which is defined…

andysfd
- 13
- 3
1
vote
0 answers
Baum-Welch algorithm scaling issue - Matlab
I am implementing Baum-Welch algorithm in Matlab from this wikipedia link : Baum-Welch algorithm. It is a part of my volatility forcasting in financial time series.
I have two questions :
1: in the last of update step in wikipedia page, It has been…
user5871360
1
vote
1 answer
Numerical problems of computing exponential numbers (from Gaussian PDFs)
I have a list of very small exponential values (for example exp(n), with n<-300), which are generated from Gaussian PDFs.
I want to compute how much each of them is proportional to the sum, for example like the following python-like pseudo-code…

dontloo
- 10,067
- 4
- 29
- 50
1
vote
1 answer
Solving a matrix equation with very small inputs
I'm programming in Matlab and in my program I need to solve a system Ax=b, where A is a m by m square matrix with very small entries. If m increases, the entries of A become smaller.
A is a sparse matrix, so I rename this matrix with the function…

Hiperion
- 113
- 3